Mercurial > hg
diff mercurial/sparse.py @ 33323:252500520d60
sparse: refactor update actions filtering and call from core
merge.calculateupdates() now filters the update actions through sparse
by default.
The filtering no-ops if sparse isn't enabled or no sparse config
is defined.
The function has been refactored to behave more like a filter
instead of a wrapper of merge.calculateupdates().
We should arguably take sparse into account earlier in
merge.calculateupdates(). This patch preserves the old behavior
of applying sparse at the end of update calculation, which is the
simplest and safest approach.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Jul 2017 16:29:31 -0700 |
parents | fa6c2c3064fd |
children | 33d0859c37bd |
line wrap: on
line diff
--- a/mercurial/sparse.py Thu Jul 06 16:17:35 2017 -0700 +++ b/mercurial/sparse.py Thu Jul 06 16:29:31 2017 -0700 @@ -301,18 +301,16 @@ return result -def calculateupdates(orig, repo, wctx, mctx, ancestors, branchmerge, *arg, - **kwargs): - """Filter updates to only lay out files that match the sparse rules. - """ - actions, diverge, renamedelete = orig(repo, wctx, mctx, ancestors, - branchmerge, *arg, **kwargs) +def filterupdatesactions(repo, wctx, mctx, branchmerge, actions): + """Filter updates to only lay out files that match the sparse rules.""" + if not enabled: + return actions oldrevs = [pctx.rev() for pctx in wctx.parents()] oldsparsematch = matcher(repo, oldrevs) if oldsparsematch.always(): - return actions, diverge, renamedelete + return actions files = set() prunedactions = {} @@ -383,4 +381,4 @@ elif old and not new: prunedactions[file] = ('r', [], '') - return prunedactions, diverge, renamedelete + return prunedactions