From patchwork Thu Aug 7 02:19:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,3] pull: pre-filter remote phases before moving local ones From: Pierre-Yves David X-Patchwork-Id: 5308 Message-Id: <868752444f3b8a350bd7.1407377941@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Wed, 06 Aug 2014 19:19:01 -0700 # HG changeset patch # User Pierre-Yves David # Date 1407311677 25200 # Wed Aug 06 00:54:37 2014 -0700 # Node ID 868752444f3b8a350bd7a64ecd55d239335578c2 # Parent 793f9276aeb9c78366c205ac0351867c72b27595 pull: pre-filter remote phases before moving local ones We were relying on the phase internal to filter out redundant phase information from remove. However as we plan to integrate phases movement inside the transaction, we want to avoid useless transaction creation on no-op pull. Therefor we filter out all the information that already match the current repository state. This will let us create a transaction only when there is actual phase movement needed. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -825,18 +825,31 @@ def _pullapplyphases(pullop, remotephase if remotephases and not publishing: # remote is new and unpublishing pheads, _dr = phases.analyzeremotephases(pullop.repo, pullop.pulledsubset, remotephases) - phases.advanceboundary(pullop.repo, phases.public, pheads) - phases.advanceboundary(pullop.repo, phases.draft, - pullop.pulledsubset) + dheads = pullop.pulledsubset else: # Remote is old or publishing all common changesets # should be seen as public - phases.advanceboundary(pullop.repo, phases.public, - pullop.pulledsubset) + pheads = pullop.pulledsubset + dheads = [] + unfi = pullop.repo.unfiltered() + phase = unfi._phasecache.phase + rev = unfi.changelog.nodemap.get + public = phases.public + draft = phases.draft + + # exclude changesets already public locally and update the others + pheads = [pn for pn in pheads if phase(unfi, rev(pn)) > public] + if pheads: + phases.advanceboundary(pullop.repo, public, pheads) + + # exclude changesets already draft locally and update the others + dheads = [pn for pn in dheads if phase(unfi, rev(pn)) > draft] + if dheads: + phases.advanceboundary(pullop.repo, draft, dheads) def _pullobsolete(pullop): """utility function to pull obsolete markers from a remote The `gettransaction` is function that return the pull transaction, creating