# HG changeset patch # User Martin von Zweigbergk # Date 2021-07-23 00:12:56 # Node ID 184d83ef2e5977414b4b0af8a1b3958e9c4c8ad4 # Parent 6b9ad3a0c3485c93c720711b720e6e62b7806254 tests: demonstrate bug in `hg fix` with incorrectly dirty working copy If the parent commit needs formatting but the working copy already has the correct formatting, then the working copy will be reported as modified even though it's clean (because the size in the dirstate is incorrect). Because the bug only occurs when the size changes, I modified the formatter used in the test case to remove repeated spaces. Differential Revision: https://phab.mercurial-scm.org/D11208 diff --git a/tests/test-fix.t b/tests/test-fix.t --- a/tests/test-fix.t +++ b/tests/test-fix.t @@ -3,6 +3,7 @@ approximates the behavior of code format $ UPPERCASEPY="$TESTTMP/uppercase.py" $ cat > $UPPERCASEPY < import re > import sys > from mercurial.utils.procutil import setbinary > setbinary(sys.stdin) @@ -10,16 +11,18 @@ approximates the behavior of code format > stdin = getattr(sys.stdin, 'buffer', sys.stdin) > stdout = getattr(sys.stdout, 'buffer', sys.stdout) > lines = set() + > def format(text): + > return re.sub(b' +', b' ', text.upper()) > for arg in sys.argv[1:]: > if arg == 'all': - > stdout.write(stdin.read().upper()) + > stdout.write(format(stdin.read())) > sys.exit(0) > else: > first, last = arg.split('-') > lines.update(range(int(first), int(last) + 1)) > for i, line in enumerate(stdin.readlines()): > if i + 1 in lines: - > stdout.write(line.upper()) + > stdout.write(format(line)) > else: > stdout.write(line) > EOF @@ -354,6 +357,24 @@ Fixing the working directory should stil $ cd .. +Test that the working copy is reported clean if formatting of the parent makes +it clean. + $ hg init wc-already-formatted + $ cd wc-already-formatted + + $ printf "hello world\n" > hello.whole + $ hg commit -Am initial + adding hello.whole + $ hg fix -w * + $ hg st + M hello.whole + $ hg fix -s . * + $ hg st + M hello.whole (known-bad-output !) + $ hg diff + + $ cd .. + Test the effect of fixing the working directory for each possible status, with and without providing explicit file arguments.