Mercurial > hg
annotate tests/test-import-context.t @ 43936:699d6be3820a
fix: use rewriteutil.precheck() instead of reimplementing it
Differential Revision: https://phab.mercurial-scm.org/D7687
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 17 Dec 2019 10:55:50 -0800 |
parents | c70bdd222dcd |
children | 4c1b4805db57 |
rev | line source |
---|---|
12825 | 1 Test applying context diffs |
2 | |
3 $ cat > writepatterns.py <<EOF | |
4 > import sys | |
5 > | |
6 > path = sys.argv[1] | |
7 > lasteol = sys.argv[2] == '1' | |
8 > patterns = sys.argv[3:] | |
9 > | |
36394
4bc983568016
py3: replace file() with open()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32940
diff
changeset
|
10 > fp = open(path, 'wb') |
12825 | 11 > for i, pattern in enumerate(patterns): |
12 > count = int(pattern[0:-1]) | |
38365
bf953d218a91
py3: encode sys.argv to bytes using .encode()
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36394
diff
changeset
|
13 > char = pattern[-1].encode('utf8') + b'\n' |
12825 | 14 > if not lasteol and i == len(patterns) - 1: |
41738
c70bdd222dcd
tests: bulk changes to avoid whitespace errors of check-code.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
40350
diff
changeset
|
15 > fp.write((char * count)[:-1]) |
12825 | 16 > else: |
41738
c70bdd222dcd
tests: bulk changes to avoid whitespace errors of check-code.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
40350
diff
changeset
|
17 > fp.write(char * count) |
12825 | 18 > fp.close() |
19 > EOF | |
20 $ cat > cat.py <<EOF | |
21 > import sys | |
40350
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
22 > from mercurial import pycompat |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
23 > from mercurial.utils import stringutil |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
24 > pycompat.stdout.write(b'%s\n' |
633da7139e4a
py3: fix test-import-context.t
Matt Harbison <matt_harbison@yahoo.com>
parents:
39707
diff
changeset
|
25 > % stringutil.pprint(open(sys.argv[1], 'rb').read())) |
12825 | 26 > EOF |
27 | |
28 Initialize the test repository | |
29 | |
30 $ hg init repo | |
31 $ cd repo | |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
32 $ "$PYTHON" ../writepatterns.py a 0 5A 1B 5C 1D |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
33 $ "$PYTHON" ../writepatterns.py b 1 1A 1B |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
34 $ "$PYTHON" ../writepatterns.py c 1 5A |
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
35 $ "$PYTHON" ../writepatterns.py d 1 5A 1B |
12825 | 36 $ hg add |
37 adding a | |
38 adding b | |
39 adding c | |
40 adding d | |
41 $ hg ci -m addfiles | |
42 | |
43 Add file, missing a last end of line | |
44 | |
45 $ hg import --no-commit - <<EOF | |
46 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200 | |
47 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200 | |
48 > *************** | |
49 > *** 0 **** | |
50 > --- 1,2 ---- | |
51 > + a | |
52 > + b | |
53 > \ No newline at end of file | |
54 > *** a/a Sat Oct 16 16:35:51 2010 | |
55 > --- b/a Sat Oct 16 16:35:51 2010 | |
56 > *************** | |
57 > *** 3,12 **** | |
58 > A | |
59 > A | |
60 > A | |
61 > ! B | |
62 > C | |
63 > C | |
64 > C | |
65 > C | |
66 > C | |
67 > ! D | |
68 > \ No newline at end of file | |
69 > --- 3,13 ---- | |
70 > A | |
71 > A | |
72 > A | |
73 > ! E | |
74 > C | |
75 > C | |
76 > C | |
77 > C | |
78 > C | |
79 > ! F | |
80 > ! F | |
81 > | |
82 > *** a/b 2010-10-16 18:40:38.000000000 +0200 | |
83 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200 | |
84 > *************** | |
85 > *** 1,2 **** | |
86 > - A | |
87 > - B | |
88 > --- 0 ---- | |
89 > *** a/c Sat Oct 16 21:34:26 2010 | |
90 > --- b/c Sat Oct 16 21:34:27 2010 | |
91 > *************** | |
92 > *** 3,5 **** | |
93 > --- 3,7 ---- | |
94 > A | |
95 > A | |
96 > A | |
97 > + B | |
98 > + B | |
99 > *** a/d Sat Oct 16 21:47:20 2010 | |
100 > --- b/d Sat Oct 16 21:47:22 2010 | |
101 > *************** | |
102 > *** 2,6 **** | |
103 > A | |
104 > A | |
105 > A | |
106 > - A | |
107 > - B | |
108 > --- 2,4 ---- | |
109 > EOF | |
110 applying patch from stdin | |
111 $ hg st | |
112 M a | |
113 M c | |
114 M d | |
115 A newnoeol | |
116 R b | |
117 | |
118 What's in a | |
119 | |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
120 $ "$PYTHON" ../cat.py a |
12825 | 121 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
122 $ "$PYTHON" ../cat.py newnoeol |
12825 | 123 'a\nb' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
124 $ "$PYTHON" ../cat.py c |
12825 | 125 'A\nA\nA\nA\nA\nB\nB\n' |
39707
5abc47d4ca6b
tests: quote PYTHON usage
Matt Harbison <matt_harbison@yahoo.com>
parents:
38365
diff
changeset
|
126 $ "$PYTHON" ../cat.py d |
12825 | 127 'A\nA\nA\nA\n' |
128 | |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
12825
diff
changeset
|
129 $ cd .. |