[PATCH 2 of 5 V1 REBASED] obsolete: drop successors sets which are subset of another one

Augie Fackler raf at durin42.com
Fri Dec 7 21:07:32 UTC 2012


On Nov 30, 2012, at 3:12 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1352509019 -3600
> # Node ID a174b9f3d76e9458e1bfbc590cb9d550dd478ad6
> # Parent  d58f0a5976a0e663e2afff58ccd4883eb4d9b99b
> obsolete: drop successors sets which are subset of another one
> 
> If both "(B,)" and "(B, C)" are successors set of "A", "(B,)" is dropped.
> We won't be interrested in detection such divergence scenario.
> 
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -516,11 +516,28 @@ def successorssets(repo, initialnode, ca
>                 break
>             else:
>                 # computation was succesful for *all* marker.
>                 # Add computed successors set to the cache
>                 # (will be poped from to proceeed on the next iteration)
> -                cache[node] = list(set(tuple(r) for r in lss if r))
> +                #
> +                # We remove successors set that are subset of another one
> +                # this fil
> +                candsucset = sorted(((len(ss), set(ss), ss) for ss in lss),
> +                                    reverse=True)

Is there a reason to not use sorted() with they key= kwarg here? Is decorate-sort-undecorate really faster here?

> +                finalsucset = []
> +                for cl, cs, css in candsucset:
> +                    if not css:
> +                        # remove empty successors set
> +                        continue
> +                    for fs, fss in finalsucset:
> +                        if cs.issubset(fs):
> +                            break
> +                    else:
> +                        finalsucset.append((cs, css))

I'm not sure why you're saving cs in the finalsucset, since you immediately trim it off on the next line as soon as the loop was over.

> +                finalsucset = [s[1] for s in finalsucset]
> +                finalsucset.reverse() # put small successors set first
> +                cache[node] = finalsucset
>     return cache[initialnode]
> 
> def _knownrevs(repo, nodes):
>     """yield revision numbers of known nodes passed in parameters
> 
> diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
> --- a/tests/test-obsolete-divergent.t
> +++ b/tests/test-obsolete-divergent.t
> @@ -73,12 +73,12 @@ A_1 have two direct and divergent succes
> 
>   $ hg debugsuccessorssets 'all()'
>   d20a80d4def3
>       d20a80d4def3
>   007dc284c1f8
> +      392fd25390da
>       82623d38b9ba
> -      392fd25390da
>   82623d38b9ba
>       82623d38b9ba
>   392fd25390da
>       392fd25390da
>   $ cd ..
> @@ -137,12 +137,12 @@ indirect divergence with known changeset
> 
>   $ hg debugsuccessorssets 'all()'
>   d20a80d4def3
>       d20a80d4def3
>   007dc284c1f8
> +      392fd25390da
>       82623d38b9ba
> -      392fd25390da
>   82623d38b9ba
>       82623d38b9ba
>   392fd25390da
>       392fd25390da
>   $ cd ..
> @@ -394,5 +394,20 @@ fix the divergence
>   a139f71be9da
>       a139f71be9da
> 
>   $ cd ..
> 
> +
> +Subset does not diverge
> +------------------------------
> +
> +Do not report divergent successors-set if it is a subset of another
> +successors-set. (report [A,B] not [A] + [A,B])
> +
> +  $ newcase subset
> +  $ hg debugobsolete `getid A_0` `getid A_2`
> +  $ hg debugobsolete `getid A_0` `getid A_1` `getid A_2`
> +  $ hg debugsuccessorssets 'desc('A_0')'
> +  007dc284c1f8
> +      82623d38b9ba 392fd25390da
> +
> +  $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel




More information about the Mercurial-devel mailing list