[PATCH] graft: new "--graftmessage" option, for better graft documentation

Martin Rieser martin.h.rieser at gmail.com
Fri Dec 28 09:15:50 CST 2012


# 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.

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


More information about the Mercurial-devel mailing list