Commits

WAKAYAMA shirou committed 05b5ec0

Compatibility with hg 2.3

Comments (0)

Files changed (1)

     except ImportError:
         return repo.findincoming
 
+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 rdiff(ui, repo, url, lrev=None, rrev=None, *pats, **opts):
     def rui():
         try:
         except AttributeError:
             # pre 1.6
             return cmdutil.remoteui(repo, opts)
+
     try:
-        other = hg.repository(rui(), url)
+        other = getpeer(rui(), {}, url)
     except AttributeError:
         # pre-1.3
         other = hg.repository(ui, url)
     ui.status(_('comparing with %s\n') % url)
 
     if rrev:
-        if 'lookup' in other.capabilities:
+        if 'lookup' in getcaps(other):
             rrev = other.lookup(rrev)
         else:
             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
     if not incoming:
         # remote is a subset of local
         if not rrev:
-            if 'lookup' in other.capabilities:
+            if 'lookup' in getcaps(other):
                 rrev = other.lookup('tip')
             else:
                 raise util.Abort(_('cannot determine remote tip'))