convert: check svn branches are directories
authorPatrick Mezard <pmezard@gmail.com>
Mon, 07 Apr 2008 11:59:20 +0200
changeset 6491 2bdd43246c95
parent 6489 204a2ca249b6
child 6492 43d14cbd69b7
child 6493 c19c26718d22
convert: check svn branches are directories
hgext/convert/subversion.py
tests/test-convert-svn-branches
tests/test-convert-svn-branches.out
--- a/hgext/convert/subversion.py	Mon Apr 07 09:02:26 2008 +0200
+++ b/hgext/convert/subversion.py	Mon Apr 07 11:59:20 2008 +0200
@@ -247,6 +247,10 @@
 
     def getheads(self):
 
+        def isdir(path, revnum):
+            kind = svn.ra.check_path(self.ra, path, revnum)
+            return kind == svn.core.svn_node_dir
+
         def getcfgpath(name, rev):
             cfgpath = self.ui.config('convert', 'svn.' + name)
             if cfgpath is not None and cfgpath.strip() == '':
@@ -288,6 +292,8 @@
                                         self.ctx)
             for branch in branchnames.keys():
                 module = '%s/%s/%s' % (oldmodule, branches, branch)
+                if not isdir(module, self.last_changed):
+                    continue
                 brevid = self.latest(module, self.last_changed)
                 if not brevid:
                     self.ui.note(_('ignoring empty branch %s\n') %
--- a/tests/test-convert-svn-branches	Mon Apr 07 09:02:26 2008 +0200
+++ b/tests/test-convert-svn-branches	Mon Apr 07 11:59:20 2008 +0200
@@ -38,7 +38,9 @@
 echo hello > trunk/letter.txt
 echo hey > trunk/letter2.txt
 echo ho > trunk/letter3.txt
-svn add trunk/letter.txt trunk/letter2.txt trunk/letter3.txt
+# Add a file within branches, used to confuse branch detection
+echo a > branches/readme.txt
+svn add trunk/letter.txt trunk/letter2.txt trunk/letter3.txt branches/readme.txt
 svn ci -m hello
 
 echo % branch to old letters
--- a/tests/test-convert-svn-branches.out	Mon Apr 07 09:02:26 2008 +0200
+++ b/tests/test-convert-svn-branches.out	Mon Apr 07 11:59:20 2008 +0200
@@ -12,10 +12,12 @@
 A         trunk/letter.txt
 A         trunk/letter2.txt
 A         trunk/letter3.txt
+A         branches/readme.txt
+Adding         branches/readme.txt
 Adding         trunk/letter.txt
 Adding         trunk/letter2.txt
 Adding         trunk/letter3.txt
-Transmitting file data ...
+Transmitting file data ....
 Committed revision 2.
 % branch to old letters
 A         branches/old