Patchwork graft: new "--graftmessage" option, for better graft documentation

login
register
mail settings
Submitter Martin Rieser
Date Dec. 28, 2012, 3:15 p.m.
Message ID <9f82b5abaa7e56ce561e.1356707750@johanna-MM061>
Download mbox | patch
Permalink /patch/318/
State Superseded
Delegated to: Pierre-Yves David
Headers show

Comments

Martin Rieser - Dec. 28, 2012, 3:15 p.m.
# HG changeset patch
# User Martin Rieser
# Date 1356625537 -3600
# Branch stable
# Node ID 9f82b5abaa7e56ce561e2c385c4607136a49e838
# Parent  777084ac84167e3bdea45b5c00de1106cca36eef
graft: new "--graftmessage" option, for better graft documentation.

With this option the person who uses the graft function, can add some
additional text to the commit message.
With this new graft option it is not required to open an editor to
change the commit message.
Pierre-Yves David - Dec. 28, 2012, 11:16 p.m.
On 28 d?c. 2012, at 16:15, Martin Rieser wrote:

> # HG changeset patch
> # User Martin Rieser
> # Date 1356625537 -3600
> # Branch stable
> # Node ID 9f82b5abaa7e56ce561e2c385c4607136a49e838
> # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
> graft: new "--graftmessage" option, for better graft documentation.
> 
> With this option the person who uses the graft function, can add some
> additional text to the commit message.
> With this new graft option it is not required to open an editor to
> change the commit message.

What the trouble with opening an editor?

Why would we need a new command switch.
Yann E. MORIN - Dec. 28, 2012, 11:40 p.m.
Pierre-Yves, All,

On Saturday 29 December 2012 Pierre-Yves David wrote:
> On 28 d?c. 2012, at 16:15, Martin Rieser wrote:
> 
> > # HG changeset patch
> > # User Martin Rieser
> > # Date 1356625537 -3600
> > # Branch stable
> > # Node ID 9f82b5abaa7e56ce561e2c385c4607136a49e838
> > # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
> > graft: new "--graftmessage" option, for better graft documentation.
> > 
> > With this option the person who uses the graft function, can add some
> > additional text to the commit message.
> > With this new graft option it is not required to open an editor to
> > change the commit message.
> 
> What the trouble with opening an editor?
> 
> Why would we need a new command switch.

The same as we have for 'commit':
  -m --message TEXT        use text as commit message

It can be usefull for automated commits.

For example, I auto-commit (via crontab) a few files in my ${HOME} repository
(eg. my user crontab itself, my ~/.bash_history, and so on...), and auto-push
so my repository server has it.

For graft, it can be used by a build-bot to try and test backporting bug
fixes to a stable branch (eg. by looking at keywords in the commit message,
the build-bot may attempt the graft and build it), and if OK, send a mail
for the project leader to pul the new changeset the next morning...

In this case (not suer it's Martin's use-case), it can be usefull to set
the commit message on the command line, as it's all scripted.

Regards,
Yann E. MORIN.
Matt Mackall - Dec. 28, 2012, 11:47 p.m.
On Sat, 2012-12-29 at 00:40 +0100, Yann E. MORIN wrote:
> Pierre-Yves, All,
> 
> On Saturday 29 December 2012 Pierre-Yves David wrote:
> > On 28 d?c. 2012, at 16:15, Martin Rieser wrote:
> > 
> > > # HG changeset patch
> > > # User Martin Rieser
> > > # Date 1356625537 -3600
> > > # Branch stable
> > > # Node ID 9f82b5abaa7e56ce561e2c385c4607136a49e838
> > > # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
> > > graft: new "--graftmessage" option, for better graft documentation.
> > > 
> > > With this option the person who uses the graft function, can add some
> > > additional text to the commit message.
> > > With this new graft option it is not required to open an editor to
> > > change the commit message.
> > 
> > What the trouble with opening an editor?
> > 
> > Why would we need a new command switch.
> 
> The same as we have for 'commit':
>   -m --message TEXT        use text as commit message

Notable, this supplements the existing commit message in a fixed format:

+            if opts.get('graftmessage'):
+                message += '\nGraft: %s' % opts.get('graftmessage')

...that's awkward for non-one-line messages.
Pierre-Yves David - Dec. 29, 2012, 4:48 a.m.
On 29 d?c. 2012, at 00:40, Yann E. MORIN wrote:

> Pierre-Yves, All,
> 
> On Saturday 29 December 2012 Pierre-Yves David wrote:
>> On 28 d?c. 2012, at 16:15, Martin Rieser wrote:
>> 
>>> # HG changeset patch
>>> # User Martin Rieser
>>> # Date 1356625537 -3600
>>> # Branch stable
>>> # Node ID 9f82b5abaa7e56ce561e2c385c4607136a49e838
>>> # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
>>> graft: new "--graftmessage" option, for better graft documentation.
>>> 
>>> With this option the person who uses the graft function, can add some
>>> additional text to the commit message.
>>> With this new graft option it is not required to open an editor to
>>> change the commit message.
>> 
>> What the trouble with opening an editor?
>> 
>> Why would we need a new command switch.
> 
> The same as we have for 'commit':
>  -m --message TEXT        use text as commit message
> 
> It can be usefull for automated commits.
> 
> For example, I auto-commit (via crontab) a few files in my ${HOME} repository
> (eg. my user crontab itself, my ~/.bash_history, and so on...), and auto-push
> so my repository server has it.
> 
> For graft, it can be used by a build-bot to try and test backporting bug
> fixes to a stable branch (eg. by looking at keywords in the commit message,
> the build-bot may attempt the graft and build it), and if OK, send a mail
> for the project leader to pul the new changeset the next morning...
> 
> In this case (not suer it's Martin's use-case), it can be usefull to set
> the commit message on the command line, as it's all scripted.

