# HG changeset patch # User Pierre-Yves David # Date 1408515764 25200 # Node ID 10e87c67f1c746ef4faf1962cf5bdb3dcda1d874 # Parent e6d01239f77969a8452bbaefc8093be7315352e9 debugobsolete: add a --rev argument This argument can be used to list markers relevant to a set of revisions. We add a test for this option and the relevant computation in the same move. diff -r e6d01239f779 -r 10e87c67f1c7 mercurial/commands.py --- a/mercurial/commands.py Wed Aug 20 18:11:23 2014 -0700 +++ b/mercurial/commands.py Tue Aug 19 23:22:44 2014 -0700 @@ -2310,6 +2310,7 @@ [('', 'flags', 0, _('markers flag')), ('', 'record-parents', False, _('record parent information for the precursor')), + ('r', 'rev', [], _('display markers relevant to REV')), ] + commitopts2, _('[OBSOLETED [REPLACEMENT] [REPL... ]')) def debugobsolete(ui, repo, precursor=None, *successors, **opts): @@ -2331,6 +2332,8 @@ 'node identifiers') if precursor is not None: + if opts['rev']: + raise util.Abort('cannot select revision when creating marker') metadata = {} metadata['user'] = opts['user'] or ui.username() succs = tuple(parsenodeid(succ) for succ in successors) @@ -2363,7 +2366,15 @@ finally: l.release() else: - for m in obsolete.getmarkers(repo): + if opts['rev']: + revs = scmutil.revrange(repo, opts['rev']) + nodes = [repo[r].node() for r in revs] + markers = list(obsolete.getmarkers(repo, nodes=nodes)) + markers.sort(key=lambda x: x._data) + else: + markers = obsolete.getmarkers(repo) + + for m in markers: cmdutil.showmarker(ui, m) @command('debugpathcomplete', diff -r e6d01239f779 -r 10e87c67f1c7 mercurial/obsolete.py --- a/mercurial/obsolete.py Wed Aug 20 18:11:23 2014 -0700 +++ b/mercurial/obsolete.py Tue Aug 19 23:22:44 2014 -0700 @@ -494,11 +494,25 @@ finally: lock.release() -def getmarkers(repo): - """returns markers known in a repository""" - for markerdata in repo.obsstore: +def getmarkers(repo, nodes=None): + """returns markers known in a repository + + If is specified, only markers "relevant" to those nodes are are + returned""" + if nodes is None: + rawmarkers = repo.obsstore + else: + rawmarkers = repo.obsstore.relevantmarkers(nodes) + + for markerdata in rawmarkers: yield marker(repo, markerdata) +def relevantmarkers(repo, node): + """all obsolete markers relevant to some revision""" + for markerdata in repo.obsstore.relevantmarkers(node): + yield marker(repo, markerdata) + + def precursormarkers(ctx): """obsolete marker marking this changeset as a successors""" for data in ctx._repo.obsstore.precursors.get(ctx.node(), ()): diff -r e6d01239f779 -r 10e87c67f1c7 tests/test-completion.t --- a/tests/test-completion.t Wed Aug 20 18:11:23 2014 -0700 +++ b/tests/test-completion.t Tue Aug 19 23:22:44 2014 -0700 @@ -244,7 +244,7 @@ debuginstall: debugknown: debuglabelcomplete: - debugobsolete: flags, record-parents, date, user + debugobsolete: flags, record-parents, rev, date, user debugpathcomplete: full, normal, added, removed debugpushkey: debugpvec: diff -r e6d01239f779 -r 10e87c67f1c7 tests/test-obsolete.t --- a/tests/test-obsolete.t Wed Aug 20 18:11:23 2014 -0700 +++ b/tests/test-obsolete.t Tue Aug 19 23:22:44 2014 -0700 @@ -513,6 +513,72 @@ adding file changes added 1 changesets with 1 changes to 1 files (+1 heads) +test relevance computation +--------------------------------------- + +Checking simple case of "marker relevance". + + +Reminder of the repo situation + + $ hg log --hidden --graph + @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e + | + | x 5:cda648ca50f5 (draft) [ ] add original_e + | | + | x 4:94b33453f93b (draft) [ ] add original_d + |/ + o 3:6f9641995072 (draft) [ ] add n3w_3_c + | + | o 2:245bde4270cd (public) [ ] add original_c + |/ + o 1:7c3bad9141dc (public) [ ] add b + | + o 0:1f0dee641bb7 (public) [ ] add a + + +List of all markers + + $ hg debugobsolete + 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} + 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:44 1970 -0000) {'user': 'test'} + cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} + ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} + cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) + +List of changesets with no chain + + $ hg debugobsolete --hidden --rev ::2 + +List of changesets that are included on marker chain + + $ hg debugobsolete --hidden --rev 6 + cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) + +List of changesets with a longer chain, (including a pruned children) + + $ hg debugobsolete --hidden --rev 3 + 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} + 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:44 1970 -0000) {'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} + ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} + +List of both + + $ hg debugobsolete --hidden --rev 3::6 + 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} + 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:44 1970 -0000) {'user': 'test'} + 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} + ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test'} (glob) + cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} + #if serve check hgweb does not explode