annotate tests/test-journal-share.t @ 29917:f32f8bf5dc4c

streamclone: force @filecache properties to be reloaded from file Before this patch, consumev1() invokes repo.invalidate() after closing transaction, to force @filecache properties to be reloaded from files at next access, because streamclone writes data into files directly. But this doesn't work as expected in the case below: 1. at closing transaction, repo._refreshfilecachestats() refreshes file stat of each @filecache properties with streamclone-ed files This means that in-memory properties are treated as valid. 2. but streamclone doesn't changes in-memory properties This means that in-memory properties are actually invalid. 3. repo.invalidate() just forces to examine file stat of @filecache properties at the first access after it Such examination should concludes that reloading from file isn't needed, because file stat was already refreshed at (1). Therefore, invalid in-memory cached properties (2) are unintentionally treated as valid (1). This patch invokes repo.invalidate() with clearfilecache=True, to force @filecache properties to be reloaded from file at next access. BTW, it is accidental that repo.invalidate() without clearfilecache=True in streamclone case seems to work as expected before this patch. If transaction is started via "filtered repo" object, repo._refreshfilecachestats() tries to refresh file stat of each @filecache properties on "filtered repo" object, even though all of them are stored into "unfiltered repo" object. In this case, repo._refreshfilecachestats() does nothing unintentionally, but this unexpected behavior causes reloading @filecache properties after repo.invalidate(). This is reason why this patch should be applied before making _refreshfilecachestats() correctly refresh file stat of @filecache properties.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 12 Sep 2016 03:06:28 +0900
parents 0103b673d6ca
children 9843e3d9f4b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29503
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
1 Journal extension test: tests the share extension support
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
3 $ cat >> testmocks.py << EOF
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
4 > # mock out util.getuser() and util.makedate() to supply testable values
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
5 > import os
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
6 > from mercurial import util
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
7 > def mockgetuser():
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
8 > return 'foobar'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
9 >
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
10 > def mockmakedate():
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
11 > filename = os.path.join(os.environ['TESTTMP'], 'testtime')
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
12 > try:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
13 > with open(filename, 'rb') as timef:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
14 > time = float(timef.read()) + 1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
15 > except IOError:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
16 > time = 0.0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
17 > with open(filename, 'wb') as timef:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
18 > timef.write(str(time))
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
19 > return (time, 0)
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
20 >
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
21 > util.getuser = mockgetuser
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
22 > util.makedate = mockmakedate
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
23 > EOF
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
24
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
25 $ cat >> $HGRCPATH << EOF
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
26 > [extensions]
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
27 > journal=
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
28 > share=
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
29 > testmocks=`pwd`/testmocks.py
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
30 > [remotenames]
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
31 > rename.default=remote
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
32 > EOF
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
33
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
34 $ hg init repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
35 $ cd repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
36 $ hg bookmark bm
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
37 $ touch file0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
38 $ hg commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
39 adding file0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
40 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
41 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
42 5640b525682e . commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
43 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
44
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
45 A shared working copy initially receives the same bookmarks and working copy
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
46
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
47 $ cd ..
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
48 $ hg share repo shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
49 updating working directory
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
51 $ cd shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
52 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
53 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
54 5640b525682e . share repo shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
55
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
56 unless you explicitly share bookmarks
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
57
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
58 $ cd ..
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
59 $ hg share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
60 updating working directory
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
61 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
62 $ cd shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
63 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
64 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
65 5640b525682e . share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
66 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
67
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
68 Moving the bookmark in the original repository is only shown in the repository
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
69 that shares bookmarks
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
70
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
71 $ cd ../repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
72 $ touch file1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
73 $ hg commit -Am "file1 added"
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
74 adding file1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
75 $ cd ../shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
76 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
77 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
78 5640b525682e . share repo shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
79 $ cd ../shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
80 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
81 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
82 6432d239ac5d bm commit -Am 'file1 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
83 5640b525682e . share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
84 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
85
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
86 But working copy changes are always 'local'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
87
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
88 $ cd ../repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
89 $ hg up 0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
90 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
91 (leaving bookmark bm)
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
92 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
93 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
94 5640b525682e . up 0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
95 6432d239ac5d . commit -Am 'file1 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
96 6432d239ac5d bm commit -Am 'file1 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
97 5640b525682e . commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
98 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
99 $ cd ../shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
100 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
101 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
102 6432d239ac5d bm commit -Am 'file1 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
103 5640b525682e . share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
104 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
105 $ hg up tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
106 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
107 $ hg up 0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
108 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
109 $ hg journal
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
110 previous locations of '.':
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
111 5640b525682e up 0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
112 6432d239ac5d up tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
113 5640b525682e share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
114
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
115 Unsharing works as expected; the journal remains consistent
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
116
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
117 $ cd ../shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
118 $ hg unshare
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
119 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
120 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
121 5640b525682e . share repo shared1
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
122 $ cd ../shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
123 $ hg unshare
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
124 $ hg journal --all
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
125 previous locations of the working copy and bookmarks:
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
126 5640b525682e . up 0
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
127 6432d239ac5d . up tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
128 6432d239ac5d bm commit -Am 'file1 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
129 5640b525682e . share --bookmarks repo shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
130 5640b525682e bm commit -Am 'file0 added'
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
131
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
132 New journal entries in the source repo no longer show up in the other working copies
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
133
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
134 $ cd ../repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
135 $ hg bookmark newbm -r tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
136 $ hg journal newbm
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
137 previous locations of 'newbm':
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
138 6432d239ac5d bookmark newbm -r tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
139 $ cd ../shared2
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
140 $ hg journal newbm
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
141 previous locations of 'newbm':
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
142 no recorded locations
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
143
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
144 This applies for both directions
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
145
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
146 $ hg bookmark shared2bm -r tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
147 $ hg journal shared2bm
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
148 previous locations of 'shared2bm':
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
149 6432d239ac5d bookmark shared2bm -r tip
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
150 $ cd ../repo
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
151 $ hg journal shared2bm
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
152 previous locations of 'shared2bm':
0103b673d6ca journal: add share extension support
Martijn Pieters <mjpieters@fb.com>
parents:
diff changeset
153 no recorded locations