comparison tests/test_push_command.py @ 50:80b923ab242b

Drop any pretense of supporting svn 1.4.x. The quality of the SWIG bindings is just too low for this to work reasonably. In theory, 1.4.x will be supported at a future date by ctypes.
author Augie Fackler <durin42@gmail.com>
date Sat, 01 Nov 2008 12:23:07 -0500
parents 2bc4999a89d3
children 41dc00c7aef1
comparison
equal deleted inserted replaced
49:2bc4999a89d3 50:80b923ab242b
14 import fetch_command 14 import fetch_command
15 import push_cmd 15 import push_cmd
16 import test_util 16 import test_util
17 import time 17 import time
18 18
19 # push fails in 1.4-SWIG-land. 19
20 push_works = False 20 class PushOverSvnserveTests(unittest.TestCase):
21 try: 21 def setUp(self):
22 import csvn 22 self.oldwd = os.getcwd()
23 push_works = True 23 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
24 except ImportError: 24 self.repo_path = '%s/testrepo' % self.tmpdir
25 from svn import core 25 self.wc_path = '%s/testrepo_wc' % self.tmpdir
26 if (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO) >= (1, 5, 0): 26 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
27 push_works = True 27 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'),
28 28 'w').write('[general]\nanon-access=write\n[sasl]\n')
29 if push_works: 29 # Paranoia: we try and connect to localhost on 3689 before we start
30 class PushOverSvnserveTests(unittest.TestCase): 30 # svnserve. If it is running, we force the test to fail early.
31 def setUp(self): 31 user_has_own_svnserve = False
32 self.oldwd = os.getcwd() 32 try:
33 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 33 s = socket.socket()
34 self.repo_path = '%s/testrepo' % self.tmpdir 34 s.settimeout(0.3)
35 self.wc_path = '%s/testrepo_wc' % self.tmpdir 35 s.connect(('localhost', 3690))
36 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') 36 s.close()
37 open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'), 37 user_has_own_svnserve = True
38 'w').write('[general]\nanon-access=write\n[sasl]\n') 38 except:
39 # Paranoia: we try and connect to localhost on 3689 before we start 39 pass
40 # svnserve. If it is running, we force the test to fail early. 40 if user_has_own_svnserve:
41 user_has_own_svnserve = False 41 assert False, ('You appear to be running your own svnserve!'
42 try: 42 ' You can probably ignore this test failure.')
43 s = socket.socket() 43 args = ['svnserve', '-d', '--foreground', '-r', self.repo_path]
44 s.settimeout(0.3) 44 self.svnserve_pid = os.spawnvp(os.P_NOWAIT, 'svnserve', args)
45 s.connect(('localhost', 3690)) 45 time.sleep(2)
46 s.close() 46 fetch_command.fetch_revisions(ui.ui(),
47 user_has_own_svnserve = True 47 svn_url='svn://localhost/',
48 except: 48 hg_repo_path=self.wc_path)
49 pass 49
50 if user_has_own_svnserve: 50 def tearDown(self):
51 assert False, ('You appear to be running your own svnserve!' 51 shutil.rmtree(self.tmpdir)
52 ' You can probably ignore this test failure.') 52 os.chdir(self.oldwd)
53 args = ['svnserve', '-d', '--foreground', '-r', self.repo_path] 53 os.system('kill -9 %d' % self.svnserve_pid)
54 self.svnserve_pid = os.spawnvp(os.P_NOWAIT, 'svnserve', args) 54
55 time.sleep(2) 55 # define this as a property so that it reloads anytime we need it
56 fetch_command.fetch_revisions(ui.ui(), 56 @property
57 svn_url='svn://localhost/', 57 def repo(self):
58 hg_repo_path=self.wc_path) 58 return hg.repository(ui.ui(), self.wc_path)
59 59
60 def tearDown(self): 60 def test_push_to_default(self, commit=True):
61 shutil.rmtree(self.tmpdir) 61 repo = self.repo
62 os.chdir(self.oldwd) 62 old_tip = repo['tip'].node()
63 os.system('kill -9 %d' % self.svnserve_pid) 63 expected_parent = repo['default'].node()
64 64 def file_callback(repo, memctx, path):
65 # define this as a property so that it reloads anytime we need it 65 if path == 'adding_file':
66 @property 66 return context.memfilectx(path=path,
67 def repo(self): 67 data='foo',
68 return hg.repository(ui.ui(), self.wc_path) 68 islink=False,
69 69 isexec=False,
70 def test_push_to_default(self, commit=True): 70 copied=False)
71 repo = self.repo 71 raise IOError()
72 old_tip = repo['tip'].node() 72 ctx = context.memctx(repo,
73 expected_parent = repo['default'].node() 73 (repo['default'].node(), node.nullid),
74 def file_callback(repo, memctx, path): 74 'automated test',
75 if path == 'adding_file': 75 ['adding_file'],
76 return context.memfilectx(path=path, 76 file_callback,
77 data='foo', 77 'an_author',
78 islink=False, 78 '2008-10-07 20:59:48 -0500',
79 isexec=False, 79 {'branch': 'default',})
80 copied=False) 80 new_hash = repo.commitctx(ctx)
81 raise IOError() 81 if not commit:
82 ctx = context.memctx(repo, 82 return # some tests use this test as an extended setup.
83 (repo['default'].node(), node.nullid), 83 hg.update(repo, repo['tip'].node())
84 'automated test', 84 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
85 ['adding_file'], 85 hg_repo_path=self.wc_path,
86 file_callback, 86 svn_url='svn://localhost/')
87 'an_author', 87 tip = self.repo['tip']
88 '2008-10-07 20:59:48 -0500', 88 self.assertNotEqual(tip.node(), old_tip)
89 {'branch': 'default',}) 89 self.assertEqual(tip.parents()[0].node(), expected_parent)
90 new_hash = repo.commitctx(ctx) 90 self.assertEqual(tip['adding_file'].data(), 'foo')
91 if not commit: 91 self.assertEqual(tip.branch(), 'default')
92 return # some tests use this test as an extended setup. 92
93 hg.update(repo, repo['tip'].node()) 93
94 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 94 class PushTests(unittest.TestCase):
95 hg_repo_path=self.wc_path, 95 def setUp(self):
96 svn_url='svn://localhost/') 96 self.oldwd = os.getcwd()
97 tip = self.repo['tip'] 97 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
98 self.assertNotEqual(tip.node(), old_tip) 98 self.repo_path = '%s/testrepo' % self.tmpdir
99 self.assertEqual(tip.parents()[0].node(), expected_parent) 99 self.wc_path = '%s/testrepo_wc' % self.tmpdir
100 self.assertEqual(tip['adding_file'].data(), 'foo') 100 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
101 self.assertEqual(tip.branch(), 'default') 101 fetch_command.fetch_revisions(ui.ui(),
102 102 svn_url='file://%s' % self.repo_path,
103 103 hg_repo_path=self.wc_path)
104 class PushTests(unittest.TestCase): 104
105 def setUp(self): 105 # define this as a property so that it reloads anytime we need it
106 self.oldwd = os.getcwd() 106 @property
107 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 107 def repo(self):
108 self.repo_path = '%s/testrepo' % self.tmpdir 108 return hg.repository(ui.ui(), self.wc_path)
109 self.wc_path = '%s/testrepo_wc' % self.tmpdir 109
110 test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump') 110 def tearDown(self):
111 fetch_command.fetch_revisions(ui.ui(), 111 shutil.rmtree(self.tmpdir)
112 svn_url='file://%s' % self.repo_path, 112 os.chdir(self.oldwd)
113 hg_repo_path=self.wc_path) 113
114 114 def test_push_to_default(self, commit=True):
115 # define this as a property so that it reloads anytime we need it 115 repo = self.repo
116 @property 116 old_tip = repo['tip'].node()
117 def repo(self): 117 expected_parent = repo['default'].node()
118 return hg.repository(ui.ui(), self.wc_path) 118 def file_callback(repo, memctx, path):
119 119 if path == 'adding_file':
120 def tearDown(self): 120 return context.memfilectx(path=path,
121 shutil.rmtree(self.tmpdir) 121 data='foo',
122 os.chdir(self.oldwd) 122 islink=False,
123 123 isexec=False,
124 def test_push_to_default(self, commit=True): 124 copied=False)
125 repo = self.repo 125 raise IOError()
126 old_tip = repo['tip'].node() 126 ctx = context.memctx(repo,
127 expected_parent = repo['default'].node() 127 (repo['default'].node(), node.nullid),
128 def file_callback(repo, memctx, path): 128 'automated test',
129 if path == 'adding_file': 129 ['adding_file'],
130 return context.memfilectx(path=path, 130 file_callback,
131 data='foo', 131 'an_author',
132 islink=False, 132 '2008-10-07 20:59:48 -0500',
133 isexec=False, 133 {'branch': 'default',})
134 copied=False) 134 new_hash = repo.commitctx(ctx)
135 raise IOError() 135 if not commit:
136 ctx = context.memctx(repo, 136 return # some tests use this test as an extended setup.
137 (repo['default'].node(), node.nullid), 137 hg.update(repo, repo['tip'].node())
138 'automated test', 138 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
139 ['adding_file'], 139 hg_repo_path=self.wc_path,
140 file_callback, 140 svn_url='file://'+self.repo_path)
141 'an_author', 141 tip = self.repo['tip']
142 '2008-10-07 20:59:48 -0500', 142 self.assertNotEqual(tip.node(), old_tip)
143 {'branch': 'default',}) 143 self.assertEqual(tip.parents()[0].node(), expected_parent)
144 new_hash = repo.commitctx(ctx) 144 self.assertEqual(tip['adding_file'].data(), 'foo')
145 if not commit: 145 self.assertEqual(tip.branch(), 'default')
146 return # some tests use this test as an extended setup. 146
147 hg.update(repo, repo['tip'].node()) 147 def test_push_two_revs(self):
148 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 148 # set up some work for us
149 hg_repo_path=self.wc_path, 149 self.test_push_to_default(commit=False)
150 svn_url='file://'+self.repo_path) 150 repo = self.repo
151 tip = self.repo['tip'] 151 old_tip = repo['tip'].node()
152 self.assertNotEqual(tip.node(), old_tip) 152 expected_parent = repo['tip'].parents()[0].node()
153 self.assertEqual(tip.parents()[0].node(), expected_parent) 153 def file_callback(repo, memctx, path):
154 self.assertEqual(tip['adding_file'].data(), 'foo') 154 if path == 'adding_file2':
155 self.assertEqual(tip.branch(), 'default') 155 return context.memfilectx(path=path,
156 156 data='foo2',
157 def test_push_two_revs(self): 157 islink=False,
158 # set up some work for us 158 isexec=False,
159 self.test_push_to_default(commit=False) 159 copied=False)
160 repo = self.repo 160 raise IOError()
161 old_tip = repo['tip'].node() 161 ctx = context.memctx(repo,
162 expected_parent = repo['tip'].parents()[0].node() 162 (repo['default'].node(), node.nullid),
163 def file_callback(repo, memctx, path): 163 'automated test',
164 if path == 'adding_file2': 164 ['adding_file2'],
165 return context.memfilectx(path=path, 165 file_callback,
166 data='foo2', 166 'an_author',
167 islink=False, 167 '2008-10-07 20:59:48 -0500',
168 isexec=False, 168 {'branch': 'default',})
169 copied=False) 169 new_hash = repo.commitctx(ctx)
170 raise IOError() 170 hg.update(repo, repo['tip'].node())
171 ctx = context.memctx(repo, 171 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
172 (repo['default'].node(), node.nullid), 172 hg_repo_path=self.wc_path,
173 'automated test', 173 svn_url='file://'+self.repo_path)
174 ['adding_file2'], 174 tip = self.repo['tip']
175 file_callback, 175 self.assertNotEqual(tip.node(), old_tip)
176 'an_author', 176 self.assertNotEqual(tip.parents()[0].node(), old_tip)
177 '2008-10-07 20:59:48 -0500', 177 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent)
178 {'branch': 'default',}) 178 self.assertEqual(tip['adding_file2'].data(), 'foo2')
179 new_hash = repo.commitctx(ctx) 179 self.assertEqual(tip['adding_file'].data(), 'foo')
180 hg.update(repo, repo['tip'].node()) 180 self.assertEqual(tip.parents()[0]['adding_file'].data(), 'foo')
181 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 181 try:
182 hg_repo_path=self.wc_path, 182 self.assertEqual(tip.parents()[0]['adding_file2'].data(), 'foo')
183 svn_url='file://'+self.repo_path) 183 assert False, "this is impossible, adding_file2 should not be in this manifest."
184 tip = self.repo['tip'] 184 except revlog.LookupError, e:
185 self.assertNotEqual(tip.node(), old_tip) 185 pass
186 self.assertNotEqual(tip.parents()[0].node(), old_tip) 186 self.assertEqual(tip.branch(), 'default')
187 self.assertEqual(tip.parents()[0].parents()[0].node(), expected_parent) 187
188 self.assertEqual(tip['adding_file2'].data(), 'foo2') 188 def test_push_to_branch(self):
189 self.assertEqual(tip['adding_file'].data(), 'foo') 189 repo = self.repo
190 self.assertEqual(tip.parents()[0]['adding_file'].data(), 'foo') 190 def file_callback(repo, memctx, path):
191 try: 191 if path == 'adding_file':
192 self.assertEqual(tip.parents()[0]['adding_file2'].data(), 'foo') 192 return context.memfilectx(path=path,
193 assert False, "this is impossible, adding_file2 should not be in this manifest." 193 data='foo',
194 except revlog.LookupError, e: 194 islink=False,
195 pass 195 isexec=False,
196 self.assertEqual(tip.branch(), 'default') 196 copied=False)
197 197 raise IOError()
198 def test_push_to_branch(self): 198 ctx = context.memctx(repo,
199 repo = self.repo 199 (repo['the_branch'].node(), node.nullid),
200 def file_callback(repo, memctx, path): 200 'automated test',
201 if path == 'adding_file': 201 ['adding_file'],
202 return context.memfilectx(path=path, 202 file_callback,
203 data='foo', 203 'an_author',
204 islink=False, 204 '2008-10-07 20:59:48 -0500',
205 isexec=False, 205 {'branch': 'the_branch',})
206 copied=False) 206 new_hash = repo.commitctx(ctx)
207 raise IOError() 207 #commands.update(ui.ui(), self.repo, node='tip')
208 ctx = context.memctx(repo, 208 hg.update(repo, repo['tip'].node())
209 (repo['the_branch'].node(), node.nullid), 209 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
210 'automated test', 210 hg_repo_path=self.wc_path,
211 ['adding_file'], 211 svn_url='file://'+self.repo_path)
212 file_callback, 212 tip = self.repo['tip']
213 'an_author', 213 self.assertNotEqual(tip.node(), new_hash)
214 '2008-10-07 20:59:48 -0500', 214 self.assertEqual(tip['adding_file'].data(), 'foo')
215 {'branch': 'the_branch',}) 215 self.assertEqual(tip.branch(), 'the_branch')
216 new_hash = repo.commitctx(ctx) 216
217 #commands.update(ui.ui(), self.repo, node='tip') 217 def test_delete_file(self):
218 hg.update(repo, repo['tip'].node()) 218 repo = self.repo
219 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 219 def file_callback(repo, memctx, path):
220 hg_repo_path=self.wc_path, 220 raise IOError()
221 svn_url='file://'+self.repo_path) 221 old_files = set(repo['default'].manifest().keys())
222 tip = self.repo['tip'] 222 ctx = context.memctx(repo,
223 self.assertNotEqual(tip.node(), new_hash) 223 (repo['default'].node(), node.nullid),
224 self.assertEqual(tip['adding_file'].data(), 'foo') 224 'automated test',
225 self.assertEqual(tip.branch(), 'the_branch') 225 ['alpha'],
226 226 file_callback,
227 def test_delete_file(self): 227 'an author',
228 repo = self.repo 228 '2008-10-29 21:26:00 -0500',
229 def file_callback(repo, memctx, path): 229 {'branch': 'default', })
230 raise IOError() 230 new_hash = repo.commitctx(ctx)
231 old_files = set(repo['default'].manifest().keys()) 231 hg.update(repo, repo['tip'].node())
232 ctx = context.memctx(repo, 232 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
233 (repo['default'].node(), node.nullid), 233 hg_repo_path=self.wc_path,
234 'automated test', 234 svn_url='file://' + self.repo_path)
235 ['alpha'], 235 tip = self.repo['tip']
236 file_callback, 236 self.assertEqual(old_files,
237 'an author', 237 set(tip.manifest().keys() + ['alpha']))
238 '2008-10-29 21:26:00 -0500', 238 self.assert_('alpha' not in tip.manifest())
239 {'branch': 'default', }) 239
240 new_hash = repo.commitctx(ctx) 240 def test_push_executable_file(self):
241 hg.update(repo, repo['tip'].node()) 241 self.test_push_to_default(commit=True)
242 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 242 repo = self.repo
243 hg_repo_path=self.wc_path, 243 def file_callback(repo, memctx, path):
244 svn_url='file://' + self.repo_path) 244 if path == 'gamma':
245 tip = self.repo['tip'] 245 return context.memfilectx(path=path,
246 self.assertEqual(old_files, 246 data='foo',
247 set(tip.manifest().keys() + ['alpha'])) 247 islink=False,
248 self.assert_('alpha' not in tip.manifest()) 248 isexec=True,
249 249 copied=False)
250 def test_push_executable_file(self): 250 raise IOError()
251 self.test_push_to_default(commit=True) 251 ctx = context.memctx(repo,
252 repo = self.repo 252 (repo['tip'].node(), node.nullid),
253 def file_callback(repo, memctx, path): 253 'message',
254 if path == 'gamma': 254 ['gamma', ],
255 return context.memfilectx(path=path, 255 file_callback,
256 data='foo', 256 'author',
257 islink=False, 257 '2008-10-29 21:26:00 -0500',
258 isexec=True, 258 {'branch': 'default', })
259 copied=False) 259 new_hash = repo.commitctx(ctx)
260 raise IOError() 260 hg.update(repo, repo['tip'].node())
261 ctx = context.memctx(repo, 261 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
262 (repo['tip'].node(), node.nullid), 262 hg_repo_path=self.wc_path,
263 'message', 263 svn_url='file://' + self.repo_path)
264 ['gamma', ], 264 tip = self.repo['tip']
265 file_callback, 265 self.assertNotEqual(tip.node(), new_hash)
266 'author', 266 self.assert_('@' in tip.user())
267 '2008-10-29 21:26:00 -0500', 267 self.assertEqual(tip['gamma'].flags(), 'x')
268 {'branch': 'default', }) 268 self.assertEqual(tip['gamma'].data(), 'foo')
269 new_hash = repo.commitctx(ctx) 269 self.assertEqual([x for x in tip.manifest().keys() if 'x' not in
270 hg.update(repo, repo['tip'].node()) 270 tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
271 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 271
272 hg_repo_path=self.wc_path, 272 def test_push_symlink_file(self):
273 svn_url='file://' + self.repo_path) 273 self.test_push_to_default(commit=True)
274 tip = self.repo['tip'] 274 repo = self.repo
275 self.assertNotEqual(tip.node(), new_hash) 275 def file_callback(repo, memctx, path):
276 self.assert_('@' in tip.user()) 276 if path == 'gamma':
277 self.assertEqual(tip['gamma'].flags(), 'x') 277 return context.memfilectx(path=path,
278 self.assertEqual(tip['gamma'].data(), 'foo') 278 data='foo',
279 self.assertEqual([x for x in tip.manifest().keys() if 'x' not in 279 islink=True,
280 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) 280 isexec=False,
281 281 copied=False)
282 def test_push_symlink_file(self): 282 raise IOError()
283 self.test_push_to_default(commit=True) 283 ctx = context.memctx(repo,
284 repo = self.repo 284 (repo['tip'].node(), node.nullid),
285 def file_callback(repo, memctx, path): 285 'message',
286 if path == 'gamma': 286 ['gamma', ],
287 return context.memfilectx(path=path, 287 file_callback,
288 data='foo', 288 'author',
289 islink=True, 289 '2008-10-29 21:26:00 -0500',
290 isexec=False, 290 {'branch': 'default', })
291 copied=False) 291 new_hash = repo.commitctx(ctx)
292 raise IOError() 292 hg.update(repo, repo['tip'].node())
293 ctx = context.memctx(repo, 293 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
294 (repo['tip'].node(), node.nullid), 294 hg_repo_path=self.wc_path,
295 'message', 295 svn_url='file://' + self.repo_path)
296 ['gamma', ], 296 tip = self.repo['tip']
297 file_callback, 297 self.assertNotEqual(tip.node(), new_hash)
298 'author', 298 self.assertEqual(tip['gamma'].flags(), 'l')
299 '2008-10-29 21:26:00 -0500', 299 self.assertEqual(tip['gamma'].data(), 'foo')
300 {'branch': 'default', }) 300 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in
301 new_hash = repo.commitctx(ctx) 301 tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
302 hg.update(repo, repo['tip'].node()) 302
303 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 303 def test_push_with_new_dir(self):
304 hg_repo_path=self.wc_path, 304 self.test_push_to_default(commit=True)
305 svn_url='file://' + self.repo_path) 305 repo = self.repo
306 tip = self.repo['tip'] 306 def file_callback(repo, memctx, path):
307 self.assertNotEqual(tip.node(), new_hash) 307 if path == 'newdir/gamma':
308 self.assertEqual(tip['gamma'].flags(), 'l') 308 return context.memfilectx(path=path,
309 self.assertEqual(tip['gamma'].data(), 'foo') 309 data='foo',
310 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in 310 islink=False,
311 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) 311 isexec=False,
312 312 copied=False)
313 def test_push_with_new_dir(self): 313 raise IOError()
314 self.test_push_to_default(commit=True) 314 ctx = context.memctx(repo,
315 repo = self.repo 315 (repo['tip'].node(), node.nullid),
316 def file_callback(repo, memctx, path): 316 'message',
317 if path == 'newdir/gamma': 317 ['newdir/gamma', ],
318 return context.memfilectx(path=path, 318 file_callback,
319 data='foo', 319 'author',
320 islink=False, 320 '2008-10-29 21:26:00 -0500',
321 isexec=False, 321 {'branch': 'default', })
322 copied=False) 322 new_hash = repo.commitctx(ctx)
323 raise IOError() 323 hg.update(repo, repo['tip'].node())
324 ctx = context.memctx(repo, 324 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
325 (repo['tip'].node(), node.nullid), 325 hg_repo_path=self.wc_path,
326 'message', 326 svn_url='file://' + self.repo_path)
327 ['newdir/gamma', ], 327 tip = self.repo['tip']
328 file_callback, 328 self.assertNotEqual(tip.node(), new_hash)
329 'author', 329 self.assertEqual(tip['newdir/gamma'].data(), 'foo')
330 '2008-10-29 21:26:00 -0500', 330
331 {'branch': 'default', }) 331 def test_push_existing_file_newly_execute(self, execute=True,
332 new_hash = repo.commitctx(ctx) 332 link=False, expected_flags='x'):
333 hg.update(repo, repo['tip'].node()) 333 self.test_push_to_default()
334 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 334 repo = self.repo
335 hg_repo_path=self.wc_path, 335 def file_callback(repo, memctx, path):
336 svn_url='file://' + self.repo_path) 336 return context.memfilectx(path=path,
337 tip = self.repo['tip'] 337 data='foo',
338 self.assertNotEqual(tip.node(), new_hash) 338 islink=link,
339 self.assertEqual(tip['newdir/gamma'].data(), 'foo') 339 isexec=execute,
340 340 copied=False)
341 def test_push_existing_file_newly_execute(self, execute=True, 341 ctx = context.memctx(repo,
342 link=False, expected_flags='x'): 342 (repo['default'].node(), node.nullid),
343 self.test_push_to_default() 343 'message',
344 repo = self.repo 344 ['alpha', ],
345 def file_callback(repo, memctx, path): 345 file_callback,
346 return context.memfilectx(path=path, 346 'author',
347 data='foo', 347 '2008-1-1 00:00:00 -0500',
348 islink=link, 348 {'branch': 'default', })
349 isexec=execute, 349 new_hash = repo.commitctx(ctx)
350 copied=False) 350 hg.update(repo, repo['tip'].node())
351 ctx = context.memctx(repo, 351 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
352 (repo['default'].node(), node.nullid), 352 hg_repo_path=self.wc_path,
353 'message', 353 svn_url='file://' + self.repo_path)
354 ['alpha', ], 354 tip = self.repo['tip']
355 file_callback, 355 self.assertNotEqual(tip.node(), new_hash)
356 'author', 356 self.assertEqual(tip['alpha'].data(), 'foo')
357 '2008-1-1 00:00:00 -0500', 357 self.assertEqual(tip.parents()[0]['alpha'].flags(), '')
358 {'branch': 'default', }) 358 self.assertEqual(tip['alpha'].flags(), expected_flags)
359 new_hash = repo.commitctx(ctx) 359 # while we're here, double check pushing an already-executable file
360 hg.update(repo, repo['tip'].node()) 360 # works
361 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, 361 repo = self.repo
362 hg_repo_path=self.wc_path, 362 def file_callback(repo, memctx, path):
363 svn_url='file://' + self.repo_path) 363 return context.memfilectx(path=path,
364 tip = self.repo['tip'] 364 data='bar',
365 self.assertNotEqual(tip.node(), new_hash) 365 islink=link,
366 self.assertEqual(tip['alpha'].data(), 'foo') 366 isexec=execute,
367 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') 367 copied=False)
368 self.assertEqual(tip['alpha'].flags(), expected_flags) 368 ctx = context.memctx(repo,
369 # while we're here, double check pushing an already-executable file 369 (repo['default'].node(), node.nullid),
370 # works 370 'message',
371 repo = self.repo 371 ['alpha', ],
372 def file_callback(repo, memctx, path): 372 file_callback,
373 return context.memfilectx(path=path, 373 'author',
374 data='bar', 374 '2008-1-1 00:00:00 -0500',
375 islink=link, 375 {'branch': 'default', })
376 isexec=execute, 376 new_hash = repo.commitctx(ctx)
377 copied=False) 377 hg.update(repo, repo['tip'].node())
378 ctx = context.memctx(repo, 378 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
379 (repo['default'].node(), node.nullid), 379 hg_repo_path=self.wc_path,
380 'message', 380 svn_url='file://' + self.repo_path)
381 ['alpha', ], 381 tip = self.repo['tip']
382 file_callback, 382 self.assertNotEqual(tip.node(), new_hash)
383 'author', 383 self.assertEqual(tip['alpha'].data(), 'bar')
384 '2008-1-1 00:00:00 -0500', 384 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags)
385 {'branch': 'default', }) 385 self.assertEqual(tip['alpha'].flags(), expected_flags)
386 new_hash = repo.commitctx(ctx) 386
387 hg.update(repo, repo['tip'].node())
388 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo,
389 hg_repo_path=self.wc_path,
390 svn_url='file://' + self.repo_path)
391 tip = self.repo['tip']
392 self.assertNotEqual(tip.node(), new_hash)
393 self.assertEqual(tip['alpha'].data(), 'bar')
394 self.assertEqual(tip.parents()[0]['alpha'].flags(), expected_flags)
395 self.assertEqual(tip['alpha'].flags(), expected_flags)
396
397 else:
398 class PushTests(unittest.TestCase):
399 """Dummy so the test runner doesn't get upset.
400 """
401 pass
402 387
403 def suite(): 388 def suite():
404 test_classes = [PushTests, PushOverSvnserveTests] 389 test_classes = [PushTests, PushOverSvnserveTests]
405 tests = [] 390 tests = []
406 # This is the quickest hack I could come up with to load all the tests from 391 # This is the quickest hack I could come up with to load all the tests from