mercurial/setdiscovery.py
changeset 39202 140992750187
parent 39201 2d218db7389b
child 39203 754f389b87f2
equal deleted inserted replaced
39201:2d218db7389b 39202:140992750187
    94         for p in dag.parents(curr):
    94         for p in dag.parents(curr):
    95             if not revs or p in revs:
    95             if not revs or p in revs:
    96                 dist.setdefault(p, d + 1)
    96                 dist.setdefault(p, d + 1)
    97                 visit.append(p)
    97                 visit.append(p)
    98 
    98 
    99 def _takequicksample(dag, revs, size):
    99 def _takequicksample(repo, dag, revs, size):
   100     """takes a quick sample of size <size>
   100     """takes a quick sample of size <size>
   101 
   101 
   102     It is meant for initial sampling and focuses on querying heads and close
   102     It is meant for initial sampling and focuses on querying heads and close
   103     ancestors of heads.
   103     ancestors of heads.
   104 
   104 
   105     :dag: a dag object
   105     :dag: a dag object
   106     :revs: set of revs to discover
   106     :revs: set of revs to discover
   107     :size: the maximum size of the sample"""
   107     :size: the maximum size of the sample"""
   108     sample = dag.headsetofconnecteds(revs)
   108     sample = set(repo.revs('heads(%ld)', revs))
       
   109 
   109     if len(sample) >= size:
   110     if len(sample) >= size:
   110         return _limitsample(sample, size)
   111         return _limitsample(sample, size)
   111     _updatesample(dag, None, sample, quicksamplesize=size)
   112     _updatesample(dag, None, sample, quicksamplesize=size)
   112     return sample
   113     return sample
   113 
   114 
   114 def _takefullsample(dag, revs, size):
   115 def _takefullsample(repo, dag, revs, size):
   115     sample = dag.headsetofconnecteds(revs)
   116     sample = set(repo.revs('heads(%ld)', revs))
       
   117 
   116     # update from heads
   118     # update from heads
   117     _updatesample(dag, revs, sample)
   119     _updatesample(dag, revs, sample)
   118     # update from roots
   120     # update from roots
   119     _updatesample(dag.inverse(), revs, sample)
   121     _updatesample(dag.inverse(), revs, sample)
   120     assert sample
   122     assert sample
   240             samplefunc = _takequicksample
   242             samplefunc = _takequicksample
   241             targetsize = initialsamplesize
   243             targetsize = initialsamplesize
   242         if len(undecided) < targetsize:
   244         if len(undecided) < targetsize:
   243             sample = list(undecided)
   245             sample = list(undecided)
   244         else:
   246         else:
   245             sample = samplefunc(dag, undecided, targetsize)
   247             sample = samplefunc(local, dag, undecided, targetsize)
   246 
   248 
   247         roundtrips += 1
   249         roundtrips += 1
   248         progress.update(roundtrips)
   250         progress.update(roundtrips)
   249         ui.debug("query %i; still undecided: %i, sample size is: %i\n"
   251         ui.debug("query %i; still undecided: %i, sample size is: %i\n"
   250                  % (roundtrips, len(undecided), len(sample)))
   252                  % (roundtrips, len(undecided), len(sample)))