# HG changeset patch # User Pierre-Yves David # Date 2012-08-25 14:20:41 # Node ID 9732473aa24bff5696f8bd761b546022ee4f6e2b # Parent 965fbe04fd96f2cb3b84e5f20b93e406a9087b03 amend: use an explicit commit message for temporary amending commit Before this changeset, the extra commit created during amend had the same description as the final commit. This was a bit confusing when trying to understand what that extra commit was about. This changeset changes the description of such commit to: temporary amend commit for The old behaviour was not a big deal, but would become more confusing once we use obsolescence marker instead of stripping the precursors. This also helps if the user restores a strip backup. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1582,10 +1582,14 @@ def amend(ui, repo, commitfunc, old, ext lock = repo.lock() tr = repo.transaction('amend') try: + # See if we got a message from -m or -l, if not, open the editor + # with the message of the changeset to amend + message = logmessage(ui, opts) # First, do a regular commit to record all changes in the working # directory (if there are any) ui.callhooks = False try: + opts['message'] = 'temporary amend commit for %s' % old node = commit(ui, repo, commitfunc, pats, opts) finally: ui.callhooks = True @@ -1618,7 +1622,6 @@ def amend(ui, repo, commitfunc, old, ext user = ctx.user() date = ctx.date() - message = ctx.description() # Recompute copies (avoid recording a -> b -> a) copied = copies.pathcopies(base, ctx) @@ -1663,17 +1666,10 @@ def amend(ui, repo, commitfunc, old, ext except KeyError: raise IOError - # See if we got a message from -m or -l, if not, open the editor - # with the message of the changeset to amend user = opts.get('user') or old.user() date = opts.get('date') or old.date() - message = logmessage(ui, opts) - if not message: - cctx = context.workingctx(repo, old.description(), - user, date, extra, - repo.status(base.node(), - old.node())) - message = commitforceeditor(repo, cctx, []) + if not message: + message = old.description() new = context.memctx(repo, parents=[base.node(), nullid], @@ -1683,6 +1679,7 @@ def amend(ui, repo, commitfunc, old, ext user=user, date=date, extra=extra) + new._text = commitforceeditor(repo, new, []) ph = repo.ui.config('phases', 'new-commit', phases.draft) try: repo.ui.setconfig('phases', 'new-commit', old.phase()) diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t --- a/tests/test-commit-amend.t +++ b/tests/test-commit-amend.t @@ -167,6 +167,8 @@ Same, but with changes in working dir (d $ echo a >> a $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v amending changeset ffb49186f961 + a + copying changeset a4f8a65b7c6a to ad120869acf0 another precious commit message @@ -177,9 +179,7 @@ Same, but with changes in working dir (d HG: branch 'default' HG: changed a a - copying changeset 27f3aacd3011 to ad120869acf0 - a - stripping intermediate changeset 27f3aacd3011 + stripping intermediate changeset a4f8a65b7c6a stripping amended changeset ffb49186f961 2 changesets found saved backup bundle to $TESTTMP/.hg/strip-backup/ffb49186f961-amend-backup.hg (glob)