changeset 119:ea65fe2b0856

hg_delta_editor: fix update of stray files in branches/ Ensure that self.current_file is a non-empty path in a branch.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 29 Nov 2008 11:25:01 -0600
parents a0401f6e14dd
children f508c1fa19a5
files fetch_command.py hg_delta_editor.py tests/fixtures/unrelatedbranch.sh tests/fixtures/unrelatedbranch.svndump
diffstat 4 files changed, 57 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -423,15 +423,6 @@ def stupid_fetch_branchrev(svn, hg_edito
     in the branch at the given revision, and 'filectxfn' is a memctx compatible
     callable to retrieve individual file information.
     """
-    kind = svn.checkpath(branchpath, r.revnum)
-    if kind != 'd':
-        # Branch does not exist at this revision. Get parent revision and
-        # remove everything.
-        files = parentctx.manifest().keys()
-        def filectxfn_rm(repo, memctx, path):
-            raise IOError()
-        return files, filectxfn_rm
-
     files = []
     if parentctx.node() == revlog.nullid:
         # Initial revision, fetch all files
@@ -485,14 +476,22 @@ def stupid_svn_server_pull_rev(ui, svn, 
     for b in branches:
         our_tempdir = tempfile.mkdtemp('svn_fetch_temp', dir=temp_location)
         parentctx = hg_editor.repo[hg_editor.get_parent_revision(r.revnum, b)]
-        try:
-            files_touched, filectxfn = stupid_diff_branchrev(
-                ui, svn, hg_editor, b, r, parentctx, our_tempdir)
-        except BadPatchApply, e:
-            # Either this revision or the previous one does not exist.
-            ui.status("fetching entire rev: %s.\n" % e.message)
-            files_touched, filectxfn = stupid_fetch_branchrev(
-                svn, hg_editor, b, branches[b], r, parentctx)
+        kind = svn.checkpath(branches[b], r.revnum)
+        if kind != 'd':
+            # Branch does not exist at this revision. Get parent revision and
+            # remove everything.
+            files_touched = parentctx.manifest().keys()
+            def filectxfn(repo, memctx, path):
+                raise IOError()
+        else:
+            try:            
+                files_touched, filectxfn = stupid_diff_branchrev(
+                    ui, svn, hg_editor, b, r, parentctx, our_tempdir)
+            except BadPatchApply, e:
+                # Either this revision or the previous one does not exist.
+                ui.status("fetching entire rev: %s.\n" % e.message)
+                files_touched, filectxfn = stupid_fetch_branchrev(
+                    svn, hg_editor, b, branches[b], r, parentctx)
 
         date = r.date.replace('T', ' ').replace('Z', '').split('.')[0]
         date += ' -0000'
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -489,7 +489,8 @@ class HgChangeReceiver(delta.Editor):
     @stash_exception_on_self
     def open_file(self, path, parent_baton, base_revision, p=None):
         self.current_file = 'foobaz'
-        if self._is_path_valid(path):
+        fpath, branch = self._path_and_branch_for_path(path)
+        if fpath:
             self.current_file = path
             self.ui.status('M %s\n' % path)
             if base_revision != -1:
@@ -529,8 +530,6 @@ class HgChangeReceiver(delta.Editor):
         self.base_revision = None
         if path in self.deleted_files:
             del self.deleted_files[path]
-        if not self._is_path_valid(path):
-            return
         fpath, branch = self._path_and_branch_for_path(path)
         if not fpath:
             return
--- a/tests/fixtures/unrelatedbranch.sh
+++ b/tests/fixtures/unrelatedbranch.sh
@@ -37,6 +37,9 @@ svn ci -m "add b to branch2"
 echo c > c
 svn add c
 svn ci -m "add c in branches/"
+# Even update it
+echo c >> c
+svn ci -m "change c"
 cd ../..
 
 svnadmin dump testrepo > ../unrelatedbranch.svndump
--- a/tests/fixtures/unrelatedbranch.svndump
+++ b/tests/fixtures/unrelatedbranch.svndump
@@ -1,6 +1,6 @@
 SVN-fs-dump-format-version: 2
 
-UUID: ec581cb1-163d-4e59-b0b6-af7afd6f1624
+UUID: 20b2173d-0f26-4070-9891-00196be06b32
 
 Revision-number: 0
 Prop-content-length: 56
@@ -9,7 +9,7 @@ Content-length: 56
 K 8
 svn:date
 V 27
-2008-11-25T22:20:33.360252Z
+2008-11-25T23:08:28.726784Z
 PROPS-END
 
 Revision-number: 1
@@ -27,7 +27,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-11-25T22:20:33.498908Z
+2008-11-25T23:08:28.798249Z
 PROPS-END
 
 Node-path: branches
@@ -63,7 +63,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-11-25T22:20:34.165016Z
+2008-11-25T23:08:29.163194Z
 PROPS-END
 
 Node-path: trunk/a
@@ -93,7 +93,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-11-25T22:20:35.178215Z
+2008-11-25T23:08:30.176855Z
 PROPS-END
 
 Node-path: branches/branch1
@@ -132,7 +132,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-11-25T22:20:37.174989Z
+2008-11-25T23:08:32.174817Z
 PROPS-END
 
 Node-path: branches/branch2
@@ -185,7 +185,7 @@ pmezard
 K 8
 svn:date
 V 27
-2008-11-25T22:20:38.167521Z
+2008-11-25T23:08:33.166454Z
 PROPS-END
 
 Node-path: branches/c
@@ -200,3 +200,32 @@ PROPS-END
 c
 
 
+Revision-number: 6
+Prop-content-length: 109
+Content-length: 109
+
+K 7
+svn:log
+V 8
+change c
+K 10
+svn:author
+V 7
+pmezard
+K 8
+svn:date
+V 27
+2008-11-25T23:08:34.144541Z
+PROPS-END
+
+Node-path: branches/c
+Node-kind: file
+Node-action: change
+Text-content-length: 4
+Text-content-md5: 63fad9092ad37713ebe26b3193f89c41
+Content-length: 4
+
+c
+c
+
+