| 1 |
Setup |
| 2 |
|
| 3 |
$ cat <<EOF >> $HGRCPATH |
| 4 |
> [ui] |
| 5 |
> color = yes |
| 6 |
> formatted = always |
| 7 |
> paginate = never |
| 8 |
> [color] |
| 9 |
> mode = ansi |
| 10 |
> EOF |
| 11 |
$ hg init repo |
| 12 |
$ cd repo |
| 13 |
$ cat > a <<EOF |
| 14 |
> c |
| 15 |
> c |
| 16 |
> a |
| 17 |
> a |
| 18 |
> b |
| 19 |
> a |
| 20 |
> a |
| 21 |
> c |
| 22 |
> c |
| 23 |
> EOF |
| 24 |
$ hg ci -Am adda |
| 25 |
\x1b[0;32madding a\x1b[0m (esc) |
| 26 |
$ cat > a <<EOF |
| 27 |
> c |
| 28 |
> c |
| 29 |
> a |
| 30 |
> a |
| 31 |
> dd |
| 32 |
> a |
| 33 |
> a |
| 34 |
> c |
| 35 |
> c |
| 36 |
> EOF |
| 37 |
|
| 38 |
default context |
| 39 |
|
| 40 |
$ hg diff --nodates |
| 41 |
\x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
| 42 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 43 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 44 |
\x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) |
| 45 |
c |
| 46 |
a |
| 47 |
a |
| 48 |
\x1b[0;31m-b\x1b[0m (esc) |
| 49 |
\x1b[0;32m+dd\x1b[0m (esc) |
| 50 |
a |
| 51 |
a |
| 52 |
c |
| 53 |
|
| 54 |
trailing whitespace |
| 55 |
|
| 56 |
$ cp a a.orig |
| 57 |
>>> with open('a', 'rb') as f: |
| 58 |
... data = f.read() |
| 59 |
>>> with open('a', 'wb') as f: |
| 60 |
... f.write(data.replace(b'dd', b'dd \r')) and None |
| 61 |
$ hg diff --nodates |
| 62 |
\x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
| 63 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 64 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 65 |
\x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) |
| 66 |
c |
| 67 |
a |
| 68 |
a |
| 69 |
\x1b[0;31m-b\x1b[0m (esc) |
| 70 |
\x1b[0;32m+dd\x1b[0m\x1b[0;1;41m \x1b[0m\r (esc) |
| 71 |
a |
| 72 |
a |
| 73 |
c |
| 74 |
|
| 75 |
$ mv a.orig a |
| 76 |
|
| 77 |
(check that 'ui.color=yes' match '--color=auto') |
| 78 |
|
| 79 |
$ hg diff --nodates --config ui.formatted=no |
| 80 |
diff -r cf9f4ba66af2 a |
| 81 |
--- a/a |
| 82 |
+++ b/a |
| 83 |
@@ -2,7 +2,7 @@ |
| 84 |
c |
| 85 |
a |
| 86 |
a |
| 87 |
-b |
| 88 |
+dd |
| 89 |
a |
| 90 |
a |
| 91 |
c |
| 92 |
|
| 93 |
(check that 'ui.color=no' disable color) |
| 94 |
|
| 95 |
$ hg diff --nodates --config ui.formatted=yes --config ui.color=no |
| 96 |
diff -r cf9f4ba66af2 a |
| 97 |
--- a/a |
| 98 |
+++ b/a |
| 99 |
@@ -2,7 +2,7 @@ |
| 100 |
c |
| 101 |
a |
| 102 |
a |
| 103 |
-b |
| 104 |
+dd |
| 105 |
a |
| 106 |
a |
| 107 |
c |
| 108 |
|
| 109 |
(check that 'ui.color=always' force color) |
| 110 |
|
| 111 |
$ hg diff --nodates --config ui.formatted=no --config ui.color=always |
| 112 |
\x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
| 113 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 114 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 115 |
\x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc) |
| 116 |
c |
| 117 |
a |
| 118 |
a |
| 119 |
\x1b[0;31m-b\x1b[0m (esc) |
| 120 |
\x1b[0;32m+dd\x1b[0m (esc) |
| 121 |
a |
| 122 |
a |
| 123 |
c |
| 124 |
|
| 125 |
--unified=2 |
| 126 |
|
| 127 |
$ hg diff --nodates -U 2 |
| 128 |
\x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc) |
| 129 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 130 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 131 |
\x1b[0;35m@@ -3,5 +3,5 @@\x1b[0m (esc) |
| 132 |
a |
| 133 |
a |
| 134 |
\x1b[0;31m-b\x1b[0m (esc) |
| 135 |
\x1b[0;32m+dd\x1b[0m (esc) |
| 136 |
a |
| 137 |
a |
| 138 |
|
| 139 |
diffstat |
| 140 |
|
| 141 |
$ hg diff --stat |
| 142 |
a | 2 \x1b[0;32m+\x1b[0m\x1b[0;31m-\x1b[0m (esc) |
| 143 |
1 files changed, 1 insertions(+), 1 deletions(-) |
| 144 |
$ cat <<EOF >> $HGRCPATH |
| 145 |
> [extensions] |
| 146 |
> record = |
| 147 |
> [ui] |
| 148 |
> interactive = true |
| 149 |
> [diff] |
| 150 |
> git = True |
| 151 |
> EOF |
| 152 |
|
| 153 |
#if execbit |
| 154 |
|
| 155 |
record |
| 156 |
|
| 157 |
$ chmod +x a |
| 158 |
$ hg record -m moda a <<EOF |
| 159 |
> y |
| 160 |
> EOF |
| 161 |
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
| 162 |
\x1b[0;36;1mold mode 100644\x1b[0m (esc) |
| 163 |
\x1b[0;36;1mnew mode 100755\x1b[0m (esc) |
| 164 |
1 hunks, 1 lines changed |
| 165 |
\x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc) |
| 166 |
c |
| 167 |
a |
| 168 |
a |
| 169 |
\x1b[0;31m-b\x1b[0m (esc) |
| 170 |
\x1b[0;32m+dd\x1b[0m (esc) |
| 171 |
a |
| 172 |
a |
| 173 |
c |
| 174 |
\x1b[0;33mrecord this change to 'a'?\x1b[0m (esc) |
| 175 |
\x1b[0;33m(enter ? for help) [Ynesfdaq?]\x1b[0m y (esc) |
| 176 |
|
| 177 |
|
| 178 |
$ echo "[extensions]" >> $HGRCPATH |
| 179 |
$ echo "mq=" >> $HGRCPATH |
| 180 |
$ hg rollback |
| 181 |
repository tip rolled back to revision 0 (undo commit) |
| 182 |
working directory now based on revision 0 |
| 183 |
|
| 184 |
qrecord |
| 185 |
|
| 186 |
$ hg qrecord -m moda patch <<EOF |
| 187 |
> y |
| 188 |
> y |
| 189 |
> EOF |
| 190 |
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
| 191 |
\x1b[0;36;1mold mode 100644\x1b[0m (esc) |
| 192 |
\x1b[0;36;1mnew mode 100755\x1b[0m (esc) |
| 193 |
1 hunks, 1 lines changed |
| 194 |
\x1b[0;33mexamine changes to 'a'?\x1b[0m (esc) |
| 195 |
\x1b[0;33m(enter ? for help) [Ynesfdaq?]\x1b[0m y (esc) |
| 196 |
|
| 197 |
\x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc) |
| 198 |
c |
| 199 |
a |
| 200 |
a |
| 201 |
\x1b[0;31m-b\x1b[0m (esc) |
| 202 |
\x1b[0;32m+dd\x1b[0m (esc) |
| 203 |
a |
| 204 |
a |
| 205 |
c |
| 206 |
\x1b[0;33mrecord this change to 'a'?\x1b[0m (esc) |
| 207 |
\x1b[0;33m(enter ? for help) [Ynesfdaq?]\x1b[0m y (esc) |
| 208 |
|
| 209 |
|
| 210 |
$ hg qpop -a |
| 211 |
popping patch |
| 212 |
patch queue now empty |
| 213 |
|
| 214 |
#endif |
| 215 |
|
| 216 |
issue3712: test colorization of subrepo diff |
| 217 |
|
| 218 |
$ hg init sub |
| 219 |
$ echo b > sub/b |
| 220 |
$ hg -R sub commit -Am 'create sub' |
| 221 |
\x1b[0;32madding b\x1b[0m (esc) |
| 222 |
$ echo 'sub = sub' > .hgsub |
| 223 |
$ hg add .hgsub |
| 224 |
$ hg commit -m 'add subrepo sub' |
| 225 |
$ echo aa >> a |
| 226 |
$ echo bb >> sub/b |
| 227 |
|
| 228 |
$ hg diff -S |
| 229 |
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
| 230 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 231 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 232 |
\x1b[0;35m@@ -7,3 +7,4 @@\x1b[0m (esc) |
| 233 |
a |
| 234 |
c |
| 235 |
c |
| 236 |
\x1b[0;32m+aa\x1b[0m (esc) |
| 237 |
\x1b[0;1mdiff --git a/sub/b b/sub/b\x1b[0m (esc) |
| 238 |
\x1b[0;31;1m--- a/sub/b\x1b[0m (esc) |
| 239 |
\x1b[0;32;1m+++ b/sub/b\x1b[0m (esc) |
| 240 |
\x1b[0;35m@@ -1,1 +1,2 @@\x1b[0m (esc) |
| 241 |
b |
| 242 |
\x1b[0;32m+bb\x1b[0m (esc) |
| 243 |
|
| 244 |
test tabs |
| 245 |
|
| 246 |
$ cat >> a <<EOF |
| 247 |
> one tab |
| 248 |
> two tabs |
| 249 |
> end tab |
| 250 |
> mid tab |
| 251 |
> all tabs |
| 252 |
> EOF |
| 253 |
$ hg diff --nodates |
| 254 |
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
| 255 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 256 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 257 |
\x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) |
| 258 |
a |
| 259 |
c |
| 260 |
c |
| 261 |
\x1b[0;32m+aa\x1b[0m (esc) |
| 262 |
\x1b[0;32m+\x1b[0m \x1b[0;32mone tab\x1b[0m (esc) |
| 263 |
\x1b[0;32m+\x1b[0m \x1b[0;32mtwo tabs\x1b[0m (esc) |
| 264 |
\x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
| 265 |
\x1b[0;32m+mid\x1b[0m \x1b[0;32mtab\x1b[0m (esc) |
| 266 |
\x1b[0;32m+\x1b[0m \x1b[0;32mall\x1b[0m \x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
| 267 |
$ echo "[color]" >> $HGRCPATH |
| 268 |
$ echo "diff.tab = bold magenta" >> $HGRCPATH |
| 269 |
$ hg diff --nodates |
| 270 |
\x1b[0;1mdiff --git a/a b/a\x1b[0m (esc) |
| 271 |
\x1b[0;31;1m--- a/a\x1b[0m (esc) |
| 272 |
\x1b[0;32;1m+++ b/a\x1b[0m (esc) |
| 273 |
\x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc) |
| 274 |
a |
| 275 |
c |
| 276 |
c |
| 277 |
\x1b[0;32m+aa\x1b[0m (esc) |
| 278 |
\x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mone tab\x1b[0m (esc) |
| 279 |
\x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtwo tabs\x1b[0m (esc) |
| 280 |
\x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
| 281 |
\x1b[0;32m+mid\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtab\x1b[0m (esc) |
| 282 |
\x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mall\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc) |
| 283 |
|
| 284 |
$ cd .. |
| 285 |
|
| 286 |
test inline color diff |
| 287 |
|
| 288 |
$ hg init inline |
| 289 |
$ cd inline |
| 290 |
$ cat > file1 << EOF |
| 291 |
> this is the first line |
| 292 |
> this is the second line |
| 293 |
> third line starts with space |
| 294 |
> + starts with a plus sign |
| 295 |
> this one with one tab |
| 296 |
> now with full two tabs |
| 297 |
> now tabs everywhere, much fun |
| 298 |
> |
| 299 |
> this line won't change |
| 300 |
> |
| 301 |
> two lines are going to |
| 302 |
> be changed into three! |
| 303 |
> |
| 304 |
> three of those lines will |
| 305 |
> collapse onto one |
| 306 |
> (to see if it works) |
| 307 |
> EOF |
| 308 |
$ hg add file1 |
| 309 |
$ hg ci -m 'commit' |
| 310 |
|
| 311 |
$ cat > file1 << EOF |
| 312 |
> that is the first paragraph |
| 313 |
> this is the second line |
| 314 |
> third line starts with space |
| 315 |
> - starts with a minus sign |
| 316 |
> this one with two tab |
| 317 |
> now with full three tabs |
| 318 |
> now there are tabs everywhere, much fun |
| 319 |
> |
| 320 |
> this line won't change |
| 321 |
> |
| 322 |
> two lines are going to |
| 323 |
> (entirely magically, |
| 324 |
> assuming this works) |
| 325 |
> be changed into four! |
| 326 |
> |
| 327 |
> three of those lines have |
| 328 |
> collapsed onto one |
| 329 |
> EOF |
| 330 |
$ hg diff --config diff.word-diff=False --color=debug |
| 331 |
[diff.diffline|diff --git a/file1 b/file1] |
| 332 |
[diff.file_a|--- a/file1] |
| 333 |
[diff.file_b|+++ b/file1] |
| 334 |
[diff.hunk|@@ -1,16 +1,17 @@] |
| 335 |
[diff.deleted|-this is the first line] |
| 336 |
[diff.deleted|-this is the second line] |
| 337 |
[diff.deleted|- third line starts with space] |
| 338 |
[diff.deleted|-+ starts with a plus sign] |
| 339 |
[diff.deleted|-][diff.tab| ][diff.deleted|this one with one tab] |
| 340 |
[diff.deleted|-][diff.tab| ][diff.deleted|now with full two tabs] |
| 341 |
[diff.deleted|-][diff.tab| ][diff.deleted|now tabs][diff.tab| ][diff.deleted|everywhere, much fun] |
| 342 |
[diff.inserted|+that is the first paragraph] |
| 343 |
[diff.inserted|+ this is the second line] |
| 344 |
[diff.inserted|+third line starts with space] |
| 345 |
[diff.inserted|+- starts with a minus sign] |
| 346 |
[diff.inserted|+][diff.tab| ][diff.inserted|this one with two tab] |
| 347 |
[diff.inserted|+][diff.tab| ][diff.inserted|now with full three tabs] |
| 348 |
[diff.inserted|+][diff.tab| ][diff.inserted|now there are tabs][diff.tab| ][diff.inserted|everywhere, much fun] |
| 349 |
|
| 350 |
this line won't change |
| 351 |
|
| 352 |
two lines are going to |
| 353 |
[diff.deleted|-be changed into three!] |
| 354 |
[diff.inserted|+(entirely magically,] |
| 355 |
[diff.inserted|+ assuming this works)] |
| 356 |
[diff.inserted|+be changed into four!] |
| 357 |
|
| 358 |
[diff.deleted|-three of those lines will] |
| 359 |
[diff.deleted|-collapse onto one] |
| 360 |
[diff.deleted|-(to see if it works)] |
| 361 |
[diff.inserted|+three of those lines have] |
| 362 |
[diff.inserted|+collapsed onto one] |
| 363 |
$ hg diff --config diff.word-diff=True --color=debug |
| 364 |
[diff.diffline|diff --git a/file1 b/file1] |
| 365 |
[diff.file_a|--- a/file1] |
| 366 |
[diff.file_b|+++ b/file1] |
| 367 |
[diff.hunk|@@ -1,16 +1,17 @@] |
| 368 |
[diff.deleted|-][diff.deleted.changed|this][diff.deleted.unchanged| is the first ][diff.deleted.changed|line] |
| 369 |
[diff.deleted|-][diff.deleted.unchanged|this is the second line] |
| 370 |
[diff.deleted|-][diff.deleted.changed| ][diff.deleted.unchanged|third line starts with space] |
| 371 |
[diff.deleted|-][diff.deleted.changed|+][diff.deleted.unchanged| starts with a ][diff.deleted.changed|plus][diff.deleted.unchanged| sign] |
| 372 |
[diff.deleted|-][diff.tab| ][diff.deleted.unchanged|this one with ][diff.deleted.changed|one][diff.deleted.unchanged| tab] |
| 373 |
[diff.deleted|-][diff.tab| ][diff.deleted.unchanged|now with full ][diff.deleted.changed|two][diff.deleted.unchanged| tabs] |
| 374 |
[diff.deleted|-][diff.tab| ][diff.deleted.unchanged|now ][diff.deleted.unchanged|tabs][diff.tab| ][diff.deleted.unchanged|everywhere, much fun] |
| 375 |
[diff.inserted|+][diff.inserted.changed|that][diff.inserted.unchanged| is the first ][diff.inserted.changed|paragraph] |
| 376 |
[diff.inserted|+][diff.inserted.changed| ][diff.inserted.unchanged|this is the second line] |
| 377 |
[diff.inserted|+][diff.inserted.unchanged|third line starts with space] |
| 378 |
[diff.inserted|+][diff.inserted.changed|-][diff.inserted.unchanged| starts with a ][diff.inserted.changed|minus][diff.inserted.unchanged| sign] |
| 379 |
[diff.inserted|+][diff.tab| ][diff.inserted.unchanged|this one with ][diff.inserted.changed|two][diff.inserted.unchanged| tab] |
| 380 |
[diff.inserted|+][diff.tab| ][diff.inserted.unchanged|now with full ][diff.inserted.changed|three][diff.inserted.unchanged| tabs] |
| 381 |
[diff.inserted|+][diff.tab| ][diff.inserted.unchanged|now ][diff.inserted.changed|there are ][diff.inserted.unchanged|tabs][diff.tab| ][diff.inserted.unchanged|everywhere, much fun] |
| 382 |
|
| 383 |
this line won't change |
| 384 |
|
| 385 |
two lines are going to |
| 386 |
[diff.deleted|-][diff.deleted.unchanged|be changed into ][diff.deleted.changed|three][diff.deleted.unchanged|!] |
| 387 |
[diff.inserted|+][diff.inserted.changed|(entirely magically,] |
| 388 |
[diff.inserted|+][diff.inserted.changed| assuming this works)] |
| 389 |
[diff.inserted|+][diff.inserted.unchanged|be changed into ][diff.inserted.changed|four][diff.inserted.unchanged|!] |
| 390 |
|
| 391 |
[diff.deleted|-][diff.deleted.unchanged|three of those lines ][diff.deleted.changed|will] |
| 392 |
[diff.deleted|-][diff.deleted.changed|collapse][diff.deleted.unchanged| onto one] |
| 393 |
[diff.deleted|-][diff.deleted.changed|(to see if it works)] |
| 394 |
[diff.inserted|+][diff.inserted.unchanged|three of those lines ][diff.inserted.changed|have] |
| 395 |
[diff.inserted|+][diff.inserted.changed|collapsed][diff.inserted.unchanged| onto one] |
| 396 |
|
| 397 |
multibyte character shouldn't be broken up in word diff: |
| 398 |
|
| 399 |
$ "$PYTHON" <<'EOF' |
| 400 |
> with open("utf8", "wb") as f: |
| 401 |
> f.write(b"blah \xe3\x82\xa2 blah\n") |
| 402 |
> EOF |
| 403 |
$ hg ci -Am 'add utf8 char' utf8 |
| 404 |
$ "$PYTHON" <<'EOF' |
| 405 |
> with open("utf8", "wb") as f: |
| 406 |
> f.write(b"blah \xe3\x82\xa4 blah\n") |
| 407 |
> EOF |
| 408 |
$ hg ci -m 'slightly change utf8 char' utf8 |
| 409 |
|
| 410 |
$ hg diff --config diff.word-diff=True --color=debug -c. |
| 411 |
[diff.diffline|diff --git a/utf8 b/utf8] |
| 412 |
[diff.file_a|--- a/utf8] |
| 413 |
[diff.file_b|+++ b/utf8] |
| 414 |
[diff.hunk|@@ -1,1 +1,1 @@] |
| 415 |
[diff.deleted|-][diff.deleted.unchanged|blah ][diff.deleted.changed|\xe3\x82\xa2][diff.deleted.unchanged| blah] (esc) |
| 416 |
[diff.inserted|+][diff.inserted.unchanged|blah ][diff.inserted.changed|\xe3\x82\xa4][diff.inserted.unchanged| blah] (esc) |