Show More
@@ -0,0 +1,55 b'' | |||
|
1 | #require tic | |
|
2 | ||
|
3 | Revert interactive tests with the Curses interface | |
|
4 | ||
|
5 | $ cat <<EOF >> $HGRCPATH | |
|
6 | > [ui] | |
|
7 | > interactive = true | |
|
8 | > interface = curses | |
|
9 | > [experimental] | |
|
10 | > crecordtest = testModeCommands | |
|
11 | > EOF | |
|
12 | ||
|
13 | TODO: Make a curses version of the other tests from test-revert-interactive.t. | |
|
14 | ||
|
15 | When a line without EOL is selected during "revert -i" | |
|
16 | ||
|
17 | $ hg init $TESTTMP/revert-i-curses-eol | |
|
18 | $ cd $TESTTMP/revert-i-curses-eol | |
|
19 | $ echo 0 > a | |
|
20 | $ hg ci -qAm 0 | |
|
21 | $ printf 1 >> a | |
|
22 | $ hg ci -qAm 1 | |
|
23 | $ cat a | |
|
24 | 0 | |
|
25 | 1 (no-eol) | |
|
26 | ||
|
27 | $ cat <<EOF >testModeCommands | |
|
28 | > c | |
|
29 | > EOF | |
|
30 | ||
|
31 | $ hg revert -ir'.^' | |
|
32 | reverting a | |
|
33 | $ cat a | |
|
34 | 0 | |
|
35 | ||
|
36 | When a selected line is reverted to have no EOL | |
|
37 | ||
|
38 | $ hg init $TESTTMP/revert-i-curses-eol2 | |
|
39 | $ cd $TESTTMP/revert-i-curses-eol2 | |
|
40 | $ printf 0 > a | |
|
41 | $ hg ci -qAm 0 | |
|
42 | $ echo 0 > a | |
|
43 | $ hg ci -qAm 1 | |
|
44 | $ cat a | |
|
45 | 0 | |
|
46 | ||
|
47 | $ cat <<EOF >testModeCommands | |
|
48 | > c | |
|
49 | > EOF | |
|
50 | ||
|
51 | $ hg revert -ir'.^' | |
|
52 | reverting a | |
|
53 | $ cat a | |
|
54 | 0 (no-eol) | |
|
55 |
@@ -500,8 +500,12 b' class uihunk(patchnode):' | |||
|
500 | 500 | """ |
|
501 | 501 | dels = [] |
|
502 | 502 | adds = [] |
|
503 | noeol = False | |
|
503 | 504 | for line in self.changedlines: |
|
504 | 505 | text = line.linetext |
|
506 | if line.linetext == b'\\ No newline at end of file\n': | |
|
507 | noeol = True | |
|
508 | break | |
|
505 | 509 | if line.applied: |
|
506 | 510 | if text.startswith(b'+'): |
|
507 | 511 | dels.append(text[1:]) |
@@ -511,6 +515,9 b' class uihunk(patchnode):' | |||
|
511 | 515 | dels.append(text[1:]) |
|
512 | 516 | adds.append(text[1:]) |
|
513 | 517 | hunk = [b'-%s' % l for l in dels] + [b'+%s' % l for l in adds] |
|
518 | if noeol and hunk: | |
|
519 | # Remove the newline from the end of the hunk. | |
|
520 | hunk[-1] = hunk[-1][:-1] | |
|
514 | 521 | h = self._hunk |
|
515 | 522 | return patchmod.recordhunk( |
|
516 | 523 | h.header, h.toline, h.fromline, h.proc, h.before, hunk, h.after |
General Comments 0
You need to be logged in to leave comments.
Login now