ui: edit(): transplant: set HGREVISION environment variable for an editor
authorAlexander Drozdov <al.drozdov@gmail.com>
Mon, 10 Feb 2014 07:13:10 +0400
changeset 20606 be140ebd506b
parent 20605 a8aa699a812a
child 20607 abd448767465
ui: edit(): transplant: set HGREVISION environment variable for an editor transplant command set 'transplant_source' extra for the revision. Allow an editor to access the extra using HGREVISION environment variable. This may be useful when an editor is actually a script which modifies a commit message. Transplant filters is an alternative way to do it.
mercurial/ui.py
--- a/mercurial/ui.py	Thu Feb 06 12:21:20 2014 +0400
+++ b/mercurial/ui.py	Mon Feb 10 07:13:10 2014 +0400
@@ -8,6 +8,7 @@
 from i18n import _
 import errno, getpass, os, socket, sys, tempfile, traceback
 import config, scmutil, util, error, formatter
+from node import hex
 
 class ui(object):
     def __init__(self, src=None):
@@ -723,6 +724,8 @@
             f.close()
 
             environ = {'HGUSER': user}
+            if 'transplant_source' in extra:
+                environ.update({'HGREVISION': hex(extra['transplant_source'])})
             for label in ('source', 'rebase_source'):
                 if label in extra:
                     environ.update({'HGREVISION': extra[label]})