[PATCH 4 of 4] ui: edit(): transplant: set HGREVISION environment variable for an editor

Alexander Drozdov al.drozdov at gmail.com
Sun Feb 9 21:18:13 CST 2014


# HG changeset patch
# User Alexander Drozdov <al.drozdov at gmail.com>
# Date 1392001990 -14400
#      Mon Feb 10 07:13:10 2014 +0400
# Node ID 3c51b5e2b01bc26bc8739857dbee27cb441fb1a1
# Parent  e74e44b95b9986dec38ff5ac1e64464a1c416e1d
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.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -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):
@@ -721,6 +722,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]})


More information about the Mercurial-devel mailing list