diff hgsubversion/svnmeta.py @ 1099:c6f7a8cfeca9

pull: correctly handle replacing the root of a branch with a non-copied directory Prior to this diff, we would either crash, or continue past the replacement without actually recording the change. This could lead to later failing varify if the state before and after weren't identical.
author David Schleimer <dschleimer@fb.com>
date Sat, 16 Nov 2013 16:16:59 -0800
parents 9a7e3dbd0f6e
children eaefb3413b87 656718fdd3be
line wrap: on
line diff
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -490,8 +490,8 @@ class SVNMeta(object):
             #    action of 'D'. We mark the branch as deleted.
             # 5. It's the parent directory of one or more
             #    already-known branches, so we mark them as deleted.
-            # 6. It's a branch being replaced by another branch - the
-            #    action will be 'R'.
+            # 6. It's a branch being replaced by another branch or a new
+            #    directory - the action will be 'R'.
             fi, br = self.split_branch_path(p)[:2]
             if fi is not None:
                 if fi == '':
@@ -501,15 +501,16 @@ class SVNMeta(object):
                         # Check the replacing source is not an ancestor
                         # branch of the branch being replaced, this
                         # would just be a revert.
-                        cfi, cbr = self.split_branch_path(
-                            paths[p].copyfrom_path, paths[p].copyfrom_rev)[:2]
-                        if cfi == '':
-                            cctx = self.repo[self.get_parent_revision(
-                                paths[p].copyfrom_rev + 1, cbr)]
-                            ctx = self.repo[self.get_parent_revision(
-                                revision.revnum, br)]
-                            if cctx and util.isancestor(ctx, cctx):
-                                continue
+                        if paths[p].copyfrom_path:
+                            cfi, cbr = self.split_branch_path(
+                                paths[p].copyfrom_path, paths[p].copyfrom_rev)[:2]
+                            if cfi == '':
+                                cctx = self.repo[self.get_parent_revision(
+                                    paths[p].copyfrom_rev + 1, cbr)]
+                                ctx = self.repo[self.get_parent_revision(
+                                    revision.revnum, br)]
+                                if cctx and util.isancestor(ctx, cctx):
+                                    continue
                         parent = self._determine_parent_branch(
                             p, paths[p].copyfrom_path, paths[p].copyfrom_rev,
                             revision.revnum)