changeset 337:46e69be8e2c8

Reorganize to have a more conventional module structure. This means that hgsubversion now uses absolute imports instead of relative ones, which makes the tests more reliable.
author Augie Fackler <durin42@gmail.com>
date Wed, 13 May 2009 21:39:39 -0500
parents c0b943cef0c3
children 47c0110046dc
files __init__.py cmdutil.py hg_delta_editor.py hgsubversion/__init__.py hgsubversion/cmdutil.py hgsubversion/hg_delta_editor.py hgsubversion/maps.py hgsubversion/stupid.py hgsubversion/svncommands.py hgsubversion/svnexternals.py hgsubversion/svnrepo.py hgsubversion/svnwrap/__init__.py hgsubversion/svnwrap/svn_ctypes_wrapper.py hgsubversion/svnwrap/svn_swig_wrapper.py hgsubversion/svnwrap/tests/__init__.py hgsubversion/svnwrap/tests/fixtures/project_root_at_repo_root.svndump hgsubversion/svnwrap/tests/fixtures/project_root_not_repo_root.svndump hgsubversion/svnwrap/tests/test_svnwrap.py hgsubversion/util.py hgsubversion/utility_commands.py hgsubversion/wrappers.py maps.py setup.py stupid.py svncommands.py svnexternals.py svnrepo.py svnwrap/__init__.py svnwrap/svn_ctypes_wrapper.py svnwrap/svn_swig_wrapper.py svnwrap/tests/__init__.py svnwrap/tests/fixtures/project_root_at_repo_root.svndump svnwrap/tests/fixtures/project_root_not_repo_root.svndump svnwrap/tests/test_svnwrap.py tests/run.py tests/test_diff.py tests/test_externals.py tests/test_fetch_branches.py tests/test_fetch_command_regexes.py tests/test_push_command.py tests/test_rebuildmeta.py tests/test_tags.py tests/test_urls.py tests/test_util.py tests/test_utility_commands.py util.py utility_commands.py wrappers.py
diffstat 30 files changed, 28 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
rename from __init__.py
rename to hgsubversion/__init__.py
--- a/__init__.py
+++ b/hgsubversion/__init__.py
@@ -87,14 +87,14 @@ def uisetup(ui):
                  'name mapping used for sources)'),
                 ('T', 'tagpaths', ['tags'], 'list of paths to search for tags '
                  'in Subversion repositories.'))
-    extname = __package__.split('_')[-1]
+    extname = 'hgsubversion'
 
     for command in ['clone']:
         doc = wrapper.__doc__.strip() % { 'extension': extname }
         getattr(commands, command).__doc__ += doc
         entry = extensions.wrapcommand(commands.table, command, wrapper)
         entry[1].extend(newflags)
-        
+
     try:
         rebase = extensions.find('rebase')
         if rebase:
