Show More
@@ -26,6 +26,7 b' from mercurial import (' | |||||
26 | node, |
|
26 | node, | |
27 | pycompat, |
|
27 | pycompat, | |
28 | scmutil, |
|
28 | scmutil, | |
|
29 | sparse, | |||
29 | util, |
|
30 | util, | |
30 | vfs as vfsmod, |
|
31 | vfs as vfsmod, | |
31 | ) |
|
32 | ) | |
@@ -147,7 +148,8 b' def openlfdirstate(ui, repo, create=True' | |||||
147 | lfstoredir = longname |
|
148 | lfstoredir = longname | |
148 | opener = vfsmod.vfs(vfs.join(lfstoredir)) |
|
149 | opener = vfsmod.vfs(vfs.join(lfstoredir)) | |
149 | lfdirstate = largefilesdirstate(opener, ui, repo.root, |
|
150 | lfdirstate = largefilesdirstate(opener, ui, repo.root, | |
150 |
|
|
151 | repo.dirstate._validate, | |
|
152 | lambda: sparse.matcher(repo)) | |||
151 |
|
153 | |||
152 | # If the largefiles dirstate does not exist, populate and create |
|
154 | # If the largefiles dirstate does not exist, populate and create | |
153 | # it. This ensures that we create it on the first meaningful |
|
155 | # it. This ensures that we create it on the first meaningful |
@@ -82,7 +82,6 b' from mercurial import (' | |||||
82 | error, |
|
82 | error, | |
83 | extensions, |
|
83 | extensions, | |
84 | hg, |
|
84 | hg, | |
85 | localrepo, |
|
|||
86 | match as matchmod, |
|
85 | match as matchmod, | |
87 | registrar, |
|
86 | registrar, | |
88 | sparse, |
|
87 | sparse, | |
@@ -106,13 +105,6 b' def extsetup(ui):' | |||||
106 | _setupadd(ui) |
|
105 | _setupadd(ui) | |
107 | _setupdirstate(ui) |
|
106 | _setupdirstate(ui) | |
108 |
|
107 | |||
109 | def reposetup(ui, repo): |
|
|||
110 | if not util.safehasattr(repo, 'dirstate'): |
|
|||
111 | return |
|
|||
112 |
|
||||
113 | if 'dirstate' in repo._filecache: |
|
|||
114 | repo.dirstate.repo = repo |
|
|||
115 |
|
||||
116 | def replacefilecache(cls, propname, replacement): |
|
108 | def replacefilecache(cls, propname, replacement): | |
117 | """Replace a filecache property with a new class. This allows changing the |
|
109 | """Replace a filecache property with a new class. This allows changing the | |
118 | cache invalidation condition.""" |
|
110 | cache invalidation condition.""" | |
@@ -200,13 +192,6 b' def _setupdirstate(ui):' | |||||
200 | and to prevent modifications to files outside the checkout. |
|
192 | and to prevent modifications to files outside the checkout. | |
201 | """ |
|
193 | """ | |
202 |
|
194 | |||
203 | def _dirstate(orig, repo): |
|
|||
204 | dirstate = orig(repo) |
|
|||
205 | dirstate.repo = repo |
|
|||
206 | return dirstate |
|
|||
207 | extensions.wrapfunction( |
|
|||
208 | localrepo.localrepository.dirstate, 'func', _dirstate) |
|
|||
209 |
|
||||
210 | # The atrocity below is needed to wrap dirstate._ignore. It is a cached |
|
195 | # The atrocity below is needed to wrap dirstate._ignore. It is a cached | |
211 | # property, which means normal function wrapping doesn't work. |
|
196 | # property, which means normal function wrapping doesn't work. | |
212 | class ignorewrapper(object): |
|
197 | class ignorewrapper(object): | |
@@ -217,10 +202,9 b' def _setupdirstate(ui):' | |||||
217 | self.sparsematch = None |
|
202 | self.sparsematch = None | |
218 |
|
203 | |||
219 | def __get__(self, obj, type=None): |
|
204 | def __get__(self, obj, type=None): | |
220 | repo = obj.repo |
|
|||
221 | origignore = self.orig.__get__(obj) |
|
205 | origignore = self.orig.__get__(obj) | |
222 |
|
206 | |||
223 |
sparsematch = |
|
207 | sparsematch = obj._sparsematcher | |
224 | if sparsematch.always(): |
|
208 | if sparsematch.always(): | |
225 | return origignore |
|
209 | return origignore | |
226 |
|
210 | |||
@@ -241,7 +225,7 b' def _setupdirstate(ui):' | |||||
241 |
|
225 | |||
242 | # dirstate.rebuild should not add non-matching files |
|
226 | # dirstate.rebuild should not add non-matching files | |
243 | def _rebuild(orig, self, parent, allfiles, changedfiles=None): |
|
227 | def _rebuild(orig, self, parent, allfiles, changedfiles=None): | |
244 |
matcher = |
|
228 | matcher = self._sparsematcher | |
245 | if not matcher.always(): |
|
229 | if not matcher.always(): | |
246 | allfiles = allfiles.matches(matcher) |
|
230 | allfiles = allfiles.matches(matcher) | |
247 | if changedfiles: |
|
231 | if changedfiles: | |
@@ -262,8 +246,7 b' def _setupdirstate(ui):' | |||||
262 | '`hg add -s <file>` to include file directory while adding') |
|
246 | '`hg add -s <file>` to include file directory while adding') | |
263 | for func in editfuncs: |
|
247 | for func in editfuncs: | |
264 | def _wrapper(orig, self, *args): |
|
248 | def _wrapper(orig, self, *args): | |
265 |
|
|
249 | sparsematch = self._sparsematcher | |
266 | sparsematch = sparse.matcher(repo) |
|
|||
267 | if not sparsematch.always(): |
|
250 | if not sparsematch.always(): | |
268 | for f in args: |
|
251 | for f in args: | |
269 | if (f is not None and not sparsematch(f) and |
|
252 | if (f is not None and not sparsematch(f) and |
@@ -70,7 +70,7 b' def nonnormalentries(dmap):' | |||||
70 |
|
70 | |||
71 | class dirstate(object): |
|
71 | class dirstate(object): | |
72 |
|
72 | |||
73 | def __init__(self, opener, ui, root, validate): |
|
73 | def __init__(self, opener, ui, root, validate, sparsematchfn): | |
74 | '''Create a new dirstate object. |
|
74 | '''Create a new dirstate object. | |
75 |
|
75 | |||
76 | opener is an open()-like callable that can be used to open the |
|
76 | opener is an open()-like callable that can be used to open the | |
@@ -80,6 +80,7 b' class dirstate(object):' | |||||
80 | self._opener = opener |
|
80 | self._opener = opener | |
81 | self._validate = validate |
|
81 | self._validate = validate | |
82 | self._root = root |
|
82 | self._root = root | |
|
83 | self._sparsematchfn = sparsematchfn | |||
83 | # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is |
|
84 | # ntpath.join(root, '') of Python 2.7.9 does not add sep if root is | |
84 | # UNC path pointing to root share (issue4557) |
|
85 | # UNC path pointing to root share (issue4557) | |
85 | self._rootdir = pathutil.normasprefix(root) |
|
86 | self._rootdir = pathutil.normasprefix(root) | |
@@ -197,6 +198,19 b' class dirstate(object):' | |||||
197 | f[normcase(name)] = name |
|
198 | f[normcase(name)] = name | |
198 | return f |
|
199 | return f | |
199 |
|
200 | |||
|
201 | @property | |||
|
202 | def _sparsematcher(self): | |||
|
203 | """The matcher for the sparse checkout. | |||
|
204 | ||||
|
205 | The working directory may not include every file from a manifest. The | |||
|
206 | matcher obtained by this property will match a path if it is to be | |||
|
207 | included in the working directory. | |||
|
208 | """ | |||
|
209 | # TODO there is potential to cache this property. For now, the matcher | |||
|
210 | # is resolved on every access. (But the called function does use a | |||
|
211 | # cache to keep the lookup fast.) | |||
|
212 | return self._sparsematchfn() | |||
|
213 | ||||
200 | @repocache('branch') |
|
214 | @repocache('branch') | |
201 | def _branch(self): |
|
215 | def _branch(self): | |
202 | try: |
|
216 | try: |
@@ -53,6 +53,7 b' from . import (' | |||||
53 | revset, |
|
53 | revset, | |
54 | revsetlang, |
|
54 | revsetlang, | |
55 | scmutil, |
|
55 | scmutil, | |
|
56 | sparse, | |||
56 | store, |
|
57 | store, | |
57 | subrepo, |
|
58 | subrepo, | |
58 | tags as tagsmod, |
|
59 | tags as tagsmod, | |
@@ -570,8 +571,10 b' class localrepository(object):' | |||||
570 |
|
571 | |||
571 | @repofilecache('dirstate') |
|
572 | @repofilecache('dirstate') | |
572 | def dirstate(self): |
|
573 | def dirstate(self): | |
|
574 | sparsematchfn = lambda: sparse.matcher(self) | |||
|
575 | ||||
573 | return dirstate.dirstate(self.vfs, self.ui, self.root, |
|
576 | return dirstate.dirstate(self.vfs, self.ui, self.root, | |
574 | self._dirstatevalidate) |
|
577 | self._dirstatevalidate, sparsematchfn) | |
575 |
|
578 | |||
576 | def _dirstatevalidate(self, node): |
|
579 | def _dirstatevalidate(self, node): | |
577 | try: |
|
580 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now