# HG changeset patch # User Pierre-Yves David # Date 2012-08-25 13:37:28 # Node ID ad1561723ddeb7cc9d6696fdad76baed91e39e7b # Parent 89467a7c2132195b7b4c17fc904db95804878acf 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -11,6 +11,7 @@ import os, sys, errno, re, tempfile 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 @@ def amend(ui, repo, commitfunc, old, ext 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 @@ def amend(ui, repo, commitfunc, old, ext # 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):