[PATCH 6 of 6 v2] import: relax import --exact if there is no # Node

Yuya Nishihara yuya at tcha.org
Sun Jan 3 14:58:17 UTC 2016


On Thu, 31 Dec 2015 00:47:20 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1451521862 0
> #      Thu Dec 31 00:31:02 2015 +0000
> # Node ID b9f3eb03b1a009dc4a95a063a612c816ee4821f4
> # Parent  37c3ba3d2f3678daa5439947f20d89496282d8b0
> import: relax import --exact if there is no # Node
> 
> This allows for a patch where the # Parent node is correct,
> and # Node is ommitted, allowing for memory based
> grafting against alternative Nodes merely by doing:
> hg export REV | rewrite Parent | grep -v '# Node ' | \
> hg import --exact --bypass -
> 
> This is a poor man's cross between graft and rebase for
> when your working directory is dirty.
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -874,6 +874,7 @@
>      date = opts.get('date') or extractdata.get('date')
>      branch = extractdata.get('branch')
>      nodeid = extractdata.get('nodeid')
> +    hgpatch = extractdata.get('hgpatch')
>      p1 = extractdata.get('p1')
>      p2 = extractdata.get('p2')
>  
> @@ -906,7 +907,7 @@
>          if len(parents) == 1:
>              parents.append(repo[nullid])
>          if usenode:
> -            if not nodeid or not p1:
> +            if not p1 or not (nodeid or hgpatch):
>                  raise error.Abort(_('not a Mercurial patch'))

"hgpatch" flag won't be necessary.

This error was introduced by 47ba52121433 with --exact flag. So we can assume
that it checks if the patch has enough meta data to do exact commit. Because
this patch relaxes the --exact flag to allow missing nodeid, the remaining
requirement is "if not p1".


More information about the Mercurial-devel mailing list