Mercurial > hgsubversion
comparison tests/test_push_command.py @ 49:2bc4999a89d3
Add tests for a bunch more cases in pushing to svn.
| author | Augie Fackler <durin42@gmail.com> |
|---|---|
| date | Wed, 29 Oct 2008 22:58:52 -0500 |
| parents | d87b57c719f0 |
| children | 80b923ab242b |
comparison
equal
deleted
inserted
replaced
| 48:d87b57c719f0 | 49:2bc4999a89d3 |
|---|---|
| 271 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | 271 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, |
| 272 hg_repo_path=self.wc_path, | 272 hg_repo_path=self.wc_path, |
| 273 svn_url='file://' + self.repo_path) | 273 svn_url='file://' + self.repo_path) |
| 274 tip = self.repo['tip'] | 274 tip = self.repo['tip'] |
| 275 self.assertNotEqual(tip.node(), new_hash) | 275 self.assertNotEqual(tip.node(), new_hash) |
| 276 self.assert_('@' in tip.user()) | |
| 276 self.assertEqual(tip['gamma'].flags(), 'x') | 277 self.assertEqual(tip['gamma'].flags(), 'x') |
| 277 self.assertEqual(tip['gamma'].data(), 'foo') | 278 self.assertEqual(tip['gamma'].data(), 'foo') |
| 278 self.assertEqual([x for x in tip.manifest().keys() if 'x' not in | 279 self.assertEqual([x for x in tip.manifest().keys() if 'x' not in |
| 279 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) | 280 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) |
| 280 | 281 |
| 306 self.assertNotEqual(tip.node(), new_hash) | 307 self.assertNotEqual(tip.node(), new_hash) |
| 307 self.assertEqual(tip['gamma'].flags(), 'l') | 308 self.assertEqual(tip['gamma'].flags(), 'l') |
| 308 self.assertEqual(tip['gamma'].data(), 'foo') | 309 self.assertEqual(tip['gamma'].data(), 'foo') |
| 309 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in | 310 self.assertEqual([x for x in tip.manifest().keys() if 'l' not in |
| 310 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) | 311 tip[x].flags()], ['alpha', 'beta', 'adding_file', ]) |
| 312 | |
| 313 def test_push_with_new_dir(self): | |
| 314 self.test_push_to_default(commit=True) | |
| 315 repo = self.repo | |
| 316 def file_callback(repo, memctx, path): | |
| 317 if path == 'newdir/gamma': | |
| 318 return context.memfilectx(path=path, | |
| 319 data='foo', | |
| 320 islink=False, | |
| 321 isexec=False, | |
| 322 copied=False) | |
| 323 raise IOError() | |
| 324 ctx = context.memctx(repo, | |
| 325 (repo['tip'].node(), node.nullid), | |
| 326 'message', | |
| 327 ['newdir/gamma', ], | |
| 328 file_callback, | |
| 329 'author', | |
| 330 '2008-10-29 21:26:00 -0500', | |
| 331 {'branch': 'default', }) | |
| 332 new_hash = repo.commitctx(ctx) | |
| 333 hg.update(repo, repo['tip'].node()) | |
| 334 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | |
| 335 hg_repo_path=self.wc_path, | |
| 336 svn_url='file://' + self.repo_path) | |
| 337 tip = self.repo['tip'] | |
| 338 self.assertNotEqual(tip.node(), new_hash) | |
| 339 self.assertEqual(tip['newdir/gamma'].data(), 'foo') | |
| 340 | |
| 341 def test_push_existing_file_newly_execute(self, execute=True, | |
| 342 link=False, expected_flags='x'): | |
| 343 self.test_push_to_default() | |
| 344 repo = self.repo | |
| 345 def file_callback(repo, memctx, path): | |
| 346 return context.memfilectx(path=path, | |
| 347 data='foo', | |
| 348 islink=link, | |
| 349 isexec=execute, | |
| 350 copied=False) | |
| 351 ctx = context.memctx(repo, | |
| 352 (repo['default'].node(), node.nullid), | |
| 353 'message', | |
| 354 ['alpha', ], | |
| 355 file_callback, | |
| 356 'author', | |
| 357 '2008-1-1 00:00:00 -0500', | |
| 358 {'branch': 'default', }) | |
| 359 new_hash = repo.commitctx(ctx) | |
| 360 hg.update(repo, repo['tip'].node()) | |
| 361 push_cmd.push_revisions_to_subversion(ui.ui(), repo=self.repo, | |
| 362 hg_repo_path=self.wc_path, | |
| 363 svn_url='file://' + self.repo_path) | |
| 364 tip = self.repo['tip'] | |
| 365 self.assertNotEqual(tip.node(), new_hash) | |
| 366 self.assertEqual(tip['alpha'].data(), 'foo') | |
| 367 self.assertEqual(tip.parents()[0]['alpha'].flags(), '') | |
| 368 self.assertEqual(tip['alpha'].flags(), expected_flags) | |
| 369 # while we're here, double check pushing an already-executable file | |
| 370 # works | |
| 371 repo = self.repo | |
| 372 def file_callback(repo, memctx, path): | |
| 373 return context.memfilectx(path=path, | |
| 374 data='bar', | |
| 375 islink=link, | |
| 376 isexec=execute, | |
| 377 copied=False) | |
| 378 ctx = context.memctx(repo, | |
| 379 (repo['default'].node(), node.nullid), | |
| 380 'message', | |
| 381 ['alpha', ], | |
| 382 file_callback, | |
| 383 'author', | |
| 384 '2008-1-1 00:00:00 -0500', | |
| 385 {'branch': 'default', }) | |
| 386 new_hash = repo.commitctx(ctx) | |
| 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) | |
| 311 | 396 |
| 312 else: | 397 else: |
| 313 class PushTests(unittest.TestCase): | 398 class PushTests(unittest.TestCase): |
| 314 """Dummy so the test runner doesn't get upset. | 399 """Dummy so the test runner doesn't get upset. |
| 315 """ | 400 """ |
