##// END OF EJS Templates
similar: sort files not by object id but by path for stable result...
Yuya Nishihara -
r31579:3a383caa default
parent child Browse files
Show More
@@ -101,19 +101,18 b' def findrenames(repo, added, removed, th'
101 # Zero length files will be frequently unrelated to each other, and
101 # Zero length files will be frequently unrelated to each other, and
102 # tracking the deletion/addition of such a file will probably cause more
102 # tracking the deletion/addition of such a file will probably cause more
103 # harm than good. We strip them out here to avoid matching them later on.
103 # harm than good. We strip them out here to avoid matching them later on.
104 addedfiles = set([workingctx[fp] for fp in added
104 addedfiles = [workingctx[fp] for fp in sorted(added)
105 if workingctx[fp].size() > 0])
105 if workingctx[fp].size() > 0]
106 removedfiles = set([parentctx[fp] for fp in removed
106 removedfiles = [parentctx[fp] for fp in sorted(removed)
107 if fp in parentctx and parentctx[fp].size() > 0])
107 if fp in parentctx and parentctx[fp].size() > 0]
108
108
109 # Find exact matches.
109 # Find exact matches.
110 for (a, b) in _findexactmatches(repo,
110 for (a, b) in _findexactmatches(repo, addedfiles[:], removedfiles):
111 sorted(addedfiles), sorted(removedfiles)):
112 addedfiles.remove(b)
111 addedfiles.remove(b)
113 yield (a.path(), b.path(), 1.0)
112 yield (a.path(), b.path(), 1.0)
114
113
115 # If the user requested similar files to be matched, search for them also.
114 # If the user requested similar files to be matched, search for them also.
116 if threshold < 1.0:
115 if threshold < 1.0:
117 for (a, b, score) in _findsimilarmatches(repo,
116 for (a, b, score) in _findsimilarmatches(repo, addedfiles,
118 sorted(addedfiles), sorted(removedfiles), threshold):
117 removedfiles, threshold):
119 yield (a.path(), b.path(), score)
118 yield (a.path(), b.path(), score)
@@ -55,6 +55,78 b' comparing two empty files caused ZeroDiv'
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
General Comments 0
You need to be logged in to leave comments. Login now