Patchwork [24,of,24] convert: make toposort order stable when multiple orderings are possible

login
register
mail settings
Submitter Mads Kiilerich
Date Dec. 16, 2012, 10:34 p.m.
Message ID <f098292b97d13e79737f.1355697259@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/145/
State Accepted
Commit 13d73bf6be29fe70ad2f63e1532f5f92f82928ed
Headers show

Comments

Mads Kiilerich - Dec. 16, 2012, 10:34 p.m.
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1355436951 -3600
# Node ID f098292b97d13e79737f1faa5b70608d68dd66a6
# Parent  00316b792246e61edcc039945f878c501e5de250
convert: make toposort order stable when multiple orderings are possible

The output of some tests are changed. Not necessarily to the better, just other
valid permutations.
Bryan O'Sullivan - Dec. 17, 2012, 9:14 p.m.
On Sun, Dec 16, 2012 at 2:34 PM, Mads Kiilerich <mads at kiilerich.com> wrote:

> convert: make toposort order stable when multiple orderings are possible
>

I had to do some convincing of myself that this was correct, but I think it
is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20121217/c0fbdc88/attachment.html>
Mads Kiilerich - Dec. 18, 2012, 2:04 a.m.
Bryan O'Sullivan wrote, On 12/17/2012 10:14 PM:
> On Sun, Dec 16, 2012 at 2:34 PM, Mads Kiilerich <mads at kiilerich.com 
> <mailto:mads at kiilerich.com>> wrote:
>
>     convert: make toposort order stable when multiple orderings are
>     possible
>
>
> I had to do some convincing of myself that this was correct, but I 
> think it is.

Patrick, do you have an opinion on this?

I could imagine other ways of stabilizing the ordering ... and using a 
reverse sort would actually reduce the diff for test cases in the suite...

/Mads

Patch

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -175,7 +175,7 @@ 
             revisions without parents. 'parents' must be a mapping of revision
             identifier to its parents ones.
             """
-            visit = parents.keys()
+            visit = sorted(parents)
             seen = set()
             children = {}
             roots = []
diff --git a/tests/test-convert-cvs-detectmerge.t b/tests/test-convert-cvs-detectmerge.t
--- a/tests/test-convert-cvs-detectmerge.t
+++ b/tests/test-convert-cvs-detectmerge.t
@@ -183,8 +183,8 @@ 
   sorting...
   converting...
   9 add file1 on trunk
-  8 add text
-  7 unrelated change
+  8 unrelated change
+  7 add text
   6 add text [MERGE from v1_0]
   5 add text [MERGE from v1_1]
   4 add file2 on trunk
@@ -204,8 +204,8 @@ 
   5: '' add file2 on trunk
   4: '' add text [MERGE from v1_1]
   3: 'v1_1' add text [MERGE from v1_0]
-  2: 'v1_1' unrelated change
-  1: 'v1_0' add text
+  2: 'v1_0' add text
+  1: 'v1_1' unrelated change
   0: '' add file1 on trunk
 
 graphical log
@@ -225,9 +225,9 @@ 
   |\|
   | o    3: 'v1_1' add text [MERGE from v1_0]
   | |\
-  +---o  2: 'v1_1' unrelated change
+  +---o  2: 'v1_0' add text
   | |
-  | o  1: 'v1_0' add text
+  | o  1: 'v1_1' unrelated change
   |/
   o  0: '' add file1 on trunk
   
diff --git a/tests/test-convert-cvs.t b/tests/test-convert-cvs.t
--- a/tests/test-convert-cvs.t
+++ b/tests/test-convert-cvs.t
@@ -91,8 +91,8 @@ 
   sorting...
   converting...
   2 Initial revision
-  1 import
-  0 ci0
+  1 ci0
+  0 import
   updating tags
   $ hgcat a
   a
@@ -116,10 +116,10 @@ 
   sorting...
   converting...
   2 Initial revision
-  1 import
+  1 ci0
+  0 import
   filtering out empty revision
-  repository tip rolled back to revision 0 (undo commit)
-  0 ci0
+  repository tip rolled back to revision 1 (undo commit)
   updating tags
   $ hgcat b/c
   c
@@ -321,9 +321,9 @@ 
   |
   o  3 () update tags date: * +0000 files: .hgtags (glob)
   |
-  o  2 () ci0 date: * -1000 files: b/c (glob)
-  |
-  | o  1 (INITIAL) import date: * -1000 files: (glob)
+  | o  2 (INITIAL) import date: * -1000 files: (glob)
+  | |
+  o |  1 () ci0 date: * -1000 files: b/c (glob)
   |/
   o  0 () Initial revision date: * -1000 files: a b/c (glob)
   
diff --git a/tests/test-convert-svn-move.t b/tests/test-convert-svn-move.t
--- a/tests/test-convert-svn-move.t
+++ b/tests/test-convert-svn-move.t
@@ -100,8 +100,8 @@ 
   4 clobber1
   3 clobber2
   2 adddb
-  1 branch
-  0 clobberdir
+  1 clobberdir
+  0 branch
 
   $ cd hg-repo
 
@@ -210,9 +210,7 @@ 
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   converting [=============================>            ] 5/7\r (no-eol) (esc)
-  scanning paths [                                      ] 0/3\r (no-eol) (esc)
-  scanning paths [===========>                          ] 1/3\r (no-eol) (esc)
-  scanning paths [========================>             ] 2/3\r (no-eol) (esc)
+  scanning paths [                                      ] 0/1\r (no-eol) (esc)
   getting files [===>                                   ] 1/8\r (no-eol) (esc)
   getting files [========>                              ] 2/8\r (no-eol) (esc)
   getting files [=============>                         ] 3/8\r (no-eol) (esc)
@@ -224,7 +222,9 @@ 
                                                               \r (no-eol) (esc)
   \r (no-eol) (esc)
   converting [===================================>      ] 6/7\r (no-eol) (esc)
-  scanning paths [                                      ] 0/1\r (no-eol) (esc)
+  scanning paths [                                      ] 0/3\r (no-eol) (esc)
+  scanning paths [===========>                          ] 1/3\r (no-eol) (esc)
+  scanning paths [========================>             ] 2/3\r (no-eol) (esc)
   getting files [===>                                   ] 1/8\r (no-eol) (esc)
   getting files [========>                              ] 2/8\r (no-eol) (esc)
   getting files [=============>                         ] 3/8\r (no-eol) (esc)
@@ -243,7 +243,7 @@ 
   4 clobber1
   3 clobber2
   2 adddb
-  1 branch
-  0 clobberdir
+  1 clobberdir
+  0 branch
 
   $ cd ..