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