changeset 13778:46c3043253fb

rebase: don't mark file as removed if missing in parent's manifest (issue2725)
author Stefano Tortarolo <stefano.tortarolo@gmail.com>
date Sun, 27 Mar 2011 13:34:20 +0200
parents f6e5035dc81a
children c13bfa451656
files hgext/rebase.py tests/test-rebase-rename.t
diffstat 2 files changed, 50 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Sun Mar 27 12:22:07 2011 +0200
+++ b/hgext/rebase.py	Sun Mar 27 13:34:20 2011 +0200
@@ -277,7 +277,7 @@
         if k in m1:
             if v in m1 or v in m2:
                 repo.dirstate.copy(v, k)
-                if v in m2 and v not in m1:
+                if v in m2 and v not in m1 and k in m2:
                     repo.dirstate.remove(v)
 
 def concludenode(repo, rev, p1, p2, commitmsg=None, extrafn=None):
--- a/tests/test-rebase-rename.t	Sun Mar 27 12:22:07 2011 +0200
+++ b/tests/test-rebase-rename.t	Sun Mar 27 13:34:20 2011 +0200
@@ -119,3 +119,52 @@
   copy from a
   copy to a-copied
   
+  $ cd ..
+
+
+Test rebase across repeating renames:
+
+  $ hg init repo
+
+  $ cd repo
+
+  $ echo testing > file1.txt
+  $ hg add file1.txt
+  $ hg ci -m "Adding file1"
+
+  $ hg rename file1.txt file2.txt
+  $ hg ci -m "Rename file1 to file2"
+
+  $ echo Unrelated change > unrelated.txt
+  $ hg add unrelated.txt
+  $ hg ci -m "Unrelated change"
+
+  $ hg rename file2.txt file1.txt
+  $ hg ci -m "Rename file2 back to file1"
+
+  $ hg update -r -2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+
+  $ echo Another unrelated change >> unrelated.txt
+  $ hg ci -m "Another unrelated change"
+  created new head
+
+  $ hg tglog
+  @  4: 'Another unrelated change'
+  |
+  | o  3: 'Rename file2 back to file1'
+  |/
+  o  2: 'Unrelated change'
+  |
+  o  1: 'Rename file1 to file2'
+  |
+  o  0: 'Adding file1'
+  
+
+  $ hg rebase -s 4 -d 3
+  saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-backup.hg (glob)
+
+  $ hg diff --stat -c .
+   unrelated.txt |  1 +
+   1 files changed, 1 insertions(+), 0 deletions(-)
+