D3377: hg: pass command intents to repo/peer creation (API)
This revision was automatically updated to reflect the committed changes. Closed by commit rHG0664be4f0c1f: hg: pass command intents to repo/peer creation (API) (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3377?vs=8289=8320 REVISION DETAIL https://phab.mercurial-scm.org/D3377 AFFECTED FILES hgext/schemes.py mercurial/bundlerepo.py mercurial/dispatch.py mercurial/hg.py mercurial/httppeer.py mercurial/localrepo.py mercurial/sshpeer.py mercurial/statichttprepo.py mercurial/unionrepo.py CHANGE DETAILS diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -231,7 +231,7 @@ def getcwd(self): return pycompat.getcwd() # always outside the repo -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new union repository')) parentpath = ui.config("bundle", "mainreporoot") diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -215,7 +215,7 @@ def _writecaches(self): pass # statichttprepository are read only -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new static-http repository')) return statichttprepository(ui, path[7:]) diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -587,7 +587,7 @@ raise error.RepoError(_('unknown version of SSH protocol: %s') % protoname) -def instance(ui, path, create): +def instance(ui, path, create, intents=None): """Create an SSH peer. The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -413,7 +413,7 @@ 'bisect.state', } -def __init__(self, baseui, path, create=False): +def __init__(self, baseui, path, create=False, intents=None): self.requirements = set() self.filtername = None # wvfs: rooted at the repository root, used to access the working copy @@ -2332,8 +2332,9 @@ assert name.startswith('journal') return os.path.join(base, name.replace('journal', 'undo', 1)) -def instance(ui, path, create): -return localrepository(ui, util.urllocalpath(path), create) +def instance(ui, path, create, intents=None): +return localrepository(ui, util.urllocalpath(path), create, + intents=intents) def islocal(path): return True diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -990,7 +990,7 @@ return httppeer(ui, path, respurl, opener, requestbuilder, info['v1capabilities']) -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new http repository')) try: diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -157,9 +157,10 @@ # a list of (ui, repo) functions called for wire peer initialization wirepeersetupfuncs = [] -def _peerorrepo(ui, path, create=False, presetupfuncs=None): +def _peerorrepo(ui, path, create=False, presetupfuncs=None, +intents=None): """return a repository object for the specified path""" -obj = _peerlookup(path).instance(ui, path, create) +obj = _peerlookup(path).instance(ui, path, create, intents=intents) ui = getattr(obj, "ui", ui) for f in presetupfuncs or []: f(ui, obj) @@ -172,19 +173,20 @@ f(ui, obj) return obj -def repository(ui, path='', create=False, presetupfuncs=None): +def repository(ui, path='', create=False, presetupfuncs=None, intents=None): """return a repository object for the specified path""" -peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs) +peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs, + intents=intents) repo = peer.local() if not repo: raise error.Abort(_("repository '%s' is not local") % (path or peer.url())) return repo.filtered('visible') -def peer(uiorrepo, opts, path, create=False): +def peer(uiorrepo, opts, path, create=False, intents=None): '''return a repository peer for the specified path''' rui = remoteui(uiorrepo, opts) -return _peerorrepo(rui, path, create).peer() +return _peerorrepo(rui, path, create, intents=intents).peer() def defaultdest(source): '''return default destination of clone if none is given diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py ---
D3377: hg: pass command intents to repo/peer creation (API)
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY The previous commit introduced a mechanism to declare command intents. This commit changes the repository and peer instantiation mechanism so the intents are passed down to each repository and peer type so they can do with them whatever they please. Currently, nobody does anything with any intent. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3377 AFFECTED FILES hgext/schemes.py mercurial/bundlerepo.py mercurial/dispatch.py mercurial/hg.py mercurial/httppeer.py mercurial/localrepo.py mercurial/sshpeer.py mercurial/statichttprepo.py mercurial/unionrepo.py CHANGE DETAILS diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py --- a/mercurial/unionrepo.py +++ b/mercurial/unionrepo.py @@ -231,7 +231,7 @@ def getcwd(self): return pycompat.getcwd() # always outside the repo -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new union repository')) parentpath = ui.config("bundle", "mainreporoot") diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -215,7 +215,7 @@ def _writecaches(self): pass # statichttprepository are read only -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new static-http repository')) return statichttprepository(ui, path[7:]) diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -587,7 +587,7 @@ raise error.RepoError(_('unknown version of SSH protocol: %s') % protoname) -def instance(ui, path, create): +def instance(ui, path, create, intents=None): """Create an SSH peer. The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -413,7 +413,7 @@ 'bisect.state', } -def __init__(self, baseui, path, create=False): +def __init__(self, baseui, path, create=False, intents=None): self.requirements = set() self.filtername = None # wvfs: rooted at the repository root, used to access the working copy @@ -2332,8 +2332,9 @@ assert name.startswith('journal') return os.path.join(base, name.replace('journal', 'undo', 1)) -def instance(ui, path, create): -return localrepository(ui, util.urllocalpath(path), create) +def instance(ui, path, create, intents=None): +return localrepository(ui, util.urllocalpath(path), create, + intents=intents) def islocal(path): return True diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -990,7 +990,7 @@ return httppeer(ui, path, respurl, opener, requestbuilder, info['v1capabilities']) -def instance(ui, path, create): +def instance(ui, path, create, intents=None): if create: raise error.Abort(_('cannot create new http repository')) try: diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -157,9 +157,10 @@ # a list of (ui, repo) functions called for wire peer initialization wirepeersetupfuncs = [] -def _peerorrepo(ui, path, create=False, presetupfuncs=None): +def _peerorrepo(ui, path, create=False, presetupfuncs=None, +intents=None): """return a repository object for the specified path""" -obj = _peerlookup(path).instance(ui, path, create) +obj = _peerlookup(path).instance(ui, path, create, intents=intents) ui = getattr(obj, "ui", ui) for f in presetupfuncs or []: f(ui, obj) @@ -172,19 +173,20 @@ f(ui, obj) return obj -def repository(ui, path='', create=False, presetupfuncs=None): +def repository(ui, path='', create=False, presetupfuncs=None, intents=None): """return a repository object for the specified path""" -peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs) +peer = _peerorrepo(ui, path, create, presetupfuncs=presetupfuncs, + intents=intents) repo = peer.local() if not repo: raise error.Abort(_("repository '%s' is not local") % (path or peer.url())) return repo.filtered('visible') -def peer(uiorrepo, opts, path, create=False): +def peer(uiorrepo, opts, path, create=False, intents=None): '''return a repository peer for the specified path''' rui = remoteui(uiorrepo, opts) -return _peerorrepo(rui, path, create).peer() +return _peerorrepo(rui, path, create,