comparison mercurial/cmdutil.py @ 18197:153659e86a5f stable

amend: invalidate dirstate in case of failure (issue3670) The temporary commit created by amend update the dirstate. If the final commit fails, we need to invalidate the change made to the dirstate, otherwise the release of the wlock will write the dirstate created after the rollbacked temporary commit. This dirstate writing logic should probably be handled in the same object than the transaction one. However such change are too big for stable.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sat, 29 Dec 2012 18:00:18 +0100
parents 0c10cf819146
children 9b4adaef0db9
comparison
equal deleted inserted replaced
18194:18fef98618cd 18197:153659e86a5f
1617 1617
1618 def amend(ui, repo, commitfunc, old, extra, pats, opts): 1618 def amend(ui, repo, commitfunc, old, extra, pats, opts):
1619 ui.note(_('amending changeset %s\n') % old) 1619 ui.note(_('amending changeset %s\n') % old)
1620 base = old.p1() 1620 base = old.p1()
1621 1621
1622 wlock = lock = None 1622 wlock = lock = newid = None
1623 try: 1623 try:
1624 wlock = repo.wlock() 1624 wlock = repo.wlock()
1625 lock = repo.lock() 1625 lock = repo.lock()
1626 tr = repo.transaction('amend') 1626 tr = repo.transaction('amend')
1627 try: 1627 try:
1780 if node: 1780 if node:
1781 ui.note(_('stripping intermediate changeset %s\n') % ctx) 1781 ui.note(_('stripping intermediate changeset %s\n') % ctx)
1782 ui.note(_('stripping amended changeset %s\n') % old) 1782 ui.note(_('stripping amended changeset %s\n') % old)
1783 repair.strip(ui, repo, old.node(), topic='amend-backup') 1783 repair.strip(ui, repo, old.node(), topic='amend-backup')
1784 finally: 1784 finally:
1785 if newid is None:
1786 repo.dirstate.invalidate()
1785 lockmod.release(wlock, lock) 1787 lockmod.release(wlock, lock)
1786 return newid 1788 return newid
1787 1789
1788 def commiteditor(repo, ctx, subs): 1790 def commiteditor(repo, ctx, subs):
1789 if ctx.description(): 1791 if ctx.description():