Patchwork dispatch: fix so that if the -M flag and an explicit revision range is given to

login
register
mail settings
Submitter Prabhu GS
Date July 3, 2014, 3:33 a.m.
Message ID <1a9c34c11f6800f80b81.1404358405@sparta.ap01.lucent.com>
Download mbox | patch
Permalink /patch/5093/
State Rejected
Headers show

Comments

Prabhu GS - July 3, 2014, 3:33 a.m.
# HG changeset patch
# User Prabhu Gnana Sundar <pprabhugs@gmail.com>
# Date 1404358260 -19800
#      Thu Jul 03 09:01:00 2014 +0530
# Node ID 1a9c34c11f6800f80b8185fc6631c9aa21694a77
# Parent  212955411633acbe7ace88f22565ce17d85ec8c5
dispatch: fix so that if the -M flag and an explicit revision range is given to
          hg log, the order is not mangled (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 reversing the revision range if -M flag is set.
Also, added a test case to test the same.

Patch

diff -r 212955411633 -r 1a9c34c11f68 mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Fri Jun 27 15:20:50 2014 -0700
+++ b/mercurial/cmdutil.py	Thu Jul 03 09:01:00 2014 +0530
@@ -1736,7 +1736,7 @@ 
         # returns the revision matching A then the revision matching B. Sort
         # again to fix that.
         revs = matcher(repo, revs)
-        if not opts.get('rev'):
+        if not opts.get('rev') or expr == "(not merge())":
             revs.sort(reverse=True)
     if limit is not None:
         count = 0
diff -r 212955411633 -r 1a9c34c11f68 tests/test-log.t
--- a/tests/test-log.t	Fri Jun 27 15:20:50 2014 -0700
+++ b/tests/test-log.t	Thu Jul 03 09:01:00 2014 +0530
@@ -1375,3 +1375,39 @@ 
   
 
   $ 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 2:1
+  2:b0b1beee06eb
+  1:4e6686af661c