##// END OF EJS Templates
py3: encode sys.argv to bytes using .encode()...
Pulkit Goyal -
r38384:bf953d21 default
parent child Browse files
Show More
@@ -1,126 +1,126 b''
1 1 Test applying context diffs
2 2
3 3 $ cat > writepatterns.py <<EOF
4 4 > import sys
5 5 >
6 6 > path = sys.argv[1]
7 7 > lasteol = sys.argv[2] == '1'
8 8 > patterns = sys.argv[3:]
9 9 >
10 10 > fp = open(path, 'wb')
11 11 > for i, pattern in enumerate(patterns):
12 12 > count = int(pattern[0:-1])
13 > char = pattern[-1] + '\n'
13 > char = pattern[-1].encode('utf8') + b'\n'
14 14 > if not lasteol and i == len(patterns) - 1:
15 15 > fp.write((char*count)[:-1])
16 16 > else:
17 17 > fp.write(char*count)
18 18 > fp.close()
19 19 > EOF
20 20 $ cat > cat.py <<EOF
21 21 > import sys
22 22 > sys.stdout.write(repr(open(sys.argv[1], 'rb').read()) + '\n')
23 23 > EOF
24 24
25 25 Initialize the test repository
26 26
27 27 $ hg init repo
28 28 $ cd repo
29 29 $ $PYTHON ../writepatterns.py a 0 5A 1B 5C 1D
30 30 $ $PYTHON ../writepatterns.py b 1 1A 1B
31 31 $ $PYTHON ../writepatterns.py c 1 5A
32 32 $ $PYTHON ../writepatterns.py d 1 5A 1B
33 33 $ hg add
34 34 adding a
35 35 adding b
36 36 adding c
37 37 adding d
38 38 $ hg ci -m addfiles
39 39
40 40 Add file, missing a last end of line
41 41
42 42 $ hg import --no-commit - <<EOF
43 43 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200
44 44 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200
45 45 > ***************
46 46 > *** 0 ****
47 47 > --- 1,2 ----
48 48 > + a
49 49 > + b
50 50 > \ No newline at end of file
51 51 > *** a/a Sat Oct 16 16:35:51 2010
52 52 > --- b/a Sat Oct 16 16:35:51 2010
53 53 > ***************
54 54 > *** 3,12 ****
55 55 > A
56 56 > A
57 57 > A
58 58 > ! B
59 59 > C
60 60 > C
61 61 > C
62 62 > C
63 63 > C
64 64 > ! D
65 65 > \ No newline at end of file
66 66 > --- 3,13 ----
67 67 > A
68 68 > A
69 69 > A
70 70 > ! E
71 71 > C
72 72 > C
73 73 > C
74 74 > C
75 75 > C
76 76 > ! F
77 77 > ! F
78 78 >
79 79 > *** a/b 2010-10-16 18:40:38.000000000 +0200
80 80 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200
81 81 > ***************
82 82 > *** 1,2 ****
83 83 > - A
84 84 > - B
85 85 > --- 0 ----
86 86 > *** a/c Sat Oct 16 21:34:26 2010
87 87 > --- b/c Sat Oct 16 21:34:27 2010
88 88 > ***************
89 89 > *** 3,5 ****
90 90 > --- 3,7 ----
91 91 > A
92 92 > A
93 93 > A
94 94 > + B
95 95 > + B
96 96 > *** a/d Sat Oct 16 21:47:20 2010
97 97 > --- b/d Sat Oct 16 21:47:22 2010
98 98 > ***************
99 99 > *** 2,6 ****
100 100 > A
101 101 > A
102 102 > A
103 103 > - A
104 104 > - B
105 105 > --- 2,4 ----
106 106 > EOF
107 107 applying patch from stdin
108 108 $ hg st
109 109 M a
110 110 M c
111 111 M d
112 112 A newnoeol
113 113 R b
114 114
115 115 What's in a
116 116
117 117 $ $PYTHON ../cat.py a
118 118 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n'
119 119 $ $PYTHON ../cat.py newnoeol
120 120 'a\nb'
121 121 $ $PYTHON ../cat.py c
122 122 'A\nA\nA\nA\nA\nB\nB\n'
123 123 $ $PYTHON ../cat.py d
124 124 'A\nA\nA\nA\n'
125 125
126 126 $ cd ..
@@ -1,82 +1,82 b''
1 1
2 2 $ cat > writepatterns.py <<EOF
3 3 > import sys
4 4 >
5 5 > path = sys.argv[1]
6 6 > patterns = sys.argv[2:]
7 7 >
8 8 > fp = open(path, 'wb')
9 9 > for pattern in patterns:
10 10 > count = int(pattern[0:-1])
11 > char = pattern[-1] + '\n'
11 > char = pattern[-1].encode('utf8') + b'\n'
12 12 > fp.write(char*count)
13 13 > fp.close()
14 14 > EOF
15 15
16 16 prepare repo
17 17
18 18 $ hg init a
19 19 $ cd a
20 20
21 21 These initial lines of Xs were not in the original file used to generate
22 22 the patch. So all the patch hunks need to be applied to a constant offset
23 23 within this file. If the offset isn't tracked then the hunks can be
24 24 applied to the wrong lines of this file.
25 25
26 26 $ $PYTHON ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
27 27 $ hg commit -Am adda
28 28 adding a
29 29
30 30 This is a cleaner patch generated via diff
31 31 In this case it reproduces the problem when
32 32 the output of hg export does not
33 33 import patch
34 34
35 35 $ hg import -v -m 'b' -d '2 0' - <<EOF
36 36 > --- a/a 2009-12-08 19:26:17.000000000 -0800
37 37 > +++ b/a 2009-12-08 19:26:17.000000000 -0800
38 38 > @@ -9,7 +9,7 @@
39 39 > A
40 40 > A
41 41 > B
42 42 > -A
43 43 > +a
44 44 > A
45 45 > A
46 46 > A
47 47 > @@ -53,7 +53,7 @@
48 48 > A
49 49 > A
50 50 > B
51 51 > -A
52 52 > +a
53 53 > A
54 54 > A
55 55 > A
56 56 > @@ -75,7 +75,7 @@
57 57 > A
58 58 > A
59 59 > B
60 60 > -A
61 61 > +a
62 62 > A
63 63 > A
64 64 > A
65 65 > EOF
66 66 applying patch from stdin
67 67 patching file a
68 68 Hunk #1 succeeded at 43 (offset 34 lines).
69 69 Hunk #2 succeeded at 87 (offset 34 lines).
70 70 Hunk #3 succeeded at 109 (offset 34 lines).
71 71 committing files:
72 72 a
73 73 committing manifest
74 74 committing changelog
75 75 created 189885cecb41
76 76
77 77 compare imported changes against reference file
78 78
79 79 $ $PYTHON ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
80 80 $ diff aref a
81 81
82 82 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now