annotate tests/test_push_dirs.py @ 730:efb87d5bb311

subvertpy: fix bug with pushing changes to stuff in subdirs Seems one needs to call direditor.open_file(path) with a full path, not one that is relative to the direditor's directory.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Thu, 23 Sep 2010 13:50:17 +0200
parents 04b3f476e2c3
children de036c2cb36a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
1 import test_util
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
2
643
d2ef7220a079 tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 323
diff changeset
3 import unittest
d2ef7220a079 tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 323
diff changeset
4
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
5 from mercurial import context
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
6 from mercurial import hg
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
7 from mercurial import node
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
8
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
9 class TestPushDirectories(test_util.TestBase):
84
01e747937d35 test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
10 def test_push_dirs(self):
700
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
11 self._load_fixture_and_fetch('emptyrepo.svndump')
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
12
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
13 changes = [
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
14 # Single file in single directory
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
15 ('d1/a', 'd1/a', 'a\n'),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
16 # Two files in one directory
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
17 ('d2/a', 'd2/a', 'a\n'),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
18 ('d2/b', 'd2/b', 'a\n'),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
19 # Single file in empty directory hierarchy
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
20 ('d31/d32/d33/d34/a', 'd31/d32/d33/d34/a', 'a\n'),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
21 ('d31/d32/a', 'd31/d32/a', 'a\n'),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
22 ]
84
01e747937d35 test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
23 self.commitchanges(changes)
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
24 self.pushrevisions()
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
25 self.assertEqual(self.svnls('trunk'),
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
26 ['d1', 'd1/a', 'd2', 'd2/a', 'd2/b', 'd31',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
27 'd31/d32', 'd31/d32/a', 'd31/d32/d33',
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
28 'd31/d32/d33/d34', 'd31/d32/d33/d34/a'])
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
29
85
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
30 # Add one revision with changed files only, no directory addition
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
31 # or deletion.
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
32 changes = [
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
33 ('d1/a', 'd1/a', 'aa\n'),
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
34 ('d2/a', 'd2/a', 'aa\n'),
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
35 ]
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
36 self.commitchanges(changes)
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
37 self.pushrevisions()
05a0c4f6060f push_cmd: consider only dirs with added/removed files for addition or deletion
Patrick Mezard <pmezard@gmail.com>
parents: 84
diff changeset
38
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
39 changes = [
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
40 # Remove single file in single directory
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
41 ('d1/a', None, None),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
42 # Remove one file out of two
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
43 ('d2/a', None, None),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
44 # Removing this file should remove one empty parent dir too
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
45 ('d31/d32/d33/d34/a', None, None),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
46 ]
84
01e747937d35 test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
47 self.commitchanges(changes)
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
48 self.pushrevisions()
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
49 self.assertEqual(self.svnls('trunk'),
323
067914ecb4eb push: Fix a bug in deletion of an entire tree.
Augie Fackler <durin42@gmail.com>
parents: 268
diff changeset
50 ['d2', 'd2/b', 'd31', 'd31/d32', 'd31/d32/a', ])
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
51
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
52 def test_push_new_dir_project_root_not_repo_root(self):
700
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
53 self._load_fixture_and_fetch('fetch_missing_files_subdir.svndump',
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
54 subdir='foo')
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
55 changes = [('magic_new/a', 'magic_new/a', 'ohai', ),
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
56 ]
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
57 self.commitchanges(changes)
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
58 self.pushrevisions()
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
59 self.assertEqual(self.svnls('foo/trunk'), ['bar',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
60 'bar/alpha',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
61 'bar/beta',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
62 'bar/delta',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
63 'bar/gamma',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
64 'foo',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
65 'magic_new',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
66 'magic_new/a'])
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
67
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
68 def test_push_new_file_existing_dir_root_not_repo_root(self):
700
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
69 self._load_fixture_and_fetch('empty_dir_in_trunk_not_repo_root.svndump',
04b3f476e2c3 test_push_dirs.py: activate tests that were previously overlooked
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 643
diff changeset
70 subdir='project')
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
71 changes = [('narf/a', 'narf/a', 'ohai', ),
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
72 ]
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
73 self.commitchanges(changes)
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
74 self.assertEqual(self.svnls('project/trunk'), ['a',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
75 'narf',])
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
76 self.pushrevisions()
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
77 self.assertEqual(self.svnls('project/trunk'), ['a',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
78 'narf',
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
79 'narf/a'])
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
80 changes = [('narf/a', None, None, ),
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
81 ]
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
82 self.commitchanges(changes)
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
83 self.pushrevisions()
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
84 self.assertEqual(self.svnls('project/trunk'), ['a' ,])
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
85
730
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
86 def test_push_single_dir_change_in_subdir(self):
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
87 # Tests simple pushing from default branch to a single dir repo
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
88 # Changes a file in a subdir (regression).
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
89 repo = self._load_fixture_and_fetch('branch_from_tag.svndump',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
90 stupid=False,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
91 layout='single',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
92 subdir='tags')
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
93 def file_callback(repo, memctx, path):
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
94 return context.memfilectx(path=path,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
95 data='foo',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
96 islink=False,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
97 isexec=False,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
98 copied=False)
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
99 ctx = context.memctx(repo,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
100 (repo['tip'].node(), node.nullid),
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
101 'automated test',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
102 ['tag_r3/alpha', 'tag_r3/new', 'new_dir/new'],
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
103 file_callback,
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
104 'an_author',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
105 '2009-10-19 18:49:30 -0500',
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
106 {'branch': 'default',})
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
107 repo.commitctx(ctx)
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
108 hg.update(repo, repo['tip'].node())
efb87d5bb311 subvertpy: fix bug with pushing changes to stuff in subdirs
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 700
diff changeset
109 self.pushrevisions()
268
6ec5b5fc5b4d Added a test case for directory-add behavior when repo root is not project root.
Augie Fackler <durin42@gmail.com>
parents: 85
diff changeset
110
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
111 def suite():
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
112 all = [unittest.TestLoader().loadTestsFromTestCase(TestPushDirectories),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
113 ]
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
114 return unittest.TestSuite(all)