changeset 20605:a8aa699a812a

ui: edit(): rebase, graft: set HGREVISION environment variable for an editor rebase and graft commands set 'rebase_source' or 'source' extras for the revision. Allow an editor to access the extras using HGREVISION environment variable. This may be useful when an editor is actually a script which modifies a commit message. The name 'HGREVISION' has been selected as transplant already sets this variable for its filters (--filter).
author Alexander Drozdov <al.drozdov@gmail.com>
date Thu, 06 Feb 2014 12:21:20 +0400
parents 4991cfc90f59
children be140ebd506b
files mercurial/ui.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Thu Feb 06 10:15:20 2014 +0400
+++ b/mercurial/ui.py	Thu Feb 06 12:21:20 2014 +0400
@@ -722,10 +722,16 @@
             f.write(text)
             f.close()
 
+            environ = {'HGUSER': user}
+            for label in ('source', 'rebase_source'):
+                if label in extra:
+                    environ.update({'HGREVISION': extra[label]})
+                    break
+
             editor = self.geteditor()
 
             util.system("%s \"%s\"" % (editor, name),
-                        environ={'HGUSER': user},
+                        environ=environ,
                         onerr=util.Abort, errprefix=_("edit failed"),
                         out=self.fout)