[PATCH STABLE] strip: fix revset usage (issue3604)

Augie Fackler raf at durin42.com
Fri Aug 31 14:39:00 CDT 2012


It sounds like we should have some kind of "revsets for internal code" best practices somewhere?

On Aug 31, 2012, at 2:25 PM, Pierre-Yves David wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1346440830 -7200
> # Branch stable
> # Node ID 8f5348657f23c0bb66625a64c792a0dba97659ef
> # Parent  b0aad9fb87f947e821f0381d461f1794e73833a7
> strip: fix revset usage (issue3604)
> 
> The `repair` code builds a giant revset query instead of using the "%lr" idiom.
> It is inefficient and crash when the number of stripped changeset is too big.
> 
> This changeset replaces the bad code by a better revset usage.
> 
> diff --git a/mercurial/repair.py b/mercurial/repair.py
> --- a/mercurial/repair.py
> +++ b/mercurial/repair.py
> @@ -111,9 +111,10 @@
>         saverevs.difference_update(descendants)
>     savebases = [cl.node(r) for r in saverevs]
>     stripbases = [cl.node(r) for r in tostrip]
> -    rset = ' or '.join([str(r) for r in tostrip])
> -    newbmtarget = repo.revs('sort(heads(ancestors(%r) - (%r)), -rev)',
> -                            rset, rset)
> +
> +    touched = saverevs | tostrip
> +    newbmtarget = repo.revs('sort(heads((::%ld) - (%ld)), -rev)',
> +                            touched, touched)
>     if newbmtarget:
>         newbmtarget = newbmtarget[0]
>     else:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list