[PATCH 3 of 3 STABLE] memctx: calculate manifest correctly with newly removed files (issue4470)

Augie Fackler raf at durin42.com
Wed Dec 17 10:28:14 CST 2014


On Dec 17, 2014, at 1:14 AM, FUJIWARA Katsunori <foozy at lares.dti.ne.jp> wrote:

> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1418796583 -32400
> #      Wed Dec 17 15:09:43 2014 +0900
> # Branch stable
> # Node ID 1989ba4cb11fc54ac52d4bb6f745d31c764eab80
> # Parent  cd53e1cddd771a95e6a2aa14a6539aa4449e3d05
> memctx: calculate manifest correctly with newly removed files (issue4470)

This series looks great to me, and it's a more comprehensive fix than my series. I really like that this doesn't loop over the entire manifest anymore. My patch for 4470 can probably be dropped in favor of this one.

The other option might be to put these larger patches on default and mine on stable, if we're worried about the size of this series on stable. I'll defer to Pierre-Yves and mpm on that front.

> 
> Before this patch, "memctx._maniefst" tries to get (and use normally)
> filectx also for newly removed files, even though "memctx.filectx()"
> returns None for such files.
> 
> To calculate manifest correctly even with newly removed files, this
> patch does:
> 
>  - replace "man.iteritems()" for the loop by "self._status.modified"
>    to avoid accessing itself to newly removed files
> 
>    this also reduces loop cost for large manifest.
> 
>  - remove files in "self._status.removed" from the manifest
> 
> In this patch, amending is confirmed twice to examine both (1) newly
> removed files and (2) ones already removed in amended revision.
> 
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1683,7 +1683,7 @@
>         pctx = self._parents[0]
>         man = pctx.manifest().copy()
> 
> -        for f, fnode in man.iteritems():
> +        for f in self._status.modified:
>             p1node = nullid
>             p2node = nullid
>             p = pctx[f].parents() # if file isn't in pctx, check p2?
> @@ -1696,6 +1696,10 @@
>         for f in self._status.added:
>             man[f] = revlog.hash(self[f].data(), nullid, nullid)
> 
> +        for f in self._status.removed:
> +            if f in man:
> +                del man[f]
> +
>         return man
> 
>     @propertycache
> diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
> --- a/tests/test-commit-amend.t
> +++ b/tests/test-commit-amend.t
> @@ -905,6 +905,58 @@
>   HG: @@ -0,0 +1,1 @@
>   HG: +y
> 
> +  $ hg rm a
> +  $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y"
> +  expecting diff of a, foo and y
> +  
> +  HG: M: 
> +  HG: A: foo y
> +  HG: R: a
> +  HG: diff -r 6de0c1bde1c8 a
> +  HG: --- a/a	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -1,2 +0,0 @@
> +  HG: -a
> +  HG: -a
> +  HG: diff -r 6de0c1bde1c8 foo
> +  HG: --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -0,0 +1,1 @@
> +  HG: +foo
> +  HG: diff -r 6de0c1bde1c8 y
> +  HG: --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ b/y	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -0,0 +1,1 @@
> +  HG: +y
> +
> +  $ hg rm x
> +  $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y"
> +  expecting diff of a, foo, x and y
> +  
> +  HG: M: 
> +  HG: A: foo y
> +  HG: R: a x
> +  HG: diff -r 6de0c1bde1c8 a
> +  HG: --- a/a	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -1,2 +0,0 @@
> +  HG: -a
> +  HG: -a
> +  HG: diff -r 6de0c1bde1c8 foo
> +  HG: --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -0,0 +1,1 @@
> +  HG: +foo
> +  HG: diff -r 6de0c1bde1c8 x
> +  HG: --- a/x	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -1,1 +0,0 @@
> +  HG: -x
> +  HG: diff -r 6de0c1bde1c8 y
> +  HG: --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +  HG: +++ b/y	Thu Jan 01 00:00:00 1970 +0000
> +  HG: @@ -0,0 +1,1 @@
> +  HG: +y
> 
> Check for issue4405
> -------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20141217/a020def2/attachment.pgp>


More information about the Mercurial-devel mailing list