comparison hgext/remotefilelog/shallowbundle.py @ 40510:fc2766860796

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
author Augie Fackler <augie@google.com>
date Tue, 16 Oct 2018 17:02:48 -0400
parents ed19958dbf5d
children 6f0b6905ef6f
comparison
equal deleted inserted replaced
40509:ed19958dbf5d 40510:fc2766860796
24 24
25 NoFiles = 0 25 NoFiles = 0
26 LocalFiles = 1 26 LocalFiles = 1
27 AllFiles = 2 27 AllFiles = 2
28 28
29 requirement = "remotefilelog"
30
31 def shallowgroup(cls, self, nodelist, rlog, lookup, units=None, reorder=None): 29 def shallowgroup(cls, self, nodelist, rlog, lookup, units=None, reorder=None):
32 if not isinstance(rlog, remotefilelog.remotefilelog): 30 if not isinstance(rlog, remotefilelog.remotefilelog):
33 for c in super(cls, self).group(nodelist, rlog, lookup, 31 for c in super(cls, self).group(nodelist, rlog, lookup,
34 units=units): 32 units=units):
35 yield c 33 yield c
54 52
55 yield self.close() 53 yield self.close()
56 54
57 class shallowcg1packer(changegroup.cgpacker): 55 class shallowcg1packer(changegroup.cgpacker):
58 def generate(self, commonrevs, clnodes, fastpathlinkrev, source): 56 def generate(self, commonrevs, clnodes, fastpathlinkrev, source):
59 if "remotefilelog" in self._repo.requirements: 57 if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements:
60 fastpathlinkrev = False 58 fastpathlinkrev = False
61 59
62 return super(shallowcg1packer, self).generate(commonrevs, clnodes, 60 return super(shallowcg1packer, self).generate(commonrevs, clnodes,
63 fastpathlinkrev, source) 61 fastpathlinkrev, source)
64 62
69 def generatefiles(self, changedfiles, *args): 67 def generatefiles(self, changedfiles, *args):
70 try: 68 try:
71 linknodes, commonrevs, source = args 69 linknodes, commonrevs, source = args
72 except ValueError: 70 except ValueError:
73 commonrevs, source, mfdicts, fastpathlinkrev, fnodes, clrevs = args 71 commonrevs, source, mfdicts, fastpathlinkrev, fnodes, clrevs = args
74 if requirement in self._repo.requirements: 72 if constants.SHALLOWREPO_REQUIREMENT in self._repo.requirements:
75 repo = self._repo 73 repo = self._repo
76 if isinstance(repo, bundlerepo.bundlerepository): 74 if isinstance(repo, bundlerepo.bundlerepository):
77 # If the bundle contains filelogs, we can't pull from it, since 75 # If the bundle contains filelogs, we can't pull from it, since
78 # bundlerepo is heavily tied to revlogs. Instead require that 76 # bundlerepo is heavily tied to revlogs. Instead require that
79 # the user use unbundle instead. 77 # the user use unbundle instead.
91 return super(shallowcg1packer, self).generatefiles( 89 return super(shallowcg1packer, self).generatefiles(
92 changedfiles, *args) 90 changedfiles, *args)
93 91
94 def shouldaddfilegroups(self, source): 92 def shouldaddfilegroups(self, source):
95 repo = self._repo 93 repo = self._repo
96 if not requirement in repo.requirements: 94 if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
97 return AllFiles 95 return AllFiles
98 96
99 if source == "push" or source == "bundle": 97 if source == "push" or source == "bundle":
100 return AllFiles 98 return AllFiles
101 99
139 yield changegroup.chunkheader(l) 137 yield changegroup.chunkheader(l)
140 yield meta 138 yield meta
141 yield delta 139 yield delta
142 140
143 def makechangegroup(orig, repo, outgoing, version, source, *args, **kwargs): 141 def makechangegroup(orig, repo, outgoing, version, source, *args, **kwargs):
144 if not requirement in repo.requirements: 142 if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
145 return orig(repo, outgoing, version, source, *args, **kwargs) 143 return orig(repo, outgoing, version, source, *args, **kwargs)
146 144
147 original = repo.shallowmatch 145 original = repo.shallowmatch
148 try: 146 try:
149 # if serving, only send files the clients has patterns for 147 # if serving, only send files the clients has patterns for
168 return orig(repo, outgoing, version, source, *args, **kwargs) 166 return orig(repo, outgoing, version, source, *args, **kwargs)
169 finally: 167 finally:
170 repo.shallowmatch = original 168 repo.shallowmatch = original
171 169
172 def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args): 170 def addchangegroupfiles(orig, repo, source, revmap, trp, expectedfiles, *args):
173 if not requirement in repo.requirements: 171 if not constants.SHALLOWREPO_REQUIREMENT in repo.requirements:
174 return orig(repo, source, revmap, trp, expectedfiles, *args) 172 return orig(repo, source, revmap, trp, expectedfiles, *args)
175 173
176 files = 0 174 files = 0
177 newfiles = 0 175 newfiles = 0
178 visited = set() 176 visited = set()