Augie Fackler avatar Augie Fackler committed 6918f60 Merge

Merge hg 2.3 fixes from bos.

Comments (0)

Files changed (6)

hgsubversion/svnrepo.py

 
 from mercurial import error
 from mercurial import util as hgutil
-from mercurial import httprepo
-import mercurial.repo
+
+try:
+    from mercurial.peer import peerrepository
+    from mercurial import httppeer
+except ImportError:
+    from mercurial.repo import repository as peerrepository
+    from mercurial import httprepo as httppeer
 
 try:
     from mercurial import phases
 
     repo.__class__ = svnlocalrepo
 
-class svnremoterepo(mercurial.repo.repository):
+class svnremoterepo(peerrepository):
     """ the dumb wrapper for actual Subversion repositories """
 
     def __init__(self, ui, path=None):
         else:
             self.password_stores = None
 
+    def _capabilities(self):
+        return self.capabilities
+
     @propertycache
     def svnauth(self):
         # DO NOT default the user to hg's getuser(). If you provide
     if url.startswith('http://') or url.startswith('https://'):
         try:
             # may yield a bogus 'real URL...' message
-            return httprepo.instance(ui, url, create)
+            return httppeer.instance(ui, url, create)
         except error.RepoError:
             ui.traceback()
             ui.note('(falling back to Subversion support)\n')

hgsubversion/wrappers.py

     return 0
 
 
+def getpeer(ui, opts, source):
+    # Since 2.3 (1ac628cd7113)
+    peer = getattr(hg, 'peer', None)
+    if peer:
+        return peer(ui, opts, source)
+    return hg.repository(ui, source)
+
+
+def getcaps(other):
+    return (getattr(other, 'caps', None) or
+            getattr(other, 'capabilities', None) or set())
+
+
 def incoming(orig, ui, repo, origsource='default', **opts):
     """show incoming revisions from Subversion
     """
 
     source, revs, checkout = util.parseurl(ui.expandpath(origsource))
-    other = hg.repository(ui, source)
-    if 'subversion' not in other.capabilities:
+    other = getpeer(ui, opts, source)
+    if 'subversion' not in getcaps(other):
         return orig(ui, repo, origsource, **opts)
 
     svn = other.svn
                    svnsourcerev=needs_transplant)
             # Reload the repo after the rebase. Do not reuse contexts across this.
             newtip = newtipctx.node()
-            repo = hg.repository(ui, meta.path)
+            repo = getpeer(ui, {}, meta.path)
+            repo = getattr(repo, 'local', lambda: repo)()
             newtipctx = repo[newtip]
             # Rewrite the node ids in outgoing to their rebased versions.
             rebasemap = dict()
         if isinstance(origsource, str):
             source, branch, checkout = util.parseurl(ui.expandpath(origsource),
                                          opts.get('branch'))
-            srcrepo = hg.repository(ui, source)
+            srcrepo = getpeer(ui, opts, source)
         else:
             srcrepo = origsource
 
     srcrepo = data.get('srcrepo')
 
     if dstrepo.local() and srcrepo.capable('subversion'):
-        fd = dstrepo.opener("hgrc", "a", text=True)
+        dst = dstrepo.local()
+        fd = dst.opener("hgrc", "a", text=True)
         for section in set(s for s, v in optionmap.itervalues()):
             config = dict(ui.configitems(section))
             for name in dontretain[section]:

tests/test_fetch_mappings.py

         ui = self.ui(stupid)
         src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone',
                                       update=False)
+        src = getattr(src, 'local', lambda: src)()
+        dest = getattr(dest, 'local', lambda: dest)()
         svncommands.rebuildmeta(ui, dest,
                                 args=[test_util.fileurl(repo_path)])
 

tests/test_rebuildmeta.py

     wc2_path = self.wc_path + '_clone'
     u = ui.ui()
     src, dest = test_util.hgclone(u, self.wc_path, wc2_path, update=False)
+    src = getattr(src, 'local', lambda: src)()
+    dest = getattr(dest, 'local', lambda: dest)()
 
     # insert a wrapper that prevents calling changectx.children()
     def failfn(orig, ctx):
                                   wc3_path,
                                   update=False,
                                   rev=[0])
+    srcrepo = getattr(src, 'local', lambda: src)()
+    dest = getattr(dest, 'local', lambda: dest)()
 
     # insert a wrapper that prevents calling changectx.children()
     extensions.wrapfunction(context.changectx, 'children', failfn)
         # remove the wrapper
         context.changectx.children = origchildren
 
-    self._run_assertions(name, stupid, single, src, dest, u)
+    self._run_assertions(name, stupid, single, srcrepo, dest, u)
 
 
 def _run_assertions(self, name, stupid, single, src, dest, u):

tests/test_tags.py

             "You should check that before assuming issues with this test.\n")
         wc2_path = self.wc_path + '2'
         src, dest = test_util.hgclone(repo.ui, self.wc_path, wc2_path, update=False)
+        dest = getattr(dest, 'local', lambda: dest)()
         svncommands.rebuildmeta(repo.ui,
                                dest,
                                args=[test_util.fileurl(repo_path), ])

tests/test_util.py

     return u
 
 def dispatch(cmd):
-    try:
-        req = dispatchmod.request(cmd)
-        dispatchmod.dispatch(req)
-    except AttributeError, e:
-        dispatchmod.dispatch(cmd)
+    cmd = getattr(dispatchmod, 'request', lambda x: x)(cmd)
+    dispatchmod.dispatch(cmd)
 
 def rmtree(path):
     # Read-only files cannot be removed under Windows
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.