# HG changeset patch # User Martin von Zweigbergk # Date 2019-01-31 23:35:51 # Node ID db69a763bc893e06b1ae338ba9719c60970ecfe3 # Parent a13268524c2589a7c84fa255358feaaa02493705 diff: make --stat respect ui.relative-paths It would have been easy to make all diffs respect ui.relative-paths, but we don't want that since it makes the diff invalid. Perhaps it makes sense to do that with --noprefix since the point of that is to make paths that are easy to copy&paste, and the diff is already invalid anyway. But this patch just makes the --stat version respect the config option. The --stat view is not even close to a valid diff, so I think it makes sense to show the paths in more human-friendly form. Differential Revision: https://phab.mercurial-scm.org/D5896 diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -99,6 +99,9 @@ def diffordiffstat(ui, repo, diffopts, n width = 80 if not ui.plain(): width = ui.termwidth() - graphwidth + # If an explicit --root was given, don't respect ui.relative-paths + if not relroot: + pathfn = compose(scmutil.getuipathfn(repo), pathfn) chunks = ctx2.diff(ctx1, match, changes, opts=diffopts, pathfn=pathfn, copysourcematch=copysourcematch, diff --git a/tests/test-diffstat.t b/tests/test-diffstat.t --- a/tests/test-diffstat.t +++ b/tests/test-diffstat.t @@ -146,10 +146,21 @@ diffstat within directories: $ hg diff --stat . dir1/new | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) + $ hg diff --stat . --config ui.relative-paths=yes + new | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) $ hg diff --stat --root . new | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) + $ hg diff --stat --root . --config ui.relative-paths=yes + new | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) +--root trumps ui.relative-paths + $ hg diff --stat --root .. --config ui.relative-paths=yes + new | 1 + + ../dir2/new | 1 + + 2 files changed, 2 insertions(+), 0 deletions(-) $ hg diff --stat --root ../dir1 ../dir2 warning: ../dir2 not inside relative root .