##// END OF EJS Templates
hg: pass command intents to repo/peer creation (API)...
Gregory Szorc -
r37735:0664be4f default
parent child Browse files
Show More
@@ -78,9 +78,9 b' class ShortRepository(object):'
78 def __repr__(self):
78 def __repr__(self):
79 return '<ShortRepository: %s>' % self.scheme
79 return '<ShortRepository: %s>' % self.scheme
80
80
81 def instance(self, ui, url, create):
81 def instance(self, ui, url, create, intents=None):
82 url = self.resolve(url)
82 url = self.resolve(url)
83 return hg._peerlookup(url).instance(ui, url, create)
83 return hg._peerlookup(url).instance(ui, url, create, intents=intents)
84
84
85 def resolve(self, url):
85 def resolve(self, url):
86 # Should this use the util.url class, or is manual parsing better?
86 # Should this use the util.url class, or is manual parsing better?
@@ -450,7 +450,7 b' class bundlerepository(localrepo.localre'
450 self.ui.warn(msg % nodemod.hex(p2))
450 self.ui.warn(msg % nodemod.hex(p2))
451 return super(bundlerepository, self).setparents(p1, p2)
451 return super(bundlerepository, self).setparents(p1, p2)
452
452
453 def instance(ui, path, create):
453 def instance(ui, path, create, intents=None):
454 if create:
454 if create:
455 raise error.Abort(_('cannot create new bundle repository'))
455 raise error.Abort(_('cannot create new bundle repository'))
456 # internal config: bundle.mainreporoot
456 # internal config: bundle.mainreporoot
@@ -928,7 +928,8 b' def _dispatch(req):'
928 else:
928 else:
929 try:
929 try:
930 repo = hg.repository(ui, path=path,
930 repo = hg.repository(ui, path=path,
931 presetupfuncs=req.prereposetups)
931 presetupfuncs=req.prereposetups,
932 intents=func.intents)
932 if not repo.local():
933 if not repo.local():
933 raise error.Abort(_("repository '%s' is not local")
934 raise error.Abort(_("repository '%s' is not local")
934 % path)
935 % path)
@@ -157,9 +157,10 b' def openpath(ui, path):'
157 # a list of (ui, repo) functions called for wire peer initialization
157 # a list of (ui, repo) functions called for wire peer initialization
158 wirepeersetupfuncs = []
158 wirepeersetupfuncs = []
159
159
160 def _peerorrepo(ui, path, create=False, presetupfuncs=None):
160 def _peerorrepo(ui, path, create=False, presetupfuncs=None,
161 intents=None):
161 """return a repository object for the specified path"""
162 """return a repository object for the specified path"""
162 obj = _peerlookup(path).instance(ui, path, create)
163 obj = _peerlookup(path).instance(ui, path, create, intents=intents)
163 ui = getattr(obj, "ui", ui)
164 ui = getattr(obj, "ui", ui)
164 for f in presetupfuncs or []:
165 for f in presetupfuncs or []:
165 f(ui, obj)
166 f(ui, obj)
@@ -172,19 +173,20 b' def _peerorrepo(ui, path, create=False, '
172 f(ui, obj)
173 f(ui, obj)
173 return obj
174 return obj
174
175
175 def repository(ui, path='', create=False, presetupfuncs=None):
176 def repository(ui, path='', create=False, presetupfuncs=None, intents=None):
176 """return a repository object for the specified path"""
177 """return a repository object for the specified path"""
177 peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs)
178 peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs,
179 intents=intents)
178 repo = peer.local()
180 repo = peer.local()
179 if not repo:
181 if not repo:
180 raise error.Abort(_("repository '%s' is not local") %
182 raise error.Abort(_("repository '%s' is not local") %
181 (path or peer.url()))
183 (path or peer.url()))
182 return repo.filtered('visible')
184 return repo.filtered('visible')
183
185
184 def peer(uiorrepo, opts, path, create=False):
186 def peer(uiorrepo, opts, path, create=False, intents=None):
185 '''return a repository peer for the specified path'''
187 '''return a repository peer for the specified path'''
186 rui = remoteui(uiorrepo, opts)
188 rui = remoteui(uiorrepo, opts)
187 return _peerorrepo(rui, path, create).peer()
189 return _peerorrepo(rui, path, create, intents=intents).peer()
188
190
189 def defaultdest(source):
191 def defaultdest(source):
190 '''return default destination of clone if none is given
192 '''return default destination of clone if none is given
@@ -990,7 +990,7 b' def makepeer(ui, path, opener=None, requ'
990 return httppeer(ui, path, respurl, opener, requestbuilder,
990 return httppeer(ui, path, respurl, opener, requestbuilder,
991 info['v1capabilities'])
991 info['v1capabilities'])
992
992
993 def instance(ui, path, create):
993 def instance(ui, path, create, intents=None):
994 if create:
994 if create:
995 raise error.Abort(_('cannot create new http repository'))
995 raise error.Abort(_('cannot create new http repository'))
996 try:
996 try:
@@ -413,7 +413,7 b' class localrepository(object):'
413 'bisect.state',
413 'bisect.state',
414 }
414 }
415
415
416 def __init__(self, baseui, path, create=False):
416 def __init__(self, baseui, path, create=False, intents=None):
417 self.requirements = set()
417 self.requirements = set()
418 self.filtername = None
418 self.filtername = None
419 # wvfs: rooted at the repository root, used to access the working copy
419 # wvfs: rooted at the repository root, used to access the working copy
@@ -2332,8 +2332,9 b' def undoname(fn):'
2332 assert name.startswith('journal')
2332 assert name.startswith('journal')
2333 return os.path.join(base, name.replace('journal', 'undo', 1))
2333 return os.path.join(base, name.replace('journal', 'undo', 1))
2334
2334
2335 def instance(ui, path, create):
2335 def instance(ui, path, create, intents=None):
2336 return localrepository(ui, util.urllocalpath(path), create)
2336 return localrepository(ui, util.urllocalpath(path), create,
2337 intents=intents)
2337
2338
2338 def islocal(path):
2339 def islocal(path):
2339 return True
2340 return True
@@ -587,7 +587,7 b' def makepeer(ui, path, proc, stdin, stdo'
587 raise error.RepoError(_('unknown version of SSH protocol: %s') %
587 raise error.RepoError(_('unknown version of SSH protocol: %s') %
588 protoname)
588 protoname)
589
589
590 def instance(ui, path, create):
590 def instance(ui, path, create, intents=None):
591 """Create an SSH peer.
591 """Create an SSH peer.
592
592
593 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
593 The returned object conforms to the ``wireprotov1peer.wirepeer`` interface.
@@ -215,7 +215,7 b' class statichttprepository(localrepo.loc'
215 def _writecaches(self):
215 def _writecaches(self):
216 pass # statichttprepository are read only
216 pass # statichttprepository are read only
217
217
218 def instance(ui, path, create):
218 def instance(ui, path, create, intents=None):
219 if create:
219 if create:
220 raise error.Abort(_('cannot create new static-http repository'))
220 raise error.Abort(_('cannot create new static-http repository'))
221 return statichttprepository(ui, path[7:])
221 return statichttprepository(ui, path[7:])
@@ -231,7 +231,7 b' class unionrepository(localrepo.localrep'
231 def getcwd(self):
231 def getcwd(self):
232 return pycompat.getcwd() # always outside the repo
232 return pycompat.getcwd() # always outside the repo
233
233
234 def instance(ui, path, create):
234 def instance(ui, path, create, intents=None):
235 if create:
235 if create:
236 raise error.Abort(_('cannot create new union repository'))
236 raise error.Abort(_('cannot create new union repository'))
237 parentpath = ui.config("bundle", "mainreporoot")
237 parentpath = ui.config("bundle", "mainreporoot")
General Comments 0
You need to be logged in to leave comments. Login now