diff fetch_command.py @ 87:b033d74be76b

fetch_command: in stupid non-diffy mode, take changed paths in account Former code was checkouting all branch files for every converted revision when diffs were not available in stupid mode. Now, only changed items are requested.
author Patrick Mezard <pmezard@gmail.com>
date Fri, 14 Nov 2008 16:18:24 -0600
parents 2e47623fa174
children 3b60f223893a
line wrap: on
line diff
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -295,20 +295,42 @@ 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.
     """
-    files = []
-    try:
-        for path, kind in svn.list_files(branchpath, r.revnum):
-            if kind == 'f':
-                files.append(path)
-    except IOError:
+    parentctx = hg_editor.repo[parentid]
+    kind = svn.checkpath(branchpath, r.revnum)
+    if kind is None:
         # Branch does not exist at this revision. Get parent revision and
         # remove everything.
-        parentctx = hg_editor.repo[parentid]
         files = parentctx.manifest().keys()
         def filectxfn(repo, memctx, path):
             raise IOError()
         return files, filectxfn
 
+    files = []
+    branchprefix = branchpath + '/'
+    for path, e in r.paths.iteritems():
+        if not path.startswith(branchprefix):
+            continue
+        kind = svn.checkpath(path, r.revnum)
+        path = path[len(branchprefix):]
+        if kind == 'f':
+            files.append(path)
+        elif kind == 'd':
+            if e.action == 'M':
+                # Ignore property changes for now
+                continue
+            dirpath = branchprefix + path
+            for child, k in svn.list_files(dirpath, r.revnum):
+                if k == 'f':
+                    files.append(path + '/' + child)
+        else:
+            if path in parentctx:
+                files.append(path)
+                continue
+            # Assume it's a deleted directory
+            path = path + '/'
+            deleted = [f for f in parentctx if f.startswith(path)]
+            files += deleted        
+
     copies = getcopies(svn, hg_editor, branch, branchpath, r, files, parentid)
     
     linkprefix = 'link '