changeset 268:6ec5b5fc5b4d

Added a test case for directory-add behavior when repo root is not project root.
author Augie Fackler <durin42@gmail.com>
date Tue, 14 Apr 2009 22:44:19 -0500
parents f000b2392fc2
children 14914dbd8a4a
files tests/fixtures/empty_dir_in_trunk_not_repo_root.sh tests/fixtures/empty_dir_in_trunk_not_repo_root.svndump tests/test_push_dirs.py
diffstat 3 files changed, 152 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
new file mode 100755
--- /dev/null
+++ b/tests/fixtures/empty_dir_in_trunk_not_repo_root.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+mkdir temp || exit 1
+cd temp
+svnadmin create repo
+svn co file://`pwd`/repo wc
+pushd wc
+mkdir -p project/trunk
+svn add project
+svn ci -m 'trunk'
+cd project/trunk
+echo a > a
+mkdir narf
+svn add a narf
+svn ci -m 'file and empty dir'
+popd
+svnadmin dump repo > ../empty_dir_in_trunk_not_repo_root.svndump
+echo 'dump in empty_dir_in_trunk_not_repo_root.svndump'
+echo 'you can probably delete temp now'
new file mode 100644
--- /dev/null
+++ b/tests/fixtures/empty_dir_in_trunk_not_repo_root.svndump
@@ -0,0 +1,89 @@
+SVN-fs-dump-format-version: 2
+
+UUID: c866b883-4c03-404b-8609-dade481701a6
+
+Revision-number: 0
+Prop-content-length: 56
+Content-length: 56
+
+K 8
+svn:date
+V 27
+2009-04-15T03:39:30.544797Z
+PROPS-END
+
+Revision-number: 1
+Prop-content-length: 104
+Content-length: 104
+
+K 7
+svn:log
+V 5
+trunk
+K 10
+svn:author
+V 5
+durin
+K 8
+svn:date
+V 27
+2009-04-15T03:39:31.069518Z
+PROPS-END
+
+Node-path: project
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Node-path: project/trunk
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
+Revision-number: 2
+Prop-content-length: 118
+Content-length: 118
+
+K 7
+svn:log
+V 18
+file and empty dir
+K 10
+svn:author
+V 5
+durin
+K 8
+svn:date
+V 27
+2009-04-15T03:39:32.069497Z
+PROPS-END
+
+Node-path: project/trunk/a
+Node-kind: file
+Node-action: add
+Prop-content-length: 10
+Text-content-length: 2
+Text-content-md5: 60b725f10c9c85c70d97880dfe8191b3
+Content-length: 12
+
+PROPS-END
+a
+
+
+Node-path: project/trunk/narf
+Node-kind: dir
+Node-action: add
+Prop-content-length: 10
+Content-length: 10
+
+PROPS-END
+
+
--- a/tests/test_push_dirs.py
+++ b/tests/test_push_dirs.py
@@ -22,9 +22,9 @@ class TestPushDirectories(test_util.Test
             ]
         self.commitchanges(changes)
         self.pushrevisions()
-        self.assertEqual(self.svnls('trunk'), 
-                          ['d1', 'd1/a', 'd2', 'd2/a', 'd2/b', 'd31', 
-                           'd31/d32', 'd31/d32/a', 'd31/d32/d33', 
+        self.assertEqual(self.svnls('trunk'),
+                          ['d1', 'd1/a', 'd2', 'd2/a', 'd2/b', 'd31',
+                           'd31/d32', 'd31/d32/a', 'd31/d32/d33',
                            'd31/d32/d33/d34', 'd31/d32/d33/d34/a'])
 
         # Add one revision with changed files only, no directory addition
@@ -46,9 +46,50 @@ class TestPushDirectories(test_util.Test
             ]
         self.commitchanges(changes)
         self.pushrevisions()
-        self.assertEqual(self.svnls('trunk'), 
+        self.assertEqual(self.svnls('trunk'),
                          ['d2', 'd2/b', 'd31', 'd31/d32', 'd31/d32/a', 'd31/d32/d33'])
 
+
+class TestPushDirsNotAtRoot(test_util.TestBase):
+    def test_push_new_dir_project_root_not_repo_root(self):
+        test_util.load_fixture_and_fetch('fetch_missing_files_subdir.svndump',
+                                         self.repo_path,
+                                         self.wc_path,
+                                         subdir='foo')
+        changes = [('magic_new/a', 'magic_new/a', 'ohai', ),
+                   ]
+        self.commitchanges(changes)
+        self.pushrevisions()
+        self.assertEqual(self.svnls('foo/trunk'), ['bar',
+                                                   'bar/alpha',
+                                                   'bar/beta',
+                                                   'bar/delta',
+                                                   'bar/gamma',
+                                                   'foo',
+                                                   'magic_new',
+                                                   'magic_new/a'])
+
+    def test_push_new_file_existing_dir_root_not_repo_root(self):
+        test_util.load_fixture_and_fetch('empty_dir_in_trunk_not_repo_root.svndump',
+                                         self.repo_path,
+                                         self.wc_path,
+                                         subdir='project')
+        changes = [('narf/a', 'narf/a', 'ohai', ),
+                   ]
+        self.commitchanges(changes)
+        self.assertEqual(self.svnls('project/trunk'), ['a',
+                                                       'narf',])
+        self.pushrevisions()
+        self.assertEqual(self.svnls('project/trunk'), ['a',
+                                                       'narf',
+                                                       'narf/a'])
+        changes = [('narf/a', None, None, ),
+                   ]
+        self.commitchanges(changes)
+        self.pushrevisions()
+        self.assertEqual(self.svnls('project/trunk'), ['a' ,])
+
+
 def suite():
     all = [unittest.TestLoader().loadTestsFromTestCase(TestPushDirectories),
           ]