Show More
@@ -61,8 +61,8 b' This command is ancient:' | |||||
61 | Verify that updating to revision 0 via commands.update() works properly |
|
61 | Verify that updating to revision 0 via commands.update() works properly | |
62 |
|
62 | |||
63 | $ cat <<EOF > update_to_rev0.py |
|
63 | $ cat <<EOF > update_to_rev0.py | |
64 |
> from mercurial import |
|
64 | > from mercurial import commands, hg, ui as uimod | |
65 | > myui = ui.ui.load() |
|
65 | > myui = uimod.ui.load() | |
66 | > repo = hg.repository(myui, path=b'.') |
|
66 | > repo = hg.repository(myui, path=b'.') | |
67 | > commands.update(myui, repo, rev=b"0") |
|
67 | > commands.update(myui, repo, rev=b"0") | |
68 | > EOF |
|
68 | > EOF |
@@ -351,7 +351,8 b' when using chg, blackbox.log should get ' | |||||
351 | $ chg noop |
|
351 | $ chg noop | |
352 |
|
352 | |||
353 | $ cat > showsize.py << 'EOF' |
|
353 | $ cat > showsize.py << 'EOF' | |
354 |
> import os |
|
354 | > import os | |
|
355 | > import sys | |||
355 | > limit = 500 |
|
356 | > limit = 500 | |
356 | > for p in sys.argv[1:]: |
|
357 | > for p in sys.argv[1:]: | |
357 | > size = os.stat(p).st_size |
|
358 | > size = os.stat(p).st_size |
@@ -934,7 +934,7 b' Test lazily acquiring the lock during un' | |||||
934 |
|
934 | |||
935 | $ cat >> $TESTTMP/locktester.py <<EOF |
|
935 | $ cat >> $TESTTMP/locktester.py <<EOF | |
936 | > import os |
|
936 | > import os | |
937 |
> from mercurial import |
|
937 | > from mercurial import bundle2, error, extensions | |
938 | > def checklock(orig, repo, *args, **kwargs): |
|
938 | > def checklock(orig, repo, *args, **kwargs): | |
939 | > if repo.svfs.lexists(b"lock"): |
|
939 | > if repo.svfs.lexists(b"lock"): | |
940 | > raise error.Abort(b"Lock should not be taken") |
|
940 | > raise error.Abort(b"Lock should not be taken") |
@@ -558,8 +558,8 b' Issue2267: Error in 1.6 hg.py: TypeError' | |||||
558 | iterable in addbranchrevs() |
|
558 | iterable in addbranchrevs() | |
559 |
|
559 | |||
560 | $ cat <<EOF > simpleclone.py |
|
560 | $ cat <<EOF > simpleclone.py | |
561 |
> from mercurial import |
|
561 | > from mercurial import hg, ui as uimod | |
562 | > myui = ui.ui.load() |
|
562 | > myui = uimod.ui.load() | |
563 | > repo = hg.repository(myui, b'a') |
|
563 | > repo = hg.repository(myui, b'a') | |
564 | > hg.clone(myui, {}, repo, dest=b"ua") |
|
564 | > hg.clone(myui, {}, repo, dest=b"ua") | |
565 | > EOF |
|
565 | > EOF | |
@@ -571,8 +571,8 b' iterable in addbranchrevs()' | |||||
571 | $ rm -r ua |
|
571 | $ rm -r ua | |
572 |
|
572 | |||
573 | $ cat <<EOF > branchclone.py |
|
573 | $ cat <<EOF > branchclone.py | |
574 |
> from mercurial import |
|
574 | > from mercurial import extensions, hg, ui as uimod | |
575 | > myui = ui.ui.load() |
|
575 | > myui = uimod.ui.load() | |
576 | > extensions.loadall(myui) |
|
576 | > extensions.loadall(myui) | |
577 | > repo = hg.repository(myui, b'a') |
|
577 | > repo = hg.repository(myui, b'a') | |
578 | > hg.clone(myui, {}, repo, dest=b"ua", branch=[b"stable",]) |
|
578 | > hg.clone(myui, {}, repo, dest=b"ua", branch=[b"stable",]) |
@@ -80,8 +80,8 b' transplant bug fixes onto release branch' | |||||
80 |
|
80 | |||
81 | now test that we fixed the bug for all scripts/extensions |
|
81 | now test that we fixed the bug for all scripts/extensions | |
82 | $ cat > $TESTTMP/committwice.py <<__EOF__ |
|
82 | $ cat > $TESTTMP/committwice.py <<__EOF__ | |
83 | > from mercurial import ui, hg, match, node |
|
83 | > import time | |
84 | > from time import sleep |
|
84 | > from mercurial import hg, match, node, ui as uimod | |
85 | > |
|
85 | > | |
86 | > def replacebyte(fn, b): |
|
86 | > def replacebyte(fn, b): | |
87 | > f = open(fn, "rb+") |
|
87 | > f = open(fn, "rb+") | |
@@ -94,12 +94,12 b' now test that we fixed the bug for all s' | |||||
94 | > % (rev, b', '.join(b"'%s'" % f |
|
94 | > % (rev, b', '.join(b"'%s'" % f | |
95 | > for f in repo[rev].files()))) |
|
95 | > for f in repo[rev].files()))) | |
96 | > |
|
96 | > | |
97 | > repo = hg.repository(ui.ui.load(), b'.') |
|
97 | > repo = hg.repository(uimod.ui.load(), b'.') | |
98 | > assert len(repo) == 6, \ |
|
98 | > assert len(repo) == 6, \ | |
99 | > "initial: len(repo): %d, expected: 6" % len(repo) |
|
99 | > "initial: len(repo): %d, expected: 6" % len(repo) | |
100 | > |
|
100 | > | |
101 | > replacebyte(b"bugfix", b"u") |
|
101 | > replacebyte(b"bugfix", b"u") | |
102 | > sleep(2) |
|
102 | > time.sleep(2) | |
103 | > try: |
|
103 | > try: | |
104 | > repo.ui.status(b"PRE: len(repo): %d\n" % len(repo)) |
|
104 | > repo.ui.status(b"PRE: len(repo): %d\n" % len(repo)) | |
105 | > wlock = repo.wlock() |
|
105 | > wlock = repo.wlock() |
@@ -342,7 +342,7 b' Test warning on config option access and' | |||||
342 | $ cat << EOF > ${TESTTMP}/buggyconfig.py |
|
342 | $ cat << EOF > ${TESTTMP}/buggyconfig.py | |
343 | > """A small extension that tests our developer warnings for config""" |
|
343 | > """A small extension that tests our developer warnings for config""" | |
344 | > |
|
344 | > | |
345 |
> from mercurial import |
|
345 | > from mercurial import configitems, registrar | |
346 | > |
|
346 | > | |
347 | > cmdtable = {} |
|
347 | > cmdtable = {} | |
348 | > command = registrar.command(cmdtable) |
|
348 | > command = registrar.command(cmdtable) |
@@ -278,9 +278,10 b' Test roundtrip encoding/decoding of utf8' | |||||
278 |
|
278 | |||
279 | #if hypothesis |
|
279 | #if hypothesis | |
280 |
|
280 | |||
281 |
>>> |
|
281 | >>> import hypothesishelpers | |
282 | >>> from mercurial import encoding |
|
282 | >>> from mercurial import encoding | |
283 | >>> roundtrips(st.binary(), encoding.fromutf8b, encoding.toutf8b) |
|
283 | >>> hypothesishelpers.roundtrips(hypothesishelpers.st.binary(), | |
|
284 | ... encoding.fromutf8b, encoding.toutf8b) | |||
284 | Round trip OK |
|
285 | Round trip OK | |
285 |
|
286 | |||
286 | #endif |
|
287 | #endif |
@@ -1266,7 +1266,8 b' Broken disabled extension and command:' | |||||
1266 | > "broken extension' |
|
1266 | > "broken extension' | |
1267 | > NO_CHECK_EOF |
|
1267 | > NO_CHECK_EOF | |
1268 | $ cat > path.py <<EOF |
|
1268 | $ cat > path.py <<EOF | |
1269 |
> import os |
|
1269 | > import os | |
|
1270 | > import sys | |||
1270 | > sys.path.insert(0, os.environ['HGEXTPATH']) |
|
1271 | > sys.path.insert(0, os.environ['HGEXTPATH']) | |
1271 | > EOF |
|
1272 | > EOF | |
1272 | $ HGEXTPATH=`pwd` |
|
1273 | $ HGEXTPATH=`pwd` |
@@ -285,7 +285,8 b' override commit message' | |||||
285 | $ rm -r b |
|
285 | $ rm -r b | |
286 |
|
286 | |||
287 | $ cat > mkmsg.py <<EOF |
|
287 | $ cat > mkmsg.py <<EOF | |
288 |
> import email.message |
|
288 | > import email.message | |
|
289 | > import sys | |||
289 | > msg = email.message.Message() |
|
290 | > msg = email.message.Message() | |
290 | > patch = open(sys.argv[1], 'rb').read() |
|
291 | > patch = open(sys.argv[1], 'rb').read() | |
291 | > msg.set_payload(b'email commit message\n' + patch) |
|
292 | > msg.set_payload(b'email commit message\n' + patch) | |
@@ -383,7 +384,8 b' subject: duplicate detection, removal of' | |||||
383 | The '---' tests the gitsendmail handling without proper mail headers |
|
384 | The '---' tests the gitsendmail handling without proper mail headers | |
384 |
|
385 | |||
385 | $ cat > mkmsg2.py <<EOF |
|
386 | $ cat > mkmsg2.py <<EOF | |
386 |
> import email.message |
|
387 | > import email.message | |
|
388 | > import sys | |||
387 | > msg = email.message.Message() |
|
389 | > msg = email.message.Message() | |
388 | > patch = open(sys.argv[1], 'rb').read() |
|
390 | > patch = open(sys.argv[1], 'rb').read() | |
389 | > msg.set_payload(b'email patch\n\nnext line\n---\n' + patch) |
|
391 | > msg.set_payload(b'email patch\n\nnext line\n---\n' + patch) | |
@@ -1871,8 +1873,8 b' Importing some extra header' | |||||
1871 | =========================== |
|
1873 | =========================== | |
1872 |
|
1874 | |||
1873 | $ cat > $TESTTMP/parseextra.py <<EOF |
|
1875 | $ cat > $TESTTMP/parseextra.py <<EOF | |
|
1876 | > import mercurial.cmdutil | |||
1874 | > import mercurial.patch |
|
1877 | > import mercurial.patch | |
1875 | > import mercurial.cmdutil |
|
|||
1876 | > |
|
1878 | > | |
1877 | > def processfoo(repo, data, extra, opts): |
|
1879 | > def processfoo(repo, data, extra, opts): | |
1878 | > if b'foo' in data: |
|
1880 | > if b'foo' in data: |
@@ -153,7 +153,9 b' not found (this is intentionally using b' | |||||
153 | $ . "$TESTDIR/helpers-testrepo.sh" |
|
153 | $ . "$TESTDIR/helpers-testrepo.sh" | |
154 |
|
154 | |||
155 | $ cat >> wixxml.py << EOF |
|
155 | $ cat >> wixxml.py << EOF | |
156 |
> import os |
|
156 | > import os | |
|
157 | > import subprocess | |||
|
158 | > import sys | |||
157 | > import xml.etree.ElementTree as ET |
|
159 | > import xml.etree.ElementTree as ET | |
158 | > |
|
160 | > | |
159 | > # MSYS mangles the path if it expands $TESTDIR |
|
161 | > # MSYS mangles the path if it expands $TESTDIR |
@@ -22,9 +22,9 b'' | |||||
22 | o c0 |
|
22 | o c0 | |
23 |
|
23 | |||
24 |
|
24 | |||
25 |
>>> from mercurial |
|
25 | >>> from mercurial import hg | |
26 |
>>> from mercurial |
|
26 | >>> from mercurial import ui as uimod | |
27 | >>> repo = repository(ui()) |
|
27 | >>> repo = hg.repository(uimod.ui()) | |
28 | >>> for anc in repo.changelog.ancestors([4], inclusive=True): |
|
28 | >>> for anc in repo.changelog.ancestors([4], inclusive=True): | |
29 | ... print(anc) |
|
29 | ... print(anc) | |
30 | 4 |
|
30 | 4 |
@@ -3,7 +3,7 b' Tests for the journal extension; records' | |||||
3 | $ cat >> testmocks.py << EOF |
|
3 | $ cat >> testmocks.py << EOF | |
4 | > # mock out procutil.getuser() and util.makedate() to supply testable values |
|
4 | > # mock out procutil.getuser() and util.makedate() to supply testable values | |
5 | > import os |
|
5 | > import os | |
6 |
> from mercurial import |
|
6 | > from mercurial import pycompat, util | |
7 | > from mercurial.utils import dateutil, procutil |
|
7 | > from mercurial.utils import dateutil, procutil | |
8 | > def mockgetuser(): |
|
8 | > def mockgetuser(): | |
9 | > return b'foobar' |
|
9 | > return b'foobar' |
@@ -244,7 +244,7 b' pager is globally set to off using a fla' | |||||
244 | Pager should not override the exit code of other commands |
|
244 | Pager should not override the exit code of other commands | |
245 |
|
245 | |||
246 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' |
|
246 | $ cat >> $TESTTMP/fortytwo.py <<'EOF' | |
247 |
> from mercurial import |
|
247 | > from mercurial import commands, registrar | |
248 | > cmdtable = {} |
|
248 | > cmdtable = {} | |
249 | > command = registrar.command(cmdtable) |
|
249 | > command = registrar.command(cmdtable) | |
250 | > @command(b'fortytwo', [], b'fortytwo', norepo=True) |
|
250 | > @command(b'fortytwo', [], b'fortytwo', norepo=True) |
@@ -27,8 +27,7 b' We approximate that by reducing the read' | |||||
27 |
|
27 | |||
28 | $ cat >> test.py << EOF |
|
28 | $ cat >> test.py << EOF | |
29 | > from __future__ import print_function |
|
29 | > from __future__ import print_function | |
30 | > from mercurial import changelog, vfs |
|
30 | > from mercurial import changelog, node, vfs | |
31 | > from mercurial.node import * |
|
|||
32 | > |
|
31 | > | |
33 | > class singlebyteread(object): |
|
32 | > class singlebyteread(object): | |
34 | > def __init__(self, real): |
|
33 | > def __init__(self, real): | |
@@ -59,7 +58,7 b' We approximate that by reducing the read' | |||||
59 | > cl = changelog.changelog(opener('.hg/store')) |
|
58 | > cl = changelog.changelog(opener('.hg/store')) | |
60 | > print(len(cl), 'revisions:') |
|
59 | > print(len(cl), 'revisions:') | |
61 | > for r in cl: |
|
60 | > for r in cl: | |
62 | > print(short(cl.node(r))) |
|
61 | > print(node.short(cl.node(r))) | |
63 | > EOF |
|
62 | > EOF | |
64 | $ "$PYTHON" test.py |
|
63 | $ "$PYTHON" test.py | |
65 | 2 revisions: |
|
64 | 2 revisions: |
@@ -41,8 +41,8 b' utility to run the test - start a push i' | |||||
41 | python hook |
|
41 | python hook | |
42 |
|
42 | |||
43 | $ cat <<EOF > reject.py |
|
43 | $ cat <<EOF > reject.py | |
44 |
> import os |
|
44 | > import os | |
45 | > from mercurial import ui, localrepo |
|
45 | > import time | |
46 | > def rejecthook(ui, repo, hooktype, node, **opts): |
|
46 | > def rejecthook(ui, repo, hooktype, node, **opts): | |
47 | > ui.write(b'hook %s\\n' % repo[b'tip'].hex()) |
|
47 | > ui.write(b'hook %s\\n' % repo[b'tip'].hex()) | |
48 | > # create the notify file so caller knows we're running |
|
48 | > # create the notify file so caller knows we're running |
@@ -66,7 +66,7 b' Install an extension that can sleep and ' | |||||
66 |
|
66 | |||
67 | $ cat >> sleepext.py << EOF |
|
67 | $ cat >> sleepext.py << EOF | |
68 | > import time |
|
68 | > import time | |
69 |
> from mercurial import registrar |
|
69 | > from mercurial import registrar | |
70 | > cmdtable = {} |
|
70 | > cmdtable = {} | |
71 | > command = registrar.command(cmdtable) |
|
71 | > command = registrar.command(cmdtable) | |
72 | > @command(b'sleep', [], b'hg sleep') |
|
72 | > @command(b'sleep', [], b'hg sleep') |
@@ -50,7 +50,8 b' delete an untracked file' | |||||
50 | $ touch untracked_file |
|
50 | $ touch untracked_file | |
51 | $ touch untracked_file_readonly |
|
51 | $ touch untracked_file_readonly | |
52 | $ "$PYTHON" <<EOF |
|
52 | $ "$PYTHON" <<EOF | |
53 |
> import os |
|
53 | > import os | |
|
54 | > import stat | |||
54 | > f= 'untracked_file_readonly' |
|
55 | > f= 'untracked_file_readonly' | |
55 | > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE) |
|
56 | > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE) | |
56 | > EOF |
|
57 | > EOF |
General Comments 0
You need to be logged in to leave comments.
Login now