Patchwork [3,of,3] ui: edit(): set HGREVISION environment variable for an editor

login
register
mail settings
Submitter Alexander Drozdov
Date Feb. 6, 2014, 9:54 a.m.
Message ID <52F35BE7.40308@gmail.com>
Download mbox | patch
Permalink /patch/3492/
State Superseded
Headers show

Comments

Alexander Drozdov - Feb. 6, 2014, 9:54 a.m.
# HG changeset patch
# User Alexander Drozdov <al.drozdov@gmail.com>
# Date 1391674880 -14400
#      Thu Feb 06 12:21:20 2014 +0400
# Node ID c103e276580c2cb0f7415ddac5b1658b3a0b0e98
# Parent  504f89e587a9861e7da2e757557c6129946a13d1
ui: edit(): set HGREVISION environment variable for an editor

rebase, graft and transplant commands set 'rebase_source', 'source'
or 'transplant_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. Transplant filters is an alternative way to do it.

Mercurial-devel mailing list
Mercurial-devel@selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -720,10 +720,16 @@ 
              f.write(text)
              f.close()
  +            environ = {'HGUSER': user}
+            for label in ('source', 'rebase_source', 'transplant_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)


_______________________________________________