##// END OF EJS Templates
sparse: refactor activeprofiles into a generic function (API)...
Gregory Szorc -
r33370:48232010 default
parent child Browse files
Show More
@@ -75,7 +75,6 b' certain files::'
75 from __future__ import absolute_import
75 from __future__ import absolute_import
76
76
77 from mercurial.i18n import _
77 from mercurial.i18n import _
78 from mercurial.node import nullid
79 from mercurial import (
78 from mercurial import (
80 cmdutil,
79 cmdutil,
81 commands,
80 commands,
@@ -448,23 +447,13 b' def _config(ui, repo, pats, opts, includ'
448
447
449 def _import(ui, repo, files, opts, force=False):
448 def _import(ui, repo, files, opts, force=False):
450 with repo.wlock():
449 with repo.wlock():
451 # load union of current active profile
452 revs = [repo.changelog.rev(node) for node in
453 repo.dirstate.parents() if node != nullid]
454
455 # read current configuration
450 # read current configuration
456 raw = repo.vfs.tryread('sparse')
451 raw = repo.vfs.tryread('sparse')
457 oincludes, oexcludes, oprofiles = sparse.parseconfig(ui, raw)
452 oincludes, oexcludes, oprofiles = sparse.parseconfig(ui, raw)
458 includes, excludes, profiles = map(
453 includes, excludes, profiles = map(
459 set, (oincludes, oexcludes, oprofiles))
454 set, (oincludes, oexcludes, oprofiles))
460
455
461 # all active rules
456 aincludes, aexcludes, aprofiles = sparse.activeconfig(repo)
462 aincludes, aexcludes, aprofiles = set(), set(), set()
463 for rev in revs:
464 rincludes, rexcludes, rprofiles = sparse.patternsforrev(repo, rev)
465 aincludes.update(rincludes)
466 aexcludes.update(rexcludes)
467 aprofiles.update(rprofiles)
468
457
469 # import rules on top; only take in rules that are not yet
458 # import rules on top; only take in rules that are not yet
470 # part of the active rules.
459 # part of the active rules.
@@ -124,15 +124,26 b' def patternsforrev(repo, rev):'
124
124
125 return includes, excludes, profiles
125 return includes, excludes, profiles
126
126
127 def activeprofiles(repo):
127 def activeconfig(repo):
128 """Determine the active sparse config rules.
129
130 Rules are constructed by reading the current sparse config and bringing in
131 referenced profiles from parents of the working directory.
132 """
128 revs = [repo.changelog.rev(node) for node in
133 revs = [repo.changelog.rev(node) for node in
129 repo.dirstate.parents() if node != nullid]
134 repo.dirstate.parents() if node != nullid]
130
135
131 profiles = set()
136 allincludes = set()
137 allexcludes = set()
138 allprofiles = set()
139
132 for rev in revs:
140 for rev in revs:
133 profiles.update(patternsforrev(repo, rev)[2])
141 includes, excludes, profiles = patternsforrev(repo, rev)
142 allincludes |= includes
143 allexcludes |= excludes
144 allprofiles |= set(profiles)
134
145
135 return profiles
146 return allincludes, allexcludes, allprofiles
136
147
137 def configsignature(repo, includetemp=True):
148 def configsignature(repo, includetemp=True):
138 """Obtain the signature string for the current sparse configuration.
149 """Obtain the signature string for the current sparse configuration.
@@ -361,7 +372,7 b' def filterupdatesactions(repo, wctx, mct'
361 for file, flags, msg in actions:
372 for file, flags, msg in actions:
362 dirstate.normal(file)
373 dirstate.normal(file)
363
374
364 profiles = activeprofiles(repo)
375 profiles = activeconfig(repo)[2]
365 changedprofiles = profiles & files
376 changedprofiles = profiles & files
366 # If an active profile changed during the update, refresh the checkout.
377 # If an active profile changed during the update, refresh the checkout.
367 # Don't do this during a branch merge, since all incoming changes should
378 # Don't do this during a branch merge, since all incoming changes should
General Comments 0
You need to be logged in to leave comments. Login now