Show More
@@ -1,373 +1,369 | |||
|
1 | 1 | import os, stat |
|
2 | 2 | import re |
|
3 | 3 | import socket |
|
4 | 4 | import sys |
|
5 | 5 | import tempfile |
|
6 | 6 | |
|
7 | 7 | tempprefix = 'hg-hghave-' |
|
8 | 8 | |
|
9 | 9 | checks = { |
|
10 | 10 | "true": (lambda: True, "yak shaving"), |
|
11 | 11 | "false": (lambda: False, "nail clipper"), |
|
12 | 12 | } |
|
13 | 13 | |
|
14 | 14 | def check(name, desc): |
|
15 | 15 | def decorator(func): |
|
16 | 16 | checks[name] = (func, desc) |
|
17 | 17 | return func |
|
18 | 18 | return decorator |
|
19 | 19 | |
|
20 | 20 | def matchoutput(cmd, regexp, ignorestatus=False): |
|
21 | 21 | """Return True if cmd executes successfully and its output |
|
22 | 22 | is matched by the supplied regular expression. |
|
23 | 23 | """ |
|
24 | 24 | r = re.compile(regexp) |
|
25 | 25 | fh = os.popen(cmd) |
|
26 | 26 | s = fh.read() |
|
27 | 27 | try: |
|
28 | 28 | ret = fh.close() |
|
29 | 29 | except IOError: |
|
30 | 30 | # Happen in Windows test environment |
|
31 | 31 | ret = 1 |
|
32 | 32 | return (ignorestatus or ret is None) and r.search(s) |
|
33 | 33 | |
|
34 | 34 | @check("baz", "GNU Arch baz client") |
|
35 | 35 | def has_baz(): |
|
36 | 36 | return matchoutput('baz --version 2>&1', r'baz Bazaar version') |
|
37 | 37 | |
|
38 | 38 | @check("bzr", "Canonical's Bazaar client") |
|
39 | 39 | def has_bzr(): |
|
40 | 40 | try: |
|
41 | 41 | import bzrlib |
|
42 | 42 | return bzrlib.__doc__ is not None |
|
43 | 43 | except ImportError: |
|
44 | 44 | return False |
|
45 | 45 | |
|
46 | 46 | @check("bzr114", "Canonical's Bazaar client >= 1.14") |
|
47 | 47 | def has_bzr114(): |
|
48 | 48 | try: |
|
49 | 49 | import bzrlib |
|
50 | 50 | return (bzrlib.__doc__ is not None |
|
51 | 51 | and bzrlib.version_info[:2] >= (1, 14)) |
|
52 | 52 | except ImportError: |
|
53 | 53 | return False |
|
54 | 54 | |
|
55 | 55 | @check("cvs", "cvs client/server") |
|
56 | 56 | def has_cvs(): |
|
57 | 57 | re = r'Concurrent Versions System.*?server' |
|
58 | 58 | return matchoutput('cvs --version 2>&1', re) and not has_msys() |
|
59 | 59 | |
|
60 | 60 | @check("cvs112", "cvs client/server >= 1.12") |
|
61 | 61 | def has_cvs112(): |
|
62 | 62 | re = r'Concurrent Versions System \(CVS\) 1.12.*?server' |
|
63 | 63 | return matchoutput('cvs --version 2>&1', re) and not has_msys() |
|
64 | 64 | |
|
65 | 65 | @check("darcs", "darcs client") |
|
66 | 66 | def has_darcs(): |
|
67 | 67 | return matchoutput('darcs --version', r'2\.[2-9]', True) |
|
68 | 68 | |
|
69 | 69 | @check("mtn", "monotone client (>= 1.0)") |
|
70 | 70 | def has_mtn(): |
|
71 | 71 | return matchoutput('mtn --version', r'monotone', True) and not matchoutput( |
|
72 | 72 | 'mtn --version', r'monotone 0\.', True) |
|
73 | 73 | |
|
74 | 74 | @check("eol-in-paths", "end-of-lines in paths") |
|
75 | 75 | def has_eol_in_paths(): |
|
76 | 76 | try: |
|
77 | 77 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') |
|
78 | 78 | os.close(fd) |
|
79 | 79 | os.remove(path) |
|
80 | 80 | return True |
|
81 | 81 | except (IOError, OSError): |
|
82 | 82 | return False |
|
83 | 83 | |
|
84 | 84 | @check("execbit", "executable bit") |
|
85 | 85 | def has_executablebit(): |
|
86 | 86 | try: |
|
87 | 87 | EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
|
88 | 88 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
89 | 89 | try: |
|
90 | 90 | os.close(fh) |
|
91 | 91 | m = os.stat(fn).st_mode & 0777 |
|
92 | 92 | new_file_has_exec = m & EXECFLAGS |
|
93 | 93 | os.chmod(fn, m ^ EXECFLAGS) |
|
94 | 94 | exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) |
|
95 | 95 | finally: |
|
96 | 96 | os.unlink(fn) |
|
97 | 97 | except (IOError, OSError): |
|
98 | 98 | # we don't care, the user probably won't be able to commit anyway |
|
99 | 99 | return False |
|
100 | 100 | return not (new_file_has_exec or exec_flags_cannot_flip) |
|
101 | 101 | |
|
102 | 102 | @check("icasefs", "case insensitive file system") |
|
103 | 103 | def has_icasefs(): |
|
104 | 104 | # Stolen from mercurial.util |
|
105 | 105 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
106 | 106 | os.close(fd) |
|
107 | 107 | try: |
|
108 | 108 | s1 = os.stat(path) |
|
109 | 109 | d, b = os.path.split(path) |
|
110 | 110 | p2 = os.path.join(d, b.upper()) |
|
111 | 111 | if path == p2: |
|
112 | 112 | p2 = os.path.join(d, b.lower()) |
|
113 | 113 | try: |
|
114 | 114 | s2 = os.stat(p2) |
|
115 | 115 | return s2 == s1 |
|
116 | 116 | except OSError: |
|
117 | 117 | return False |
|
118 | 118 | finally: |
|
119 | 119 | os.remove(path) |
|
120 | 120 | |
|
121 | 121 | @check("fifo", "named pipes") |
|
122 | 122 | def has_fifo(): |
|
123 | 123 | if getattr(os, "mkfifo", None) is None: |
|
124 | 124 | return False |
|
125 | 125 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
126 | 126 | try: |
|
127 | 127 | os.mkfifo(name) |
|
128 | 128 | os.unlink(name) |
|
129 | 129 | return True |
|
130 | 130 | except OSError: |
|
131 | 131 | return False |
|
132 | 132 | |
|
133 | 133 | @check("killdaemons", 'killdaemons.py support') |
|
134 | 134 | def has_killdaemons(): |
|
135 | 135 | return True |
|
136 | 136 | |
|
137 | 137 | @check("cacheable", "cacheable filesystem") |
|
138 | 138 | def has_cacheable_fs(): |
|
139 | 139 | from mercurial import util |
|
140 | 140 | |
|
141 | 141 | fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
142 | 142 | os.close(fd) |
|
143 | 143 | try: |
|
144 | 144 | return util.cachestat(path).cacheable() |
|
145 | 145 | finally: |
|
146 | 146 | os.remove(path) |
|
147 | 147 | |
|
148 | 148 | @check("lsprof", "python lsprof module") |
|
149 | 149 | def has_lsprof(): |
|
150 | 150 | try: |
|
151 | 151 | import _lsprof |
|
152 | 152 | _lsprof.Profiler # silence unused import warning |
|
153 | 153 | return True |
|
154 | 154 | except ImportError: |
|
155 | 155 | return False |
|
156 | 156 | |
|
157 | 157 | @check("gettext", "GNU Gettext (msgfmt)") |
|
158 | 158 | def has_gettext(): |
|
159 | 159 | return matchoutput('msgfmt --version', 'GNU gettext-tools') |
|
160 | 160 | |
|
161 | 161 | @check("git", "git command line client") |
|
162 | 162 | def has_git(): |
|
163 | 163 | return matchoutput('git --version 2>&1', r'^git version') |
|
164 | 164 | |
|
165 | 165 | @check("docutils", "Docutils text processing library") |
|
166 | 166 | def has_docutils(): |
|
167 | 167 | try: |
|
168 | 168 | from docutils.core import publish_cmdline |
|
169 | 169 | publish_cmdline # silence unused import |
|
170 | 170 | return True |
|
171 | 171 | except ImportError: |
|
172 | 172 | return False |
|
173 | 173 | |
|
174 | 174 | def getsvnversion(): |
|
175 | 175 | m = matchoutput('svn --version --quiet 2>&1', r'^(\d+)\.(\d+)') |
|
176 | 176 | if not m: |
|
177 | 177 | return (0, 0) |
|
178 | 178 | return (int(m.group(1)), int(m.group(2))) |
|
179 | 179 | |
|
180 | 180 | @check("svn15", "subversion client and admin tools >= 1.5") |
|
181 | 181 | def has_svn15(): |
|
182 | 182 | return getsvnversion() >= (1, 5) |
|
183 | 183 | |
|
184 | 184 | @check("svn13", "subversion client and admin tools >= 1.3") |
|
185 | 185 | def has_svn13(): |
|
186 | 186 | return getsvnversion() >= (1, 3) |
|
187 | 187 | |
|
188 | 188 | @check("svn", "subversion client and admin tools") |
|
189 | 189 | def has_svn(): |
|
190 | 190 | return matchoutput('svn --version 2>&1', r'^svn, version') and \ |
|
191 | 191 | matchoutput('svnadmin --version 2>&1', r'^svnadmin, version') |
|
192 | 192 | |
|
193 | 193 | @check("svn-bindings", "subversion python bindings") |
|
194 | 194 | def has_svn_bindings(): |
|
195 | 195 | try: |
|
196 | 196 | import svn.core |
|
197 | 197 | version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR |
|
198 | 198 | if version < (1, 4): |
|
199 | 199 | return False |
|
200 | 200 | return True |
|
201 | 201 | except ImportError: |
|
202 | 202 | return False |
|
203 | 203 | |
|
204 | 204 | @check("p4", "Perforce server and client") |
|
205 | 205 | def has_p4(): |
|
206 | 206 | return (matchoutput('p4 -V', r'Rev\. P4/') and |
|
207 | 207 | matchoutput('p4d -V', r'Rev\. P4D/')) |
|
208 | 208 | |
|
209 | 209 | @check("symlink", "symbolic links") |
|
210 | 210 | def has_symlink(): |
|
211 | 211 | if getattr(os, "symlink", None) is None: |
|
212 | 212 | return False |
|
213 | 213 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
214 | 214 | try: |
|
215 | 215 | os.symlink(".", name) |
|
216 | 216 | os.unlink(name) |
|
217 | 217 | return True |
|
218 | 218 | except (OSError, AttributeError): |
|
219 | 219 | return False |
|
220 | 220 | |
|
221 | 221 | @check("hardlink", "hardlinks") |
|
222 | 222 | def has_hardlink(): |
|
223 | 223 | from mercurial import util |
|
224 | 224 | fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
|
225 | 225 | os.close(fh) |
|
226 | 226 | name = tempfile.mktemp(dir='.', prefix=tempprefix) |
|
227 | 227 | try: |
|
228 | 228 | util.oslink(fn, name) |
|
229 | 229 | os.unlink(name) |
|
230 | 230 | return True |
|
231 | 231 | except OSError: |
|
232 | 232 | return False |
|
233 | 233 | finally: |
|
234 | 234 | os.unlink(fn) |
|
235 | 235 | |
|
236 | 236 | @check("tla", "GNU Arch tla client") |
|
237 | 237 | def has_tla(): |
|
238 | 238 | return matchoutput('tla --version 2>&1', r'The GNU Arch Revision') |
|
239 | 239 | |
|
240 | 240 | @check("gpg", "gpg client") |
|
241 | 241 | def has_gpg(): |
|
242 | 242 | return matchoutput('gpg --version 2>&1', r'GnuPG') |
|
243 | 243 | |
|
244 | 244 | @check("unix-permissions", "unix-style permissions") |
|
245 | 245 | def has_unix_permissions(): |
|
246 | 246 | d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
|
247 | 247 | try: |
|
248 | 248 | fname = os.path.join(d, 'foo') |
|
249 | 249 | for umask in (077, 007, 022): |
|
250 | 250 | os.umask(umask) |
|
251 | 251 | f = open(fname, 'w') |
|
252 | 252 | f.close() |
|
253 | 253 | mode = os.stat(fname).st_mode |
|
254 | 254 | os.unlink(fname) |
|
255 | 255 | if mode & 0777 != ~umask & 0666: |
|
256 | 256 | return False |
|
257 | 257 | return True |
|
258 | 258 | finally: |
|
259 | 259 | os.rmdir(d) |
|
260 | 260 | |
|
261 | 261 | @check("unix-socket", "AF_UNIX socket family") |
|
262 | 262 | def has_unix_socket(): |
|
263 | 263 | return getattr(socket, 'AF_UNIX', None) is not None |
|
264 | 264 | |
|
265 | 265 | @check("root", "root permissions") |
|
266 | 266 | def has_root(): |
|
267 | 267 | return getattr(os, 'geteuid', None) and os.geteuid() == 0 |
|
268 | 268 | |
|
269 | 269 | @check("pyflakes", "Pyflakes python linter") |
|
270 | 270 | def has_pyflakes(): |
|
271 | 271 | return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", |
|
272 | 272 | r"<stdin>:1: 're' imported but unused", |
|
273 | 273 | True) |
|
274 | 274 | |
|
275 | 275 | @check("pygments", "Pygments source highlighting library") |
|
276 | 276 | def has_pygments(): |
|
277 | 277 | try: |
|
278 | 278 | import pygments |
|
279 | 279 | pygments.highlight # silence unused import warning |
|
280 | 280 | return True |
|
281 | 281 | except ImportError: |
|
282 | 282 | return False |
|
283 | 283 | |
|
284 | @check("python243", "python >= 2.4.3") | |
|
285 | def has_python243(): | |
|
286 | return sys.version_info >= (2, 4, 3) | |
|
287 | ||
|
288 | 284 | @check("json", "some json module available") |
|
289 | 285 | def has_json(): |
|
290 | 286 | try: |
|
291 | 287 | import json |
|
292 | 288 | json.dumps |
|
293 | 289 | return True |
|
294 | 290 | except ImportError: |
|
295 | 291 | try: |
|
296 | 292 | import simplejson as json |
|
297 | 293 | json.dumps |
|
298 | 294 | return True |
|
299 | 295 | except ImportError: |
|
300 | 296 | pass |
|
301 | 297 | return False |
|
302 | 298 | |
|
303 | 299 | @check("outer-repo", "outer repo") |
|
304 | 300 | def has_outer_repo(): |
|
305 | 301 | # failing for other reasons than 'no repo' imply that there is a repo |
|
306 | 302 | return not matchoutput('hg root 2>&1', |
|
307 | 303 | r'abort: no repository found', True) |
|
308 | 304 | |
|
309 | 305 | @check("ssl", ("(python >= 2.6 ssl module and python OpenSSL) " |
|
310 | 306 | "OR python >= 2.7.9 ssl")) |
|
311 | 307 | def has_ssl(): |
|
312 | 308 | try: |
|
313 | 309 | import ssl |
|
314 | 310 | if getattr(ssl, 'create_default_context', False): |
|
315 | 311 | return True |
|
316 | 312 | import OpenSSL |
|
317 | 313 | OpenSSL.SSL.Context |
|
318 | 314 | return True |
|
319 | 315 | except ImportError: |
|
320 | 316 | return False |
|
321 | 317 | |
|
322 | 318 | @check("defaultcacerts", "can verify SSL certs by system's CA certs store") |
|
323 | 319 | def has_defaultcacerts(): |
|
324 | 320 | from mercurial import sslutil |
|
325 | 321 | return sslutil._defaultcacerts() != '!' |
|
326 | 322 | |
|
327 | 323 | @check("windows", "Windows") |
|
328 | 324 | def has_windows(): |
|
329 | 325 | return os.name == 'nt' |
|
330 | 326 | |
|
331 | 327 | @check("system-sh", "system() uses sh") |
|
332 | 328 | def has_system_sh(): |
|
333 | 329 | return os.name != 'nt' |
|
334 | 330 | |
|
335 | 331 | @check("serve", "platform and python can manage 'hg serve -d'") |
|
336 | 332 | def has_serve(): |
|
337 | 333 | return os.name != 'nt' # gross approximation |
|
338 | 334 | |
|
339 | 335 | @check("test-repo", "running tests from repository") |
|
340 | 336 | def has_test_repo(): |
|
341 | 337 | t = os.environ["TESTDIR"] |
|
342 | 338 | return os.path.isdir(os.path.join(t, "..", ".hg")) |
|
343 | 339 | |
|
344 | 340 | @check("tic", "terminfo compiler and curses module") |
|
345 | 341 | def has_tic(): |
|
346 | 342 | try: |
|
347 | 343 | import curses |
|
348 | 344 | curses.COLOR_BLUE |
|
349 | 345 | return matchoutput('test -x "`which tic`"', '') |
|
350 | 346 | except ImportError: |
|
351 | 347 | return False |
|
352 | 348 | |
|
353 | 349 | @check("msys", "Windows with MSYS") |
|
354 | 350 | def has_msys(): |
|
355 | 351 | return os.getenv('MSYSTEM') |
|
356 | 352 | |
|
357 | 353 | @check("aix", "AIX") |
|
358 | 354 | def has_aix(): |
|
359 | 355 | return sys.platform.startswith("aix") |
|
360 | 356 | |
|
361 | 357 | @check("osx", "OS X") |
|
362 | 358 | def has_osx(): |
|
363 | 359 | return sys.platform == 'darwin' |
|
364 | 360 | |
|
365 | 361 | @check("absimport", "absolute_import in __future__") |
|
366 | 362 | def has_absimport(): |
|
367 | 363 | import __future__ |
|
368 | 364 | from mercurial import util |
|
369 | 365 | return util.safehasattr(__future__, "absolute_import") |
|
370 | 366 | |
|
371 | 367 | @check("py3k", "running with Python 3.x") |
|
372 | 368 | def has_py3k(): |
|
373 | 369 | return 3 == sys.version_info[0] |
@@ -1,328 +1,324 | |||
|
1 | 1 | #require serve |
|
2 | 2 | |
|
3 | 3 | $ hg init test |
|
4 | 4 | $ cd test |
|
5 | 5 | $ echo foo>foo |
|
6 | 6 | $ mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg |
|
7 | 7 | $ echo foo>foo.d/foo |
|
8 | 8 | $ echo bar>foo.d/bAr.hg.d/BaR |
|
9 | 9 | $ echo bar>foo.d/baR.d.hg/bAR |
|
10 | 10 | $ hg commit -A -m 1 |
|
11 | 11 | adding foo |
|
12 | 12 | adding foo.d/bAr.hg.d/BaR |
|
13 | 13 | adding foo.d/baR.d.hg/bAR |
|
14 | 14 | adding foo.d/foo |
|
15 | 15 | $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log |
|
16 | 16 | $ hg --config server.uncompressed=False serve -p $HGPORT1 -d --pid-file=../hg2.pid |
|
17 | 17 | |
|
18 | 18 | Test server address cannot be reused |
|
19 | 19 | |
|
20 | 20 | #if windows |
|
21 | 21 | $ hg serve -p $HGPORT1 2>&1 |
|
22 | 22 | abort: cannot start server at ':$HGPORT1': * (glob) |
|
23 | 23 | [255] |
|
24 | 24 | #else |
|
25 | 25 | $ hg serve -p $HGPORT1 2>&1 |
|
26 | 26 | abort: cannot start server at ':$HGPORT1': Address already in use |
|
27 | 27 | [255] |
|
28 | 28 | #endif |
|
29 | 29 | $ cd .. |
|
30 | 30 | $ cat hg1.pid hg2.pid >> $DAEMON_PIDS |
|
31 | 31 | |
|
32 | 32 | clone via stream |
|
33 | 33 | |
|
34 | 34 | $ hg clone --uncompressed http://localhost:$HGPORT/ copy 2>&1 |
|
35 | 35 | streaming all changes |
|
36 | 36 | 6 files to transfer, 606 bytes of data |
|
37 | 37 | transferred * bytes in * seconds (*/sec) (glob) |
|
38 | 38 | searching for changes |
|
39 | 39 | no changes found |
|
40 | 40 | updating to branch default |
|
41 | 41 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
42 | 42 | $ hg verify -R copy |
|
43 | 43 | checking changesets |
|
44 | 44 | checking manifests |
|
45 | 45 | crosschecking files in changesets and manifests |
|
46 | 46 | checking files |
|
47 | 47 | 4 files, 1 changesets, 4 total revisions |
|
48 | 48 | |
|
49 | 49 | try to clone via stream, should use pull instead |
|
50 | 50 | |
|
51 | 51 | $ hg clone --uncompressed http://localhost:$HGPORT1/ copy2 |
|
52 | 52 | requesting all changes |
|
53 | 53 | adding changesets |
|
54 | 54 | adding manifests |
|
55 | 55 | adding file changes |
|
56 | 56 | added 1 changesets with 4 changes to 4 files |
|
57 | 57 | updating to branch default |
|
58 | 58 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
59 | 59 | |
|
60 | 60 | clone via pull |
|
61 | 61 | |
|
62 | 62 | $ hg clone http://localhost:$HGPORT1/ copy-pull |
|
63 | 63 | requesting all changes |
|
64 | 64 | adding changesets |
|
65 | 65 | adding manifests |
|
66 | 66 | adding file changes |
|
67 | 67 | added 1 changesets with 4 changes to 4 files |
|
68 | 68 | updating to branch default |
|
69 | 69 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
70 | 70 | $ hg verify -R copy-pull |
|
71 | 71 | checking changesets |
|
72 | 72 | checking manifests |
|
73 | 73 | crosschecking files in changesets and manifests |
|
74 | 74 | checking files |
|
75 | 75 | 4 files, 1 changesets, 4 total revisions |
|
76 | 76 | $ cd test |
|
77 | 77 | $ echo bar > bar |
|
78 | 78 | $ hg commit -A -d '1 0' -m 2 |
|
79 | 79 | adding bar |
|
80 | 80 | $ cd .. |
|
81 | 81 | |
|
82 | 82 | clone over http with --update |
|
83 | 83 | |
|
84 | 84 | $ hg clone http://localhost:$HGPORT1/ updated --update 0 |
|
85 | 85 | requesting all changes |
|
86 | 86 | adding changesets |
|
87 | 87 | adding manifests |
|
88 | 88 | adding file changes |
|
89 | 89 | added 2 changesets with 5 changes to 5 files |
|
90 | 90 | updating to branch default |
|
91 | 91 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
92 | 92 | $ hg log -r . -R updated |
|
93 | 93 | changeset: 0:8b6053c928fe |
|
94 | 94 | user: test |
|
95 | 95 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
96 | 96 | summary: 1 |
|
97 | 97 | |
|
98 | 98 | $ rm -rf updated |
|
99 | 99 | |
|
100 | 100 | incoming via HTTP |
|
101 | 101 | |
|
102 | 102 | $ hg clone http://localhost:$HGPORT1/ --rev 0 partial |
|
103 | 103 | adding changesets |
|
104 | 104 | adding manifests |
|
105 | 105 | adding file changes |
|
106 | 106 | added 1 changesets with 4 changes to 4 files |
|
107 | 107 | updating to branch default |
|
108 | 108 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
109 | 109 | $ cd partial |
|
110 | 110 | $ touch LOCAL |
|
111 | 111 | $ hg ci -qAm LOCAL |
|
112 | 112 | $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n' |
|
113 | 113 | comparing with http://localhost:$HGPORT1/ |
|
114 | 114 | searching for changes |
|
115 | 115 | 2 |
|
116 | 116 | $ cd .. |
|
117 | 117 | |
|
118 | 118 | pull |
|
119 | 119 | |
|
120 | 120 | $ cd copy-pull |
|
121 | 121 | $ echo '[hooks]' >> .hg/hgrc |
|
122 | 122 | $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup" >> .hg/hgrc |
|
123 | 123 | $ hg pull |
|
124 | 124 | pulling from http://localhost:$HGPORT1/ |
|
125 | 125 | searching for changes |
|
126 | 126 | adding changesets |
|
127 | 127 | adding manifests |
|
128 | 128 | adding file changes |
|
129 | 129 | added 1 changesets with 1 changes to 1 files |
|
130 | 130 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=http://localhost:$HGPORT1/ (glob) |
|
131 | 131 | (run 'hg update' to get a working copy) |
|
132 | 132 | $ cd .. |
|
133 | 133 | |
|
134 | 134 | clone from invalid URL |
|
135 | 135 | |
|
136 | 136 | $ hg clone http://localhost:$HGPORT/bad |
|
137 | 137 | abort: HTTP Error 404: Not Found |
|
138 | 138 | [255] |
|
139 | 139 | |
|
140 | 140 | test http authentication |
|
141 | 141 | + use the same server to test server side streaming preference |
|
142 | 142 | |
|
143 | 143 | $ cd test |
|
144 | 144 | $ cat << EOT > userpass.py |
|
145 | 145 | > import base64 |
|
146 | 146 | > from mercurial.hgweb import common |
|
147 | 147 | > def perform_authentication(hgweb, req, op): |
|
148 | 148 | > auth = req.env.get('HTTP_AUTHORIZATION') |
|
149 | 149 | > if not auth: |
|
150 | 150 | > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, 'who', |
|
151 | 151 | > [('WWW-Authenticate', 'Basic Realm="mercurial"')]) |
|
152 | 152 | > if base64.b64decode(auth.split()[1]).split(':', 1) != ['user', 'pass']: |
|
153 | 153 | > raise common.ErrorResponse(common.HTTP_FORBIDDEN, 'no') |
|
154 | 154 | > def extsetup(): |
|
155 | 155 | > common.permhooks.insert(0, perform_authentication) |
|
156 | 156 | > EOT |
|
157 | 157 | $ hg --config extensions.x=userpass.py serve -p $HGPORT2 -d --pid-file=pid \ |
|
158 | 158 | > --config server.preferuncompressed=True \ |
|
159 | 159 | > --config web.push_ssl=False --config web.allow_push=* -A ../access.log |
|
160 | 160 | $ cat pid >> $DAEMON_PIDS |
|
161 | 161 | |
|
162 | 162 | $ cat << EOF > get_pass.py |
|
163 | 163 | > import getpass |
|
164 | 164 | > def newgetpass(arg): |
|
165 | 165 | > return "pass" |
|
166 | 166 | > getpass.getpass = newgetpass |
|
167 | 167 | > EOF |
|
168 | 168 | |
|
169 | #if python243 | |
|
170 | 169 | $ hg id http://localhost:$HGPORT2/ |
|
171 | 170 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
172 | 171 | [255] |
|
173 | 172 | $ hg id http://localhost:$HGPORT2/ |
|
174 | 173 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
175 | 174 | [255] |
|
176 | 175 | $ hg id --config ui.interactive=true --config extensions.getpass=get_pass.py http://user@localhost:$HGPORT2/ |
|
177 | 176 | http authorization required for http://localhost:$HGPORT2/ |
|
178 | 177 | realm: mercurial |
|
179 | 178 | user: user |
|
180 | 179 | password: 5fed3813f7f5 |
|
181 | 180 | $ hg id http://user:pass@localhost:$HGPORT2/ |
|
182 | 181 | 5fed3813f7f5 |
|
183 | #endif | |
|
184 | 182 | $ echo '[auth]' >> .hg/hgrc |
|
185 | 183 | $ echo 'l.schemes=http' >> .hg/hgrc |
|
186 | 184 | $ echo 'l.prefix=lo' >> .hg/hgrc |
|
187 | 185 | $ echo 'l.username=user' >> .hg/hgrc |
|
188 | 186 | $ echo 'l.password=pass' >> .hg/hgrc |
|
189 | 187 | $ hg id http://localhost:$HGPORT2/ |
|
190 | 188 | 5fed3813f7f5 |
|
191 | 189 | $ hg id http://localhost:$HGPORT2/ |
|
192 | 190 | 5fed3813f7f5 |
|
193 | 191 | $ hg id http://user@localhost:$HGPORT2/ |
|
194 | 192 | 5fed3813f7f5 |
|
195 | #if python243 | |
|
196 | 193 | $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1 |
|
197 | 194 | streaming all changes |
|
198 | 195 | 7 files to transfer, 916 bytes of data |
|
199 | 196 | transferred * bytes in * seconds (*/sec) (glob) |
|
200 | 197 | searching for changes |
|
201 | 198 | no changes found |
|
202 | 199 | updating to branch default |
|
203 | 200 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
204 | 201 | --pull should override server's preferuncompressed |
|
205 | 202 | $ hg clone --pull http://user:pass@localhost:$HGPORT2/ dest-pull 2>&1 |
|
206 | 203 | requesting all changes |
|
207 | 204 | adding changesets |
|
208 | 205 | adding manifests |
|
209 | 206 | adding file changes |
|
210 | 207 | added 2 changesets with 5 changes to 5 files |
|
211 | 208 | updating to branch default |
|
212 | 209 | 5 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
213 | 210 | |
|
214 | 211 | $ hg id http://user2@localhost:$HGPORT2/ |
|
215 | 212 | abort: http authorization required for http://localhost:$HGPORT2/ |
|
216 | 213 | [255] |
|
217 | 214 | $ hg id http://user:pass2@localhost:$HGPORT2/ |
|
218 | 215 | abort: HTTP Error 403: no |
|
219 | 216 | [255] |
|
220 | 217 | |
|
221 | 218 | $ hg -R dest tag -r tip top |
|
222 | 219 | $ hg -R dest push http://user:pass@localhost:$HGPORT2/ |
|
223 | 220 | pushing to http://user:***@localhost:$HGPORT2/ |
|
224 | 221 | searching for changes |
|
225 | 222 | remote: adding changesets |
|
226 | 223 | remote: adding manifests |
|
227 | 224 | remote: adding file changes |
|
228 | 225 | remote: added 1 changesets with 1 changes to 1 files |
|
229 | 226 | $ hg rollback -q |
|
230 | 227 | |
|
231 | 228 | $ cut -c38- ../access.log |
|
232 | 229 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
233 | 230 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
234 | 231 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
235 | 232 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
236 | 233 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
237 | 234 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
238 | 235 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
239 | 236 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
240 | 237 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
241 | 238 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces |
|
242 | 239 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
243 | 240 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
244 | 241 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
245 | 242 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
246 | 243 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces |
|
247 | 244 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
248 | 245 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
249 | 246 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
250 | 247 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
251 | 248 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces |
|
252 | 249 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
253 | 250 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
254 | 251 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
255 | 252 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
256 | 253 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces |
|
257 | 254 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
258 | 255 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
259 | 256 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
260 | 257 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
261 | 258 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces |
|
262 | 259 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
263 | 260 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
264 | 261 | "GET /?cmd=branchmap HTTP/1.1" 200 - |
|
265 | 262 | "GET /?cmd=stream_out HTTP/1.1" 401 - |
|
266 | 263 | "GET /?cmd=stream_out HTTP/1.1" 200 - |
|
267 | 264 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
268 | 265 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D5fed3813f7f5e1824344fdc9cf8f63bb662c292d |
|
269 | 266 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases |
|
270 | 267 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
271 | 268 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks |
|
272 | 269 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
273 | 270 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D |
|
274 | 271 | "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=5fed3813f7f5e1824344fdc9cf8f63bb662c292d |
|
275 | 272 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases |
|
276 | 273 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
277 | 274 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
278 | 275 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
279 | 276 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
280 | 277 | "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip |
|
281 | 278 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces |
|
282 | 279 | "GET /?cmd=listkeys HTTP/1.1" 403 - x-hgarg-1:namespace=namespaces |
|
283 | 280 | "GET /?cmd=capabilities HTTP/1.1" 200 - |
|
284 | 281 | "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D7f4e523d01f2cc3765ac8934da3d14db775ff872 |
|
285 | 282 | "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=phases |
|
286 | 283 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases |
|
287 | 284 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
288 | 285 | "GET /?cmd=branchmap HTTP/1.1" 200 - |
|
289 | 286 | "GET /?cmd=branchmap HTTP/1.1" 200 - |
|
290 | 287 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks |
|
291 | 288 | "POST /?cmd=unbundle HTTP/1.1" 200 - x-hgarg-1:heads=686173686564+5eb5abfefeea63c80dd7553bcc3783f37e0c5524 |
|
292 | 289 | "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=phases |
|
293 | 290 | |
|
294 | #endif | |
|
295 | 291 | $ cd .. |
|
296 | 292 | |
|
297 | 293 | clone of serve with repo in root and unserved subrepo (issue2970) |
|
298 | 294 | |
|
299 | 295 | $ hg --cwd test init sub |
|
300 | 296 | $ echo empty > test/sub/empty |
|
301 | 297 | $ hg --cwd test/sub add empty |
|
302 | 298 | $ hg --cwd test/sub commit -qm 'add empty' |
|
303 | 299 | $ hg --cwd test/sub tag -r 0 something |
|
304 | 300 | $ echo sub = sub > test/.hgsub |
|
305 | 301 | $ hg --cwd test add .hgsub |
|
306 | 302 | $ hg --cwd test commit -qm 'add subrepo' |
|
307 | 303 | $ hg clone http://localhost:$HGPORT noslash-clone |
|
308 | 304 | requesting all changes |
|
309 | 305 | adding changesets |
|
310 | 306 | adding manifests |
|
311 | 307 | adding file changes |
|
312 | 308 | added 3 changesets with 7 changes to 7 files |
|
313 | 309 | updating to branch default |
|
314 | 310 | abort: HTTP Error 404: Not Found |
|
315 | 311 | [255] |
|
316 | 312 | $ hg clone http://localhost:$HGPORT/ slash-clone |
|
317 | 313 | requesting all changes |
|
318 | 314 | adding changesets |
|
319 | 315 | adding manifests |
|
320 | 316 | adding file changes |
|
321 | 317 | added 3 changesets with 7 changes to 7 files |
|
322 | 318 | updating to branch default |
|
323 | 319 | abort: HTTP Error 404: Not Found |
|
324 | 320 | [255] |
|
325 | 321 | |
|
326 | 322 | check error log |
|
327 | 323 | |
|
328 | 324 | $ cat error.log |
General Comments 0
You need to be logged in to leave comments.
Login now