[PATCH 2 of 3] Updated svn 1.4.3 bugfixes
Brendan Cully
brendan at kublai.com
Sun Jul 1 12:39:04 CDT 2007
# HG changeset patch
# User Brendan Cully <brendan at kublai.com>
# Date 1183266825 25200
# Node ID fd573e1754ec703670e1404fde38d403bd5df27e
# Parent 6b3eab5d9ee471c064aa9a64e8c3ffddf25bfc3b
Updated svn 1.4.3 bugfixes
diff --git a/svn/compat-1.4.3.patch b/svn/compat-1.4.3.patch
--- a/svn/compat-1.4.3.patch
+++ b/svn/compat-1.4.3.patch
@@ -26,10 +26,36 @@ diff --git a/hgext/convert/common.py b/h
+ return s.decode("latin-1").encode("utf-8")
+ except:
+ return s.decode("utf-8", "replace").encode("utf-8")
+diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
+--- a/hgext/convert/hg.py
++++ b/hgext/convert/hg.py
+@@ -30,13 +30,7 @@ class convert_mercurial(converter_sink):
+ self.repo.dirstate.update([f], "a")
+
+ def copyfile(self, source, dest):
+- # Hold a copymap map[dest] = source, like Mercurial does?
+- # Might need to say self.repo.dirstate.copies()[dest] = source
+- # Just mark it, don't let it actually do anything:a
+- if hasattr(self.repo.dirstate, '_copymap'):
+- self.repo.dirstate._copymap[dest] = source
+- else:
+- self.ui.warn("no copymap in dirstate\n")
++ self.repo.copy(source, dest)
+
+ def delfile(self, f):
+ try:
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
-@@ -42,6 +42,12 @@ class svn_paths(object):
+@@ -21,6 +21,7 @@ from cStringIO import StringIO
+
+ from common import NoRepo, commit, converter_source, recode
+
++class CompatibilityException(Exception): pass
+
+ class svn_entry(object):
+ """Emulate a Subversion path change."""
+@@ -42,6 +43,12 @@ class svn_paths(object):
def __init__(self, orig_paths):
self.order = []
self.values = {}
@@ -42,7 +68,60 @@ diff --git a/hgext/convert/subversion.py
for path in orig_paths:
self.order.append(path)
self.values[path] = svn_entry(orig_paths[path])
-@@ -356,13 +362,14 @@ class convert_svn(converter_source):
+@@ -179,7 +186,7 @@ class convert_svn(converter_source):
+ copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions.
+ copies = {}
+ entries = []
+- # print "Revision %d" % revnum
++ self.ui.debug("parsing evision %d\n" % revnum)
+ if orig_paths is not None:
+ if revnum in (4380, 6907, 6940):
+ print orig_paths
+@@ -190,7 +197,6 @@ class convert_svn(converter_source):
+ branch = None
+
+ for path in orig_paths:
+- # self.ui.write("path %s\n" % path)
+ if path == self.module: # Follow branching back in history
+ ent = orig_paths[path]
+ if ent:
+@@ -272,7 +278,10 @@ class convert_svn(converter_source):
+ if ent.action == 'C':
+ children = self._find_children(path, fromrev)
+ else:
+- children = self._find_children(path, fromrev)
++ oroot = entrypath.strip('/')
++ nroot = path.strip('/')
++ children = self._find_children(oroot, fromrev)
++ children = [s.replace(oroot,nroot) for s in children]
+ # Mark all [files, not directories] as deleted.
+ for child in children:
+ # Can we move a child directory and its
+@@ -281,8 +290,12 @@ class convert_svn(converter_source):
+ # we have to look in (copyfrom_path, revnum - 1)
+ entrypath = get_entry_from_path("/" + child, module=old_module)
+ if entrypath:
+- entry = entrypath.decode(self.encoding)
+- entries.append(recode(entry))
++ entry = recode(entrypath.decode(self.encoding))
++ if entry in copies:
++ # deleted file within a copy
++ del copies[entry]
++ else:
++ entries.append(entry)
+ elif kind == svn.core.svn_node_dir:
+ # Should probably synthesize normal file entries
+ # and handle as above to clean up copy/rename handling.
+@@ -329,7 +342,7 @@ class convert_svn(converter_source):
+ copyfrom_entry = get_entry_from_path(copyfrom_path, module=self.module)
+ if copyfrom_entry:
+ copyfrom[path] = ent
+- print "mark", path, "came from", copyfrom[path]
++ self.ui.debug('%s came from %s\n' % (path, copyfrom_path))
+
+ # Good, /probably/ a regular copy. Really should check
+ # to see whether the parent revision actually contains
+@@ -356,13 +369,14 @@ class convert_svn(converter_source):
# ISO-8601 conformant
# '2007-01-04T17:35:00.902377Z'
date = util.parsedate(date[:18] + " UTC", ["%Y-%m-%dT%H:%M:%S"])
@@ -59,10 +138,20 @@ diff --git a/hgext/convert/subversion.py
date=util.datestr(date),
desc=log,
parents=[],
-@@ -447,6 +454,19 @@ class convert_svn(converter_source):
+@@ -376,7 +390,6 @@ class convert_svn(converter_source):
+ self.commits[rev] = cset
+
+ try:
+- print "\n\n\n\n"
+ discover_changed_paths = True
+ strict_node_history = False
+ svn.ra.get_log(self.ra, [self.module], from_revnum, to_revnum,
+@@ -447,10 +460,24 @@ class convert_svn(converter_source):
return []
def _find_children(self, path, revnum):
++ path = path.strip("/")
++
+ def _find_children_fallback(path, revnum):
+ # SWIG python bindings for getdir are broken up to at least 1.4.3
+ if not hasattr(self, 'client_ctx'):
@@ -71,22 +160,41 @@ diff --git a/hgext/convert/subversion.py
+ optrev.kind = svn.core.svn_opt_revision_number
+ optrev.value.number = revnum
+ rpath = '/'.join([self.url, path]).strip('/')
-+ return svn.client.ls(rpath, optrev, True, self.client_ctx).keys()
++ return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev, True, self.client_ctx).keys()]
+
+ if hasattr(self, '_find_children_fallback'):
+ return _find_children_fallback(path, revnum)
+
++ self.reparent("/" + path)
pool = Pool()
- path = path.strip("/")
- self.reparent("/" + path)
-@@ -458,6 +478,10 @@ class convert_svn(converter_source):
+- path = path.strip("/")
+- self.reparent("/" + path)
+-
++
+ children = []
+ def find_children_inner(children, path, revnum = revnum):
+ if hasattr(svn.ra, 'get_dir2'): # Since SVN 1.4
+@@ -458,6 +485,9 @@ class convert_svn(converter_source):
getdir = svn.ra.get_dir2(self.ra, path, revnum, fields, pool)
else:
getdir = svn.ra.get_dir(self.ra, path, revnum, pool)
+ if type(getdir) == dict:
+ # python binding for getdir is broken up to at least 1.4.3
-+ self._find_children_fallback = True
-+ return _find_children_fallback(path, revnum)
++ raise CompatibilityException()
dirents = getdir[0]
if type(dirents) == int:
print "integer"
+@@ -473,7 +503,12 @@ class convert_svn(converter_source):
+ else:
+ children.append((path + "/" + child).strip("/"))
+
+- find_children_inner(children, "")
++ try:
++ find_children_inner(children, "")
++ except CompatibilityException:
++ self._find_children_fallback = True
++ self.reparent(self.module)
++ return _find_children_fallback(path, revnum)
+
+ self.reparent(self.module)
+ return [path + "/" + c for c in children]
More information about the Mercurial-devel
mailing list