Comments
Patch
@@ -2213,10 +2213,13 @@
"""update to parent revision
Displays the summary line of the destination for clarity."""
- if True:
+ wlock = None
+ dryrunopt = opts['dry_run']
+ if not dryrunopt:
+ wlock = repo.wlock()
+ try:
wkctx = repo[None]
wparents = wkctx.parents()
- dryrunopt = opts['dry_run']
if len(wparents) != 1:
raise error.Abort('merge in progress')
if not opts['merge']:
@@ -2246,7 +2249,6 @@
ret = hg.update(repo, p.rev())
if not ret:
tr = lock = None
- wlock = repo.wlock()
try:
lock = repo.lock()
tr = repo.transaction('previous')
@@ -2258,6 +2260,8 @@
tr.close()
finally:
lockmod.release(tr, lock, wlock)
+ wlock = None
+
displayer.show(p)
return 0
else:
@@ -2265,6 +2269,8 @@
displayer.show(p)
ui.warn(_('multiple parents, explicitly update to one\n'))
return 1
+ finally:
+ lockmod.release(wlock)
@command('^next',
[('B', 'move-bookmark', False,
@@ -2282,10 +2288,13 @@
Displays the summary line of the destination for clarity.
"""
- if True:
+ wlock = None
+ dryrunopt = opts['dry_run']
+ if not dryrunopt:
+ wlock = repo.wlock()
+ try:
wkctx = repo[None]
wparents = wkctx.parents()
- dryrunopt = opts['dry_run']
if len(wparents) != 1:
raise error.Abort('merge in progress')
if not opts['merge']:
@@ -2315,7 +2324,6 @@
ret = hg.update(repo, c.rev())
if not ret:
lock = tr = None
- wlock = repo.wlock()
try:
lock = repo.lock()
tr = repo.transaction('next')
@@ -2327,6 +2335,7 @@
tr.close()
finally:
lockmod.release(tr, lock, wlock)
+ wlock = None
displayer.show(c)
result = 0
elif children:
@@ -2368,6 +2377,8 @@
return result
return 1
return result
+ finally:
+ lockmod.release(wlock)
def _reachablefrombookmark(repo, revs, bookmarks):
"""filter revisions and bookmarks reachable from the given bookmark
new file mode 100755
@@ -0,0 +1,3 @@
+#!/bin/sh
+sleep 5
+echo "new desc" >> $1
@@ -206,3 +206,34 @@
move:[5] added d
atop:[6] added b (3)
working directory is now at 47ea25be8aea
+
+prev and next should lock properly against other commands
+
+ $ hg init repo
+ $ cd repo
+ $ HGEDITOR=${TESTDIR}/fake-editor.sh
+ $ echo hi > foo
+ $ hg ci -Am 'one'
+ adding foo
+ $ echo bye > foo
+ $ hg ci -Am 'two'
+
+ $ hg amend --edit &
+ $ sleep 1
+ $ hg prev
+ waiting for lock on working directory of $TESTTMP/repo held by process '*' on host '*' (glob)
+ got lock after [4-6] seconds (re)
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ [0] one
+ $ wait
+
+ $ hg amend --edit &
+ $ sleep 1
+ $ hg next --evolve
+ waiting for lock on working directory of $TESTTMP/repo held by process '*' on host '*' (glob)
+ 1 new unstable changesets
+ got lock after [4-6] seconds (re)
+ move:[2] two
+ atop:[3] one
+ working directory now at a7d885c75614
+ $ wait