annotate tests/test-context.py @ 34980:705d0f2bb677 stable

pathutil: add doctests for canonpath() This is a followup to f445b10dc7fb. Since there's no way to ensure that more drive letters than C: exist, this seems like the only way to test it. This is enough to catch the f445b10dc7fb scenario, as well as CWD outside of the repo when the path isn't prefixed with path/to/repo.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 03 Nov 2017 22:22:50 -0400
parents af20468eb0a4
children 8a0cac20a1ad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
1 from __future__ import absolute_import, print_function
4110
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
2 import os
32518
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
3 from mercurial.node import hex
28735
5edde05ff58e py3: use absolute_import in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27056
diff changeset
4 from mercurial import (
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
5 context,
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
6 encoding,
28735
5edde05ff58e py3: use absolute_import in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27056
diff changeset
7 hg,
32518
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
8 scmutil,
28775
67bff672ccc2 tests: alias ui as uimod in test-context
Yuya Nishihara <yuya@tcha.org>
parents: 28738
diff changeset
9 ui as uimod,
28735
5edde05ff58e py3: use absolute_import in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27056
diff changeset
10 )
4110
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
11
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 29187
diff changeset
12 u = uimod.ui.load()
4110
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
13
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
14 repo = hg.repository(u, 'test1', create=1)
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
15 os.chdir('test1')
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
16
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
17 # create 'foo' with fixed time stamp
23060
4eaea93b3e5b tests: open file in binary mode to use POSIX end-of-line style anywhere
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21837
diff changeset
18 f = open('foo', 'wb')
29187
aec5d8561be2 tests: mark test-context.py write as binary
timeless <timeless@mozdev.org>
parents: 28775
diff changeset
19 f.write(b'foo\n')
4110
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
20 f.close()
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
21 os.utime('foo', (1000, 1000))
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
22
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
23 # add+commit 'foo'
11303
a1aad8333864 move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 9031
diff changeset
24 repo[None].add(['foo'])
4110
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
25 repo.commit(text='commit1', date="0 0")
20af6a2f0b0e Fixed workingfilectx.date() (found by Thomas Waldmann) with test.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
26
33751
3889cf955a62 hg: tolerate long vs. int in test-context.py
Tristan Seligmann <mithrandi@mithrandi.net>
parents: 32518
diff changeset
27 d = repo[None]['foo'].date()
27056
01489fa0bbbe test-context: conditionalize the workingfilectx date printing for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 24180
diff changeset
28 if os.name == 'nt':
33751
3889cf955a62 hg: tolerate long vs. int in test-context.py
Tristan Seligmann <mithrandi@mithrandi.net>
parents: 32518
diff changeset
29 d = d[:2]
3889cf955a62 hg: tolerate long vs. int in test-context.py
Tristan Seligmann <mithrandi@mithrandi.net>
parents: 32518
diff changeset
30 print("workingfilectx.date = (%d, %d)" % d)
14379
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
31
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
32 # test memctx with non-ASCII commit message
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
33
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
34 def filectxfn(repo, memctx, path):
21689
503bb3af70fe memfilectx: call super.__init__ instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 14379
diff changeset
35 return context.memfilectx(repo, "foo", "")
14379
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
36
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
37 ctx = context.memctx(repo, ['tip', None],
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
38 encoding.tolocal("Gr\xc3\xbcezi!"),
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
39 ["foo"], filectxfn)
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
40 ctx.commit()
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
41 for enc in "ASCII", "Latin-1", "UTF-8":
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
42 encoding.encoding = enc
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
43 print("%-8s: %s" % (enc, repo["tip"].description()))
21836
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
44
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
45 # test performing a status
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
46
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
47 def getfilectx(repo, memctx, f):
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
48 fctx = memctx.parents()[0][f]
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
49 data, flags = fctx.data(), fctx.flags()
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
50 if f == 'foo':
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
51 data += 'bar\n'
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
52 return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags)
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
53
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
54 ctxa = repo.changectx(0)
21837
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
55 ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
56 getfilectx, ctxa.user(), ctxa.date())
21836
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
57
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
58 print(ctxb.status(ctxa))
21837
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
59
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
60 # test performing a diff on a memctx
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
61
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
62 for d in ctxb.diff(ctxa, git=True):
31270
59aec562a50b test: end printed diff "hunks" with an empty string in test-context.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 30559
diff changeset
63 print(d, end='')
23700
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
64
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23712
diff changeset
65 # test safeness and correctness of "ctx.status()"
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
66 print('= checking context.status():')
23700
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
67
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
68 # ancestor "wcctx ~ 2"
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
69 actx2 = repo['.']
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
70
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
71 repo.wwrite('bar-m', 'bar-m\n', '')
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
72 repo.wwrite('bar-r', 'bar-r\n', '')
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
73 repo[None].add(['bar-m', 'bar-r'])
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
74 repo.commit(text='add bar-m, bar-r', date="0 0")
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
75
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
76 # ancestor "wcctx ~ 1"
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
77 actx1 = repo['.']
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
78
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
79 repo.wwrite('bar-m', 'bar-m bar-m\n', '')
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
80 repo.wwrite('bar-a', 'bar-a\n', '')
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
81 repo[None].add(['bar-a'])
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
82 repo[None].forget(['bar-r'])
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
83
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
84 # status at this point:
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
85 # M bar-m
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
86 # A bar-a
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
87 # R bar-r
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
88 # C foo
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
89
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
90 from mercurial import scmutil
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
91
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
92 print('== checking workingctx.status:')
23700
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
93
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
94 wctx = repo[None]
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
95 print('wctx._status=%s' % (str(wctx._status)))
23700
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
96
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
97 print('=== with "pattern match":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
98 print(actx1.status(other=wctx,
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
99 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
100 print('wctx._status=%s' % (str(wctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
101 print(actx2.status(other=wctx,
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
102 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
103 print('wctx._status=%s' % (str(wctx._status)))
23709
33e5431684c0 context: make unknown/ignored/clean of cached status empty for equivalence
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23700
diff changeset
104
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
105 print('=== with "always match" and "listclean=True":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
106 print(actx1.status(other=wctx, listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
107 print('wctx._status=%s' % (str(wctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
108 print(actx2.status(other=wctx, listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
109 print('wctx._status=%s' % (str(wctx._status)))
23711
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
110
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
111 print("== checking workingcommitctx.status:")
23711
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
112
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
113 wcctx = context.workingcommitctx(repo,
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
114 scmutil.status(['bar-m'],
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
115 ['bar-a'],
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
116 [],
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
117 [], [], [], []),
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
118 text='', date='0 0')
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
119 print('wcctx._status=%s' % (str(wcctx._status)))
23711
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
120
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
121 print('=== with "always match":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
122 print(actx1.status(other=wcctx))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
123 print('wcctx._status=%s' % (str(wcctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
124 print(actx2.status(other=wcctx))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
125 print('wcctx._status=%s' % (str(wcctx._status)))
23711
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
126
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
127 print('=== with "always match" and "listclean=True":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
128 print(actx1.status(other=wcctx, listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
129 print('wcctx._status=%s' % (str(wcctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
130 print(actx2.status(other=wcctx, listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
131 print('wcctx._status=%s' % (str(wcctx._status)))
23712
bfce25d25c96 context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23711
diff changeset
132
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
133 print('=== with "pattern match":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
134 print(actx1.status(other=wcctx,
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
135 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
136 print('wcctx._status=%s' % (str(wcctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
137 print(actx2.status(other=wcctx,
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
138 match=scmutil.matchfiles(repo, ['bar-m', 'foo'])))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
139 print('wcctx._status=%s' % (str(wcctx._status)))
23712
bfce25d25c96 context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23711
diff changeset
140
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
141 print('=== with "pattern match" and "listclean=True":')
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
142 print(actx1.status(other=wcctx,
23712
bfce25d25c96 context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23711
diff changeset
143 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
144 listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
145 print('wcctx._status=%s' % (str(wcctx._status)))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
146 print(actx2.status(other=wcctx,
23712
bfce25d25c96 context: override _dirstatestatus in workingcommitctx for correct matching
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23711
diff changeset
147 match=scmutil.matchfiles(repo, ['bar-r', 'foo']),
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
148 listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
149 print('wcctx._status=%s' % (str(wcctx._status)))
32518
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
150
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
151 os.chdir('..')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
152
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
153 # test manifestlog being changed
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
154 print('== commit with manifestlog invalidated')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
155
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
156 repo = hg.repository(u, 'test2', create=1)
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
157 os.chdir('test2')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
158
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
159 # make some commits
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
160 for i in [b'1', b'2', b'3']:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
161 with open(i, 'wb') as f:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
162 f.write(i)
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
163 status = scmutil.status([], [i], [], [], [], [], [])
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
164 ctx = context.workingcommitctx(repo, status, text=i, user=b'test@test.com',
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
165 date=(0, 0))
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
166 ctx.p1().manifest() # side effect: cache manifestctx
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
167 n = repo.commitctx(ctx)
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
168 print('commit %s: %s' % (i, hex(n)))
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
169
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
170 # touch 00manifest.i mtime so storecache could expire.
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
171 # repo.__dict__['manifestlog'] is deleted by transaction releasefn.
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
172 st = repo.svfs.stat('00manifest.i')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
173 repo.svfs.utime('00manifest.i', (st.st_mtime + 1, st.st_mtime + 1))
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
174
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
175 # read the file just committed
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
176 try:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
177 if repo[n][i].data() != i:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
178 print('data mismatch')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
179 except Exception as ex:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
180 print('cannot read data: %r' % ex)
33706
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
181
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
182 with repo.wlock(), repo.lock(), repo.transaction('test'):
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
183 with open(b'4', 'wb') as f:
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
184 f.write(b'4')
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
185 repo.dirstate.normal('4')
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
186 repo.commit('4')
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
187 revsbefore = len(repo.changelog)
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
188 repo.invalidate(clearfilecache=True)
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
189 revsafter = len(repo.changelog)
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
190 if revsbefore != revsafter:
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
191 print('changeset lost by repo.invalidate()')