[PATCH] dispatch: fix so that if the -M flag does not change the order of records in hg log (issue4289)

Matt Mackall mpm at selenic.com
Sun Jul 13 16:03:08 CDT 2014


On Wed, 2014-07-09 at 00:43 +0530, Prabhu Gnana Sundar wrote:
> # HG changeset patch
> # User Prabhu Gnana Sundar <pprabhugs at gmail.com>
> # Date 1404846809 -19800
> #      Wed Jul 09 00:43:29 2014 +0530
> # Node ID 9989ab0eaa2e43979a3b3bbeb0518fa0735d9d22
> # Parent  212955411633acbe7ace88f22565ce17d85ec8c5
> dispatch: fix so that if the -M flag does not change the order of records in hg log (issue4289)
> 
> >From hg 3.0.1, if the -M flag and an explicit revision range is given to hg log,
> like "hg log -M -q -r 10:9", the revision order gets reversed, which is unexpected.
> 
> Example:
> 
> Observed:
> $ hg log -M -q -r 10:9
> 9:087ee80fc7bd
> 10:ac2633661a37
> 
> Expected:
> $ hg log -M -q -r 10:9
> 10:ac2633661a37
> 9:087ee80fc7bd
> 
> This patch fixes the above issue by just removing the merged rev while filetering
> the revision range and not re-ordering the revisions.
> Also, added a test case to test the same.
> 
> diff -r 212955411633 -r 9989ab0eaa2e mercurial/revset.py
> --- a/mercurial/revset.py	Fri Jun 27 15:20:50 2014 -0700
> +++ b/mercurial/revset.py	Wed Jul 09 00:43:29 2014 +0530
> @@ -294,7 +294,9 @@
>      return xl + yl
>  
>  def notset(repo, subset, x):
> -    return subset - getset(repo, subset, x)
> +    merged_rev_set = set(getset(repo, subset, x))
> +    subset_list = list(subset)
> +    return filter(lambda x: x not in merged_rev_set, subset_list)

This looks like it undoes all the lazy evaluation logic we added in 3.0.
That isn't there just to make the code confusing.

Two style notes:
- modern Python style uses list comprehensions rather than filter and
lambda
- the Mercurial codebase doesn't use names_with_underscores

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list