annotate tests/test_push_dirs.py @ 323:067914ecb4eb

push: Fix a bug in deletion of an entire tree. This bug meant that if an entire subtree of the repo was deleted and there were files at varying levels of the hierarchy, then some of the files at higher levels might escape deletion when the revision was pushed to svn.
author Augie Fackler <durin42@gmail.com>
date Fri, 08 May 2009 16:26:33 -0500
parents 6ec5b5fc5b4d
children d2ef7220a079
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 unittest
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
2
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
3 import test_util
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
4
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
5 class TestPushDirectories(test_util.TestBase):
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
6 def setUp(self):
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
7 test_util.TestBase.setUp(self)
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
8 test_util.load_fixture_and_fetch('emptyrepo.svndump',
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
9 self.repo_path,
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
10 self.wc_path)
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
11
84
01e747937d35 test_util: add commitchanges() to TestBase
Patrick Mezard <pmezard@gmail.com>
parents: 83
diff changeset
12 def test_push_dirs(self):
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
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
53 class TestPushDirsNotAtRoot(test_util.TestBase):
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
54 def test_push_new_dir_project_root_not_repo_root(self):
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 test_util.load_fixture_and_fetch('fetch_missing_files_subdir.svndump',
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 self.repo_path,
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.wc_path,
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 subdir='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
59 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
60 ]
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 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
62 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
63 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
64 '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
65 '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
66 '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
67 '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
68 '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
69 '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
70 '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
71
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 def test_push_new_file_existing_dir_root_not_repo_root(self):
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 test_util.load_fixture_and_fetch('empty_dir_in_trunk_not_repo_root.svndump',
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.repo_path,
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 self.wc_path,
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 subdir='project')
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 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
78 ]
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 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
80 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
81 '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
82 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
83 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
84 '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
85 '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
86 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
87 ]
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
88 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
89 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
90 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
91
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
92
83
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
93 def suite():
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
94 all = [unittest.TestLoader().loadTestsFromTestCase(TestPushDirectories),
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
95 ]
6c9b7cf1c5aa push_cmd: delete empty svn directories, refactor directory creation
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
96 return unittest.TestSuite(all)