Michael Tharp avatar Michael Tharp committed 90f5bf4

Add compatibility for hg 1.6

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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.