mercurial/treediscovery.py
changeset 37634 0ed11f9368fd
parent 26587 56b2bcea2529
child 38400 2f5c622fcb73
equal deleted inserted replaced
37633:33a6eee08db2 37634:0ed11f9368fd
    34     seen = set()
    34     seen = set()
    35     seenbranch = set()
    35     seenbranch = set()
    36     base = set()
    36     base = set()
    37 
    37 
    38     if not heads:
    38     if not heads:
    39         heads = remote.heads()
    39         with remote.commandexecutor() as e:
       
    40             heads = e.callcommand('heads', {}).result()
    40 
    41 
    41     if repo.changelog.tip() == nullid:
    42     if repo.changelog.tip() == nullid:
    42         base.add(nullid)
    43         base.add(nullid)
    43         if heads != [nullid]:
    44         if heads != [nullid]:
    44             return [nullid], [nullid], list(heads)
    45             return [nullid], [nullid], list(heads)
    63 
    64 
    64     # search through remote branches
    65     # search through remote branches
    65     # a 'branch' here is a linear segment of history, with four parts:
    66     # a 'branch' here is a linear segment of history, with four parts:
    66     # head, root, first parent, second parent
    67     # head, root, first parent, second parent
    67     # (a branch always has two parents (or none) by definition)
    68     # (a branch always has two parents (or none) by definition)
    68     unknown = collections.deque(remote.branches(unknown))
    69     with remote.commandexecutor() as e:
       
    70         branches = e.callcommand('branches', {'nodes': unknown}).result()
       
    71 
       
    72     unknown = collections.deque(branches)
    69     while unknown:
    73     while unknown:
    70         r = []
    74         r = []
    71         while unknown:
    75         while unknown:
    72             n = unknown.popleft()
    76             n = unknown.popleft()
    73             if n[0] in seen:
    77             if n[0] in seen:
   105             reqcnt += 1
   109             reqcnt += 1
   106             repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
   110             repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
   107             repo.ui.debug("request %d: %s\n" %
   111             repo.ui.debug("request %d: %s\n" %
   108                         (reqcnt, " ".join(map(short, r))))
   112                         (reqcnt, " ".join(map(short, r))))
   109             for p in xrange(0, len(r), 10):
   113             for p in xrange(0, len(r), 10):
   110                 for b in remote.branches(r[p:p + 10]):
   114                 with remote.commandexecutor() as e:
       
   115                     branches = e.callcommand('branches', {
       
   116                         'nodes': r[p:p + 10],
       
   117                     }).result()
       
   118 
       
   119                 for b in branches:
   111                     repo.ui.debug("received %s:%s\n" %
   120                     repo.ui.debug("received %s:%s\n" %
   112                                   (short(b[0]), short(b[1])))
   121                                   (short(b[0]), short(b[1])))
   113                     unknown.append(b)
   122                     unknown.append(b)
   114 
   123 
   115     # do binary search on the branches we found
   124     # do binary search on the branches we found
   116     while search:
   125     while search:
   117         newsearch = []
   126         newsearch = []
   118         reqcnt += 1
   127         reqcnt += 1
   119         repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
   128         repo.ui.progress(_('searching'), reqcnt, unit=_('queries'))
   120         for n, l in zip(search, remote.between(search)):
   129 
       
   130         with remote.commandexecutor() as e:
       
   131             between = e.callcommand('between', {'pairs': search}).result()
       
   132 
       
   133         for n, l in zip(search, between):
   121             l.append(n[1])
   134             l.append(n[1])
   122             p = n[0]
   135             p = n[0]
   123             f = 1
   136             f = 1
   124             for i in l:
   137             for i in l:
   125                 repo.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i)))
   138                 repo.ui.debug("narrowing %d:%d %s\n" % (f, len(l), short(i)))