# HG changeset patch # User Augie Fackler # Date 1450137243 18000 # Node ID 43c00ca887d185c6e334edfff0bafe52ce841dd5 # Parent c59647c6694d45b2ab68bbb9e8b48fc782ba91e7 merge: have merge.update use a matcher instead of partial fn This is relatively rarely used functionality, but migrating this to a matcher will make future work on narrow clones more feasible. diff -r c59647c6694d -r 43c00ca887d1 hgext/histedit.py --- a/hgext/histedit.py Sat Dec 12 09:57:05 2015 -0800 +++ b/hgext/histedit.py Mon Dec 14 18:54:03 2015 -0500 @@ -712,8 +712,8 @@ def run(self): if self.repo['.'].node() != self.node: - mergemod.update(self.repo, self.node, False, True, False) - # branchmerge, force, partial) + mergemod.update(self.repo, self.node, False, True) + # branchmerge, force) return self.continueclean() def continuedirty(self): diff -r c59647c6694d -r 43c00ca887d1 hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py Sat Dec 12 09:57:05 2015 -0800 +++ b/hgext/largefiles/overrides.py Mon Dec 14 18:54:03 2015 -0500 @@ -1364,8 +1364,11 @@ err = 0 return err -def mergeupdate(orig, repo, node, branchmerge, force, partial, +def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs): + matcher = kwargs.get('matcher', None) + # note if this is a partial update + partial = matcher and not matcher.always() wlock = repo.wlock() try: # branch | | | @@ -1405,7 +1408,7 @@ oldstandins = lfutil.getstandinsstate(repo) - result = orig(repo, node, branchmerge, force, partial, *args, **kwargs) + result = orig(repo, node, branchmerge, force, *args, **kwargs) newstandins = lfutil.getstandinsstate(repo) filelist = lfutil.getlfilestoupdate(oldstandins, newstandins) diff -r c59647c6694d -r 43c00ca887d1 hgext/rebase.py --- a/hgext/rebase.py Sat Dec 12 09:57:05 2015 -0800 +++ b/hgext/rebase.py Mon Dec 14 18:54:03 2015 -0500 @@ -632,7 +632,7 @@ # Update to target and merge it with local if repo['.'].rev() != p1: repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1])) - merge.update(repo, p1, False, True, False) + merge.update(repo, p1, False, True) else: repo.ui.debug(" already in target\n") repo.dirstate.write(repo.currenttransaction()) @@ -641,7 +641,7 @@ repo.ui.debug(" detach base %d:%s\n" % (base, repo[base])) # When collapsing in-place, the parent is the common ancestor, we # have to allow merging with it. - stats = merge.update(repo, rev, True, True, False, base, collapse, + stats = merge.update(repo, rev, True, True, base, collapse, labels=['dest', 'source']) if collapse: copies.duplicatecopies(repo, rev, target) @@ -958,7 +958,7 @@ if cleanup: # Update away from the rebase if necessary if needupdate(repo, state): - merge.update(repo, originalwd, False, True, False) + merge.update(repo, originalwd, False, True) # Strip from the first rebased revision rebased = filter(lambda x: x >= 0 and x != target, state.values()) diff -r c59647c6694d -r 43c00ca887d1 hgext/transplant.py --- a/hgext/transplant.py Sat Dec 12 09:57:05 2015 -0800 +++ b/hgext/transplant.py Mon Dec 14 18:54:03 2015 -0500 @@ -152,7 +152,7 @@ if pulls: if source != repo: exchange.pull(repo, source.peer(), heads=pulls) - merge.update(repo, pulls[-1], False, False, None) + merge.update(repo, pulls[-1], False, False) p1, p2 = repo.dirstate.parents() pulls = [] @@ -216,7 +216,7 @@ tr.close() if pulls: exchange.pull(repo, source.peer(), heads=pulls) - merge.update(repo, pulls[-1], False, False, None) + merge.update(repo, pulls[-1], False, False) finally: self.saveseries(revmap, merges) self.transplants.write() diff -r c59647c6694d -r 43c00ca887d1 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Sat Dec 12 09:57:05 2015 -0800 +++ b/mercurial/cmdutil.py Mon Dec 14 18:54:03 2015 -0500 @@ -183,9 +183,9 @@ # 3a. apply filtered patch to clean repo (clean) if backups: # Equivalent to hg.revert - choices = lambda key: key in backups + m = scmutil.matchfiles(repo, backups.keys()) mergemod.update(repo, repo.dirstate.p1(), - False, True, choices) + False, True, matcher=m) # 3b. (apply) if dopatch: diff -r c59647c6694d -r 43c00ca887d1 mercurial/commands.py --- a/mercurial/commands.py Sat Dec 12 09:57:05 2015 -0800 +++ b/mercurial/commands.py Mon Dec 14 18:54:03 2015 -0500 @@ -636,8 +636,7 @@ try: ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'backout') - stats = mergemod.update(repo, parent, True, True, False, - node, False) + stats = mergemod.update(repo, parent, True, True, node, False) repo.setparents(op1, op2) dsguard.close() hg._showstats(repo, stats) diff -r c59647c6694d -r 43c00ca887d1 mercurial/hg.py --- a/mercurial/hg.py Sat Dec 12 09:57:05 2015 -0800 +++ b/mercurial/hg.py Mon Dec 14 18:54:03 2015 -0500 @@ -637,7 +637,7 @@ When overwrite is set, changes are clobbered, merged else returns stats (see pydoc mercurial.merge.applyupdates)""" - return mergemod.update(repo, node, False, overwrite, None, + return mergemod.update(repo, node, False, overwrite, labels=['working copy', 'destination']) def update(repo, node): @@ -662,7 +662,7 @@ def merge(repo, node, force=None, remind=True): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" - stats = mergemod.update(repo, node, True, force, False) + stats = mergemod.update(repo, node, True, force) _showstats(repo, stats) if stats[3]: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " diff -r c59647c6694d -r 43c00ca887d1 mercurial/merge.py --- a/mercurial/merge.py Sat Dec 12 09:57:05 2015 -0800 +++ b/mercurial/merge.py Mon Dec 14 18:54:03 2015 -0500 @@ -1266,15 +1266,15 @@ else: repo.dirstate.normal(f) -def update(repo, node, branchmerge, force, partial, ancestor=None, - mergeancestor=False, labels=None): +def update(repo, node, branchmerge, force, ancestor=None, + mergeancestor=False, labels=None, matcher=None): """ Perform a merge between the working directory and the given node node = the node to update to, or None if unspecified branchmerge = whether to merge between branches force = whether to force branch merging or file overwriting - partial = a function to filter file lists (dirstate not updated) + matcher = a matcher to filter file lists (dirstate not updated) mergeancestor = whether it is merging with an ancestor. If true, we should accept the incoming changes for any prompts that occur. If false, merging with an ancestor (fast-forward) is only allowed @@ -1313,6 +1313,13 @@ onode = node wlock = repo.wlock() + # If we're doing a partial update, we need to skip updating + # the dirstate, so make a note of any partial-ness to the + # update here. + if matcher is None or matcher.always(): + partial = False + else: + partial = True try: wc = repo[None] pl = wc.parents() @@ -1407,6 +1414,10 @@ followcopies = True ### calculate phase + if matcher is None or matcher.always(): + partial = False + else: + partial = matcher.matchfn actionbyfile, diverge, renamedelete = calculateupdates( repo, wc, p2, pas, branchmerge, force, partial, mergeancestor, followcopies) @@ -1516,7 +1527,7 @@ # which local deleted". mergeancestor = repo.changelog.isancestor(repo['.'].node(), ctx.node()) - stats = update(repo, ctx.node(), True, True, False, pctx.node(), + stats = update(repo, ctx.node(), True, True, pctx.node(), mergeancestor=mergeancestor, labels=labels) pother = nullid diff -r c59647c6694d -r 43c00ca887d1 tests/test-revlog-ancestry.py --- a/tests/test-revlog-ancestry.py Sat Dec 12 09:57:05 2015 -0800 +++ b/tests/test-revlog-ancestry.py Mon Dec 14 18:54:03 2015 -0500 @@ -17,10 +17,10 @@ commit(name, time) def update(rev): - merge.update(repo, rev, False, True, False) + merge.update(repo, rev, False, True) def merge_(rev): - merge.update(repo, rev, True, False, False) + merge.update(repo, rev, True, False) if __name__ == '__main__': addcommit("A", 0) @@ -82,4 +82,3 @@ print '\nDescendants of 5 and 4' for r in repo.changelog.descendants([5, 4]): print r, -