rename from cmdutil.py
rename to hgsubversion/cmdutil.py
rename from hg_delta_editor.py
rename to hgsubversion/hg_delta_editor.py
rename from maps.py
rename to hgsubversion/maps.py
rename from stupid.py
rename to hgsubversion/stupid.py
rename from svncommands.py
rename to hgsubversion/svncommands.py
rename from svnexternals.py
rename to hgsubversion/svnexternals.py
rename from svnrepo.py
rename to hgsubversion/svnrepo.py
rename from svnwrap/__init__.py
rename to hgsubversion/svnwrap/__init__.py
rename from svnwrap/svn_ctypes_wrapper.py
rename to hgsubversion/svnwrap/svn_ctypes_wrapper.py
rename from svnwrap/svn_swig_wrapper.py
rename to hgsubversion/svnwrap/svn_swig_wrapper.py
rename from svnwrap/tests/__init__.py
rename to hgsubversion/svnwrap/tests/__init__.py
rename from svnwrap/tests/fixtures/project_root_at_repo_root.svndump
rename to hgsubversion/svnwrap/tests/fixtures/project_root_at_repo_root.svndump
rename from svnwrap/tests/fixtures/project_root_not_repo_root.svndump
rename to hgsubversion/svnwrap/tests/fixtures/project_root_not_repo_root.svndump
rename from svnwrap/tests/test_svnwrap.py
rename to hgsubversion/svnwrap/tests/test_svnwrap.py
rename from util.py
rename to hgsubversion/util.py
rename from utility_commands.py
rename to hgsubversion/utility_commands.py
rename from wrappers.py
rename to hgsubversion/wrappers.py
--- a/setup.py
+++ b/setup.py
@@ -23,8 +23,7 @@ setup(
     long_description = open(os.path.join(os.path.dirname(__file__),
                                          'README')).read(),
     keywords = 'mercurial',
-    packages = ['hgext.hgsubversion', 'hgext.hgsubversion.svnwrap'],
-    package_dir = {'hgext.hgsubversion': ''},
+    packages = ['hgsubversion', 'hgsubversion.svnwrap'],
     platforms = 'any',
     classifiers = [
         'License :: OSI Approved :: GNU General Public License (GPL)',
--- a/tests/run.py
+++ b/tests/run.py
@@ -2,7 +2,7 @@ import os
 import sys
 import unittest
 
-sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 import test_binaryfiles
 import test_diff
--- a/tests/test_diff.py
+++ b/tests/test_diff.py
@@ -2,7 +2,7 @@ import unittest
 
 from mercurial import ui
 
-import wrappers
+from hgsubversion import wrappers
 
 import test_util
 
--- a/tests/test_externals.py
+++ b/tests/test_externals.py
@@ -2,7 +2,7 @@ import os, unittest
 
 from mercurial import commands
 
-import svnexternals
+from hgsubversion import svnexternals
 import test_util
 
 class TestFetchExternals(test_util.TestBase):
@@ -47,7 +47,7 @@ class TestFetchExternals(test_util.TestB
             ('http://svn.example.com/skin-maker@21 third-party/skins/toolkit',
              ('third-party/skins/toolkit', None, 'http://svn.example.com/skin-maker', '21')),
             ]
-        
+
         for line, expected in samples:
             self.assertEqual(expected, svnexternals.parsedefinition(line))
 
@@ -106,7 +106,7 @@ class TestFetchExternals(test_util.TestB
             svnexternals.updateexternals(ui, [rev], repo)
             for d in deps:
                 p = os.path.join(repo.root, d)
-                self.assertTrue(os.path.isdir(p), 
+                self.assertTrue(os.path.isdir(p),
                                 'missing: %s@%r' % (d, rev))
             for d in nodeps:
                 p = os.path.join(repo.root, d)
@@ -118,10 +118,10 @@ class TestFetchExternals(test_util.TestB
         commands.update(ui, repo)
         checkdeps(['deps/project1'], [], repo, 0)
         checkdeps(['deps/project1', 'deps/project2'], [], repo, 1)
-        checkdeps(['subdir/deps/project1', 'subdir2/deps/project1', 
-                   'deps/project2'], 
+        checkdeps(['subdir/deps/project1', 'subdir2/deps/project1',
+                   'deps/project2'],
                   ['deps/project1'], repo, 2)
-        checkdeps(['subdir/deps/project1', 'deps/project2'], 
+        checkdeps(['subdir/deps/project1', 'deps/project2'],
                   ['subdir2/deps/project1'], repo, 3)
         checkdeps(['subdir/deps/project1'], ['deps/project2'], repo, 4)
 
--- a/tests/test_fetch_branches.py
+++ b/tests/test_fetch_branches.py
@@ -74,10 +74,10 @@ class TestFetchBranches(test_util.TestBa
                                             stupid, noupdate=False)
         self.assertEqual(repo[None].branch(), 'default')
         self.assertTrue('tip' not in repo[None].tags())
-    
+
     def test_branch_tip_update_to_default_stupid(self):
         self.test_branch_tip_update_to_default(True)
-    
+
     def test_branch_tip_update_to_branch_anchor(self):
         repo = self._load_fixture_and_fetch_with_anchor(
             'unorderedbranch.svndump', 'branch')
--- a/tests/test_fetch_command_regexes.py
+++ b/tests/test_fetch_command_regexes.py
@@ -1,6 +1,8 @@
-import stupid
 import unittest
 
+from hgsubversion import stupid
+
+
 two_empties = """Index: __init__.py
 ===================================================================
 Index: bar/__init__.py
--- a/tests/test_push_command.py
+++ b/tests/test_push_command.py
@@ -63,6 +63,8 @@ class PushTests(test_util.TestBase):
         self.svnserve_pid = subprocess.Popen(args).pid
         try:
             time.sleep(2)
+            import shutil
+            shutil.rmtree(self.wc_path)
             commands.clone(ui.ui(), 'svn://%s:%d/' % (self.host, self.port),
                            self.wc_path, noupdate=True)
 
--- a/tests/test_rebuildmeta.py
+++ b/tests/test_rebuildmeta.py
@@ -5,8 +5,8 @@ import unittest
 from mercurial import hg
 from mercurial import ui
 
-import svncommands
-import hg_delta_editor
+from hgsubversion import svncommands
+from hgsubversion import hg_delta_editor
 
 import test_util
 
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -6,7 +6,7 @@ from mercurial import ui
 
 import test_util
 
-import svnrepo
+from hgsubversion import svnrepo
 
 class TestTags(test_util.TestBase):
     def _load_fixture_and_fetch(self, fixture_name, stupid=False):
--- a/tests/test_urls.py
+++ b/tests/test_urls.py
@@ -1,6 +1,6 @@
 import test_util
 import unittest
-from svnwrap.svn_swig_wrapper import parse_url
+from hgsubversion.svnwrap.svn_swig_wrapper import parse_url
 
 class TestSubversionUrls(test_util.TestBase):
     def test_standard_url(self):
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -14,7 +14,7 @@ from mercurial import hg
 from mercurial import node
 from mercurial import ui
 
-import util
+from hgsubversion import util
 
 # Fixtures that need to be pulled at a subdirectory of the repo path
 subdir = {'truncatedhistory.svndump': '/project2',
@@ -50,7 +50,7 @@ def load_fixture_and_fetch(fixture_name,
     load_svndump_fixture(repo_path, fixture_name)
     if subdir:
         repo_path += '/' + subdir
-    
+
     _ui = ui.ui()
     _ui.setconfig('hgsubversion', 'stupid', str(stupid))
     commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate)
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -8,10 +8,10 @@ from mercurial import revlog
 from mercurial import context
 from mercurial import node
 
-import util
-import utility_commands
+from hgsubversion import util
+from hgsubversion import utility_commands
 import test_util
-import wrappers
+from hgsubversion import wrappers
 
 expected_info_output = '''URL: %(repourl)s/%(branch)s
 Repository Root: %(repourl)s
@@ -174,7 +174,7 @@ class UtilityTests(test_util.TestBase):
 
     def test_genignore(self):
         """ Test generation of .hgignore file. """
-        test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path, 
+        test_util.load_fixture_and_fetch('ignores.svndump', self.repo_path,
                                          self.wc_path, noupdate=False)
         u = ui.ui()
         u.pushbuffer()