Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
33322:fa6c2c3064fd | 33323:252500520d60 |
---|---|
299 | 299 |
300 repo._sparsematchercache[key] = result | 300 repo._sparsematchercache[key] = result |
301 | 301 |
302 return result | 302 return result |
303 | 303 |
304 def calculateupdates(orig, repo, wctx, mctx, ancestors, branchmerge, *arg, | 304 def filterupdatesactions(repo, wctx, mctx, branchmerge, actions): |
305 **kwargs): | 305 """Filter updates to only lay out files that match the sparse rules.""" |
306 """Filter updates to only lay out files that match the sparse rules. | 306 if not enabled: |
307 """ | 307 return actions |
308 actions, diverge, renamedelete = orig(repo, wctx, mctx, ancestors, | |
309 branchmerge, *arg, **kwargs) | |
310 | 308 |
311 oldrevs = [pctx.rev() for pctx in wctx.parents()] | 309 oldrevs = [pctx.rev() for pctx in wctx.parents()] |
312 oldsparsematch = matcher(repo, oldrevs) | 310 oldsparsematch = matcher(repo, oldrevs) |
313 | 311 |
314 if oldsparsematch.always(): | 312 if oldsparsematch.always(): |
315 return actions, diverge, renamedelete | 313 return actions |
316 | 314 |
317 files = set() | 315 files = set() |
318 prunedactions = {} | 316 prunedactions = {} |
319 | 317 |
320 if branchmerge: | 318 if branchmerge: |
381 flags = mf.flags(file) | 379 flags = mf.flags(file) |
382 prunedactions[file] = ('g', (flags, False), '') | 380 prunedactions[file] = ('g', (flags, False), '') |
383 elif old and not new: | 381 elif old and not new: |
384 prunedactions[file] = ('r', [], '') | 382 prunedactions[file] = ('r', [], '') |
385 | 383 |
386 return prunedactions, diverge, renamedelete | 384 return prunedactions |