Submitter | Kostia Balytskyi |
---|---|
Date | March 23, 2016, 5:52 p.m. |
Message ID | <8a3ea065ab2ef2dca6cc.1458755552@dev1902.lla1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/14048/ |
State | Accepted |
Headers | show |
Comments
On 03/23/2016 10:52 AM, Kostia Balytskyi wrote: > # HG changeset patch > # User Kostia Balytskyi <ikostia@fb.com> > # Date 1458755424 25200 > # Wed Mar 23 10:50:24 2016 -0700 > # Node ID 8a3ea065ab2ef2dca6cca0f5f658ae8b2d051bcb > # Parent c11f0992d1246286a6a0b2531ff5f31948abcf58 > debugobsolete: add an option to show marker index > > A bigger picture is the ability to be delete an arbitrary marker form the > repo's obsstore. This is a useful debug ability and it needs a way to indentify > the marker one wants to delete. Having a marker's index provides such an > ability. Pushed, thanks. tests/test-completion.t sent his regard. > 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-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! > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@mercurial-scm.org > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel >
Patch
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-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!