[PATCH] merge: move forgets to the beginning of the action list

Siddharth Agarwal sid0 at fb.com
Wed Nov 6 12:20:35 CST 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1383762018 28800
#      Wed Nov 06 10:20:18 2013 -0800
# Node ID 59bfba81dd3daf97591b9c907f9ad26fda8c5b60
# Parent  419788cc0e5e889477786e4a4cae55b13819979a
merge: move forgets to the beginning of the action list

Forgets need to be in the beginning of the action list, same as removes. This
lets us avoid clashes in the dirstate where a directory is forgotten and a
file with the same name is added, or vice versa.

diff -r 419788cc0e5e -r 59bfba81dd3d mercurial/merge.py
--- a/mercurial/merge.py	Mon Oct 14 00:25:29 2013 -0400
+++ b/mercurial/merge.py	Wed Nov 06 10:20:18 2013 -0800
@@ -384,7 +384,7 @@ def manifestmerge(repo, wctx, p2, pa, br
     return actions
 
 def actionkey(a):
-    return a[1] == "r" and -1 or 0, a
+    return a[1] in "rf" and -1 or 0, a
 
 def getremove(repo, mctx, overwrite, args):
     """apply usually-non-interactive updates to the working directory
diff -r 419788cc0e5e -r 59bfba81dd3d tests/test-add.t
--- a/tests/test-add.t	Mon Oct 14 00:25:29 2013 -0400
+++ b/tests/test-add.t	Wed Nov 06 10:20:18 2013 -0800
@@ -136,5 +136,23 @@ Issue683: peculiarity with hg revert of 
   M a
   A c
   ? a.orig
+  $ hg up -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+forget and get should have the right order: added but missing dir should be
+forgotten before file with same name is added
+
+  $ echo file d > d
+  $ hg add d
+  $ hg ci -md
+  $ hg rm d
+  $ mkdir d
+  $ echo a > d/a
+  $ hg add d/a
+  $ rm -r d
+  $ hg up -C
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat d
+  file d
 
   $ cd ..


More information about the Mercurial-devel mailing list