diff mercurial/commands.py @ 17191:5884812686f7

peer: introduce peer methods to prepare for peer classes This introduces a peer method into all repository classes, which currently simply returns self. It also changes hg.repository so it now raises an exception if the supplied paths does not resolve to a localrepo or descendant. Finally, all call sites are changed to use the peer and local methods as appropriate, where peer is used whenever the code is dealing with a remote repository (even if it's on local disk).
author Sune Foldager <cryo@cyanite.org>
date Fri, 13 Jul 2012 21:46:53 +0200
parents d99d0b559084
children 1ac628cd7113
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jul 06 14:12:42 2012 -0500
+++ b/mercurial/commands.py	Fri Jul 13 21:46:53 2012 +0200
@@ -1784,7 +1784,7 @@
     # make sure tests are repeatable
     random.seed(12323)
 
-    def doit(localheads, remoteheads):
+    def doit(localheads, remoteheads, remote=remote):
         if opts.get('old'):
             if localheads:
                 raise util.Abort('cannot use localheads with old style '
@@ -3463,10 +3463,11 @@
 
     if source:
         source, branches = hg.parseurl(ui.expandpath(source))
-        repo = hg.peer(ui, opts, source)
-        revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
-
-    if not repo.local():
+        peer = hg.peer(ui, opts, source)
+        repo = peer.local()
+        revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
+
+    if not repo:
         if num or branch or tags:
             raise util.Abort(
                 _("can't query remote revision number, branch, or tags"))
@@ -3475,16 +3476,16 @@
         if not rev:
             rev = "tip"
 
-        remoterev = repo.lookup(rev)
+        remoterev = peer.lookup(rev)
         if default or id:
             output = [hexfunc(remoterev)]
 
         def getbms():
             bms = []
 
-            if 'bookmarks' in repo.listkeys('namespaces'):
+            if 'bookmarks' in peer.listkeys('namespaces'):
                 hexremoterev = hex(remoterev)
-                bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems()
+                bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
                        if bmr == hexremoterev]
 
             return bms