Mercurial > hg
comparison tests/test-diffstat.t @ 32320:0e29ce16ec38
diffstat: properly count lines starting in '--' or '++' (issue5479)
Lines that start in '--' or '++' were previously not counted
as deletions or additions in diffstat, resulting in incorrect
addition/deletion counts. The bug was present if the start
of the line, combined with the diff character resulted
in '---' or '+++'.
diffstatdata will now track, for each file, if it has moved
pas the header section by looking for a line beginning with
'@@'. Once that has happened, lines beginning with '-'
or '+' will be counted for deletions and additions. Once a
line beginning with 'diff' is found, the process starts over.
author | Andrew Zwicky <andrew.zwicky@gmail.com> |
---|---|
date | Wed, 17 May 2017 20:51:17 -0500 |
parents | 2e0301ac5c91 |
children | 4441705b7111 058c725925e3 |
comparison
equal
deleted
inserted
replaced
32319:d3177aecac01 | 32320:0e29ce16ec38 |
---|---|
103 warning: ../dir2 not inside relative root . (glob) | 103 warning: ../dir2 not inside relative root . (glob) |
104 | 104 |
105 $ hg diff --stat --root . -I old | 105 $ hg diff --stat --root . -I old |
106 | 106 |
107 $ cd .. | 107 $ cd .. |
108 | |
109 Files with lines beginning with '--' or '++' should be properly counted in diffstat | |
110 | |
111 $ hg up -Cr tip | |
112 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
113 $ rm dir1/new | |
114 $ rm dir2/new | |
115 $ rm "file with spaces" | |
116 $ cat > file << EOF | |
117 > line 1 | |
118 > line 2 | |
119 > line 3 | |
120 > EOF | |
121 $ hg commit -Am file | |
122 adding file | |
123 | |
124 Lines added starting with '--' should count as additions | |
125 $ cat > file << EOF | |
126 > line 1 | |
127 > -- line 2, with dashes | |
128 > line 3 | |
129 > EOF | |
130 | |
131 $ hg diff --root . | |
132 diff -r be1569354b24 file | |
133 --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
134 +++ b/file * (glob) | |
135 @@ -1,3 +1,3 @@ | |
136 line 1 | |
137 -line 2 | |
138 +-- line 2, with dashes | |
139 line 3 | |
140 | |
141 $ hg diff --root . --stat | |
142 file | 2 +- | |
143 1 files changed, 1 insertions(+), 1 deletions(-) | |
144 | |
145 Lines changed starting with '--' should count as deletions | |
146 $ hg commit -m filev2 | |
147 $ cat > file << EOF | |
148 > line 1 | |
149 > -- line 2, with dashes, changed again | |
150 > line 3 | |
151 > EOF | |
152 | |
153 $ hg diff --root . | |
154 diff -r 160f7c034df6 file | |
155 --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
156 +++ b/file * (glob) | |
157 @@ -1,3 +1,3 @@ | |
158 line 1 | |
159 --- line 2, with dashes | |
160 +-- line 2, with dashes, changed again | |
161 line 3 | |
162 | |
163 $ hg diff --root . --stat | |
164 file | 2 +- | |
165 1 files changed, 1 insertions(+), 1 deletions(-) | |
166 | |
167 Lines changed starting with '--' should count as deletions | |
168 and starting with '++' should count as additions | |
169 $ cat > file << EOF | |
170 > line 1 | |
171 > ++ line 2, switched dashes to plusses | |
172 > line 3 | |
173 > EOF | |
174 | |
175 $ hg diff --root . | |
176 diff -r 160f7c034df6 file | |
177 --- a/file Thu Jan 01 00:00:00 1970 +0000 | |
178 +++ b/file * (glob) | |
179 @@ -1,3 +1,3 @@ | |
180 line 1 | |
181 --- line 2, with dashes | |
182 +++ line 2, switched dashes to plusses | |
183 line 3 | |
184 | |
185 $ hg diff --root . --stat | |
186 file | 2 +- | |
187 1 files changed, 1 insertions(+), 1 deletions(-) |