Patchwork [1,of,2,Evolve] fold: add --message and --logfile options

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 13, 2014, 7:41 p.m.
Message ID <196c2801544045102ce8.1394739661@Iris>
Download mbox | patch
Permalink /patch/3940/
State Not Applicable
Headers show

Comments

Jordi Gutiérrez Hermoso - March 13, 2014, 7:41 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1394380515 14400
#      Sun Mar 09 11:55:15 2014 -0400
# Node ID 196c2801544045102ce87b2ede3c385f1cc61138
# Parent  6cb81dbb95163806f31522a17f01cff25daf9708
fold: add --message and --logfile options

This uses cmdutil.logmessage to match common usage for `hg commit`.
Pierre-Yves David - March 13, 2014, 9:42 p.m.
On 03/13/2014 12:41 PM, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1394380515 14400
> #      Sun Mar 09 11:55:15 2014 -0400
> # Node ID 196c2801544045102ce87b2ede3c385f1cc61138
> # Parent  6cb81dbb95163806f31522a17f01cff25daf9708
> fold: add --message and --logfile options
>
> This uses cmdutil.logmessage to match common usage for `hg commit`.

I would happily accept this changes if it came along a test.

(thanks)
Jordi Gutiérrez Hermoso - March 14, 2014, 1:23 p.m.
On Thu, 2014-03-13 at 14:42 -0700, Pierre-Yves David wrote:
> 
> On 03/13/2014 12:41 PM, Jordi Gutiérrez Hermoso wrote:
> > # HG changeset patch
> > # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> > # Date 1394380515 14400
> > #      Sun Mar 09 11:55:15 2014 -0400
> > # Node ID 196c2801544045102ce87b2ede3c385f1cc61138
> > # Parent  6cb81dbb95163806f31522a17f01cff25daf9708
> > fold: add --message and --logfile options
> >
> > This uses cmdutil.logmessage to match common usage for `hg commit`.
> 
> I would happily accept this changes if it came along a test.

Okay. I suppose the tests should go test-evolve.t? I'll add them
there.

- Jordi G. H.
Pierre-Yves David - March 23, 2014, 4:14 a.m.
On 03/14/2014 06:23 AM, Jordi Gutiérrez Hermoso wrote:
> On Thu, 2014-03-13 at 14:42 -0700, Pierre-Yves David wrote:
>>
>> On 03/13/2014 12:41 PM, Jordi Gutiérrez Hermoso wrote:
>>> # HG changeset patch
>>> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
>>> # Date 1394380515 14400
>>> #      Sun Mar 09 11:55:15 2014 -0400
>>> # Node ID 196c2801544045102ce87b2ede3c385f1cc61138
>>> # Parent  6cb81dbb95163806f31522a17f01cff25daf9708
>>> fold: add --message and --logfile options
>>>
>>> This uses cmdutil.logmessage to match common usage for `hg commit`.
>>
>> I would happily accept this changes if it came along a test.
>
> Okay. I suppose the tests should go test-evolve.t? I'll add them
> there.

Current fold test are in test-evolve.t,

Fold test could be extracted in they own test-fold.t file if you feel 
motivatd.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -1929,7 +1929,7 @@ 
 
 @command('^fold',
     [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
-    ],
+    ] + commitopts,
     # allow to choose the seed ?
     _('rev'))
 def fold(ui, repo, *revs, **opts):
@@ -1972,11 +1972,18 @@ 
         try:
             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
+
+            message = cmdutil.logmessage(ui, opts)
+            if message:
+                commitopts = {'message': message}
+                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)