Patchwork [2,of,2,V2] manifestmerge: handle workdir removed, remote removed with flags

login
register
mail settings
Submitter Siddharth Agarwal
Date April 10, 2013, 7:43 p.m.
Message ID <edfb9f620895ca341773.1365623013@sid0x220>
Download mbox | patch
Permalink /patch/1271/
State Superseded
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Siddharth Agarwal - April 10, 2013, 7:43 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1365622482 25200
#      Wed Apr 10 12:34:42 2013 -0700
# Node ID edfb9f620895ca341773438b045124ec3454722b
# Parent  a17b73403f3b1ebb2d217dbbc1aa502ee19cb879
manifestmerge: handle workdir removed, remote removed with flags

This can happen when a file with flags is removed or deleted in the working
directory and also not present in m2. The obvious solution is to add a
__delitem__ override to manifestdict that removes the file from flags if
necessary, but that has a significant performance cost in some cases, e.g.
hg status --rev rev1 --rev rev2 <file>.
Augie Fackler - April 10, 2013, 8:29 p.m.
On Wed, Apr 10, 2013 at 12:43:33PM -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1365622482 25200
> #      Wed Apr 10 12:34:42 2013 -0700
> # Node ID edfb9f620895ca341773438b045124ec3454722b
> # Parent  a17b73403f3b1ebb2d217dbbc1aa502ee19cb879
> manifestmerge: handle workdir removed, remote removed with flags

Series seems clear enough to me, but I'd like Bryan to take a look too
in case it's not clear to him.

>
> This can happen when a file with flags is removed or deleted in the working
> directory and also not present in m2. The obvious solution is to add a
> __delitem__ override to manifestdict that removes the file from flags if
> necessary, but that has a significant performance cost in some cases, e.g.
> hg status --rev rev1 --rev rev2 <file>.
>
> diff -r a17b73403f3b -r edfb9f620895 mercurial/merge.py
> --- a/mercurial/merge.py	Wed Apr 10 12:31:07 2013 -0700
> +++ b/mercurial/merge.py	Wed Apr 10 12:34:42 2013 -0700
> @@ -246,7 +246,13 @@ def manifestmerge(repo, wctx, p2, pa, br
>          if n12:
>              n1, n2 = n12
>          else: # file contents didn't change, but flags did
> -            n1 = n2 = m1[f]
> +            n1 = n2 = m1.get(f, None)
> +            if n1 is None:
> +                # Since n1 == n2, the file isn't present in m2 either. This
> +                # means that the file was removed or deleted locally and
> +                # removed remotely, but that residual entries remain in flags.
> +                # This can happen in manifests generated by workingctx.
> +                continue
>          if fl12:
>              fl1, fl2 = fl12
>          else: # flags didn't change, file contents did
> diff -r a17b73403f3b -r edfb9f620895 tests/test-update-issue1456.t
> --- a/tests/test-update-issue1456.t	Wed Apr 10 12:31:07 2013 -0700
> +++ b/tests/test-update-issue1456.t	Wed Apr 10 12:34:42 2013 -0700
> @@ -6,9 +6,16 @@
>
>    $ echo foo > foo
>    $ hg ci -qAm0
> -  $ chmod +x foo
> -  $ hg ci -m1
> +  $ echo toremove > toremove
> +  $ echo todelete > todelete
> +  $ chmod +x foo toremove todelete
> +  $ hg ci -qAm1
> +
> +Test that local removed/deleted, remote removed works with flags
> +  $ hg rm toremove
> +  $ rm todelete
>    $ hg co -q 0
> +
>    $ echo dirty > foo
>    $ hg up -c
>    abort: uncommitted local changes
> @@ -18,11 +25,13 @@
>    dirty
>    $ hg st -A
>    M foo
> +  C todelete
> +  C toremove
>
>  Validate update of standalone execute bit change:
>
>    $ hg up -C 0
> -  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
>    $ chmod -x foo
>    $ hg ci -m removeexec
>    nothing changed
> @@ -30,7 +39,7 @@ Validate update of standalone execute bi
>    $ hg up -C 0
>    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg up
> -  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
>    $ hg st
>
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Bryan O'Sullivan - April 10, 2013, 9:19 p.m.
On Wed, Apr 10, 2013 at 12:43 PM, Siddharth Agarwal <sid0@fb.com> wrote:

> manifestmerge: handle workdir removed, remote removed with flags
>

Both patches crewed, thanks.

Patch

diff -r a17b73403f3b -r edfb9f620895 mercurial/merge.py
--- a/mercurial/merge.py	Wed Apr 10 12:31:07 2013 -0700
+++ b/mercurial/merge.py	Wed Apr 10 12:34:42 2013 -0700
@@ -246,7 +246,13 @@  def manifestmerge(repo, wctx, p2, pa, br
         if n12:
             n1, n2 = n12
         else: # file contents didn't change, but flags did
-            n1 = n2 = m1[f]
+            n1 = n2 = m1.get(f, None)
+            if n1 is None:
+                # Since n1 == n2, the file isn't present in m2 either. This
+                # means that the file was removed or deleted locally and
+                # removed remotely, but that residual entries remain in flags.
+                # This can happen in manifests generated by workingctx.
+                continue
         if fl12:
             fl1, fl2 = fl12
         else: # flags didn't change, file contents did
diff -r a17b73403f3b -r edfb9f620895 tests/test-update-issue1456.t
--- a/tests/test-update-issue1456.t	Wed Apr 10 12:31:07 2013 -0700
+++ b/tests/test-update-issue1456.t	Wed Apr 10 12:34:42 2013 -0700
@@ -6,9 +6,16 @@ 
 
   $ echo foo > foo
   $ hg ci -qAm0
-  $ chmod +x foo
-  $ hg ci -m1
+  $ echo toremove > toremove
+  $ echo todelete > todelete
+  $ chmod +x foo toremove todelete
+  $ hg ci -qAm1
+
+Test that local removed/deleted, remote removed works with flags
+  $ hg rm toremove
+  $ rm todelete
   $ hg co -q 0
+
   $ echo dirty > foo
   $ hg up -c
   abort: uncommitted local changes
@@ -18,11 +25,13 @@ 
   dirty
   $ hg st -A
   M foo
+  C todelete
+  C toremove
 
 Validate update of standalone execute bit change:
 
   $ hg up -C 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ chmod -x foo
   $ hg ci -m removeexec
   nothing changed
@@ -30,7 +39,7 @@  Validate update of standalone execute bi
   $ hg up -C 0
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg up
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg st
 
   $ cd ..