Patchwork merge: move forgets to the beginning of the action list

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 6, 2013, 6:20 p.m.
Message ID <59bfba81dd3daf97591b.1383762035@sid0x220>
Download mbox | patch
Permalink /patch/2863/
State Superseded
Commit 9bfa86746c9c1f6ab51deb8f174ffc482417d09f
Headers show

Comments

Siddharth Agarwal - Nov. 6, 2013, 6:20 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.
Matt Mackall - Nov. 6, 2013, 10:13 p.m.
On Wed, 2013-11-06 at 10:20 -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@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

Queued for stable, thanks.

Patch

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 ..