From patchwork Wed Sep 9 12:20:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 2] test-grep: document that trivially moved lines might not be detected From: Yuya Nishihara X-Patchwork-Id: 47112 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Wed, 09 Sep 2020 21:20:34 +0900 # HG changeset patch # User Yuya Nishihara # Date 1599568690 -32400 # Tue Sep 08 21:38:10 2020 +0900 # Node ID cc233fb2375feef75d3f9619ed69cd5d5dea89dd # Parent 89d2c8f8bb4f5bfda272d2665ebcacd98e273d25 test-grep: document that trivially moved lines might not be detected I'm not going to fix this. I just learned "grep --diff" does clever thing than a simple grep(patch.diff(context=0)), and I think it's better to document how things work. diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -640,6 +640,49 @@ revisions printed, just their order. $ cd .. +Moved line may not be collected by "grep --diff" since it first filters +the contents to be diffed by the pattern. (i.e. +"diff <(grep pat a) <(grep pat b)", not "diff a b | grep pat".) +This is much faster than generating full diff per revision. + + $ hg init moved-line + $ cd moved-line + $ cat <<'EOF' > a + > foo + > bar + > baz + > EOF + $ hg ci -Am initial + adding a + $ cat <<'EOF' > a + > bar + > baz + > foo + > EOF + $ hg ci -m reorder + + $ hg diff -c 1 + diff -r a593cc55e81b -r 69789a3b6e80 a + --- a/a Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:00 1970 +0000 + @@ -1,3 +1,3 @@ + -foo + bar + baz + +foo + + can't find the move of "foo" at the revision 1: + + $ hg grep --diff foo -r1 + [1] + + "bar" isn't moved at the revisoin 1: + + $ hg grep --diff bar -r1 + [1] + + $ cd .. + Test for showing working of allfiles flag $ hg init sng