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

Prabhu GS pprabhugs at gmail.com
Mon Jul 14 11:16:22 CDT 2014


Hi Matt,

I have fixed the style and used list comprehensions in the above patch. But
about the logic, I could not think of another approach. Any pointers would
help me fix it in a better way.



Cheers,
Prabhu


On Mon, Jul 14, 2014 at 9:42 PM, Prabhu Gnana Sundar <pprabhugs at gmail.com>
wrote:

> # HG changeset patch
> # User Prabhu Gnana Sundar <pprabhugs at gmail.com>
> # Date 1405330767 -19800
> #      Mon Jul 14 15:09:27 2014 +0530
> # Node ID ee3d37ca8c80bff0d3c57cc0110c79971b7c448e
> # 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 ee3d37ca8c80 mercurial/revset.py
> --- a/mercurial/revset.py       Fri Jun 27 15:20:50 2014 -0700
> +++ b/mercurial/revset.py       Mon Jul 14 15:09:27 2014 +0530
> @@ -294,7 +294,9 @@
>      return xl + yl
>
>  def notset(repo, subset, x):
> -    return subset - getset(repo, subset, x)
> +    mergedrevset = set(getset(repo, subset, x))
> +    subsetlist = list(subset)
> +    return [x for x in subsetlist if x not in mergedrevset]
>
>  def listset(repo, subset, a, b):
>      raise error.ParseError(_("can't use a list in this context"))
> diff -r 212955411633 -r ee3d37ca8c80 tests/test-log.t
> --- a/tests/test-log.t  Fri Jun 27 15:20:50 2014 -0700
> +++ b/tests/test-log.t  Mon Jul 14 15:09:27 2014 +0530
> @@ -1375,3 +1375,43 @@
>
>
>    $ cd ..
> +
> +issue4289: if -M flag and an explicit revision range is given to hg log,
> the order
> +should not be reversed.
> +
> +Create a new repo
> +  $ hg init issue4289
> +  $ cd issue4289
> +Initial commit to the repo
> +  $ echo "hello" > a.txt
> +  $ hg add
> +  adding a.txt
> +  $ hg ci -m "initial commit"
> +
> +Make another commit to the repo
> +  $ echo "world" >> a.txt
> +  $ hg ci -m "Another commit"
> +
> +Create another head
> +  $ hg up -r 0
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  $ echo "hello world" > b.txt
> +  $ hg add
> +  adding b.txt
> +  $ hg ci -m "added a new file"
> +  created new head
> +
> +Merge the two heads
> +  $ hg merge
> +  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> +  (branch merge, don't forget to commit)
> +  $ hg ci -m "merged"
> +
> +Run log command
> +  $ hg log -M -q -r 3:1
> +  2:b0b1beee06eb
> +  1:4e6686af661c
> +
> +  $ hg log -M -q -r 1:3
> +  1:4e6686af661c
> +  2:b0b1beee06eb
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140714/ddba04dd/attachment.html>


More information about the Mercurial-devel mailing list