tests/test-merge-closedheads.t
author Matt Harbison <matt_harbison@yahoo.com>
Mon, 22 May 2017 21:45:02 -0400
changeset 32677 f840b2621cce
parent 16913 f2719b387380
child 43114 8197b395710e
permissions -rw-r--r--
killdaemons: close pid file before killing processes With #serve enabled on Windows, I was getting occasional stacktraces like this: Errored test-hgweb-json.t: Traceback (most recent call last): File "./run-tests.py", line 724, in run self.tearDown() File "./run-tests.py", line 805, in tearDown killdaemons(entry) File "./run-tests.py", line 540, in killdaemons logfn=vlog) File "...\tests\killdaemons.py", line 94, in killdaemons os.unlink(pidfile) WindowsError: [Error 32] The process cannot access the file because it is being used by another process: '...\\hgtests.zmpqj3\\child80\\daemon.pids' Adrian suggested using util.posixfile, which works. However, the 'mercurial' package isn't in sys.path when invoking run-tests.py, and it isn't clear that hacking[1] it in is a good thing (especially for test-run-tests.t, which uses an installation in a temp folder). I tried using ProcessMonitor to figure out what the other process is, but that monitoring slows things down to such a degree that the issue doesn't occur. I was ready to blame the virus scanner, but it happens without that too. Looking at the code, I don't see anything that would have the pid file open. But I was able to get through about 20 full test runs without an issue with this minor change, whereas before it was pretty certain to hit this at least once in two or three runs. [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097907.html

  $ hgcommit() {
  >    hg commit -u user "$@"
  > }

  $ hg init clhead
  $ cd clhead

  $ touch foo && hg add && hgcommit -m 'foo'
  adding foo
  $ touch bar && hg add && hgcommit -m 'bar'
  adding bar
  $ touch baz && hg add && hgcommit -m 'baz'
  adding baz

  $ echo "flub" > foo
  $ hgcommit -m "flub"
  $ echo "nub" > foo
  $ hgcommit -m "nub"

  $ hg up -C 2
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ echo "c1" > c1
  $ hg add c1
  $ hgcommit -m "c1"
  created new head
  $ echo "c2" > c1
  $ hgcommit -m "c2"

  $ hg up -C 2
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved

  $ echo "d1" > d1
  $ hg add d1
  $ hgcommit -m "d1"
  created new head
  $ echo "d2" > d1
  $ hgcommit -m "d2"
  $ hg tag -l good

fail with three heads
  $ hg up -C good
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg merge
  abort: branch 'default' has 3 heads - please merge with an explicit rev
  (run 'hg heads .' to see heads)
  [255]

close one of the heads
  $ hg up -C 6
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hgcommit -m 'close this head' --close-branch

succeed with two open heads
  $ hg up -C good
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg up -C good
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hgcommit -m 'merged heads'

hg update -C 8
  $ hg update -C 8
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

hg branch some-branch
  $ hg branch some-branch
  marked working directory as branch some-branch
  (branches are permanent and global, did you want a bookmark?)
hg commit
  $ hgcommit -m 'started some-branch'
hg commit --close-branch
  $ hgcommit --close-branch -m 'closed some-branch'

hg update default
  $ hg update default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
hg merge some-branch
  $ hg merge some-branch
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
hg commit (no reopening of some-branch)
  $ hgcommit -m 'merge with closed branch'

  $ cd ..