changeset 16099:4e4c416a0b1f

convert/bzr: ignore nested repos when listing branches (issue3254) Reported by A.S. Budden <abudden@gmail.com>
author Patrick Mezard <patrick@mezard.eu>
date Wed, 08 Feb 2012 17:45:10 +0100
parents 8dc573a9c5e5
children 50682c07a8d0
files hgext/convert/bzr.py tests/test-convert-bzr.t
diffstat 2 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/bzr.py	Wed Feb 08 20:00:52 2012 +0100
+++ b/hgext/convert/bzr.py	Wed Feb 08 17:45:10 2012 +0100
@@ -91,13 +91,16 @@
     def after(self):
         self.sourcerepo.unlock()
 
+    def _bzrbranches(self):
+        return self.sourcerepo.find_branches(using=True)
+
     def getheads(self):
         if not self.rev:
-            heads = sorted([b.last_revision()
-                            for b in self.sourcerepo.find_branches()])
+            # Set using=True to avoid nested repositories (see issue3254)
+            heads = sorted([b.last_revision() for b in self._bzrbranches()])
         else:
             revid = None
-            for branch in self.sourcerepo.find_branches():
+            for branch in self._bzrbranches():
                 try:
                     r = RevisionSpec.from_string(self.rev)
                     info = r.in_history(branch)
@@ -164,7 +167,7 @@
 
     def gettags(self):
         bytetags = {}
-        for branch in self.sourcerepo.find_branches():
+        for branch in self._bzrbranches():
             if not branch.supports_tags():
                 return {}
             tagdict = branch.tags.get_tag_dict()
--- a/tests/test-convert-bzr.t	Wed Feb 08 20:00:52 2012 +0100
+++ b/tests/test-convert-bzr.t	Wed Feb 08 17:45:10 2012 +0100
@@ -261,3 +261,24 @@
   tip                                3:* (glob)
   branch-tag                         1:* (glob)
   trunk-tag                          0:* (glob)
+
+Nested repositories (issue3254)
+
+  $ bzr init-repo -q --no-trees repo/inner
+  $ bzr init -q repo/inner/trunk
+  $ bzr co repo/inner/trunk inner-trunk
+  $ cd inner-trunk
+  $ echo b > b
+  $ bzr add b
+  adding b
+  $ bzr ci -qm addb
+  $ cd ..
+  $ hg convert --datesort repo noinner-bzr
+  initializing destination noinner-bzr repository
+  scanning source...
+  sorting...
+  converting...
+  2 adda
+  1 addb
+  0 changea
+  updating tags