changeset 6852:8dc510c4caee

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Wed, 30 Jul 2008 22:33:40 +0200
parents 1a9577da9d02 (current diff) 6ec941b6003d (diff)
children e8c2dae47799
files hgext/convert/subversion.py
diffstat 5 files changed, 40 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/subversion.py	Fri Jul 25 20:47:04 2008 +0200
+++ b/hgext/convert/subversion.py	Wed Jul 30 22:33:40 2008 +0200
@@ -130,18 +130,6 @@
             self._stdout.close()
             self._stdout = None
 
-def get_log(url, paths, start, end, limit=0, discover_changed_paths=True,
-                strict_node_history=False):
-    args = [url, paths, start, end, limit, discover_changed_paths,
-            strict_node_history]
-    arg = encodeargs(args)
-    hgexe = util.hgexecutable()
-    cmd = '%s debugsvnlog' % util.shellquote(hgexe)
-    stdin, stdout = os.popen2(cmd, 'b')
-    stdin.write(arg)
-    stdin.close()
-    return logstream(stdout)
-
 # SVN conversion code stolen from bzr-svn and tailor
 #
 # Subversion looks like a versioned filesystem, branches structures
@@ -394,7 +382,7 @@
         tagspath = self.tags
         start = svn.ra.get_latest_revnum(self.ra)
         try:
-            for entry in get_log(self.url, [self.tags], start, self.startrev):
+            for entry in self._getlog([self.tags], start, self.startrev):
                 origpaths, revnum, author, date, message = entry
                 copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e
                           in origpaths.iteritems() if e.copyfrom_path]
@@ -490,7 +478,7 @@
         # stat() gives us the previous revision on this line of development, but
         # it might be in *another module*. Fetch the log and detect renames down
         # to the latest revision.
-        stream = get_log(self.url, [path], stop, dirent.created_rev)
+        stream = self._getlog([path], stop, dirent.created_rev)
         try:
             for entry in stream:
                 paths, revnum, author, date, message = entry
@@ -812,7 +800,7 @@
         try:
             firstcset = None
             lastonbranch = False
-            stream = get_log(self.url, [self.module], from_revnum, to_revnum)
+            stream = self._getlog([self.module], from_revnum, to_revnum)
             try:
                 for entry in stream:
                     paths, revnum, author, date, message = entry
@@ -910,6 +898,25 @@
         # to PROPFIND subversion errors
         return svn.ra.check_path(self.ra, path.strip('/'), revnum)
 
+    def _getlog(self, paths, start, end, limit=0, discover_changed_paths=True,
+                strict_node_history=False):
+        # Normalize path names, svn >= 1.5 only wants paths relative to
+        # supplied URL
+        relpaths = []
+        for p in paths:
+            if not p.startswith('/'):
+                p = self.module + '/' + p
+            relpaths.append(p.strip('/'))
+        args = [self.base, relpaths, start, end, limit, discover_changed_paths,
+                strict_node_history]
+        arg = encodeargs(args)
+        hgexe = util.hgexecutable()
+        cmd = '%s debugsvnlog' % util.shellquote(hgexe)
+        stdin, stdout = os.popen2(cmd, 'b')
+        stdin.write(arg)
+        stdin.close()
+        return logstream(stdout)
+
 pre_revprop_change = '''#!/bin/sh
 
 REPOS="$1"
--- a/tests/test-convert-svn-branches	Fri Jul 25 20:47:04 2008 +0200
+++ b/tests/test-convert-svn-branches	Wed Jul 30 22:33:40 2008 +0200
@@ -58,7 +58,7 @@
 svn ci -m "change b"
 
 echo % create a cross-branch revision
-svn move -m "move b" trunk/b branches/old/c
+svn move trunk/b branches/old/c
 "$TESTDIR/svn-safe-append.py" c branches/old/c
 svn ci -m "move and update c"
 
--- a/tests/test-convert-svn-move	Fri Jul 25 20:47:04 2008 +0200
+++ b/tests/test-convert-svn-move	Wed Jul 30 22:33:40 2008 +0200
@@ -58,10 +58,19 @@
 svn rm subproject/trunk/d2
 svn ci -m "changeb and rm d2"
 svn mv $svnurl/subproject/trunk/d1 $svnurl/subproject/branches/d1 -m moved1again
-echo % copy a file from a past revision
-svn copy -r 7 $svnurl/subproject/trunk/d2/d $svnurl/subproject/trunk -m copyfilefrompast
-echo % copy a directory from a past revision
-svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast
+
+if svn help copy | grep 'SRC\[@REV\]' > /dev/null 2>&1; then
+    # SVN >= 1.5 replaced the -r REV syntax with @REV
+    echo % copy a file from a past revision
+    svn copy $svnurl/subproject/trunk/d2/d@7 $svnurl/subproject/trunk -m copyfilefrompast
+    echo % copy a directory from a past revision
+    svn copy $svnurl/subproject/trunk/d2@7 $svnurl/subproject/trunk -m copydirfrompast
+else
+    echo % copy a file from a past revision
+    svn copy -r 7 $svnurl/subproject/trunk/d2/d $svnurl/subproject/trunk -m copyfilefrompast
+    echo % copy a directory from a past revision
+    svn copy -r 7 $svnurl/subproject/trunk/d2 $svnurl/subproject/trunk -m copydirfrompast
+fi
 cd ..
 
 echo % convert trunk and branches
--- a/tests/test-convert-svn-tags	Fri Jul 25 20:47:04 2008 +0200
+++ b/tests/test-convert-svn-tags	Wed Jul 30 22:33:40 2008 +0200
@@ -31,7 +31,7 @@
 cd ..
 
 svnurl=file://$svnpath/svn-repo/projA
-svn import -m "init projA" projA $svnurl | fix_path
+svn import -m "init projA" projA $svnurl | fix_path | sort
 
 echo % update svn repository
 svn co $svnurl A | fix_path
--- a/tests/test-convert-svn-tags.out	Fri Jul 25 20:47:04 2008 +0200
+++ b/tests/test-convert-svn-tags.out	Wed Jul 30 22:33:40 2008 +0200
@@ -1,9 +1,9 @@
 % initial svn import
+
+Adding         projA/branches
+Adding         projA/tags
 Adding         projA/trunk
 Adding         projA/unrelated
-Adding         projA/branches
-Adding         projA/tags
-
 Committed revision 1.
 % update svn repository
 A    A/trunk