amend: lock the repository during the whole process
Without this changes another writer can lock the repository in the middle the
amend process. The resulting mess can be pretty ugly.
--- a/mercurial/cmdutil.py Mon Sep 10 14:08:10 2012 -0700
+++ b/mercurial/cmdutil.py Sat Aug 25 15:37:28 2012 +0200
@@ -11,6 +11,7 @@
import util, scmutil, templater, patch, error, templatekw, revlog, copies
import match as matchmod
import subrepo, context, repair, bookmarks, graphmod, revset, phases
+import lock as lockmod
def parsealiases(cmd):
return cmd.lstrip("^").split("|")
@@ -1575,8 +1576,10 @@
ui.note(_('amending changeset %s\n') % old)
base = old.p1()
- wlock = repo.wlock()
+ wlock = lock = None
try:
+ wlock = repo.wlock()
+ lock = repo.lock()
# First, do a regular commit to record all changes in the working
# directory (if there are any)
ui.callhooks = False
@@ -1694,16 +1697,12 @@
# Strip the intermediate commit (if there was one) and the amended
# commit
- lock = repo.lock()
- try:
- if node:
- ui.note(_('stripping intermediate changeset %s\n') % ctx)
- ui.note(_('stripping amended changeset %s\n') % old)
- repair.strip(ui, repo, old.node(), topic='amend-backup')
- finally:
- lock.release()
+ if node:
+ ui.note(_('stripping intermediate changeset %s\n') % ctx)
+ ui.note(_('stripping amended changeset %s\n') % old)
+ repair.strip(ui, repo, old.node(), topic='amend-backup')
finally:
- wlock.release()
+ lockmod.release(wlock, lock)
return newid
def commiteditor(repo, ctx, subs):