incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [3/3] git commit: [#6344] ticket:379 only allow web based svn import if repo is empty
Date Wed, 26 Jun 2013 21:52:20 GMT
[#6344]  ticket:379 only allow web based svn import if repo is empty


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/3e5360c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3e5360c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3e5360c5

Branch: refs/heads/master
Commit: 3e5360c539b28b05b9ee2f8614b9acaed163a94c
Parents: b970970
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Jun 24 11:19:06 2013 +0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Wed Jun 26 21:51:39 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/svn_main.py                   | 24 +++++++-------
 ForgeSVN/forgesvn/templates/svn/import.html     | 33 +++++++++++++-------
 .../tests/functional/test_controllers.py        | 14 ++++++++-
 3 files changed, 47 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3e5360c5/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index dcb4fd6..73af7b7 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -139,6 +139,7 @@ class SVNImportController(BaseController):
     @with_trailing_slash
     @expose('jinja:forgesvn:templates/svn/import.html')
     def index(self, **kw):
+        c.is_empty = self.app.repo.is_empty()
         c.form = self.import_form
         return dict()
 
@@ -147,15 +148,16 @@ class SVNImportController(BaseController):
     @require_post()
     @validate(import_form, error_handler=index)
     def do_import(self, checkout_url=None, **kwargs):
-        with h.push_context(
-            self.app.config.project_id,
-            app_config_id=self.app.config._id):
-            allura.tasks.repo_tasks.reclone.post(
-                cloned_from_path=None,
-                cloned_from_name=None,
-                cloned_from_url=checkout_url)
-        M.Notification.post_user(
-            c.user, self.app.repo, 'importing',
-            text='''Repository import scheduled,
-                   an email notification will be sent when complete.''')
+        if self.app.repo.is_empty():
+            with h.push_context(
+                self.app.config.project_id,
+                app_config_id=self.app.config._id):
+                allura.tasks.repo_tasks.reclone.post(
+                    cloned_from_path=None,
+                    cloned_from_name=None,
+                    cloned_from_url=checkout_url)
+            M.Notification.post_user(
+                c.user, self.app.repo, 'importing',
+                text='''Repository import scheduled,
+                        an email notification will be sent when complete.''')
         redirect(c.project.url() + 'admin/tools')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3e5360c5/ForgeSVN/forgesvn/templates/svn/import.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/import.html b/ForgeSVN/forgesvn/templates/svn/import.html
index 4cee3ab..313cb18 100644
--- a/ForgeSVN/forgesvn/templates/svn/import.html
+++ b/ForgeSVN/forgesvn/templates/svn/import.html
@@ -29,16 +29,25 @@
 {% block header %}{{c.app.config.options.mount_label}}{% endblock %}
 
 {% block content %}
-<div class="message error" style="width:90%">
-  <h1 class="header">Warning</h1>
-  <p class="content">Importing a repository will <strong>overwrite any and all
data</strong>
-    in your existing repository.</p>
-</div>
-<br style="clear:both"/>
-<p><strong>Be careful! Importing will overwrite current repository contents.</strong></p>
-<p>We expect a URL to a publicly accessible repository (no password).<br />
-(Examples: http://repository.url/svn/name, https://repository.url/svn/name or svn://repository.url/svn/name)</p>
-<p>Notification email will be sent when import complete.</p>
-<p>If you really, <strong>really</strong> want to do this, enter the URL
of the source repository below:</p>
-{{ c.form.display(action='do_import') }}
+{%if c.is_empty%}
+    <div class="message error" style="width:90%">
+        <h1 class="header">Warning</h1>
+        <p class="content">Importing a repository will <strong>overwrite any
and all data</strong>
+            in your existing repository.</p>
+    </div>
+    <br style="clear:both"/>
+    <p><strong>Be careful! Importing will overwrite current repository contents.</strong></p>
+    <p>We expect a URL to a publicly accessible repository (no password).<br />
+    (Examples: http://repository.url/svn/name, https://repository.url/svn/name or svn://repository.url/svn/name)</p>
+    <p>Notification email will be sent when import complete.</p>
+    <p>If you really, <strong>really</strong> want to do this, enter the
URL of the source repository below:</p>
+    {{ c.form.display(action='do_import') }}
+{% else%}
+    <div class="message error" style="width:90%">
+        <h1 class="header">Warning</h1>
+        <p class="content">You cannot import into a repository that already has commits
in it.
+            Please delete this SVN tool if you really want to delete this whole repository.
+            Then install a new SVN tool and you will be able to import into it.</p>
+    </div>
+{%endif%}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3e5360c5/ForgeSVN/forgesvn/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/functional/test_controllers.py b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
index e07543a..cc1d44d 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -253,4 +253,16 @@ class TestRootController(SVNTestController):
 
 class TestImportController(SVNTestController):
     def test_index(self):
-        self.app.get('/p/test/admin/src/importer').follow(status=200)
+        r = self.app.get('/p/test/admin/src/importer').follow(status=200)
+        assert 'You cannot import into a repository that already has commits in it.' in r
+
+
+class TestImportControllerEmptyRepo(TestController):
+    def setUp(self):
+        TestController.setUp(self)
+
+    @with_svn
+    def test_index(self):
+        r = self.app.get('/p/test/admin/src/importer').follow(status=200)
+        assert 'Be careful! Importing will overwrite current repository contents.' in r
+


Mime
View raw message