Patchwork [7,of,7] export: map wctx.node() to 'ff...' node id (issue5438)

login
register
mail settings
Submitter Yuya Nishihara
Date June 3, 2017, 2:39 p.m.
Message ID <d9d54fdf193fc7296de4.1496500771@mimosa>
Download mbox | patch
Permalink /patch/21162/
State Accepted
Headers show

Comments

Yuya Nishihara - June 3, 2017, 2:39 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1496485039 -32400
#      Sat Jun 03 19:17:19 2017 +0900
# Node ID d9d54fdf193fc7296de41c0ff259f1d58ace2763
# Parent  1a10667a630c1558e2fe6b4ed081a4c5f7bf59f7
export: map wctx.node() to 'ff...' node id (issue5438)
Augie Fackler - June 3, 2017, 8:35 p.m.
On Sat, Jun 03, 2017 at 11:39:31PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1496485039 -32400
> #      Sat Jun 03 19:17:19 2017 +0900
> # Node ID d9d54fdf193fc7296de41c0ff259f1d58ace2763
> # Parent  1a10667a630c1558e2fe6b4ed081a4c5f7bf59f7
> export: map wctx.node() to 'ff...' node id (issue5438)

queued, thanks
Matt Harbison - June 4, 2017, 5:02 a.m.
On Sat, 03 Jun 2017 10:39:31 -0400, Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1496485039 -32400
> #      Sat Jun 03 19:17:19 2017 +0900
> # Node ID d9d54fdf193fc7296de41c0ff259f1d58ace2763
> # Parent  1a10667a630c1558e2fe6b4ed081a4c5f7bf59f7
> export: map wctx.node() to 'ff...' node id (issue5438)
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1140,7 +1140,7 @@ extraexport = []
>  extraexportmap = {}
> def _exportsingle(repo, ctx, match, switch_parent, rev, seqno, write,  
> diffopts):
> -    node = ctx.node()
> +    node = scmutil.binnode(ctx)
>      parents = [p.node() for p in ctx.parents() if p]
>      branch = ctx.branch()
>      if switch_parent:
> diff --git a/tests/test-export.t b/tests/test-export.t
> --- a/tests/test-export.t
> +++ b/tests/test-export.t
> @@ -137,6 +137,28 @@ Exporting revision -2 to a file:
>     foo-9
>    +foo-10
> +Exporting wdir revision:
> +
> +  $ echo "foo-wdir" >> foo
> +  $ hg export 'wdir()'
> +  # HG changeset patch
> +  # User test
> +  # Date 0 0
> +  #      Thu Jan 01 00:00:00 1970 +0000
> +  # Node ID ffffffffffffffffffffffffffffffffffffffff
> +  # Parent  f3acbafac161ec68f1598af38f794f28847ca5d3

I wonder if a node of ff..ff should imply --no-commit on import.

> +
> +  diff -r f3acbafac161 foo
> +  --- a/foo	Thu Jan 01 00:00:00 1970 +0000
> +  +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
> +  @@ -10,3 +10,4 @@
> +   foo-9
> +   foo-10
> +   foo-11
> +  +foo-wdir
> +  $ hg revert -q foo
> +
>  No filename should be printed if stdout is specified explicitly:
>   $ hg export -v 1 -o -
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - June 4, 2017, 2:48 p.m.
On Sun, 04 Jun 2017 01:02:45 -0400, Matt Harbison wrote:
> On Sat, 03 Jun 2017 10:39:31 -0400, Yuya Nishihara <yuya@tcha.org> wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1496485039 -32400
> > #      Sat Jun 03 19:17:19 2017 +0900
> > # Node ID d9d54fdf193fc7296de41c0ff259f1d58ace2763
> > # Parent  1a10667a630c1558e2fe6b4ed081a4c5f7bf59f7
> > export: map wctx.node() to 'ff...' node id (issue5438)
> >
> > diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py
> > +++ b/mercurial/cmdutil.py
> > @@ -1140,7 +1140,7 @@ extraexport = []
> >  extraexportmap = {}
> > def _exportsingle(repo, ctx, match, switch_parent, rev, seqno, write,  
> > diffopts):
> > -    node = ctx.node()
> > +    node = scmutil.binnode(ctx)
> >      parents = [p.node() for p in ctx.parents() if p]
> >      branch = ctx.branch()
> >      if switch_parent:
> > diff --git a/tests/test-export.t b/tests/test-export.t
> > --- a/tests/test-export.t
> > +++ b/tests/test-export.t
> > @@ -137,6 +137,28 @@ Exporting revision -2 to a file:
> >     foo-9
> >    +foo-10
> > +Exporting wdir revision:
> > +
> > +  $ echo "foo-wdir" >> foo
> > +  $ hg export 'wdir()'
> > +  # HG changeset patch
> > +  # User test
> > +  # Date 0 0
> > +  #      Thu Jan 01 00:00:00 1970 +0000
> > +  # Node ID ffffffffffffffffffffffffffffffffffffffff
> > +  # Parent  f3acbafac161ec68f1598af38f794f28847ca5d3
> 
> I wonder if a node of ff..ff should imply --no-commit on import.

I don't think it's good idea. The node (and parent) value is just a hint
and unused unless --exact is specified.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1140,7 +1140,7 @@  extraexport = []
 extraexportmap = {}
 
 def _exportsingle(repo, ctx, match, switch_parent, rev, seqno, write, diffopts):
-    node = ctx.node()
+    node = scmutil.binnode(ctx)
     parents = [p.node() for p in ctx.parents() if p]
     branch = ctx.branch()
     if switch_parent:
diff --git a/tests/test-export.t b/tests/test-export.t
--- a/tests/test-export.t
+++ b/tests/test-export.t
@@ -137,6 +137,28 @@  Exporting revision -2 to a file:
    foo-9
   +foo-10
 
+Exporting wdir revision:
+
+  $ echo "foo-wdir" >> foo
+  $ hg export 'wdir()'
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #      Thu Jan 01 00:00:00 1970 +0000
+  # Node ID ffffffffffffffffffffffffffffffffffffffff
+  # Parent  f3acbafac161ec68f1598af38f794f28847ca5d3
+  
+  
+  diff -r f3acbafac161 foo
+  --- a/foo	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
+  @@ -10,3 +10,4 @@
+   foo-9
+   foo-10
+   foo-11
+  +foo-wdir
+  $ hg revert -q foo
+
 No filename should be printed if stdout is specified explicitly:
 
   $ hg export -v 1 -o -