diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1597,10 +1597,12 @@ def show_changeset(ui, repo, opts, buffe raise error.Abort(inst.args[0]) return t -def showmarker(ui, marker): +def showmarker(ui, marker, index=None): """utility function to display obsolescence marker in a readable way To be used by debug function.""" + if index is not None: + ui.write("%i " % index) ui.write(hex(marker.precnode())) for repl in marker.succnodes(): ui.write(' ') diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3029,6 +3029,7 @@ def debuglocks(ui, repo, **opts): ('', 'record-parents', False, _('record parent information for the precursor')), ('r', 'rev', [], _('display markers relevant to REV')), + ('', 'index', False, _('display index of the marker')), ] + commitopts2, _('[OBSOLETED [REPLACEMENT ...]]')) def debugobsolete(ui, repo, precursor=None, *successors, **opts): @@ -3091,8 +3092,9 @@ def debugobsolete(ui, repo, precursor=No else: markers = obsolete.getmarkers(repo) - for m in markers: - cmdutil.showmarker(ui, m) + for i, m in enumerate(markers): + ind = i if opts.get('index') else None + cmdutil.showmarker(ui, m, index=ind) @command('debugpathcomplete', [('f', 'full', None, _('complete an entire path')), diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -261,7 +261,7 @@ Show all commands + options debuglocks: force-lock, force-wlock debugmergestate: debugnamecomplete: - debugobsolete: flags, record-parents, rev, date, user + debugobsolete: flags, record-parents, rev, index, date, user debugpathcomplete: full, normal, added, removed debugpushkey: debugpvec: diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -129,6 +129,13 @@ Register two markers with a missing node 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'} +Test the --index option of debugobsolete command + $ hg debugobsolete --index + 0 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'} + 1 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'} + 2 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'} + 3 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'} + Refuse pathological nullid successors $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000 transaction abort!