Commits

anatoly techtonik committed d9eef91

fix error when changeset contains copy operation of file that is out of
scope of shallow checkout

this particular bug occured during conversion of sparse subtree of
distutils module, the output is below:

...
Attempting to update to revision 63607...

Interrupted, please wait for cleanup!

External program failed (return code 1): C:\Mercurial\hg.exe "--encoding" "utf-8" "add" "Lib/ConfigParser.py"
Lib\ConfigParser.py: The system cannot find the file specified

retcode: 0

Comments (0)

Files changed (1)

hgsvn/run/hgpullsvn.py

     changed_paths = []
     unrelated_paths = []
     replaced_paths = {}
+
+    # 1. Prepare for the `svn up` changes that are pulled in the second step
+    #    by analyzing log_entry for the changeset
     for d in log_entry['changed_paths']:
         # e.g. u'/branches/xmpp-subprotocols-2178-2/twisted/words/test/test_jabberxmlstream.py'
         p = d['path']
             if old_p != p:
                 # Try to hint hg about file and dir copies
                 if not os.path.isdir(old_p):
-                    copied_paths.append((old_p, p))
-                    if action == 'R':
-                        removed_paths.append(old_p)
+                    if not os.path.exists(old_p):
+                        # Source file may not exist for shallow checkouts
+                        # TODO: error if checkout is not shallow (need a way to
+                        #       detect when file is out of scope)
+                        # TODO: notify when a copy to current scope is made as
+                        #       that means some history may be missing
+                        pass # p is appended to added_paths later
+                    else:
+                        copied_paths.append((old_p, p))
+                        if action == 'R':
+                            removed_paths.append(old_p)
                 else:
                     # Extract actual copied files (hg doesn't track dirs
                     # and will refuse "hg copy -A" with dirs)
                 # is safest.
                 added_paths.append(p)
 
-    # Update SVN + add/remove/commit hg
+    # 2. Update SVN + add/remove/commit hg
     try:
         if changed_paths:
             args = ["up", "--ignore-externals"]
         next_rev = hgsvn_rev + 1
 
     # Reset working branch to last svn head to have a clean and linear SVN
-    # histoy.
+    # history.
     heads_before = None
     if hgsvn_rev is None:
         heads_before = run_hg(["heads", "--template",