Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 41662:0a5a6675c86c
addremove: use uipathfn instead of m.rel() for recorded similatity message
When no path arguments are given to addremove, it generally prints
absolute paths. However, before this patch, we would always print the
"recording removal of foo as rename to bar (78% similar)" message with
relative paths.
Differential Revision: https://phab.mercurial-scm.org/D5913
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 08 Feb 2019 13:51:29 -0800 |
parents | 6a447a3d1bd0 |
children | 0ed7a8ac5711 |
comparison
equal
deleted
inserted
replaced
41661:05433ad59c52 | 41662:0a5a6675c86c |
---|---|
1090 status = _('removing %s\n') % uipathfn(abs) | 1090 status = _('removing %s\n') % uipathfn(abs) |
1091 label = 'ui.addremove.removed' | 1091 label = 'ui.addremove.removed' |
1092 repo.ui.status(status, label=label) | 1092 repo.ui.status(status, label=label) |
1093 | 1093 |
1094 renames = _findrenames(repo, m, added + unknown, removed + deleted, | 1094 renames = _findrenames(repo, m, added + unknown, removed + deleted, |
1095 similarity) | 1095 similarity, uipathfn) |
1096 | 1096 |
1097 if not dry_run: | 1097 if not dry_run: |
1098 _markchanges(repo, unknown + forgotten, deleted, renames) | 1098 _markchanges(repo, unknown + forgotten, deleted, renames) |
1099 | 1099 |
1100 for f in rejected: | 1100 for f in rejected: |
1119 status = _('adding %s\n') % abs | 1119 status = _('adding %s\n') % abs |
1120 else: | 1120 else: |
1121 status = _('removing %s\n') % abs | 1121 status = _('removing %s\n') % abs |
1122 repo.ui.status(status) | 1122 repo.ui.status(status) |
1123 | 1123 |
1124 # TODO: We should probably have the caller pass in uipathfn and apply it to | |
1125 # the messages above too. forcerelativevalue=True is consistent with how | |
1126 # it used to work. | |
1127 uipathfn = getuipathfn(repo, forcerelativevalue=True) | |
1124 renames = _findrenames(repo, m, added + unknown, removed + deleted, | 1128 renames = _findrenames(repo, m, added + unknown, removed + deleted, |
1125 similarity) | 1129 similarity, uipathfn) |
1126 | 1130 |
1127 _markchanges(repo, unknown + forgotten, deleted, renames) | 1131 _markchanges(repo, unknown + forgotten, deleted, renames) |
1128 | 1132 |
1129 for f in rejected: | 1133 for f in rejected: |
1130 if f in m.files(): | 1134 if f in m.files(): |
1159 elif dstate == 'a': | 1163 elif dstate == 'a': |
1160 added.append(abs) | 1164 added.append(abs) |
1161 | 1165 |
1162 return added, unknown, deleted, removed, forgotten | 1166 return added, unknown, deleted, removed, forgotten |
1163 | 1167 |
1164 def _findrenames(repo, matcher, added, removed, similarity): | 1168 def _findrenames(repo, matcher, added, removed, similarity, uipathfn): |
1165 '''Find renames from removed files to added ones.''' | 1169 '''Find renames from removed files to added ones.''' |
1166 renames = {} | 1170 renames = {} |
1167 if similarity > 0: | 1171 if similarity > 0: |
1168 for old, new, score in similar.findrenames(repo, added, removed, | 1172 for old, new, score in similar.findrenames(repo, added, removed, |
1169 similarity): | 1173 similarity): |
1170 if (repo.ui.verbose or not matcher.exact(old) | 1174 if (repo.ui.verbose or not matcher.exact(old) |
1171 or not matcher.exact(new)): | 1175 or not matcher.exact(new)): |
1172 repo.ui.status(_('recording removal of %s as rename to %s ' | 1176 repo.ui.status(_('recording removal of %s as rename to %s ' |
1173 '(%d%% similar)\n') % | 1177 '(%d%% similar)\n') % |
1174 (matcher.rel(old), matcher.rel(new), | 1178 (uipathfn(old), uipathfn(new), |
1175 score * 100)) | 1179 score * 100)) |
1176 renames[new] = old | 1180 renames[new] = old |
1177 return renames | 1181 return renames |
1178 | 1182 |
1179 def _markchanges(repo, unknown, deleted, renames): | 1183 def _markchanges(repo, unknown, deleted, renames): |