comparison mercurial/hg.py @ 17192:1ac628cd7113

peer: introduce real peer classes This change separates peer implementations from the repository implementation. localpeer currently is a simple pass-through to localrepository, except for legacy calls, which have already been removed from localpeer. This ensures that the local client code only uses the most modern peer API when talking to local repos. Peers have a .local() method which returns either None or the underlying localrepository (or descendant thereof). Repos have a .peer() method to return a freshly constructed localpeer. The latter is used by hg.peer(), and also to allow folks to pass either a peer or a repo to some generic helper methods. We might want to get rid of .peer() eventually. The only user of locallegacypeer is debugdiscovery, which uses it to pose as a pre-setdiscovery client. But we decided to leave the old API defined in locallegacypeer for clarity and maybe for other uses in the future. It might be nice to actually define the peer API directly in peer.py as stub methods. One problem there is, however, that localpeer implements lock/addchangegroup, whereas the true remote peers implement unbundle. It might be desireable to get rid of this distinction eventually.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Fri, 13 Jul 2012 21:47:06 +0200
parents 5884812686f7
children 32a6a33b9a35
comparison
equal deleted inserted replaced
17191:5884812686f7 17192:1ac628cd7113
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 from i18n import _ 9 from i18n import _
10 from lock import release 10 from lock import release
11 from node import hex, nullid 11 from node import hex, nullid
12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo, bookmarks 12 import localrepo, bundlerepo, httppeer, sshpeer, statichttprepo, bookmarks
13 import lock, util, extensions, error, node, scmutil 13 import lock, util, extensions, error, node, scmutil
14 import cmdutil, discovery 14 import cmdutil, discovery
15 import merge as mergemod 15 import merge as mergemod
16 import verify as verifymod 16 import verify as verifymod
17 import errno, os, shutil 17 import errno, os, shutil
63 return str(u), (branch, branches or []) 63 return str(u), (branch, branches or [])
64 64
65 schemes = { 65 schemes = {
66 'bundle': bundlerepo, 66 'bundle': bundlerepo,
67 'file': _local, 67 'file': _local,
68 'http': httprepo, 68 'http': httppeer,
69 'https': httprepo, 69 'https': httppeer,
70 'ssh': sshrepo, 70 'ssh': sshpeer,
71 'static-http': statichttprepo, 71 'static-http': statichttprepo,
72 } 72 }
73 73
74 def _peerlookup(path): 74 def _peerlookup(path):
75 u = util.url(path) 75 u = util.url(path)