[PATCH 3 of 4 evolve-ext V2] fold: add --message and --logfile options

Jordi Gutiérrez Hermoso jordigh at octave.org
Mon Apr 14 15:48:44 CDT 2014


# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1397504787 14400
#      Mon Apr 14 15:46:27 2014 -0400
# Branch stable
# Node ID 09b4808632bc218f3078ae86e18ac0190f9ccc29
# Parent  da022f9236b1f51392ab1cc6d24a234969c9ee9f
fold: add --message and --logfile options

Like other commit-creating commands, this add two options for
specifying the resulting commit message, with tests. If either of
these options is specified, no editor is popped up asking for a commit
message.

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1717,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):
@@ -1761,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
@@ -650,3 +650,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 at default(draft) Folding with custom commit message
+  |
+  o  13:e9c952d5bc4b at default(draft) dansk!
+  |
+  o  7:abe98aeaaa35 at default(public) another feature
+  |
+  o  6:ba0ec09b1bab at default(public) a nifty feature
+  |
+  o  0:e55e0562ee93 at default(public) base
+  
+  $ cat > commit-message <<EOF
+  > 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)


More information about the Mercurial-devel mailing list