Patchwork [4,of,4,V3,RESEND] ui: edit(): transplant: set HGREVISION environment variable for an editor

login
register
mail settings
Submitter Alexander Drozdov
Date Feb. 17, 2014, 3:29 a.m.
Message ID <e542767e79c75eee903f.1392607778@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/3685/
State Accepted
Commit be140ebd506b469632d1f29f63beb63510e40398
Headers show

Comments

Alexander Drozdov - Feb. 17, 2014, 3:29 a.m.
# HG changeset patch
# User Alexander Drozdov <al.drozdov@gmail.com>
# Date 1392001990 -14400
#      Mon Feb 10 07:13:10 2014 +0400
# Node ID e542767e79c75eee903fd03d85818798a1ad4ab8
# Parent  3dc40b4b56301758c818e374df04af72f36bb7de
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.
Augie Fackler - Feb. 28, 2014, 8:03 p.m.
On Feb 16, 2014, at 10:29 PM, Alexander Drozdov <al.drozdov@gmail.com> wrote:

> # HG changeset patch
> # User Alexander Drozdov <al.drozdov@gmail.com>
> # Date 1392001990 -14400
> #      Mon Feb 10 07:13:10 2014 +0400
> # Node ID e542767e79c75eee903fd03d85818798a1ad4ab8
> # Parent  3dc40b4b56301758c818e374df04af72f36bb7de
> ui: edit(): transplant: set HGREVISION environment variable for an editor

Looks handy, queued, thanks.

> 
> 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]})
> _______________________________________________
> 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
@@ -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]})