[PATCH 2 of 2 v3] commands make --rev and --index compatible in debugobsolete

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Apr 3 18:14:21 EDT 2016



On 04/03/2016 07:48 AM, Kostia Balytskyi wrote:
> # HG changeset patch
> # User Kostia Balytskyi <ikostia at fb.com>
> # Date 1459694863 25200
> #      Sun Apr 03 07:47:43 2016 -0700
> # Node ID e48365e2b0de1bbec6229a23e28339651454243a
> # Parent  183720bebbe60f248afa277dcfc08468899f5d77
> commands make --rev and --index compatible in debugobsolete

We probably want this patch before adding delete. It would also be 
useful to have a more verbose description for other people following 
this. I've various other comment below.

>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3135,7 +3135,16 @@ def debugobsolete(ui, repo, precursor=No
>           else:
>               markers = obsolete.getmarkers(repo)
>
> -        for i, m in enumerate(markers):
> +        markerstoiter = markers
> +        isrelevant = lambda m: True
> +        if opts.get('rev') and opts.get('index'):
> +            markerstoiter = obsolete.getmarkers(repo)
> +            markerset = set(markers)
> +            isrelevant = lambda m: m in markerset
> +
> +        for i, m in enumerate(markerstoiter):
> +            if not isrelevant(m):
> +                continue
>               ind = i if opts.get('index') else None
>               cmdutil.showmarker(ui, m, index=ind)
>

Let's also add a small inline comment that explain why we are jumping 
through this hoops.

> diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
> --- a/tests/test-obsolete.t
> +++ b/tests/test-obsolete.t
> @@ -136,6 +136,10 @@ Test the --index option of debugobsolete
>     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'}
>
> +Test the cooperation of --index and --rev option of debugobsolete command
> +  $ hg debugobsolete --index --rev cdbce2 --hidden
> +  0 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
> +

The tricky part of --index and --rev is to keep display the global 
indexing. But selecting the very first marker, with a 0 index, you make 
the result of this test indistinct-able from at a broken implementation).

To make sure this feature is actually working we want at minimal to tests:

- something not starting at index 0
- multiple markers with non-consecutive indexes

(same here, you probably want to expand your comment to explain what you 
are trying to cover here).

>   Refuse pathological nullid successors
>     $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
>     transaction abort!

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list