comparison tests/test-addremove-similar.t @ 31579:3a383caa97f4

similar: sort files not by object id but by path for stable result Perhaps the original implementation would want to sort added/removed files alphabetically, but actually it did sort fctx objects by memory location. This patch removes the use of set()s in order to preserve the order of added/removed files. addedfiles.remove() becomes quadratic, but its cost appears not dominant. Anyway, the quadratic behavior will be eliminated by the next patch. Benchmark with 50k added/removed files, on tmpfs: $ mkdir src $ for n in `seq 0 49`; do > mkdir `printf src/%02d $n` > done $ for n in `seq 0 49999`; do > f=`printf src/%02d/%05d $(($n/1000)) $n` > dd if=/dev/urandom of=$f bs=8k count=1 status=none > done $ hg ci -qAm 'add 50k files of random content' $ mv src dest $ hg addremove --dry-run --time -q original: real 16.550 secs (user 15.000+0.000 sys 1.540+0.000) this patch: real 16.730 secs (user 15.280+0.000 sys 1.440+0.000)
author Yuya Nishihara <yuya@tcha.org>
date Sun, 15 Mar 2015 18:58:56 +0900
parents 478e2b85fcce
children 2efd9771323e
comparison
equal deleted inserted replaced
31578:6262e30b0c09 31579:3a383caa97f4
53 removing tiny-file 53 removing tiny-file
54 recording removal of tiny-file as rename to small-file (82% similar) 54 recording removal of tiny-file as rename to small-file (82% similar)
55 55
56 $ hg commit -m B 56 $ hg commit -m B
57 57
58 should be sorted by path for stable result
59
60 $ for i in `python $TESTDIR/seq.py 0 9`; do
61 > cp small-file $i
62 > done
63 $ rm small-file
64 $ hg addremove
65 adding 0
66 adding 1
67 adding 2
68 adding 3
69 adding 4
70 adding 5
71 adding 6
72 adding 7
73 adding 8
74 adding 9
75 removing small-file
76 recording removal of small-file as rename to 0 (100% similar)
77 recording removal of small-file as rename to 1 (100% similar)
78 recording removal of small-file as rename to 2 (100% similar)
79 recording removal of small-file as rename to 3 (100% similar)
80 recording removal of small-file as rename to 4 (100% similar)
81 recording removal of small-file as rename to 5 (100% similar)
82 recording removal of small-file as rename to 6 (100% similar)
83 recording removal of small-file as rename to 7 (100% similar)
84 recording removal of small-file as rename to 8 (100% similar)
85 recording removal of small-file as rename to 9 (100% similar)
86 $ hg commit -m '10 same files'
87
88 pick one from many identical files
89
90 $ cp 0 a
91 $ rm `python $TESTDIR/seq.py 0 9`
92 $ hg addremove
93 removing 0
94 removing 1
95 removing 2
96 removing 3
97 removing 4
98 removing 5
99 removing 6
100 removing 7
101 removing 8
102 removing 9
103 adding a
104 recording removal of 9 as rename to a (100% similar)
105 $ hg revert -aq
106
107 pick one from many similar files
108
109 $ cp 0 a
110 $ for i in `python $TESTDIR/seq.py 0 9`; do
111 > echo $i >> $i
112 > done
113 $ hg commit -m 'make them slightly different'
114 $ rm `python $TESTDIR/seq.py 0 9`
115 $ hg addremove -s50
116 removing 0
117 removing 1
118 removing 2
119 removing 3
120 removing 4
121 removing 5
122 removing 6
123 removing 7
124 removing 8
125 removing 9
126 adding a
127 recording removal of 9 as rename to a (99% similar)
128 $ hg commit -m 'always the same file should be selected'
129
58 should all fail 130 should all fail
59 131
60 $ hg addremove -s foo 132 $ hg addremove -s foo
61 abort: similarity must be a number 133 abort: similarity must be a number
62 [255] 134 [255]