pull: pre-filter remote phases before moving local ones
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 06 Aug 2014 00:54:37 -0700
changeset 22068 d34058dd3246
parent 22067 14306a686e71
child 22069 616a455b02ca
pull: pre-filter remote phases before moving local ones We were relying on the phase internals to filter out redundant phase information from remove. However as we plan to integrate phase movement inside the transaction, we want to avoid useless transaction creation on no-op pulls. Therefore we filter out all the information that already matches the current repository state. This will let us create a transaction only when there is actual phase movement needed.
mercurial/exchange.py
--- a/mercurial/exchange.py	Wed Aug 06 01:40:51 2014 -0700
+++ b/mercurial/exchange.py	Wed Aug 06 00:54:37 2014 -0700
@@ -825,14 +825,27 @@
         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