comparison mercurial/patch.py @ 30807:6381a6dbc325

patch: use opt.showsimilarity to calculate and show the similarity Tests have been added.
author Sean Farley <sean@farley.io>
date Mon, 09 Jan 2017 11:24:18 -0800
parents e2796f193f06
children 8540967cd9e0
comparison
equal deleted inserted replaced
30806:e2796f193f06 30807:6381a6dbc325
33 error, 33 error,
34 mail, 34 mail,
35 mdiff, 35 mdiff,
36 pathutil, 36 pathutil,
37 scmutil, 37 scmutil,
38 similar,
38 util, 39 util,
39 ) 40 )
40 stringio = util.stringio 41 stringio = util.stringio
41 42
42 gitre = re.compile('diff --git a/(.*) b/(.*)') 43 gitre = re.compile('diff --git a/(.*) b/(.*)')
2519 mode1, mode2 = gitmode[flag1], gitmode[flag2] 2520 mode1, mode2 = gitmode[flag1], gitmode[flag2]
2520 if mode1 != mode2: 2521 if mode1 != mode2:
2521 header.append('old mode %s' % mode1) 2522 header.append('old mode %s' % mode1)
2522 header.append('new mode %s' % mode2) 2523 header.append('new mode %s' % mode2)
2523 if copyop is not None: 2524 if copyop is not None:
2525 if opts.showsimilarity:
2526 sim = similar.score(ctx1[path1], ctx2[path2]) * 100
2527 header.append('similarity index %d%%' % sim)
2524 header.append('%s from %s' % (copyop, path1)) 2528 header.append('%s from %s' % (copyop, path1))
2525 header.append('%s to %s' % (copyop, path2)) 2529 header.append('%s to %s' % (copyop, path2))
2526 elif revs and not repo.ui.quiet: 2530 elif revs and not repo.ui.quiet:
2527 header.append(diffline(path1, revs)) 2531 header.append(diffline(path1, revs))
2528 2532