If you are in a script context, you should be able to forge the new message in a temporary file and pass it to a --logfile option. (or even use a custom editor that does that)

If you are a user you should survivre et editor invocation.

I'm still not very convinced that this usecase deserve a specific flag.

However it seems like graft does not have -l/--logfile option. Adding one would make sense in my opinion.
Martin Rieser - Dec. 30, 2012, 10:34 a.m.
Thank you for your feedback.
My use case:
I do one or more grafts with a GUI (e.g. TortoiseHG). And I would like to
add some equal text to the grafts. I think, the edit option is for
automated batch operations not very well designed.

How would the -I/--logfile option work, if you do multiple grafts with one
hg graft ... command?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121230/391f693f/attachment.html>
Pierre-Yves David - Dec. 30, 2012, 4:04 p.m.
On 30 d?c. 2012, at 11:34, Martin Rieser wrote:

> Thank you for your feedback. 
> My use case:
> I do one or more grafts with a GUI (e.g. TortoiseHG). And I would like to add some equal text to the grafts. I think, the edit option is for automated batch operations not very well designed. 

I still think it's a case rare enough and simple to script enough not to add a dedicated switch *for the command line tool*

> How would the -I/--logfile option work, if you do multiple grafts with one hg graft ... command?

Good point, one would fallback to a custom HGEDITOR for scripting

Patch

diff -r 777084ac8416 -r 9f82b5abaa7e mercurial/commands.py
--- a/mercurial/commands.py	Don Nov 29 08:44:54 2012 -0500
+++ b/mercurial/commands.py	Don Dez 27 17:25:37 2012 +0100
@@ -2692,6 +2692,7 @@ 
      ('c', 'continue', False, _('resume interrupted graft')),
      ('e', 'edit', False, _('invoke editor on commit messages')),
      ('', 'log', None, _('append graft info to log message')),
+     ('', 'graftmessage', '', _('append <text> to commit message'), _('TEXT')),
      ('D', 'currentdate', False,
       _('record the current date as commit date')),
      ('U', 'currentuser', False,
@@ -2710,6 +2711,11 @@ 
     Changesets that are ancestors of the current revision, that have
     already been grafted, or that are merges will be skipped.
 
+    If --graftmessage 'some text' is specified, log messages will have
+    a appended text of the form::
+
+      Graft: some text
+
     If --log is specified, log messages will have a comment appended
     of the form::
 
@@ -2869,6 +2875,8 @@ 
             if opts.get('date'):
                 date = opts['date']
             message = ctx.description()
+            if opts.get('graftmessage'):
+                message += '\nGraft: %s' % opts.get('graftmessage')
             if opts.get('log'):
                 message += '\n(grafted from %s)' % ctx.hex()
             node = repo.commit(text=message, user=user,
diff -r 777084ac8416 -r 9f82b5abaa7e tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t	Don Nov 29 08:44:54 2012 -0500
+++ b/tests/test-debugcomplete.t	Don Dez 27 17:25:37 2012 +0100
@@ -248,7 +248,7 @@ 
   debugsub: rev
   debugwalk: include, exclude
   debugwireargs: three, four, five, ssh, remotecmd, insecure
-  graft: rev, continue, edit, log, currentdate, currentuser, date, user, tool, dry-run
+  graft: rev, continue, edit, log, graftmessage, currentdate, currentuser, date, user, tool, dry-run
   grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
   heads: rev, topo, active, closed, style, template
   help: extension, command, keyword
diff -r 777084ac8416 -r 9f82b5abaa7e tests/test-graft.t
--- a/tests/test-graft.t	Don Nov 29 08:44:54 2012 -0500
+++ b/tests/test-graft.t	Don Dez 27 17:25:37 2012 +0100
@@ -304,6 +304,15 @@ 
   14 1:5d205f8b35b6  3
   (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
 
+Graft with --graftmessage
+
+  $ hg up -Cq 1
+  $ hg graft 4 --graftmessage GraftTest -u foo
+  grafting revision 4
+  $ hg log --template '{rev} {parents} {desc}\n' -r tip
+  15 1:5d205f8b35b6  4
+  Graft: GraftTest
+
 Resolve conflicted graft
   $ hg up -q 0
   $ echo b > a
@@ -444,17 +453,23 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     3
   
-  changeset:   17:64ecd9071ce8
+  changeset:   15:9c5e18046072
+  parent:      1:5d205f8b35b6
+  user:        foo
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     4
+  
+  changeset:   18:64ecd9071ce8
   user:        bar
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     1
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -473,12 +488,12 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -487,7 +502,7 @@ 
   
 Transplants of grafts can find a destination...
   $ hg log -r 'destination(7)'
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -515,18 +530,18 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   user:        foo
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   22:1313d0a825e2
+  changeset:   23:1313d0a825e2
   branch:      dev
   tag:         tip
   user:        foo