andyhelp avatar andyhelp committed aedf790 Merge

branch merge

Comments (0)

Files changed (2)

     parseurl = cmdutil.parseurl
 except:
     try:
-        parseurl = hg.parseurl
+        _parseurl = hg.parseurl
+        def parseurl(url, branches=None):
+            url, revs = _parseurl(url, branches)
+            if isinstance(revs, tuple):
+                # hg >= 1.6
+                return url, revs[1]
+            return url, revs
     except:
         def parseurl(url, revs):
             """Mercurial <= 0.9.3 doesn't have this feature."""
 
 localrepo.localrepository.forests = _localrepo_forests
 
+def repocall(repo, *args, **kwargs):
+    if hasattr(repo, '_call'):
+        # hg >= 1.7
+        callfn = repo._call
+    else:
+        callfn = repo.do_read
+    return callfn(*args, **kwargs)
 
 def _sshrepo_forests(self, walkhg):
     """Shim this function into mercurial.sshrepo.sshrepository so
         raise util.Abort(_("Remote forests cannot be cloned because the "
                            "other repository doesn't support the forest "
                            "extension."))
-    data = self.call("forests", walkhg=("", "True")[walkhg])
+    data = repocall(self, "forests", walkhg=("", "True")[walkhg])
     return data.splitlines()
 
 sshrepo.sshrepository.forests = _sshrepo_forests
 sshserver.sshserver.do_hello = _sshserver_do_hello
 
 
+try:
+    from mercurial import wireproto
+    # Force the lazy importer to trigger
+    wireproto.capabilities
+except ImportError:
+    pass
+else:
+    # hg >= 1.7
+    _old_caps = wireproto.capabilities
+    def _forest_caps(*args, **kwargs):
+        caps = _old_caps(*args, **kwargs)
+        caps += ' forests'
+        return caps
+    wireproto.capabilities = _forest_caps
+
+    def do_forests(repo, proto, walkhg):
+        forests = repo.forests(bool(walkhg))
+        return "\n".join(forests)
+    wireproto.commands['forests'] = (do_forests, 'walkhg')
+
+
+
 def _sshserver_do_forests(self):
     """Shim this function into the sshserver so that it responds to
     the forests command.  It gives a list of roots relative to the
     self.repo repository, sorted lexigraphically.
     """
-    
+    # hg < 1.7
     key, walkhg = self.getarg()
     forests = self.repo.forests(bool(walkhg))
     self.respond("\n".join(forests))
         raise util.Abort(_("Remote forests cannot be cloned because the "
                            "other repository doesn't support the forest "
                            "extension."))
-    data = self.do_read("forests", walkhg=("", "True")[walkhg])
+    data = repocall(self, "forests", walkhg=("", "True")[walkhg])
     return data.splitlines()
 
 httprepo.httprepository.forests = _httprepo_forests
             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 "
         elif 'rev' in opts:
             revs = opts['rev']
         else:
-            revs = None
+            revs = []
         die_on_numeric_revs(revs)
         for tree in self.trees:
             rpath = relpath(self.top().root, tree.root)
     source = [source]
     try:
         import hgext.fetch as fetch
+        # Force the lazy importer to trigger
+        fetch.cmdtable
     except ImportError:
         raise util.Abort(_("could not import fetch module\n"))
 
             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):
         def __init__(self, transform, ui):
             self._transform = transform
             self._ui = ui
-        def write(self, output):
-            self._ui.write(self._transform(output))
+        def write(self, *args, **opts):
+            args = [self._transform(a) for a in args]
+            self._ui.write(*args, **opts)
         def __getattr__(self, attrname):
             return getattr(self._ui, attrname)
 
             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):
                  prehooks=[lambda tree: check_mq(tree)])
 
 
-cmdtable = None
+cmdtable = {}
 
 def uisetup(ui):
     global cmdtable
 
     try:
         import hgext.fetch
+        # Force the lazy importer to trigger
+        hgext.fetch.cmdtable
     except ImportError:
         return
     try:
 
 # fclone
 [.]
-updating working directory
+updating to branch default
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [d/d/t]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [e/d]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # fsnap
 summary:     new line
 
 # fseed
-updating working directory
+updating to branch default
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 [d/d/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [e/d]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [tree1]
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
 adding manifests
 adding file changes
 added 2 changesets with 2 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # foutgoing
 
 # fseed and fpull, missing section
 [.]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 3 changes to 3 files
-updating working directory
+updating to branch default
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [e/d]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 .
 t
 t/t
 [e/d]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 .
 t/t
 [.]
 pulling from HGTMP/test-forest/toplevel
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 
 # fseed and fpull, named section
 [.]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 3 changes to 3 files
-updating working directory
+updating to branch default
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [d/d/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [e/d]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t/t]
-requesting all changes
 adding changesets
 adding manifests
 adding file changes
 added 1 changesets with 1 changes to 1 files
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 .
 
 # fclone + mq
 [.]
-updating working directory
+updating to branch default
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [d/d/t]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [e/d]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [t]
 skipped: 't/t' has mq patches applied
 
 [t/t/.hg/patches]
-updating working directory
+updating to branch default
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 # fsnap + mq
 adding f
 adding f
 [.]
-updating working directory
+updating to branch default
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [a]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [b]
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 [.]
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.