Patchwork [4,of,8,V2] phase: gather remote phase information in a summary object

login
register
mail settings
Submitter Boris Feld
Date Oct. 16, 2017, 6:23 p.m.
Message ID <c581583a2c085662c9a5.1508178225@FB>
Download mbox | patch
Permalink /patch/25019/
State Accepted
Headers show

Comments

Boris Feld - Oct. 16, 2017, 6:23 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1507739944 -7200
#      Wed Oct 11 18:39:04 2017 +0200
# Node ID c581583a2c085662c9a59f55f2483a2c748eb573
# Parent  9fb76d6c80d20b5af8ee1d0e7d6c221924b1d7bb
# EXP-Topic b2.phases.push
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c581583a2c08
phase: gather remote phase information in a summary object

We keep useful phase information around. The data will be reused with detecting
push-race in later changesets.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -340,6 +340,8 @@ 
         self.pushbranchmap = None
         # testable as a boolean indicating if any nodes are missing locally.
         self.incoming = None
+        # summary of the remote phase situation
+        self.remotephases = None
         # phases changes that must be pushed along side the changesets
         self.outdatedphases = None
         # phases changes that must be pushed if changeset push fails
@@ -527,7 +529,6 @@ 
     outgoing = pushop.outgoing
     unfi = pushop.repo.unfiltered()
     remotephases = pushop.remote.listkeys('phases')
-    publishing = remotephases.get('publishing', False)
     if (pushop.ui.configbool('ui', '_usedassubrepo')
         and remotephases    # server supports phases
         and not pushop.outgoing.missing # no changesets to be pushed
@@ -544,12 +545,14 @@ 
         pushop.outdatedphases = []
         pushop.fallbackoutdatedphases = []
         return
-    ana = phases.analyzeremotephases(pushop.repo,
-                                     pushop.fallbackheads,
-                                     remotephases)
-    pheads, droots = ana
+
+    pushop.remotephases = phases.remotephasessummary(pushop.repo,
+                                                     pushop.fallbackheads,
+                                                     remotephases)
+    droots = pushop.remotephases.draftroots
+
     extracond = ''
-    if not publishing:
+    if not pushop.remotephases.publishing:
         extracond = ' and public()'
     revset = 'heads((%%ln::%%ln) %s)' % extracond
     # Get the list of all revs draft on remote by public here.
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -604,6 +604,27 @@ 
     publicheads = newheads(repo, subset, draftroots)
     return publicheads, draftroots
 
+class remotephasessummary(object):
+    """summarize phase information on the remote side
+
+    :publishing: True is the remote is publishing
+    :publicheads: list of remote public phase heads (nodes)
+    :draftheads: list of remote draft phase heads (nodes)
+    :draftroots: list of remote draft phase root (nodes)
+    """
+
+    def __init__(self, repo, remotesubset, remoteroots):
+        unfi = repo.unfiltered()
+        self._allremoteroots = remoteroots
+
+        self.publishing = remoteroots.get('publishing', False)
+
+        ana = analyzeremotephases(repo, remotesubset, remoteroots)
+        self.publicheads, self.draftroots = ana
+        # Get the list of all "heads" revs draft on remote
+        dheads = unfi.set('heads(%ln::%ln)', self.draftroots, remotesubset)
+        self.draftheads = [c.node() for c in dheads]
+
 def newheads(repo, heads, roots):
     """compute new head of a subset minus another