[PATCH] convert/bzr: ignore nested repos when listing branches (issue3254)

Patrick Mezard patrick at mezard.eu
Wed Feb 8 16:49:52 UTC 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1328719510 -3600
# Node ID a9c61b726f76ed803aa9cf0668cf3fa0cb7ffab4
# Parent  e1d8218d733bb318605308fa8c6f261f49d0c163
convert/bzr: ignore nested repos when listing branches (issue3254)

Reported by A.S. Budden <abudden at gmail.com>

diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py
--- a/hgext/convert/bzr.py
+++ b/hgext/convert/bzr.py
@@ -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()
diff --git a/tests/test-convert-bzr.t b/tests/test-convert-bzr.t
--- a/tests/test-convert-bzr.t
+++ b/tests/test-convert-bzr.t
@@ -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



More information about the Mercurial-devel mailing list