hgfastobs.py
changeset 795 c6888ec28e9e
parent 794 089755743050
child 796 443e563f0943
equal deleted inserted replaced
794:089755743050 795:c6888ec28e9e
    22 import sys
    22 import sys
    23 
    23 
    24 from mercurial import base85
    24 from mercurial import base85
    25 from mercurial import commands
    25 from mercurial import commands
    26 from mercurial import extensions
    26 from mercurial import extensions
       
    27 from mercurial import node
    27 from mercurial import obsolete
    28 from mercurial import obsolete
    28 from mercurial import node
    29 from mercurial import revset
    29 from mercurial.i18n import _
    30 from mercurial.i18n import _
    30 
    31 
    31 _strategies = {
    32 _strategies = {
    32     'stock': obsolete.syncpush,
    33     'stock': obsolete.syncpush,
    33     }
    34     }
    55 
    56 
    56 def _getoutgoing():
    57 def _getoutgoing():
    57     f = sys._getframe(4)
    58     f = sys._getframe(4)
    58     return f.f_locals['outgoing']
    59     return f.f_locals['outgoing']
    59 
    60 
       
    61 
       
    62 def _precursors(repo, s):
       
    63     """Precursor of a changeset"""
       
    64     cs = set()
       
    65     nm = repo.changelog.nodemap
       
    66     markerbysubj = repo.obsstore.precursors
       
    67     for r in s:
       
    68         for p in markerbysubj.get(repo[r].node(), ()):
       
    69             pr = nm.get(p[0])
       
    70             if pr is not None:
       
    71                 cs.add(pr)
       
    72     return cs
       
    73 
       
    74 def _revsetprecursors(repo, subset, x):
       
    75     s = revset.getset(repo, range(len(repo)), x)
       
    76     cs = _precursors(repo, s)
       
    77     return [r for r in subset if r in cs]
       
    78 
       
    79 revset.symbols['_fastobs_precursors'] = _revsetprecursors
       
    80 
       
    81 
    60 @_strategy('boxfill', default=True)
    82 @_strategy('boxfill', default=True)
    61 def boxfill(repo, remote):
    83 def boxfill(repo, remote):
    62     """The "fill in the box" strategy from the 2.6 sprint.
    84     """The "fill in the box" strategy from the 2.6 sprint.
    63 
    85 
    64     See the notes[0] from the 2.6 sprint for what "fill in the box"
    86     See the notes[0] from the 2.6 sprint for what "fill in the box"
    73     # need to collect obsolete markers which list any of
    95     # need to collect obsolete markers which list any of
    74     # outgoing.missing as a successor (transitively), as well as any
    96     # outgoing.missing as a successor (transitively), as well as any
    75     # kill markers for dead nodes descended from any of the precursors
    97     # kill markers for dead nodes descended from any of the precursors
    76     # of outgoing.missing.
    98     # of outgoing.missing.
    77     boxedges = urepo.revs(
    99     boxedges = urepo.revs(
    78         '(descendants(precursors(%ln)) or descendants(%ln)) and hidden()',
   100         '(descendants(_fastobs_precursors(%ln)) or '
       
   101         ' descendants(%ln)) and hidden()',
    79         outgoing.missing, outgoing.missing)
   102         outgoing.missing, outgoing.missing)
    80     transmit = []
   103     transmit = []
    81     for node in outgoing.missing:
   104     for node in outgoing.missing:
    82         transmit.extend(obsolete.precursormarkers(urepo[node]))
   105         transmit.extend(obsolete.precursormarkers(urepo[node]))
    83     for node in boxedges:
   106     for node in boxedges: