# HG changeset patch # User Augie Fackler # Date 2018-10-16 21:02:48 # Node ID fc27668607962f38969b5d65d2b80af2f3c2b7a8 # Parent ed19958dbf5d032aba920bf44c875e958054cb85 remotefilelog: consolidate and rename on-disk store requirement The value of this constant appeared in too many places. While we're here, rename it to be more consistent with our naming conventions for experimental functionality. Differential Revision: https://phab.mercurial-scm.org/D5128 diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py --- a/hgext/remotefilelog/__init__.py +++ b/hgext/remotefilelog/__init__.py @@ -209,7 +209,7 @@ configitem('remotefilelog', 'history.rep testedwith = 'ships-with-hg-core' repoclass = localrepo.localrepository -repoclass._basesupported.add(shallowrepo.requirement) +repoclass._basesupported.add(constants.SHALLOWREPO_REQUIREMENT) def uisetup(ui): """Wraps user facing Mercurial commands to swap them out with shallow @@ -231,7 +231,8 @@ def uisetup(ui): # Prevent 'hg manifest --all' def _manifest(orig, ui, repo, *args, **opts): - if shallowrepo.requirement in repo.requirements and opts.get('all'): + if (constants.SHALLOWREPO_REQUIREMENT in repo.requirements + and opts.get('all')): raise error.Abort(_("--all is not supported in a shallow repo")) return orig(ui, repo, *args, **opts) @@ -256,7 +257,7 @@ def cloneshallow(orig, ui, repo, *args, if opts.get('shallow'): repos = [] def pull_shallow(orig, self, *args, **kwargs): - if shallowrepo.requirement not in self.requirements: + if constants.SHALLOWREPO_REQUIREMENT not in self.requirements: repos.append(self.unfiltered()) # set up the client hooks so the post-clone update works setupclient(self.ui, self.unfiltered()) @@ -266,7 +267,7 @@ def cloneshallow(orig, ui, repo, *args, if isinstance(self, repoview.repoview): self.__class__.__bases__ = (self.__class__.__bases__[0], self.unfiltered().__class__) - self.requirements.add(shallowrepo.requirement) + self.requirements.add(constants.SHALLOWREPO_REQUIREMENT) self._writerequirements() # Since setupclient hadn't been called, exchange.pull was not @@ -312,14 +313,14 @@ def cloneshallow(orig, ui, repo, *args, return False, None supported, requirements = orig(pullop, bundle2=bundle2) if requirements is not None: - requirements.add(shallowrepo.requirement) + requirements.add(constants.SHALLOWREPO_REQUIREMENT) return supported, requirements extensions.wrapfunction( streamclone, 'canperformstreamclone', canperformstreamclone) else: def stream_in_shallow(orig, repo, remote, requirements): setup_streamout(repo, remote) - requirements.add(shallowrepo.requirement) + requirements.add(constants.SHALLOWREPO_REQUIREMENT) return orig(repo, remote, requirements) extensions.wrapfunction( localrepo.localrepository, 'stream_in', stream_in_shallow) @@ -349,7 +350,7 @@ def reposetup(ui, repo): ui.setconfig('hooks', 'commit.prefetch', wcpprefetch) isserverenabled = ui.configbool('remotefilelog', 'server') - isshallowclient = shallowrepo.requirement in repo.requirements + isshallowclient = constants.SHALLOWREPO_REQUIREMENT in repo.requirements if isserverenabled and isshallowclient: raise RuntimeError("Cannot be both a server and shallow client.") @@ -388,7 +389,7 @@ def onetimeclientsetup(ui): def storewrapper(orig, requirements, path, vfstype): s = orig(requirements, path, vfstype) - if shallowrepo.requirement in requirements: + if constants.SHALLOWREPO_REQUIREMENT in requirements: s = shallowstore.wrapstore(s) return s @@ -398,7 +399,7 @@ def onetimeclientsetup(ui): # prefetch files before update def applyupdates(orig, repo, actions, wctx, mctx, overwrite, labels=None): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: manifest = mctx.manifest() files = [] for f, args, msg in actions['g']: @@ -411,7 +412,7 @@ def onetimeclientsetup(ui): # Prefetch merge checkunknownfiles def checkunknownfiles(orig, repo, wctx, mctx, force, actions, *args, **kwargs): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: files = [] sparsematch = repo.maybesparsematch(mctx.rev()) for f, (m, actionargs, msg) in actions.iteritems(): @@ -430,7 +431,7 @@ def onetimeclientsetup(ui): # Prefetch files before status attempts to look at their size and contents def checklookup(orig, self, files): repo = self._repo - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: prefetchfiles = [] for parent in self._parents: for f in files: @@ -443,7 +444,7 @@ def onetimeclientsetup(ui): # Prefetch the logic that compares added and removed files for renames def findrenames(orig, repo, matcher, added, removed, *args, **kwargs): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: files = [] parentctx = repo['.'] for f in removed: @@ -456,7 +457,7 @@ def onetimeclientsetup(ui): # prefetch files before mergecopies check def computenonoverlap(orig, repo, c1, c2, *args, **kwargs): u1, u2 = orig(repo, c1, c2, *args, **kwargs) - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: m1 = c1.manifest() m2 = c2.manifest() files = [] @@ -488,7 +489,7 @@ def onetimeclientsetup(ui): def computeforwardmissing(orig, a, b, match=None): missing = list(orig(a, b, match=match)) repo = a._repo - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: mb = b.manifest() files = [] @@ -515,7 +516,7 @@ def onetimeclientsetup(ui): # repo can be None when running in chg: # - at startup, reposetup was called because serve is not norepo # - a norepo command like "help" is called - if repo and shallowrepo.requirement in repo.requirements: + if repo and constants.SHALLOWREPO_REQUIREMENT in repo.requirements: repo.fileservice.close() extensions.wrapfunction(dispatch, 'runcommand', runcommand) @@ -527,7 +528,7 @@ def onetimeclientsetup(ui): # prevent strip from stripping remotefilelogs def _collectbrokencsets(orig, repo, files, striprev): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: files = list([f for f in files if not repo.shallowmatch(f)]) return orig(repo, files, striprev) extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets) @@ -578,7 +579,7 @@ def onetimeclientsetup(ui): def filectx(orig, self, path, fileid=None, filelog=None): if fileid is None: fileid = self.filenode(path) - if (shallowrepo.requirement in self._repo.requirements and + if (constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements and self._repo.shallowmatch(path)): return remotefilectx.remotefilectx(self._repo, path, fileid=fileid, changectx=self, filelog=filelog) @@ -586,7 +587,7 @@ def onetimeclientsetup(ui): extensions.wrapfunction(context.changectx, 'filectx', filectx) def workingfilectx(orig, self, path, filelog=None): - if (shallowrepo.requirement in self._repo.requirements and + if (constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements and self._repo.shallowmatch(path)): return remotefilectx.remoteworkingfilectx(self._repo, path, workingctx=self, filelog=filelog) @@ -596,7 +597,7 @@ def onetimeclientsetup(ui): # prefetch required revisions before a diff def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed, copy, getfilectx, *args, **kwargs): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: prefetch = [] mf1 = ctx1.manifest() for fname in modified + added + removed: @@ -654,7 +655,7 @@ def getrenamedfn(repo, endrev=None): return getrenamed def walkfilerevs(orig, repo, match, follow, revs, fncache): - if not shallowrepo.requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return orig(repo, match, follow, revs, fncache) # remotefilelog's can't be walked in rev order, so throw. @@ -694,7 +695,7 @@ def filelogrevset(orig, repo, subset, x) a slower, more accurate result, use ``file()``. """ - if not shallowrepo.requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return orig(repo, subset, x) # i18n: "filelog" is a keyword @@ -802,7 +803,7 @@ def gcclient(ui, cachepath): # Protect against any repo or config changes that have happened since # this repo was added to the repos file. We'd rather this loop succeed # and too much be deleted, than the loop fail and nothing gets deleted. - if shallowrepo.requirement not in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT not in repo.requirements: continue if not util.safehasattr(repo, 'name'): @@ -851,7 +852,7 @@ def gcclient(ui, cachepath): ui.warn(_("warning: no valid repos in repofile\n")) def log(orig, ui, repo, *pats, **opts): - if shallowrepo.requirement not in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT not in repo.requirements: return orig(ui, repo, *pats, **opts) follow = opts.get('follow') @@ -912,7 +913,7 @@ def wcpprefetch(ui, repo, **kwargs): """Prefetches in background revisions specified by bgprefetchrevs revset. Does background repack if backgroundrepack flag is set in config. """ - shallow = shallowrepo.requirement in repo.requirements + shallow = constants.SHALLOWREPO_REQUIREMENT in repo.requirements bgprefetchrevs = ui.config('remotefilelog', 'bgprefetchrevs') isready = readytofetch(repo) @@ -934,7 +935,7 @@ def wcpprefetch(ui, repo, **kwargs): def pull(orig, ui, repo, *pats, **opts): result = orig(ui, repo, *pats, **opts) - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: # prefetch if it's configured prefetchrevset = ui.config('remotefilelog', 'pullprefetch') bgrepack = repo.ui.configbool('remotefilelog', 'backgroundrepack') @@ -974,7 +975,7 @@ def exchangepull(orig, repo, remote, *ar return orig(repo, remote, *args, **kwargs) def _fileprefetchhook(repo, revs, match): - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: allfiles = [] for rev in revs: if rev == nodemod.wdirrev or rev is None: @@ -1070,7 +1071,7 @@ def prefetch(ui, repo, *pats, **opts): Return 0 on success. """ - if not shallowrepo.requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: raise error.Abort(_("repo is not shallow")) opts = resolveprefetchopts(ui, opts) diff --git a/hgext/remotefilelog/constants.py b/hgext/remotefilelog/constants.py --- a/hgext/remotefilelog/constants.py +++ b/hgext/remotefilelog/constants.py @@ -4,9 +4,9 @@ import struct from mercurial.i18n import _ -REQUIREMENT = "remotefilelog" +NETWORK_CAP_LEGACY_SSH_GETFILES = 'exp-remotefilelog-ssh-getfiles-1' -NETWORK_CAP_LEGACY_SSH_GETFILES = 'exp-remotefilelog-ssh-getfiles-1' +SHALLOWREPO_REQUIREMENT = "exp-remotefilelog-repo-req-1" BUNDLE2_CAPABLITY = "exp-remotefilelog-b2cap-1" diff --git a/hgext/remotefilelog/debugcommands.py b/hgext/remotefilelog/debugcommands.py --- a/hgext/remotefilelog/debugcommands.py +++ b/hgext/remotefilelog/debugcommands.py @@ -24,7 +24,6 @@ from . import ( fileserverclient, historypack, repack, - shallowrepo, shallowutil, ) @@ -93,7 +92,7 @@ def debugindex(orig, ui, repo, file_=Non if (opts.get('changelog') or opts.get('manifest') or opts.get('dir') or - not shallowrepo.requirement in repo.requirements or + not constants.SHALLOWREPO_REQUIREMENT in repo.requirements or not repo.shallowmatch(file_)): return orig(ui, repo, file_, **opts) @@ -140,7 +139,7 @@ def debugindex(orig, ui, repo, file_=Non def debugindexdot(orig, ui, repo, file_): """dump an index DAG as a graphviz dot file""" - if not shallowrepo.requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return orig(ui, repo, file_) r = buildtemprevlog(repo, os.path.basename(file_)[:-2]) diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py --- a/hgext/remotefilelog/fileserverclient.py +++ b/hgext/remotefilelog/fileserverclient.py @@ -83,7 +83,8 @@ def peersetup(ui, peer): return if not util.safehasattr(self, '_localrepo'): return - if constants.REQUIREMENT not in self._localrepo.requirements: + if (constants.SHALLOWREPO_REQUIREMENT + not in self._localrepo.requirements): return bundlecaps = opts.get('bundlecaps') diff --git a/hgext/remotefilelog/remotefilelogserver.py b/hgext/remotefilelog/remotefilelogserver.py --- a/hgext/remotefilelog/remotefilelogserver.py +++ b/hgext/remotefilelog/remotefilelogserver.py @@ -30,7 +30,6 @@ from mercurial import ( ) from . import ( constants, - shallowrepo, shallowutil, ) @@ -133,7 +132,7 @@ def onetimesetup(ui): def _walkstreamfiles(orig, repo): if state.shallowremote: # if we are shallow ourselves, stream our local commits - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: striplen = len(repo.store.path) + 1 readdir = repo.store.rawvfs.readdir visit = [os.path.join(repo.store.path, 'data')] @@ -167,7 +166,7 @@ def onetimesetup(ui): continue yield x - elif shallowrepo.requirement in repo.requirements: + elif constants.SHALLOWREPO_REQUIREMENT in repo.requirements: # don't allow cloning from a shallow repo to a full repo # since it would require fetching every version of every # file in order to create the revlogs. @@ -194,7 +193,7 @@ def onetimesetup(ui): # expose remotefilelog capabilities def _capabilities(orig, repo, proto): caps = orig(repo, proto) - if ((shallowrepo.requirement in repo.requirements or + if ((constants.SHALLOWREPO_REQUIREMENT in repo.requirements or ui.configbool('remotefilelog', 'server'))): if isinstance(proto, _sshv1server): # legacy getfiles method which only works over ssh @@ -279,7 +278,7 @@ def getfile(repo, proto, file, node): data is a compressed blob with revlog flag and ancestors information. See createfileblob for its content. """ - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return '1\0' + _('cannot fetch remote files from shallow repo') cachepath = repo.ui.config("remotefilelog", "servercachepath") if not cachepath: @@ -292,7 +291,7 @@ def getfile(repo, proto, file, node): def getfiles(repo, proto): """A server api for requesting particular versions of particular files. """ - if shallowrepo.requirement in repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in repo.requirements: raise error.Abort(_('cannot fetch remote files from shallow repo')) if not isinstance(proto, _sshv1server): raise error.Abort(_('cannot fetch remote files over non-ssh protocol')) diff --git a/hgext/remotefilelog/shallowbundle.py b/hgext/remotefilelog/shallowbundle.py --- a/hgext/remotefilelog/shallowbundle.py +++ b/hgext/remotefilelog/shallowbundle.py @@ -26,8 +26,6 @@ NoFiles = 0 LocalFiles = 1 AllFiles = 2 -requirement = "remotefilelog" - def shallowgroup(cls, self, nodelist, rlog, lookup, units=None, reorder=None): if not isinstance(rlog, remotefilelog.remotefilelog): for c in super(cls, self).group(nodelist, rlog, lookup, @@ -56,7 +54,7 @@ def shallowgroup(cls, self, nodelist, rl class shallowcg1packer(changegroup.cgpacker): def generate(self, commonrevs, clnodes, fastpathlinkrev, source): - if "remotefilelog" in self._repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements: fastpathlinkrev = False return super(shallowcg1packer, self).generate(commonrevs, clnodes, @@ -71,7 +69,7 @@ class shallowcg1packer(changegroup.cgpac linknodes, commonrevs, source = args except ValueError: commonrevs, source, mfdicts, fastpathlinkrev, fnodes, clrevs = args - if requirement in self._repo.requirements: + if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements: repo = self._repo if isinstance(repo, bundlerepo.bundlerepository): # If the bundle contains filelogs, we can't pull from it, since @@ -93,7 +91,7 @@ class shallowcg1packer(changegroup.cgpac def shouldaddfilegroups(self, source): repo = self._repo - if not requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return AllFiles if source == "push" or source == "bundle": @@ -141,7 +139,7 @@ class shallowcg1packer(changegroup.cgpac yield delta def makechangegroup(orig, repo, outgoing, version, source, *args, **kwargs): - if not requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return orig(repo, outgoing, version, source, *args, **kwargs) original = repo.shallowmatch @@ -170,7 +168,7 @@ def makechangegroup(orig, repo, outgoing repo.shallowmatch = original def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args): - if not requirement in repo.requirements: + if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements: return orig(repo, source, revmap, trp, expectedfiles, *args) files = 0 diff --git a/hgext/remotefilelog/shallowrepo.py b/hgext/remotefilelog/shallowrepo.py --- a/hgext/remotefilelog/shallowrepo.py +++ b/hgext/remotefilelog/shallowrepo.py @@ -40,7 +40,6 @@ else: from mercurial.utils import procutil _hgexecutable = procutil.hgexecutable -requirement = "remotefilelog" _prefetching = _('prefetching') # These make*stores functions are global so that other extensions can replace diff --git a/tests/test-remotefilelog-clone-tree.t b/tests/test-remotefilelog-clone-tree.t --- a/tests/test-remotefilelog-clone-tree.t +++ b/tests/test-remotefilelog-clone-tree.t @@ -28,9 +28,9 @@ $ cd shallow $ cat .hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store treemanifest @@ -68,9 +68,9 @@ $ cd shallow2 $ cat .hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store treemanifest @@ -109,9 +109,9 @@ $ ls shallow3/.hg/store/data $ cat shallow3/.hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store treemanifest diff --git a/tests/test-remotefilelog-clone.t b/tests/test-remotefilelog-clone.t --- a/tests/test-remotefilelog-clone.t +++ b/tests/test-remotefilelog-clone.t @@ -25,9 +25,9 @@ $ cd shallow $ cat .hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store @@ -58,9 +58,9 @@ $ cd shallow2 $ cat .hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store $ ls .hg/store/data @@ -106,8 +106,8 @@ check its contents separately. $ ls shallow3/.hg/store/data $ cat shallow3/.hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store diff --git a/tests/test-remotefilelog-log.t b/tests/test-remotefilelog-log.t --- a/tests/test-remotefilelog-log.t +++ b/tests/test-remotefilelog-log.t @@ -28,9 +28,9 @@ Shallow clone from full $ cd shallow $ cat .hg/requires dotencode + exp-remotefilelog-repo-req-1 fncache generaldelta - remotefilelog revlogv1 store