changeset 754:caa527346a0f

svncommands: abort on missing metadata or Subversion URL (fixes #226)
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Thu, 18 Nov 2010 14:03:26 +0100
parents b218d2bb8c45
children 9c9565643704
files hgsubversion/svncommands.py hgsubversion/svnrepo.py hgsubversion/util.py tests/test_utility_commands.py
diffstat 4 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -89,7 +89,8 @@ def rebuildmeta(ui, repo, args, **opts):
     elif len(args) > 1:
         raise hgutil.Abort('rebuildmeta takes 1 or no arguments')
     uuid = None
-    url = repo.ui.expandpath(dest or 'default-push', dest or 'default')
+    url = repo.ui.expandpath(dest or repo.ui.config('paths', 'default-push') or
+                             repo.ui.config('paths', 'default') or '')
     svn = svnrepo.svnremoterepo(ui, url).svn
     subdir = svn.subdir
     svnmetadir = os.path.join(repo.path, 'svn')
--- a/hgsubversion/svnrepo.py
+++ b/hgsubversion/svnrepo.py
@@ -78,6 +78,8 @@ class svnremoterepo(mercurial.repo.repos
         self.ui = ui
         if path is None:
             path = self.ui.config('paths', 'default')
+        if not path:
+            raise hgutil.Abort('no Subversion URL specified')
         self.path = path
         self.capabilities = set(['lookup', 'subversion'])
 
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -82,6 +82,8 @@ def version(ui):
 
 
 def normalize_url(url):
+    if not url:
+        return url
     if url.startswith('svn+http://') or url.startswith('svn+https://'):
         url = url[4:]
     url, revs, checkout = parseurl(url)
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -82,13 +82,31 @@ class UtilityTests(test_util.TestBase):
                      })
         self.assertMultiLineEqual(expected, actual)
 
-    def test_info_missing_metadata(self):
-        repo = self._load_fixture_and_fetch('two_heads.svndump')
-        test_util.rmtree(repo.join('svn'))
+    def test_missing_metadata(self):
+        self._load_fixture_and_fetch('two_heads.svndump')
+        test_util.rmtree(self.repo.join('svn'))
+        self.assertRaises(hgutil.Abort,
+                          self.repo.svnmeta)
+        self.assertRaises(hgutil.Abort,
+                          svncommands.info,
+                          self.ui(), repo=self.repo, args=[])
+        self.assertRaises(hgutil.Abort,
+                          svncommands.genignore,
+                          self.ui(), repo=self.repo, args=[])
+
+        os.remove(self.repo.join('hgrc'))
+        self.assertRaises(hgutil.Abort,
+                          self.repo.svnmeta)
         self.assertRaises(hgutil.Abort,
-                          repo.svnmeta)
+                          svncommands.info,
+                          self.ui(), repo=self.repo, args=[])
+        self.assertRaises(hgutil.Abort,
+                          svncommands.genignore,
+                          self.ui(), repo=self.repo, args=[])
+
         self.assertRaises(hgutil.Abort,
-                          svncommands.info, self.ui, self.repo)
+                          svncommands.rebuildmeta,
+                          self.ui(), repo=self.repo, args=[])
 
     def test_parent_output(self):
         self._load_fixture_and_fetch('two_heads.svndump')