# HG changeset patch # User Steve Borho # Date 2010-10-21 21:04:34 # Node ID 0e0a52bd58f941c00b2a1d57f23676fa486e58c3 # Parent 15b8a652b558552320dc32373ddad3bbeff5c4ba import: --no-commit should update .hg/last-message.txt The patch parser goes through all of that trouble extracting the commit message from the patch file. It seems such a waste not to use it. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2279,6 +2279,7 @@ def import_(ui, repo, patch1, *patches, d = opts["base"] strip = opts["strip"] wlock = lock = None + msgs = [] def tryone(ui, hunk): tmpname, message, user, date, branch, nodeid, p1, p2 = \ @@ -2329,7 +2330,10 @@ def import_(ui, repo, patch1, *patches, finally: files = cmdutil.updatedir(ui, repo, files, similarity=sim / 100.0) - if not opts.get('no_commit'): + if opts.get('no_commit'): + if message: + msgs.append(message) + else: if opts.get('exact'): m = None else: @@ -2378,6 +2382,8 @@ def import_(ui, repo, patch1, *patches, if not haspatch: raise util.Abort(_('no diffs found')) + if msgs: + repo.opener('last-message.txt', 'wb').write('* * *\n'.join(msgs)) finally: release(lock, wlock) diff --git a/tests/test-import.t b/tests/test-import.t --- a/tests/test-import.t +++ b/tests/test-import.t @@ -437,6 +437,14 @@ Test fuzziness (ambiguous patch location $ hg revert -a reverting a + +import with --no-commit should have written .hg/last-message.txt + + $ echo '\n' | cat .hg/last-message.txt - + change + + + test fuzziness with eol=auto $ hg --config patch.eol=auto import --no-commit -v tip.patch