hgext3rd/evolve/stablesort.py
changeset 3255 bb3f8c8c1232
parent 3254 00e20077bccf
child 3256 c82a2632327e
equal deleted inserted replaced
3254:00e20077bccf 3255:bb3f8c8c1232
    42 
    42 
    43 @eh.command(
    43 @eh.command(
    44     'debugstablesort',
    44     'debugstablesort',
    45     [
    45     [
    46         ('r', 'rev', [], 'heads to start from'),
    46         ('r', 'rev', [], 'heads to start from'),
    47         ('', 'method', 'branchpoint', "method used for sorting, one of: 'branchpoint'"),
    47         ('', 'method', 'branchpoint', "method used for sorting, one of: "
       
    48          "branchpoint, basic-mergepoint and basic-headstart"),
    48     ] + commands.formatteropts,
    49     ] + commands.formatteropts,
    49     _(''))
    50     _(''))
    50 def debugstablesort(ui, repo, **opts):
    51 def debugstablesort(ui, repo, **opts):
    51     """display the ::REVS set topologically sorted in a stable way
    52     """display the ::REVS set topologically sorted in a stable way
    52     """
    53     """
   225 
   226 
   226     result.reverse()
   227     result.reverse()
   227     assert len(result) == len(resultset)
   228     assert len(result) == len(resultset)
   228     return result
   229     return result
   229 
   230 
       
   231 def stablesort_mergepoint_head_basic(repo, revs):
       
   232     heads = repo.revs('heads(%ld)', revs)
       
   233     if not heads:
       
   234         return []
       
   235     elif 2 < len(heads):
       
   236         raise error.Abort('cannot use head based merging, %d heads found'
       
   237                           % len(heads))
       
   238     head = heads.first()
       
   239     return stablesort_mergepoint_bounded(repo, head, repo.revs('::%d', head))
       
   240 
   230 _methodmap = {
   241 _methodmap = {
   231     'branchpoint': stablesort_branchpoint,
   242     'branchpoint': stablesort_branchpoint,
   232     'basic-mergepoint': stablesort_mergepoint_multirevs,
   243     'basic-mergepoint': stablesort_mergepoint_multirevs,
       
   244     'basic-headstart': stablesort_mergepoint_head_basic,
   233 }
   245 }