# HG changeset patch # User Navaneeth Suresh # Date 1548488661 -19800 # Node ID 4a33a6bf2b521f9e257ae1aa77f1718d9e3c9ec2 # Parent 4a409c19831fb83171e4e65e02ba57da9eb4c3bd diffstat: support filenames with whitespaces on renames This is a follow-up patch to D5628. `line.split()` cannot get filenames with whitespaces as mentioned by @yuja. This patch replaces `split()` method with `slice`. Corresponding tests were also added. Differential Revision: https://phab.mercurial-scm.org/D5709 diff -r 4a409c19831f -r 4a33a6bf2b52 mercurial/patch.py --- a/mercurial/patch.py Mon Jan 21 23:08:31 2019 -0800 +++ b/mercurial/patch.py Sat Jan 26 13:14:21 2019 +0530 @@ -2806,9 +2806,9 @@ line.startswith('Binary file')): isbinary = True elif line.startswith('rename from'): - filename = line.split()[-1] + filename = line[12:] elif line.startswith('rename to'): - filename += ' => %s' % line.split()[-1] + filename += ' => %s' % line[10:] addresult() return results diff -r 4a409c19831f -r 4a33a6bf2b52 tests/test-diffstat.t --- a/tests/test-diffstat.t Mon Jan 21 23:08:31 2019 -0800 +++ b/tests/test-diffstat.t Sat Jan 26 13:14:21 2019 +0530 @@ -255,3 +255,19 @@ $ hg diff --stat --git a => b | 0 1 files changed, 0 insertions(+), 0 deletions(-) +-- filename may contain whitespaces + $ echo > c + $ hg ci -Am 'add c' + adding c + $ hg mv c 'new c' + $ hg diff --git + diff --git a/c b/new c + rename from c + rename to new c + $ hg diff --stat + c | 1 - + new c | 1 + + 2 files changed, 1 insertions(+), 1 deletions(-) + $ hg diff --stat --git + c => new c | 0 + 1 files changed, 0 insertions(+), 0 deletions(-)