mercurial/setdiscovery.py
changeset 39159 5b32b3c618b2
parent 38373 ef692614e601
child 39161 858a12846f4f
equal deleted inserted replaced
39158:b0c73866c9fb 39159:5b32b3c618b2
   140     '''
   140     '''
   141     start = util.timer()
   141     start = util.timer()
   142 
   142 
   143     roundtrips = 0
   143     roundtrips = 0
   144     cl = local.changelog
   144     cl = local.changelog
       
   145     clnode = cl.node
   145     localsubset = None
   146     localsubset = None
       
   147 
   146     if ancestorsof is not None:
   148     if ancestorsof is not None:
   147         rev = local.changelog.rev
   149         rev = local.changelog.rev
   148         localsubset = [rev(n) for n in ancestorsof]
   150         localsubset = [rev(n) for n in ancestorsof]
   149     dag = dagutil.revlogdag(cl, localsubset=localsubset)
   151     dag = dagutil.revlogdag(cl, localsubset=localsubset)
   150 
   152 
   157     sample = list(sample)
   159     sample = list(sample)
   158 
   160 
   159     with remote.commandexecutor() as e:
   161     with remote.commandexecutor() as e:
   160         fheads = e.callcommand('heads', {})
   162         fheads = e.callcommand('heads', {})
   161         fknown = e.callcommand('known', {
   163         fknown = e.callcommand('known', {
   162             'nodes': dag.externalizeall(sample),
   164             'nodes': [clnode(r) for r in sample],
   163         })
   165         })
   164 
   166 
   165     srvheadhashes, yesno = fheads.result(), fknown.result()
   167     srvheadhashes, yesno = fheads.result(), fknown.result()
   166 
   168 
   167     if cl.tip() == nullid:
   169     if cl.tip() == nullid:
   174     ui.status(_("searching for changes\n"))
   176     ui.status(_("searching for changes\n"))
   175 
   177 
   176     srvheads = dag.internalizeall(srvheadhashes, filterunknown=True)
   178     srvheads = dag.internalizeall(srvheadhashes, filterunknown=True)
   177     if len(srvheads) == len(srvheadhashes):
   179     if len(srvheads) == len(srvheadhashes):
   178         ui.debug("all remote heads known locally\n")
   180         ui.debug("all remote heads known locally\n")
   179         return (srvheadhashes, False, srvheadhashes,)
   181         return srvheadhashes, False, srvheadhashes
   180 
   182 
   181     if len(sample) == len(ownheads) and all(yesno):
   183     if len(sample) == len(ownheads) and all(yesno):
   182         ui.note(_("all local heads known remotely\n"))
   184         ui.note(_("all local heads known remotely\n"))
   183         ownheadhashes = dag.externalizeall(ownheads)
   185         ownheadhashes = [clnode(r) for r in ownheads]
   184         return (ownheadhashes, True, srvheadhashes,)
   186         return ownheadhashes, True, srvheadhashes
   185 
   187 
   186     # full blown discovery
   188     # full blown discovery
   187 
   189 
   188     # own nodes I know we both know
   190     # own nodes I know we both know
   189     # treat remote heads (and maybe own heads) as a first implicit sample
   191     # treat remote heads (and maybe own heads) as a first implicit sample
   233         # indices between sample and externalized version must match
   235         # indices between sample and externalized version must match
   234         sample = list(sample)
   236         sample = list(sample)
   235 
   237 
   236         with remote.commandexecutor() as e:
   238         with remote.commandexecutor() as e:
   237             yesno = e.callcommand('known', {
   239             yesno = e.callcommand('known', {
   238                 'nodes': dag.externalizeall(sample),
   240                 'nodes': [clnode(r) for r in sample],
   239             }).result()
   241             }).result()
   240 
   242 
   241         full = True
   243         full = True
   242 
   244 
   243         if sample:
   245         if sample:
   266         else:
   268         else:
   267             ui.warn(_("warning: repository is unrelated\n"))
   269             ui.warn(_("warning: repository is unrelated\n"))
   268         return ({nullid}, True, srvheadhashes,)
   270         return ({nullid}, True, srvheadhashes,)
   269 
   271 
   270     anyincoming = (srvheadhashes != [nullid])
   272     anyincoming = (srvheadhashes != [nullid])
   271     return dag.externalizeall(result), anyincoming, srvheadhashes
   273     result = {clnode(r) for r in result}
       
   274     return result, anyincoming, srvheadhashes