changeset 41673: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 05433ad59c52
children 28ce9184d495
files mercurial/scmutil.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/scmutil.py	Thu Feb 07 14:22:11 2019 -0800
+++ b/mercurial/scmutil.py	Fri Feb 08 13:51:29 2019 -0800
@@ -1092,7 +1092,7 @@
             repo.ui.status(status, label=label)
 
     renames = _findrenames(repo, m, added + unknown, removed + deleted,
-                           similarity)
+                           similarity, uipathfn)
 
     if not dry_run:
         _markchanges(repo, unknown + forgotten, deleted, renames)
@@ -1121,8 +1121,12 @@
                 status = _('removing %s\n') % abs
             repo.ui.status(status)
 
+    # TODO: We should probably have the caller pass in uipathfn and apply it to
+    # the messages above too. forcerelativevalue=True is consistent with how
+    # it used to work.
+    uipathfn = getuipathfn(repo, forcerelativevalue=True)
     renames = _findrenames(repo, m, added + unknown, removed + deleted,
-                           similarity)
+                           similarity, uipathfn)
 
     _markchanges(repo, unknown + forgotten, deleted, renames)
 
@@ -1161,7 +1165,7 @@
 
     return added, unknown, deleted, removed, forgotten
 
-def _findrenames(repo, matcher, added, removed, similarity):
+def _findrenames(repo, matcher, added, removed, similarity, uipathfn):
     '''Find renames from removed files to added ones.'''
     renames = {}
     if similarity > 0:
@@ -1171,7 +1175,7 @@
                 or not matcher.exact(new)):
                 repo.ui.status(_('recording removal of %s as rename to %s '
                                  '(%d%% similar)\n') %
-                               (matcher.rel(old), matcher.rel(new),
+                               (uipathfn(old), uipathfn(new),
                                 score * 100))
             renames[new] = old
     return renames