Commits

Michael Tharp  committed 90f5bf4

Add compatibility for hg 1.6

  • Participants
  • Parent commits 9e722e8

Comments (0)

Files changed (1)

             parents = ctx.parents()
             return [node.hex(parents[0].node())]
 
+        def rollback(self):
+            if self._repo:
+                try:
+                    self._repo.transaction('forest').__del__()
+                except TypeError, err:
+                    # Wrong number of arguments for hg < 1.6
+                    if '2 given' not in str(err):
+                        raise
+                    self._repo.transaction().__del__()
+
         def __repr__(self):
             return ("<forest.Tree object "
                     "- repo: %s "
         if paths:
             # Extract revisions from # syntax in path.
             paths[0], revs = parseurl(paths[0], opts['rev'])[0:2]
+            if isinstance(revs, tuple):
+                # hg >= 1.6
+                revs = revs[1]
         elif 'rev' in opts:
             revs = opts['rev']
         else:
             fetch.fetch(ui, tree.getrepo(ui), srcpath, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            try:
-                tree.repo.transaction().__del__()
-            except AttributeError:
-                pass
+            tree.rollback()
 
     @Forest.Tree.skip
     def check_mq(tree):
             commands.pull(ui, tree.getrepo(ui), srcpath, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            if tree._repo:
-                tree.repo.transaction().__del__()
+            tree.rollback()
 
     @Forest.Tree.skip
     def check_mq(tree):
             commands.push(ui, tree.getrepo(ui), destpath, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            try:
-                tree.repo.transaction().__del__()
-            except AttributeError:
-                pass
+            tree.rollback()
 
     @Forest.Tree.skip
     def check_mq(tree):
             commands.tag(ui, tree.getrepo(ui), name, rev_=None, **opts)
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            tree.repo.transaction().__del__()
+            tree.rollback()
 
     @Forest.Tree.skip
     def check_mq(tree):
                                 clean=opts['clean'], date=opts['date'])
         except Exception, err:
             ui.warn(_("skipped: %s\n") % err)
-            tree.repo.transaction().__del__()
+            tree.rollback()
 
     @Forest.Tree.skip
     def check_mq(tree):