ui: edit(): rebase, graft: set HGREVISION environment variable for an editor
authorAlexander Drozdov <al.drozdov@gmail.com>
Thu, 06 Feb 2014 12:21:20 +0400
changeset 20605 a8aa699a812a
parent 20604 4991cfc90f59
child 20606 be140ebd506b
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).
mercurial/ui.py
--- 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)