changeset 128:c5506ce082b3

7902467: jcheck fails with mercurial 5: object of type 'branchcache' has no len() Reviewed-by: erikj Contributed-by: tim.bell@oracle.com
author erikj
date Thu, 02 Jan 2020 10:28:30 +0100
parents 3f30d0fbf215
children 95d229cc1165
files jcheck.py
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jcheck.py	Mon Jul 08 16:10:06 2019 -0700
+++ b/jcheck.py	Thu Jan 02 10:28:30 2020 +0100
@@ -707,10 +707,25 @@
                     self.error(None,
                                "Illegal tag name: %s" % t)
 
-        bs = self.repo.branchmap()
-        if len(bs) > 1:
-            bs = bs.copy()
-            del bs["default"]
+        # Check for non default branches
+        if hasattr(self.repo.branchmap(), 'iterbranches'):
+            bs = {}
+            for n, h, t, c in self.repo.branchmap().iterbranches():
+                if n != "default":
+                    bs[n] = n
+            if len(bs) < 1:
+                bs = None
+        else:
+            # hg version 3.x and earlier: Peek at the internal dict of
+            # branches
+            bs = self.repo.branchmap()
+            if len(bs) > 1:
+                bs = bs.copy()
+                del bs["default"]
+            else:
+                bs = None
+
+        if bs is not None:
             self.error(None,
                        "Named branches not permitted; this repository has: %s"
                        % ", ".join(bs.keys()))