annotate tests/test-context.py @ 33782:40739aef97f7

label: rename trouble.X into instability.X The renaming is done according to https://www.mercurial-scm.org/wiki/CEDVocabulary. Differential Revision: https://phab.mercurial-scm.org/D258
author Boris Feld <boris.feld@octobus.net>
date Thu, 03 Aug 2017 15:30:41 +0200
parents 01a1c4e66816
children af20468eb0a4
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
27056
01489fa0bbbe test-context: conditionalize the workingfilectx date printing for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 24180
diff changeset
27 if os.name == 'nt':
01489fa0bbbe test-context: conditionalize the workingfilectx date printing for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 24180
diff changeset
28 d = repo[None]['foo'].date()
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
29 print("workingfilectx.date = (%d, %d)" % (d[0], d[1]))
27056
01489fa0bbbe test-context: conditionalize the workingfilectx date printing for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 24180
diff changeset
30 else:
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
31 print("workingfilectx.date =", repo[None]['foo'].date())
14379
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
32
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
33 # 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
34
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
35 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
36 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
37
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
38 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
39 encoding.tolocal("Gr\xc3\xbcezi!"),
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
40 ["foo"], filectxfn)
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
41 ctx.commit()
bd23d5f28bbb changelog: convert user and desc from local encoding early
Martin Geisler <mg@aragost.com>
parents: 11303
diff changeset
42 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
43 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
44 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
45
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
46 # test performing a status
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
47
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
48 def getfilectx(repo, memctx, f):
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
49 fctx = memctx.parents()[0][f]
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
50 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
51 if f == 'foo':
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
52 data += 'bar\n'
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
53 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
54
232038a05fdb test-context: add test for memctx status
Sean Farley <sean.michael.farley@gmail.com>
parents: 21689
diff changeset
55 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
56 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
57 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
58
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
59 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
60
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
61 # 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
62
61b333b982ea test-context: add test for performing a diff on a memctx
Sean Farley <sean.michael.farley@gmail.com>
parents: 21836
diff changeset
63 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
64 print(d, end='')
23700
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
65
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23712
diff changeset
66 # 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
67 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
68
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
69 # ancestor "wcctx ~ 2"
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
70 actx2 = repo['.']
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
71
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
72 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
73 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
74 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
75 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
76
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
77 # ancestor "wcctx ~ 1"
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
78 actx1 = repo['.']
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
79
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
80 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
81 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
82 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
83 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
84
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
85 # status at this point:
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
86 # M bar-m
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
87 # A bar-a
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
88 # R bar-r
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
89 # C foo
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
90
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
91 from mercurial import scmutil
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
92
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
93 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
94
a4958cdb2202 context: cache self._status correctly at workingctx.status
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23060
diff changeset
95 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
96 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
97
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
106 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
107 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
108 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
109 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
110 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
111
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
112 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
113
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
114 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
115 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
116 ['bar-a'],
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 [], [], [], []),
1e6fb8db666e context: avoid breaking already fixed self._status at ctx.status()
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23709
diff changeset
119 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
120 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
121
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
122 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
123 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
124 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
125 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
126 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
127
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
128 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
129 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
130 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
131 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
132 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
133
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141
28738
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
142 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
143 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
144 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
145 listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
146 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
147 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
148 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
149 listclean=True))
706f4ab710c8 py3: lexicographical order imports and print_function in test-context.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28735
diff changeset
150 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
151
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
152 os.chdir('..')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
153
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
154 # test manifestlog being changed
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
155 print('== commit with manifestlog invalidated')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
156
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
157 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
158 os.chdir('test2')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
159
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
160 # make some commits
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
161 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
162 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
163 f.write(i)
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
164 status = scmutil.status([], [i], [], [], [], [], [])
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
165 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
166 date=(0, 0))
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
167 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
168 n = repo.commitctx(ctx)
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
169 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
170
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
171 # 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
172 # 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
173 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
174 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
175
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
176 # read the file just committed
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
177 try:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
178 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
179 print('data mismatch')
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
180 except Exception as ex:
bb628fc85b0e test-context: add a case demonstrating manifest caching problem
Jun Wu <quark@fb.com>
parents: 31270
diff changeset
181 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
182
01a1c4e66816 repo: skip invalidation of changelog if it has 'delayed' changes (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 32518
diff changeset
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 print('changeset lost by repo.invalidate()')