Commits

Anonymous committed e5baeb8

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.

  • Participants
  • Parent commits 3291514

Comments (0)

Files changed (4)

   (fix issues #16, #35 and #42)
 - adds a --obsolete flag to import (requieres Mercurial 3.0)
 - prune: update to successor rather than parent when pruning '.' with -s
+- fold: add missing --message and --logfile option
 
 3.3.1 -- 2014-04-23
 

File hgext/evolve.py

 
 @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):
             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)

File tests/test-evolve.t

   A c
     a
   R a
+
+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 <<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)

File tests/test-tutorial.t

   options:
   
    -r --rev VALUE [+] explicitly specify the full set of revision to fold
+   -m --message TEXT  use text as commit message
+   -l --logfile FILE  read commit message from file
    -d --date DATE     record the specified date as commit date
    -u --user USER     record the specified user as committer