From patchwork Sat Apr 12 02:02:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [2,of,4,evolve-ext] fold: add --message and --logfile options From: =?utf-8?q?Jordi_Guti=C3=A9rrez_Hermoso?= X-Patchwork-Id: 4292 Message-Id: To: mercurial-devel@selenic.com Date: Fri, 11 Apr 2014 22:02:58 -0400 # HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1397160122 14400 # Thu Apr 10 16:02:02 2014 -0400 # Branch stable # Node ID e7b0d54215c1e539d79f86dd2c518d2407087958 # Parent c5b806b24aadeb64ff32476b850d521f0bc37bef fold: add --message and --logfile options This uses cmdutil.logmessage to match common usage for `hg commit`. diff --git a/hgext/evolve.py b/hgext/evolve.py --- a/hgext/evolve.py +++ b/hgext/evolve.py @@ -696,14 +696,9 @@ copied=copied.get(path)) return mctx raise IOError() - if commitopts.get('message') and commitopts.get('logfile'): - raise util.Abort(_('options --message and --logfile are mutually' - ' exclusive')) - if commitopts.get('logfile'): - message= open(commitopts['logfile']).read() - elif commitopts.get('message'): - message = commitopts['message'] - else: + + message = cmdutil.logmessage(repo.ui, commitopts) + if not message: message = old.description() user = commitopts.get('user') or old.user() @@ -1722,7 +1717,7 @@ @command('^fold', [('r', 'rev', [], _("explicitly specify the full set of revision to fold")), - ] + commitopts2, + ] + commitopts + commitopts2, # allow to choose the seed ? _('rev')) def fold(ui, repo, *revs, **opts): @@ -1766,11 +1761,16 @@ commitopts = opts.copy() allctx = [repo[r] for r in revs] targetphase = max(c.phase() for c in allctx) - msgs = ["HG: This is a fold of %d changesets." % len(allctx)] - msgs += ["HG: Commit message of changeset %s.\n\n%s\n" % - (c.rev(), c.description()) for c in allctx] - commitopts['message'] = "\n".join(msgs) - commitopts['edit'] = True + + if commitopts.get('message') or commitopts.get('logfile'): + commitopts['edit'] = False + else: + msgs = ["HG: This is a fold of %d changesets." % len(allctx)] + msgs += ["HG: Commit message of changeset %s.\n\n%s\n" % + (c.rev(), c.description()) for c in allctx] + commitopts['message'] = "\n".join(msgs) + commitopts['edit'] = True + newid, _ = rewrite(repo, root, allctx, head, [root.p1().node(), root.p2().node()], commitopts=commitopts) diff --git a/tests/test-evolve.t b/tests/test-evolve.t --- a/tests/test-evolve.t +++ b/tests/test-evolve.t @@ -646,3 +646,35 @@ 4 : add 4 - test 5 : add 3 - test 11 : add 1 - test + +Test fold with commit messages + + $ cd ../work + $ hg fold .^ --message "Folding with custom commit message" + 2 changesets folded + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ glog + @ 16:e6d8dace77a1@default(draft) Folding with custom commit message + | + o 13:e9c952d5bc4b@default(draft) dansk! + | + o 7:abe98aeaaa35@default(public) another feature + | + o 6:ba0ec09b1bab@default(public) a nifty feature + | + o 0:e55e0562ee93@default(public) base + + $ cat > commit-message < A longer + > commit message + > EOF + + $ hg fold .^ --logfile commit-message + 2 changesets folded + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg qlog + 17 - 2451d817c756 A longer + commit message (draft) + 7 - abe98aeaaa35 another feature (public) + 6 - ba0ec09b1bab a nifty feature (public) + 0 - e55e0562ee93 base (public)