Kiln » Kiln Extensions
Clone URL:  
test-forget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env python # Test remove import os import common hgt = common.BfilesTester() def rejoin(path): '''convert unix path to local convention''' return os.path.join(*path.split('/')) # add size and patterns for adding as bfiles hgt.updaterc({'bfiles': [('size', '2'), ('patterns', 'glob:**.dat')]}) hgt.announce('setup') os.mkdir('repo1') os.chdir('repo1') hgt.hg(['init', '-q']) hgt.writefile('normal1', 'foo') os.mkdir('sub') hgt.writefile('sub/normal2', 'bar') hgt.writefile('sub/normal3.txt', 'bar2') hgt.writefile('sub/normal4.txt', 'bar3') hgt.hg(['add', '-q', 'normal1', rejoin('sub/normal2'), rejoin('sub/normal3.txt'), rejoin('sub/normal4.txt')]) hgt.hg(['commit', '-m', 'add normal files']) hgt.announce('add bfiles') hgt.writefile('big1', 'abc') hgt.writefile('sub/big2', 'xyz') hgt.writefile('sub/big3.txt', 'xyz') hgt.hg(['add', '-q', '--bf', 'big1', rejoin('sub/big2'), rejoin('sub/big3.txt')]) hgt.hg(['commit', '-m', 'added bfiles']) hgt.announce('forget sub/*.txt') hgt.hg(['forget', 'glob:sub/*.txt'], stdout=('removing sub/normal3.txt\n' 'removing sub/normal4.txt\n' 'removing sub/big3.txt\n')) hgt.asserttrue(os.path.exists('sub/normal3.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal4.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big3.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('normal1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal2'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('big1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big2'), 'added file doesnt exist') hgt.hg(['status'], stdout=('R sub/big3.txt\n' 'R sub/normal3.txt\n' 'R sub/normal4.txt\n')) hgt.hg(['commit', '-m', 'forget bfiles']) os.unlink('sub/normal3.txt') os.unlink('sub/normal4.txt') os.unlink('sub/big3.txt') hgt.announce('test update') hgt.hg(['up', '-r', '1'], stdout=('3 files updated, 0 files merged, 0 files removed, 0 files unresolved\n' 'getting changed bfiles\n' '1 big files updated, 0 removed\n')) hgt.asserttrue(os.path.exists('sub/normal3.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal4.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big3.txt'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('normal1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal2'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('big1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big2'), 'added file doesnt exist') hgt.hg(['up'], stdout=('0 files updated, 0 files merged, 3 files removed, 0 files unresolved\n' 'getting changed bfiles\n' '0 big files updated, 1 removed\n')) hgt.assertfalse(os.path.exists('sub/normal3.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/normal4.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/big3.txt'), 'removed file exists') hgt.asserttrue(os.path.exists('normal1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal2'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('big1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big2'), 'added file doesnt exist') hgt.announce('forget single normal files') hgt.hg(['forget', 'normal1']) hgt.hg(['forget', 'sub/normal2']) hgt.assertfalse(os.path.exists('sub/normal3.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/normal4.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/big3.txt'), 'removed file exists') hgt.asserttrue(os.path.exists('normal1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal2'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('big1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big2'), 'added file doesnt exist') hgt.hg(['status'], stdout=('R normal1\n' 'R sub/normal2\n')) hgt.announce('forget single bfiles') hgt.hg(['forget', 'big1']) hgt.hg(['forget', 'sub/big2']) hgt.assertfalse(os.path.exists('sub/normal3.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/normal4.txt'), 'removed file exists') hgt.assertfalse(os.path.exists('sub/big3.txt'), 'removed file exists') hgt.asserttrue(os.path.exists('normal1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/normal2'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('big1'), 'added file doesnt exist') hgt.asserttrue(os.path.exists('sub/big2'), 'added file doesnt exist') hgt.hg(['status'], stdout=('R big1\n' 'R normal1\n' 'R sub/big2\n' 'R sub/normal2\n')) hgt.hg(['commit', '-m', 'all gone']) hgt.hg(['status'], stdout='''? big1 ? normal1 ? sub/big2 ? sub/normal2 ''') hgt.announce('setup') os.chdir('..') os.mkdir('repo2') os.chdir('repo2') hgt.hg(['init']) os.mkdir('bar') os.chdir('bar') os.mkdir('bar') os.chdir('bar') os.mkdir('foo') os.chdir('foo') hgt.writefile('n1', 'n1') hgt.writefile('n2.txt', 'n2') hgt.writefile('../n3.foo', 'n3') hgt.writefile('b1', 'b1') hgt.writefile('b2.txt', 'b2') hgt.writefile('../b3.foo', 'b3') hgt.hg(['add', 'n1', 'n2.txt', '../n3.foo']) hgt.hg(['add', '--bf', 'b1', 'b2.txt', '../b3.foo']) hgt.hg(['status'], stdout='''A bar/bar/b3.foo A bar/bar/foo/b1 A bar/bar/foo/b2.txt A bar/bar/foo/n1 A bar/bar/foo/n2.txt A bar/bar/n3.foo ''') hgt.hg(['commit', '-m', 'add files']) hgt.announce('test forget and add') hgt.hg(['forget', 'glob:../*.foo'], stdout='''removing ../n3.foo removing ../b3.foo ''') hgt.hg(['status'], stdout='''R bar/bar/b3.foo R bar/bar/n3.foo ''') hgt.hg(['add', '../n3.foo']) hgt.hg(['add', '--bf', '../b3.foo']) hgt.hg(['status']) # Mercurial < 1.6 doesn't return non zero status, but >= 1.6 does so allow both hgt.hg(['commit', '-m', 'did i change things?'], stdout='nothing changed\n', status = [0,1]) hgt.hg(['forget', '../n3.foo', '../b3.foo']) hgt.hg(['status'], stdout='''R bar/bar/b3.foo R bar/bar/n3.foo ''') hgt.hg(['commit', '-m', 'forget files']) hgt.hg(['status'], stdout='''? bar/bar/b3.foo ? bar/bar/n3.foo ''') hgt.hg(['forget', 'glob:*.txt'], stdout='''removing n2.txt removing b2.txt ''') hgt.hg(['status'], stdout='''R bar/bar/foo/b2.txt R bar/bar/foo/n2.txt ? bar/bar/b3.foo ? bar/bar/n3.foo ''') hgt.hg(['commit', '-m', 'forget files']) hgt.hg(['status'], stdout='''? bar/bar/b3.foo ? bar/bar/foo/b2.txt ? bar/bar/foo/n2.txt ? bar/bar/n3.foo ''')