Show More
@@ -1,35 +1,36 b'' | |||
|
1 | 1 | from __future__ import absolute_import, print_function |
|
2 | 2 | import os |
|
3 | 3 | from mercurial import ( |
|
4 | 4 | dispatch, |
|
5 | 5 | ) |
|
6 | 6 | |
|
7 | 7 | def testdispatch(cmd): |
|
8 | 8 | """Simple wrapper around dispatch.dispatch() |
|
9 | 9 | |
|
10 | 10 | Prints command and result value, but does not handle quoting. |
|
11 | 11 | """ |
|
12 | 12 | print("running: %s" % (cmd,)) |
|
13 | 13 | req = dispatch.request(cmd.split()) |
|
14 | 14 | result = dispatch.dispatch(req) |
|
15 | 15 | print("result: %r" % (result,)) |
|
16 | 16 | |
|
17 | testdispatch("init test1") | |
|
18 | os.chdir('test1') | |
|
19 | ||
|
20 | 17 | # create file 'foo', add and commit |
|
21 | 18 | f = open('foo', 'wb') |
|
22 | 19 | f.write('foo\n') |
|
23 | 20 | f.close() |
|
24 | 21 | testdispatch("add foo") |
|
25 | 22 | testdispatch("commit -m commit1 -d 2000-01-01 foo") |
|
26 | 23 | |
|
27 | 24 | # append to file 'foo' and commit |
|
28 | 25 | f = open('foo', 'ab') |
|
29 | 26 | f.write('bar\n') |
|
30 | 27 | f.close() |
|
28 | # remove blackbox.log directory (proxy for readonly log file) | |
|
29 | os.rmdir(".hg/blackbox.log") | |
|
30 | # replace it with the real blackbox.log file | |
|
31 | os.rename(".hg/blackbox.log-", ".hg/blackbox.log") | |
|
31 | 32 | testdispatch("commit -m commit2 -d 2000-01-02 foo") |
|
32 | 33 | |
|
33 | 34 | # check 88803a69b24 (fancyopts modified command table) |
|
34 | 35 | testdispatch("log -r 0") |
|
35 | 36 | testdispatch("log -r tip") |
@@ -1,195 +1,195 b'' | |||
|
1 | 1 | setup |
|
2 | 2 | $ cat >> $HGRCPATH <<EOF |
|
3 | 3 | > [extensions] |
|
4 | 4 | > blackbox= |
|
5 | 5 | > mock=$TESTDIR/mockblackbox.py |
|
6 | 6 | > mq= |
|
7 | 7 | > EOF |
|
8 | 8 | $ hg init blackboxtest |
|
9 | 9 | $ cd blackboxtest |
|
10 | 10 | |
|
11 | 11 | command, exit codes, and duration |
|
12 | 12 | |
|
13 | 13 | $ echo a > a |
|
14 | 14 | $ hg add a |
|
15 | 15 | $ hg blackbox --config blackbox.dirty=True |
|
16 | 16 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a |
|
17 | 17 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) |
|
18 | 18 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox |
|
19 | 19 | |
|
20 | 20 | incoming change tracking |
|
21 | 21 | |
|
22 | 22 | create two heads to verify that we only see one change in the log later |
|
23 | 23 | $ hg commit -ma |
|
24 | 24 | $ hg up null |
|
25 | 25 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
26 | 26 | $ echo b > b |
|
27 | 27 | $ hg commit -Amb |
|
28 | 28 | adding b |
|
29 | 29 | created new head |
|
30 | 30 | |
|
31 | 31 | clone, commit, pull |
|
32 | 32 | $ hg clone . ../blackboxtest2 |
|
33 | 33 | updating to branch default |
|
34 | 34 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
35 | 35 | $ echo c > c |
|
36 | 36 | $ hg commit -Amc |
|
37 | 37 | adding c |
|
38 | 38 | $ cd ../blackboxtest2 |
|
39 | 39 | $ hg pull |
|
40 | 40 | pulling from $TESTTMP/blackboxtest (glob) |
|
41 | 41 | searching for changes |
|
42 | 42 | adding changesets |
|
43 | 43 | adding manifests |
|
44 | 44 | adding file changes |
|
45 | 45 | added 1 changesets with 1 changes to 1 files |
|
46 | 46 | (run 'hg update' to get a working copy) |
|
47 | 47 | $ hg blackbox -l 6 |
|
48 | 48 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull |
|
49 | 49 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob) |
|
50 | 50 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes |
|
51 | 51 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 |
|
52 | 52 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) |
|
53 | 53 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
54 | 54 | |
|
55 | 55 | we must not cause a failure if we cannot write to the log |
|
56 | 56 | |
|
57 | 57 | $ hg rollback |
|
58 | 58 | repository tip rolled back to revision 1 (undo pull) |
|
59 | 59 | |
|
60 | 60 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
61 | 61 | $ mkdir .hg/blackbox.log |
|
62 | 62 | $ hg --debug incoming |
|
63 | 63 | warning: cannot write to blackbox.log: * (glob) |
|
64 | 64 | comparing with $TESTTMP/blackboxtest (glob) |
|
65 | 65 | query 1; heads |
|
66 | 66 | searching for changes |
|
67 | 67 | all local heads known remotely |
|
68 | 68 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 |
|
69 | 69 | tag: tip |
|
70 | 70 | phase: draft |
|
71 | 71 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 |
|
72 | 72 | parent: -1:0000000000000000000000000000000000000000 |
|
73 | 73 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 |
|
74 | 74 | user: test |
|
75 | 75 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
76 | 76 | files+: c |
|
77 | 77 | extra: branch=default |
|
78 | 78 | description: |
|
79 | 79 | c |
|
80 | 80 | |
|
81 | 81 | |
|
82 | 82 | $ hg pull |
|
83 | 83 | pulling from $TESTTMP/blackboxtest (glob) |
|
84 | 84 | searching for changes |
|
85 | 85 | adding changesets |
|
86 | 86 | adding manifests |
|
87 | 87 | adding file changes |
|
88 | 88 | added 1 changesets with 1 changes to 1 files |
|
89 | 89 | (run 'hg update' to get a working copy) |
|
90 | 90 | |
|
91 | 91 | a failure reading from the log is fatal |
|
92 | 92 | |
|
93 | 93 | $ hg blackbox -l 3 |
|
94 | 94 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) |
|
95 | 95 | [255] |
|
96 | 96 | |
|
97 | 97 | $ rmdir .hg/blackbox.log |
|
98 | 98 | $ mv .hg/blackbox.log- .hg/blackbox.log |
|
99 | 99 | |
|
100 | 100 | backup bundles get logged |
|
101 | 101 | |
|
102 | 102 | $ touch d |
|
103 | 103 | $ hg commit -Amd |
|
104 | 104 | adding d |
|
105 | 105 | created new head |
|
106 | 106 | $ hg strip tip |
|
107 | 107 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
108 | 108 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) |
|
109 | 109 | $ hg blackbox -l 6 |
|
110 | 110 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip |
|
111 | 111 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg |
|
112 | 112 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob) |
|
113 | 113 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes |
|
114 | 114 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) |
|
115 | 115 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
116 | 116 | |
|
117 | 117 | extension and python hooks - use the eol extension for a pythonhook |
|
118 | 118 | |
|
119 | 119 | $ echo '[extensions]' >> .hg/hgrc |
|
120 | 120 | $ echo 'eol=' >> .hg/hgrc |
|
121 | 121 | $ echo '[hooks]' >> .hg/hgrc |
|
122 | 122 | $ echo 'update = echo hooked' >> .hg/hgrc |
|
123 | 123 | $ hg update |
|
124 | 124 | hooked |
|
125 | 125 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
126 | 126 | 1 other heads for branch "default" |
|
127 | 127 | $ hg blackbox -l 6 |
|
128 | 128 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update |
|
129 | 129 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
130 | 130 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) |
|
131 | 131 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) |
|
132 | 132 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) |
|
133 | 133 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6 |
|
134 | 134 | |
|
135 | 135 | log rotation |
|
136 | 136 | |
|
137 | 137 | $ echo '[blackbox]' >> .hg/hgrc |
|
138 | 138 | $ echo 'maxsize = 20 b' >> .hg/hgrc |
|
139 | 139 | $ echo 'maxfiles = 3' >> .hg/hgrc |
|
140 | 140 | $ hg status |
|
141 | 141 | $ hg status |
|
142 | 142 | $ hg status |
|
143 | 143 | $ hg tip -q |
|
144 | 144 | 2:d02f48003e62 |
|
145 | 145 | $ ls .hg/blackbox.log* |
|
146 | 146 | .hg/blackbox.log |
|
147 | 147 | .hg/blackbox.log.1 |
|
148 | 148 | .hg/blackbox.log.2 |
|
149 | 149 | $ cd .. |
|
150 | 150 | |
|
151 | 151 | $ hg init blackboxtest3 |
|
152 | 152 | $ cd blackboxtest3 |
|
153 | 153 | $ hg blackbox |
|
154 | 154 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
155 | 155 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
156 | 156 | $ mkdir .hg/blackbox.log |
|
157 | 157 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ |
|
158 | 158 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ |
|
159 | 159 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py |
|
160 |
$ python |
|
|
160 | $ python $TESTDIR/blackbox-readonly-dispatch.py | |
|
161 | 161 | running: add foo |
|
162 | 162 | result: 0 |
|
163 | 163 | running: commit -m commit1 -d 2000-01-01 foo |
|
164 | 164 | result: None |
|
165 | 165 | running: commit -m commit2 -d 2000-01-02 foo |
|
166 | 166 | result: None |
|
167 | 167 | running: log -r 0 |
|
168 | 168 | changeset: 0:0e4634943879 |
|
169 | 169 | user: test |
|
170 | 170 | date: Sat Jan 01 00:00:00 2000 +0000 |
|
171 | 171 | summary: commit1 |
|
172 | 172 | |
|
173 | 173 | result: None |
|
174 | 174 | running: log -r tip |
|
175 | 175 | changeset: 1:45589e459b2e |
|
176 | 176 | tag: tip |
|
177 | 177 | user: test |
|
178 | 178 | date: Sun Jan 02 00:00:00 2000 +0000 |
|
179 | 179 | summary: commit2 |
|
180 | 180 | |
|
181 | 181 | result: None |
|
182 | 182 | $ hg blackbox |
|
183 | 183 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo |
|
184 | 184 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> updated served branch cache in * seconds (glob) |
|
185 | 185 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> wrote served branch cache with 1 labels and 1 nodes |
|
186 | 186 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob) |
|
187 | 187 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 |
|
188 | 188 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
189 | 189 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob) |
|
190 | 190 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip |
|
191 | 191 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob) |
|
192 | 192 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox |
|
193 | 193 | |
|
194 | 194 | cleanup |
|
195 | 195 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now