[PATCH] debugobsolete: add an option to show marker index

Kostia Balytskyi ikostia at fb.com
Wed Mar 23 02:49:14 EDT 2016


This should be v2, I forgot to include a flag.




On 3/22/16, 11:44 PM, "Mercurial-devel on behalf of Kostia Balytskyi" <mercurial-devel-bounces at mercurial-scm.org on behalf of ikostia at fb.com> wrote:

># HG changeset patch
># User Kostia Balytskyi <ikostia at fb.com>
># Date 1458715471 25200
>#      Tue Mar 22 23:44:31 2016 -0700
># Node ID d15ea5b6dec8d82ae8e1d48d640b3be39c1ca81b
># 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.
>
>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-debugcommands.t b/tests/test-debugcommands.t
>--- a/tests/test-debugcommands.t
>+++ b/tests/test-debugcommands.t
>@@ -126,3 +126,18 @@ Test internal debugstacktrace command
>    debugstacktrace.py:7 *in * (glob)
>    debugstacktrace.py:6 *in g (glob)
>    */util.py:* in debugstacktrace (glob)
>+
>+Test that debugobsolete command supports --intex option
>+  $ cd ..
>+  $ echo "[experimental]" >> $HGRCPATH
>+  $ echo "evolution=createmarkers" >> $HGRCPATH
>+  $ hg init obsrepo
>+  $ cd obsrepo
>+  $ echo a > a && hg ci -Am a
>+  adding a
>+  $ hg ci --amend -m b
>+  $ hg debugobsolete
>+  cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 0e141029c361d35262b35cc605f6f1e5e999c7f8 0 (Wed Mar 23 06:44:19 2016 +0000) {'user': 'test'}
>+  $ hg debugobsolete --index
>+  0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 0e141029c361d35262b35cc605f6f1e5e999c7f8 0 (Wed Mar 23 06:44:19 2016 +0000) {'user': 'test'}
>+
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel at mercurial-scm.org
>https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=UGgFWrZ67crG4M-BdeqmuGMFI2VPsBAbkLlcSsfPIME&s=zNF0K9RwH15e0On-x8MId5ghOEc2-rOzm1oUCQ9NR5w&e= 


More information about the Mercurial-devel mailing list