Patchwork [2,of,3] debugdiscovery: add support for local_head and remote_head

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 31, 2015, 6:37 a.m.
Message ID <d97550408d1c5d6afa71.1451543824@waste.org>
Download mbox | patch
Permalink /patch/12438/
State Superseded
Headers show

Comments

timeless@mozdev.org - Dec. 31, 2015, 6:37 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451543473 0
#      Thu Dec 31 06:31:13 2015 +0000
# Node ID d97550408d1c5d6afa71b7d24448221d1dce7601
# Parent  1c05a339cbaff1bd145ac3b909d447dbd275d290
debugdiscovery: add support for local_head and remote_head

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -24,6 +24,7 @@ 
 import ui as uimod
 import streamclone
 import commandserver
+import repoview
 
 table = {}
 
@@ -2267,6 +2268,8 @@ 
 
 @command('debugdiscovery',
     [('', 'old', None, _('use old-style discovery')),
+    ('l', 'local_head', [], _('local head changeset'), _('REV')),
+    ('r', 'remote_head', [], _('remote head changeset'), _('REV')),
     ('', 'nonheads', None,
      _('use old-style discovery with non-heads included')),
     ] + remoteopts,
@@ -2278,13 +2281,35 @@ 
                               remoteurl or 'default')
     remoteurl, branches = hg.parseurl(remoteurl,
                                       opts.get('branch'))
-    remote = hg.peer(repo, opts, remoteurl)
-    ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
+    remote = None
+
+    def hide(headlist):
+        def computehidden(repo):
+            cl = repo.changelog
+            assert not cl.filteredrevs
+            frozen = frozenset(repo.unfiltered())
+
+            blocked = cl.ancestors([int(r) for r in headlist], inclusive=True)
+            hidden = frozenset(r for r in frozen if r not in blocked)
+            return hidden
+        return computehidden
 
     # make sure tests are repeatable
     random.seed(12323)
 
     def doit(localheads, remoteheads, remote=remote):
+        if localheads:
+           repoview.filtertable['discoverylocal'] = hide(localheads)
+
+        if remoteheads:
+            remoteheadfilter = hide(remoteheads)
+            repoview.filtertable['served'] = remoteheadfilter
+            repoview.filtertable['visible'] = remoteheadfilter
+            remote = repoview.repoview(repo, 'served')
+            remote = localrepo.localpeer(remote)
+        else:
+            remote = hg.peer(repo, opts, remoteurl)
+
         if opts.get('old'):
             if localheads:
                 raise error.Abort('cannot use localheads with old style '
@@ -2302,7 +2327,10 @@ 
                 all = dag.ancestorset(dag.internalizeall(common))
                 common = dag.externalizeall(dag.headsetofconnecteds(all))
         else:
-            common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
+            local = repo
+            if localheads:
+                local = repoview.repoview(repo, 'discoverylocal')
+            common, any, hds = setdiscovery.findcommonheads(ui, local, remote)
         common = set(common)
         rheads = set(hds)
         lheads = set(repo.heads())
@@ -2313,6 +2341,12 @@ 
         elif rheads <= common:
             ui.write(("remote is subset\n"))
 
+    remote_heads = opts.get('remote_head')
+    if remote_heads:
+        ui.status(_('comparing with local\n'))
+    else:
+        ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
+
     serverlogs = opts.get('serverlog')
     if serverlogs:
         for filename in serverlogs:
@@ -2333,8 +2367,9 @@ 
                 logfile.close()
 
     else:
-        remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
-                                                 opts.get('remote_head'))
+        remoterevs = opts.get('remote_head')
+        #remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
+        #                                         remoterevs)
         localrevs = opts.get('local_head')
         doit(localrevs, remoterevs)