Show More
@@ -250,14 +250,17 b' def _setupcommit(ui):' | |||||
250 | """ |
|
250 | """ | |
251 | orig(self, node) |
|
251 | orig(self, node) | |
252 | repo = self._repo |
|
252 | repo = self._repo | |
253 | if util.safehasattr(repo, 'getsparsepatterns'): |
|
253 | ||
254 |
|
|
254 | ctx = repo[node] | |
255 |
|
|
255 | profiles = sparse.patternsforrev(repo, ctx.rev())[2] | |
256 | if set(profiles) & set(ctx.files()): |
|
|||
257 | origstatus = repo.status() |
|
|||
258 | origsparsematch = repo.sparsematch() |
|
|||
259 | _refresh(repo.ui, repo, origstatus, origsparsematch, True) |
|
|||
260 |
|
256 | |||
|
257 | # profiles will only have data if sparse is enabled. | |||
|
258 | if set(profiles) & set(ctx.files()): | |||
|
259 | origstatus = repo.status() | |||
|
260 | origsparsematch = repo.sparsematch() | |||
|
261 | _refresh(repo.ui, repo, origstatus, origsparsematch, True) | |||
|
262 | ||||
|
263 | if util.safehasattr(repo, 'prunetemporaryincludes'): | |||
261 | repo.prunetemporaryincludes() |
|
264 | repo.prunetemporaryincludes() | |
262 |
|
265 | |||
263 | extensions.wrapfunction(context.committablectx, 'markcommitted', |
|
266 | extensions.wrapfunction(context.committablectx, 'markcommitted', | |
@@ -410,53 +413,6 b' def _setupdirstate(ui):' | |||||
410 |
|
413 | |||
411 | def _wraprepo(ui, repo): |
|
414 | def _wraprepo(ui, repo): | |
412 | class SparseRepo(repo.__class__): |
|
415 | class SparseRepo(repo.__class__): | |
413 | def getsparsepatterns(self, rev): |
|
|||
414 | """Returns the include/exclude patterns specified by the |
|
|||
415 | given rev. |
|
|||
416 | """ |
|
|||
417 | raw = self.vfs.tryread('sparse') |
|
|||
418 | if not raw: |
|
|||
419 | return set(), set(), [] |
|
|||
420 | if rev is None: |
|
|||
421 | raise error.Abort(_("cannot parse sparse patterns from " + |
|
|||
422 | "working copy")) |
|
|||
423 |
|
||||
424 | includes, excludes, profiles = sparse.parseconfig(self.ui, raw) |
|
|||
425 |
|
||||
426 | ctx = self[rev] |
|
|||
427 | if profiles: |
|
|||
428 | visited = set() |
|
|||
429 | while profiles: |
|
|||
430 | profile = profiles.pop() |
|
|||
431 | if profile in visited: |
|
|||
432 | continue |
|
|||
433 | visited.add(profile) |
|
|||
434 |
|
||||
435 | try: |
|
|||
436 | raw = sparse.readprofile(self, profile, rev) |
|
|||
437 | except error.ManifestLookupError: |
|
|||
438 | msg = ( |
|
|||
439 | "warning: sparse profile '%s' not found " |
|
|||
440 | "in rev %s - ignoring it\n" % (profile, ctx)) |
|
|||
441 | if self.ui.configbool( |
|
|||
442 | 'sparse', 'missingwarning', True): |
|
|||
443 | self.ui.warn(msg) |
|
|||
444 | else: |
|
|||
445 | self.ui.debug(msg) |
|
|||
446 | continue |
|
|||
447 | pincludes, pexcludes, subprofs = sparse.parseconfig( |
|
|||
448 | self.ui, raw) |
|
|||
449 | includes.update(pincludes) |
|
|||
450 | excludes.update(pexcludes) |
|
|||
451 | for subprofile in subprofs: |
|
|||
452 | profiles.append(subprofile) |
|
|||
453 |
|
||||
454 | profiles = visited |
|
|||
455 |
|
||||
456 | if includes: |
|
|||
457 | includes.add('.hg*') |
|
|||
458 | return includes, excludes, profiles |
|
|||
459 |
|
||||
460 | def _sparsechecksum(self, path): |
|
416 | def _sparsechecksum(self, path): | |
461 | data = self.vfs.read(path) |
|
417 | data = self.vfs.read(path) | |
462 | return hashlib.sha1(data).hexdigest() |
|
418 | return hashlib.sha1(data).hexdigest() | |
@@ -521,7 +477,8 b' def _wraprepo(ui, repo):' | |||||
521 | matchers = [] |
|
477 | matchers = [] | |
522 | for rev in revs: |
|
478 | for rev in revs: | |
523 | try: |
|
479 | try: | |
524 |
includes, excludes, profiles = se |
|
480 | includes, excludes, profiles = sparse.patternsforrev( | |
|
481 | self, rev) | |||
525 |
|
482 | |||
526 | if includes or excludes: |
|
483 | if includes or excludes: | |
527 | # Explicitly include subdirectories of includes so |
|
484 | # Explicitly include subdirectories of includes so | |
@@ -566,7 +523,7 b' def _wraprepo(ui, repo):' | |||||
566 |
|
523 | |||
567 | activeprofiles = set() |
|
524 | activeprofiles = set() | |
568 | for rev in revs: |
|
525 | for rev in revs: | |
569 |
_, _, profiles = self |
|
526 | _, _, profiles = sparse.patternsforrev(self, rev) | |
570 | activeprofiles.update(profiles) |
|
527 | activeprofiles.update(profiles) | |
571 |
|
528 | |||
572 | return activeprofiles |
|
529 | return activeprofiles | |
@@ -817,7 +774,7 b' def _import(ui, repo, files, opts, force' | |||||
817 | # all active rules |
|
774 | # all active rules | |
818 | aincludes, aexcludes, aprofiles = set(), set(), set() |
|
775 | aincludes, aexcludes, aprofiles = set(), set(), set() | |
819 | for rev in revs: |
|
776 | for rev in revs: | |
820 |
rincludes, rexcludes, rprofiles = repo |
|
777 | rincludes, rexcludes, rprofiles = sparse.patternsforrev(repo, rev) | |
821 | aincludes.update(rincludes) |
|
778 | aincludes.update(rincludes) | |
822 | aexcludes.update(rexcludes) |
|
779 | aexcludes.update(rexcludes) | |
823 | aprofiles.update(rprofiles) |
|
780 | aprofiles.update(rprofiles) |
@@ -58,3 +58,60 b' def readprofile(repo, profile, changeid)' | |||||
58 | # TODO add some kind of cache here because this incurs a manifest |
|
58 | # TODO add some kind of cache here because this incurs a manifest | |
59 | # resolve and can be slow. |
|
59 | # resolve and can be slow. | |
60 | return repo.filectx(profile, changeid=changeid).data() |
|
60 | return repo.filectx(profile, changeid=changeid).data() | |
|
61 | ||||
|
62 | def patternsforrev(repo, rev): | |||
|
63 | """Obtain sparse checkout patterns for the given rev. | |||
|
64 | ||||
|
65 | Returns a tuple of iterables representing includes, excludes, and | |||
|
66 | patterns. | |||
|
67 | """ | |||
|
68 | # Feature isn't enabled. No-op. | |||
|
69 | if not enabled: | |||
|
70 | return set(), set(), [] | |||
|
71 | ||||
|
72 | raw = repo.vfs.tryread('sparse') | |||
|
73 | if not raw: | |||
|
74 | return set(), set(), [] | |||
|
75 | ||||
|
76 | if rev is None: | |||
|
77 | raise error.Abort(_('cannot parse sparse patterns from working ' | |||
|
78 | 'directory')) | |||
|
79 | ||||
|
80 | includes, excludes, profiles = parseconfig(repo.ui, raw) | |||
|
81 | ctx = repo[rev] | |||
|
82 | ||||
|
83 | if profiles: | |||
|
84 | visited = set() | |||
|
85 | while profiles: | |||
|
86 | profile = profiles.pop() | |||
|
87 | if profile in visited: | |||
|
88 | continue | |||
|
89 | ||||
|
90 | visited.add(profile) | |||
|
91 | ||||
|
92 | try: | |||
|
93 | raw = readprofile(repo, profile, rev) | |||
|
94 | except error.ManifestLookupError: | |||
|
95 | msg = ( | |||
|
96 | "warning: sparse profile '%s' not found " | |||
|
97 | "in rev %s - ignoring it\n" % (profile, ctx)) | |||
|
98 | # experimental config: sparse.missingwarning | |||
|
99 | if repo.ui.configbool( | |||
|
100 | 'sparse', 'missingwarning', True): | |||
|
101 | repo.ui.warn(msg) | |||
|
102 | else: | |||
|
103 | repo.ui.debug(msg) | |||
|
104 | continue | |||
|
105 | ||||
|
106 | pincludes, pexcludes, subprofs = parseconfig(repo.ui, raw) | |||
|
107 | includes.update(pincludes) | |||
|
108 | excludes.update(pexcludes) | |||
|
109 | for subprofile in subprofs: | |||
|
110 | profiles.append(subprofile) | |||
|
111 | ||||
|
112 | profiles = visited | |||
|
113 | ||||
|
114 | if includes: | |||
|
115 | includes.add('.hg*') | |||
|
116 | ||||
|
117 | return includes, excludes, profiles |
General Comments 0
You need to be logged in to leave comments.
Login now