# HG changeset patch # User Pierre-Yves David # Date 1511451444 -3600 # Node ID 543708c3f754ff1968b1372be23d0e1f41845360 # Parent 63d58f7db1204d6b978219c8b1d81149719352bb stablesort: add a 'method' argument to the debugstablesort command Let start experimenting with other way to do stable sorting. diff -r 63d58f7db120 -r 543708c3f754 hgext3rd/evolve/stablesort.py --- a/hgext3rd/evolve/stablesort.py Sat Nov 25 02:58:47 2017 -0500 +++ b/hgext3rd/evolve/stablesort.py Thu Nov 23 16:37:24 2017 +0100 @@ -12,6 +12,7 @@ from mercurial import ( commands, cmdutil, + error, node as nodemod, scmutil, ) @@ -29,15 +30,24 @@ @eh.command( 'debugstablesort', [ - ('', 'rev', [], 'heads to start from'), + ('r', 'rev', [], 'heads to start from'), + ('', 'method', 'branchpoint', "method used for sorting, one of: 'branchpoint'"), ] + commands.formatteropts, _('')) def debugstablesort(ui, repo, **opts): """display the ::REVS set topologically sorted in a stable way """ revs = scmutil.revrange(repo, opts['rev']) + + method = opts['method'] + sorting = _methodmap.get(method) + if sorting is None: + valid_method = ', '.join(sorted(_methodmap)) + raise error.Abort('unknown sorting method: "%s"' % method, + hint='pick one of: %s' % valid_method) + displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) - for r in stablesort_branchpoint(repo, revs): + for r in sorting(repo, revs): ctx = repo[r] displayer.show(ctx) displayer.flush(ctx) @@ -123,3 +133,7 @@ stack.extend(cs) # stack the rest for later assert len(result) == len(set(result)) return result + +_methodmap = { + 'branchpoint': stablesort_branchpoint, +} diff -r 63d58f7db120 -r 543708c3f754 tests/test-stablesort-criss-cross.t --- a/tests/test-stablesort-criss-cross.t Sat Nov 25 02:58:47 2017 -0500 +++ b/tests/test-stablesort-criss-cross.t Thu Nov 23 16:37:24 2017 +0100 @@ -9,7 +9,7 @@ > [ui] > logtemplate = "{rev} {node|short} {desc} {tags}\n" > [alias] - > showsort = debugstablesort --template="{node|short}\n" + > showsort = debugstablesort --template="{node|short}\n" --method branchpoint > EOF $ checktopo () { diff -r 63d58f7db120 -r 543708c3f754 tests/test-stablesort.t --- a/tests/test-stablesort.t Sat Nov 25 02:58:47 2017 -0500 +++ b/tests/test-stablesort.t Thu Nov 23 16:37:24 2017 +0100 @@ -9,7 +9,7 @@ > [ui] > logtemplate = "{rev} {node|short} {desc} {tags}\n" > [alias] - > showsort = debugstablesort --template="{node|short}\n" + > showsort = debugstablesort --template="{node|short}\n" --method branchpoint > EOF