Show More
@@ -86,6 +86,8 b' from mercurial import (' | |||||
86 | pycompat, |
|
86 | pycompat, | |
87 | registrar, |
|
87 | registrar, | |
88 | sparse, |
|
88 | sparse, | |
|
89 | subrepo, | |||
|
90 | subrepoutil, | |||
89 | util, |
|
91 | util, | |
90 | ) |
|
92 | ) | |
91 |
|
93 | |||
@@ -106,6 +108,7 b' def extsetup(ui):' | |||||
106 | _setuplog(ui) |
|
108 | _setuplog(ui) | |
107 | _setupadd(ui) |
|
109 | _setupadd(ui) | |
108 | _setupdirstate(ui) |
|
110 | _setupdirstate(ui) | |
|
111 | _setupsubrepo(ui) | |||
109 |
|
112 | |||
110 |
|
113 | |||
111 | def replacefilecache(cls, propname, replacement): |
|
114 | def replacefilecache(cls, propname, replacement): | |
@@ -286,6 +289,54 b' def _setupdirstate(ui):' | |||||
286 | extensions.wrapfunction(dirstate.dirstate, func, _wrapper) |
|
289 | extensions.wrapfunction(dirstate.dirstate, func, _wrapper) | |
287 |
|
290 | |||
288 |
|
291 | |||
|
292 | class DummySubrepo(subrepo.abstractsubrepo): | |||
|
293 | """Dumy subrepo is replacement of subrepo, that should be filterout from sparce. | |||
|
294 | this subrepo acts as always clean and always get/remove well. | |||
|
295 | """ | |||
|
296 | ||||
|
297 | def dirty(self, ignoreupdate=False, missing=False): | |||
|
298 | return False | |||
|
299 | ||||
|
300 | def get(self, state, overwrite=False): | |||
|
301 | return | |||
|
302 | ||||
|
303 | def remove(self): | |||
|
304 | return | |||
|
305 | ||||
|
306 | ||||
|
307 | def _setupsubrepo(ui): | |||
|
308 | """Modify the dirstate to prevent stat'ing excluded files, | |||
|
309 | and to prevent modifications to files outside the checkout. | |||
|
310 | """ | |||
|
311 | ||||
|
312 | def _state(orig, ctx, ui): | |||
|
313 | sparsematch = sparse.matcher(ctx.repo(), revs=[ctx.rev()]) | |||
|
314 | if not sparsematch.always(): | |||
|
315 | # filter allstate, leave only sparce pathes | |||
|
316 | allstate = orig(ctx, ui) | |||
|
317 | sparcestate = dict() | |||
|
318 | for (idx, item) in allstate.items(): | |||
|
319 | if sparsematch(idx): | |||
|
320 | sparcestate[idx] = item | |||
|
321 | return sparcestate | |||
|
322 | else: | |||
|
323 | return orig(ctx, ui) | |||
|
324 | ||||
|
325 | # extensions.wrapfunction(subrepoutil, b'state', _state) | |||
|
326 | ||||
|
327 | """ provide DummySubrepo for pathes out of sparse | |||
|
328 | """ | |||
|
329 | ||||
|
330 | def _subrepo(orig, ctx, path, allowwdir=False, allowcreate=True): | |||
|
331 | sparsematch = sparse.matcher(ctx.repo(), revs=[ctx.rev()]) | |||
|
332 | if not sparsematch.always(): | |||
|
333 | if not sparsematch(path): | |||
|
334 | return DummySubrepo(ctx, path) | |||
|
335 | return orig(ctx, path, allowwdir, allowcreate) | |||
|
336 | ||||
|
337 | extensions.wrapfunction(subrepo, b'subrepo', _subrepo) | |||
|
338 | ||||
|
339 | ||||
289 | @command( |
|
340 | @command( | |
290 | b'debugsparse', |
|
341 | b'debugsparse', | |
291 | [ |
|
342 | [ |
@@ -21,6 +21,7 b' from . import (' | |||||
21 | pathutil, |
|
21 | pathutil, | |
22 | phases, |
|
22 | phases, | |
23 | pycompat, |
|
23 | pycompat, | |
|
24 | sparse, | |||
24 | util, |
|
25 | util, | |
25 | ) |
|
26 | ) | |
26 | from .utils import ( |
|
27 | from .utils import ( | |
@@ -183,6 +184,9 b' def submerge(repo, wctx, mctx, actx, ove' | |||||
183 | sa = actx.substate |
|
184 | sa = actx.substate | |
184 | sm = {} |
|
185 | sm = {} | |
185 |
|
186 | |||
|
187 | s1match = sparse.matcher(repo, revs=[wctx.rev()]) | |||
|
188 | s2match = sparse.matcher(repo, revs=[mctx.rev()]) | |||
|
189 | ||||
186 | repo.ui.debug(b"subrepo merge %s %s %s\n" % (wctx, mctx, actx)) |
|
190 | repo.ui.debug(b"subrepo merge %s %s %s\n" % (wctx, mctx, actx)) | |
187 |
|
191 | |||
188 | def debug(s, msg, r=b""): |
|
192 | def debug(s, msg, r=b""): | |
@@ -192,6 +196,9 b' def submerge(repo, wctx, mctx, actx, ove' | |||||
192 |
|
196 | |||
193 | promptssrc = filemerge.partextras(labels) |
|
197 | promptssrc = filemerge.partextras(labels) | |
194 | for s, l in sorted(pycompat.iteritems(s1)): |
|
198 | for s, l in sorted(pycompat.iteritems(s1)): | |
|
199 | if not s1match(s): | |||
|
200 | sm[s] = l # ignore changes out of sparse | |||
|
201 | continue | |||
195 | a = sa.get(s, nullstate) |
|
202 | a = sa.get(s, nullstate) | |
196 | ld = l # local state with possible dirty flag for compares |
|
203 | ld = l # local state with possible dirty flag for compares | |
197 | if wctx.sub(s).dirty(): |
|
204 | if wctx.sub(s).dirty(): | |
@@ -202,6 +209,9 b' def submerge(repo, wctx, mctx, actx, ove' | |||||
202 | prompts = promptssrc.copy() |
|
209 | prompts = promptssrc.copy() | |
203 | prompts[b's'] = s |
|
210 | prompts[b's'] = s | |
204 | if s in s2: |
|
211 | if s in s2: | |
|
212 | if not s2match(s): | |||
|
213 | sm[s] = l # ignore changes out of sparse | |||
|
214 | continue | |||
205 | r = s2[s] |
|
215 | r = s2[s] | |
206 | if ld == r or r == a: # no change or local is newer |
|
216 | if ld == r or r == a: # no change or local is newer | |
207 | sm[s] = l |
|
217 | sm[s] = l | |
@@ -288,6 +298,14 b' def submerge(repo, wctx, mctx, actx, ove' | |||||
288 | mctx.sub(s).get(r) |
|
298 | mctx.sub(s).get(r) | |
289 | sm[s] = r |
|
299 | sm[s] = r | |
290 | elif r != sa[s]: |
|
300 | elif r != sa[s]: | |
|
301 | if not s2match(s): | |||
|
302 | # ignore changes out of sparse, | |||
|
303 | continue | |||
|
304 | elif not s1match(s): | |||
|
305 | # recreate changes out of sparse, | |||
|
306 | # sm[s] = r | |||
|
307 | continue | |||
|
308 | ||||
291 | prompts = promptssrc.copy() |
|
309 | prompts = promptssrc.copy() | |
292 | prompts[b's'] = s |
|
310 | prompts[b's'] = s | |
293 | if ( |
|
311 | if ( |
General Comments 0
You need to be logged in to leave comments.
Login now