Brendan Cully avatar Brendan Cully committed 4936c81

Make rdiff compatible with 1.6, preserving backward compatibility.
Ah, the joys of an unstable API!

Comments (0)

Files changed (2)

 # rdiff.py: diff against remote repositories
 #
-# Copyright 2007 Brendan Cully <brendan@kublai.com>
+# Copyright 2007-10 Brendan Cully <brendan@kublai.com>
 #
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
 import os
 
+#!#*@#$()* continual unfriendly API changes!
+def findincomingfn(repo):
+    try:
+        from mercurial import discovery
+        discovery.findincoming
+        def fi(*args, **opts):
+            return discovery.findincoming(repo, *args, **opts)
+        return fi
+    except ImportError:
+        return repo.findincoming
+
 def rdiff(ui, repo, url, lrev=None, rrev=None, *pats, **opts):
+    def rui():
+        try:
+            return hg.remoteui(repo, opts)
+        except AttributeError:
+            # pre 1.6
+            return cmdutil.remoteui(repo, opts)
     try:
-        other = hg.repository(cmdutil.remoteui(repo, opts), url)
+        other = hg.repository(rui(), url)
     except AttributeError:
         # pre-1.3
         other = hg.repository(ui, url)
             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
             raise util.Abort(error)
 
-    incoming = repo.findincoming(other, heads=rrev and [rrev] or [])
+    incoming = findincomingfn(repo)(other, heads=rrev and [rrev] or [])
     if not incoming:
         # remote is a subset of local
         if not rrev:
     if pats:
         path = ui.expandpath(pats[0])
         if hasattr(hg, 'parseurl'):
+            args = hg.parseurl(ui.expandpath(pats[0]), [])
             # parseurl changed from returning two args to three
-            args = hg.parseurl(ui.expandpath(pats[0]), [])
             path, rrev = args[0], args[-1]
+            # 1.6 (3d6915f5a2bb): parseurl returns (url, (branch, branches))
+            if type(rrev) == tuple:
+                rrev = rrev[0]
         if '://' in path or os.path.isdir(os.path.join(path, '.hg')):
             url = path
             pats = pats[1:]
 adding foo
-updating working directory
+updating to branch default
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % working directory diff
 comparing with ../base
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.