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).
--- 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)