You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/27 20:28:39 UTC
[13/14] git commit: [#7134] Refactoring of external checkout URL
option
[#7134] Refactoring of external checkout URL option
Signed-off-by: Cory Johns <cj...@slashdotmedia.com>
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/4c306365
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/4c306365
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/4c306365
Branch: refs/heads/cj/7134
Commit: 4c30636512697fad207289c05183368cf0723874
Parents: d59c3dc
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Mar 26 21:47:56 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Mar 27 17:42:35 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/repository.py | 33 ++++++++++++------
Allura/allura/model/repository.py | 4 +--
Allura/allura/templates/repo/admin_options.html | 32 -----------------
Allura/allura/templates/repo/checkout_url.html | 36 ++++++++++++++++++++
.../forgegit/tests/model/test_repository.py | 2 +-
ForgeSVN/forgesvn/svn_main.py | 31 +++++++----------
.../forgesvn/templates/svn/checkout_url.html | 19 +++++++++--
.../forgesvn/tests/model/test_repository.py | 2 +-
ForgeSVN/forgesvn/tests/test_svn_app.py | 2 +-
9 files changed, 92 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 4e956bf..0dda832 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -55,7 +55,7 @@ class RepositoryApp(Application):
ConfigOption('cloned_from_project_id', ObjectId, None),
ConfigOption('cloned_from_repo_id', ObjectId, None),
ConfigOption('init_from_url', str, None),
- ConfigOption('clone_url', str, None)
+ ConfigOption('external_checkout_url', str, None)
]
tool_label = 'Repository'
default_mount_label = 'Code'
@@ -95,13 +95,24 @@ class RepositoryApp(Application):
admin_url = c.project.url() + 'admin/' + \
self.config.options.mount_point + '/'
links = [
- SitemapEntry('Viewable Files', admin_url + 'extensions', className='admin_modal')]
- links.append(SitemapEntry('Refresh Repository',
- c.project.url() +
- self.config.options.mount_point +
- '/refresh',
- ))
+ SitemapEntry(
+ 'Checkout URL',
+ c.project.url() + 'admin/' +
+ self.config.options.mount_point +
+ '/' + 'checkout_url',
+ className='admin_modal'),
+ SitemapEntry(
+ 'Viewable Files',
+ admin_url + 'extensions',
+ className='admin_modal'),
+ SitemapEntry(
+ 'Refresh Repository',
+ c.project.url() +
+ self.config.options.mount_point +
+ '/refresh'),
+ ]
links += super(RepositoryApp, self).admin_menu()
+ [links.remove(l) for l in links[:] if l.label == 'Options']
return links
@h.exceptionless([], log)
@@ -248,14 +259,14 @@ class RepoAdminController(DefaultAdminController):
default_branch_name=self.app.default_branch_name)
@without_trailing_slash
- @expose('jinja:allura:templates/repo/admin_options.html')
- def options(self):
+ @expose('jinja:allura:templates/repo/checkout_url.html')
+ def checkout_url(self):
return dict(app=self.app)
@without_trailing_slash
@expose()
@require_post()
- def set_options(self, clone_url=None, **kw):
- self.app.config.options.clone_url = clone_url or None
+ def set_checkout_url(self, **post_data):
+ self.app.config.options.external_checkout_url = post_data.get('external_checkout_url') or None
flash('Repo options updated')
redirect(c.project.url() + 'admin/tools')
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 12661a9..c08e546 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -555,8 +555,8 @@ class Repository(Artifact, ActivityObject):
'''Return a URL string suitable for copy/paste that describes _this_ repo,
e.g., for use in a clone/checkout command
'''
- if self.app.config.options.clone_url:
- tpl = string.Template(self.app.config.options.clone_url)
+ if self.app.config.options.get('external_checkout_url', None):
+ tpl = string.Template(self.app.config.options.external_checkout_url)
else:
tpl = string.Template(
tg.config.get('scm.host.%s.%s' % (category, self.tool)))
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/templates/repo/admin_options.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/admin_options.html b/Allura/allura/templates/repo/admin_options.html
deleted file mode 100644
index 2b2c0b7..0000000
--- a/Allura/allura/templates/repo/admin_options.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{#-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--#}
-<!DOCTYPE html>
-<form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_options" method="post">
- <label class="grid-4">Clone / checkout URL:</label>
- <div class="grid-9">
- <input type="text" name="clone_url" id="clone_url" value="{{app.config.options.clone_url or ''}}"/>
- </div>
- <div class="grid-13"> </div>
- <hr>
- <div class="grid-13"> </div>
- <div class="grid-13">
- <input type="submit" value="Save"/>
- <a href="#" class="close">Cancel</a>
- </div>
-</form>
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/Allura/allura/templates/repo/checkout_url.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/checkout_url.html b/Allura/allura/templates/repo/checkout_url.html
new file mode 100644
index 0000000..8eaafd9
--- /dev/null
+++ b/Allura/allura/templates/repo/checkout_url.html
@@ -0,0 +1,36 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+<!DOCTYPE html>
+<form action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_checkout_url" method="post">
+ <label class="grid-4">External checkout URL:</label>
+ <div class="grid-9">
+ <input type="text" name="external_checkout_url" id="external_checkout_url" value="{{app.config.options.external_checkout_url or ''}}"/>
+ </div>
+ <div class="grid-13">
+ Override the checkout URL with an external one. This is useful if this repository is a mirror
+ of another, canonical repository.
+ </div>
+ <div class="grid-13"> </div>
+ <hr>
+ <div class="grid-13"> </div>
+ <div class="grid-13">
+ <input type="submit" value="Save"/>
+ <a href="#" class="close">Cancel</a>
+ </div>
+</form>
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 106c63e..ff4ee48 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -477,7 +477,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
assert_equal(
self.repo.clone_url('https', 'nobody'),
'https://nobody@localhost:8022/scm-repo/test/testgit')
- with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+ with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
assert_equal(
self.repo.clone_url('https', 'user'),
'https://user@foo.com/')
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 0bce7f6..e1cf7f7 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -100,17 +100,10 @@ class ForgeSVNApp(RepositoryApp):
allura.tasks.repo_tasks.init.post()
def admin_menu(self):
- links = []
- links.append(SitemapEntry(
- 'Checkout URL',
- c.project.url() + 'admin/' +
- self.config.options.mount_point +
- '/' + 'checkout_url',
- className='admin_modal'))
- links.append(SitemapEntry(
+ links = super(ForgeSVNApp, self).admin_menu()
+ links.insert(1, SitemapEntry(
'Import Repo',
c.project.url() + 'admin/' + self.config.options.mount_point + '/' + 'importer/'))
- links += super(ForgeSVNApp, self).admin_menu()
return links
@@ -123,23 +116,25 @@ class SVNRepoAdminController(RepoAdminController):
@without_trailing_slash
@expose('jinja:forgesvn:templates/svn/checkout_url.html')
def checkout_url(self, **kw):
- return dict(app=self.app,
- allow_config=True,
- checkout_url=self.app.config.options.get('checkout_url'))
+ return dict(app=self.app, allow_config=True)
@without_trailing_slash
@expose()
@require_post()
def set_checkout_url(self, **post_data):
- if svn_path_exists("file://%s%s/%s" %
- (self.app.repo.fs_path,
- self.app.repo.name,
- post_data['checkout_url'])):
- self.app.config.options['checkout_url'] = post_data['checkout_url']
+ checkout_url = post_data.get('checkout_url')
+ external_checkout_url = post_data.get('external_checkout_url')
+ if checkout_url and svn_path_exists("file://%s%s/%s" %
+ (self.app.repo.fs_path,
+ self.app.repo.name,
+ checkout_url)):
+ self.app.config.options['checkout_url'] = checkout_url
flash("Checkout URL successfully changed")
else:
flash("%s is not a valid path for this repository" %
- post_data['checkout_url'], "error")
+ checkout_url, "error")
+ self.app.config.options.external_checkout_url = external_checkout_url
+ flash("External checkout URL successfully changed")
class SVNImportController(BaseController):
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/templates/svn/checkout_url.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/checkout_url.html b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
index 3960798..9931d0c 100644
--- a/ForgeSVN/forgesvn/templates/svn/checkout_url.html
+++ b/ForgeSVN/forgesvn/templates/svn/checkout_url.html
@@ -18,17 +18,29 @@
-#}
{% block content %}
<form>
- <label class="grid-13" for="checkout_url">Checkout url:</label>
- <div class="grid-13">
+ <label class="grid-13" for="checkout_url">Checkout branch:</label>
+ <div class="grid-9" style="text-align:right">
{{app.repo.clone_url('ro', app)}}
{% if allow_config %}
<input type="text" name="checkout_url"
id="checkout_url"
- {% if checkout_url %} value="{{checkout_url}}"{% endif %}/>
+ {% if app.config.options.checkout_url %} value="{{app.config.options.checkout_url}}"{% endif %}/>
{% else %}
<span>{{checkout_url}}</span>
{% endif %}
</div>
+ <div class="grid-4">
+ e.g., trunk
+ </div>
+ <div class="grid-13"> </div>
+ <label class="grid-4">External checkout URL:</label>
+ <div class="grid-5" style="text-align:right">
+ <input type="text" name="external_checkout_url" id="external_checkout_url" value="{{app.config.options.external_checkout_url or ''}}"/>
+ </div>
+ <div class="grid-13">
+ Override the checkout URL with an external one. This is useful if this repository is a mirror
+ of another, canonical repository.
+ </div>
{% if allow_config %}
<div class="grid-13"> </div>
@@ -45,6 +57,7 @@
var cval = $.cookie('_session_id');
$.post('{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_checkout_url', {
checkout_url: $('#checkout_url').val(),
+ external_checkout_url: $('#external_checkout_url').val(),
_session_id:cval
},
function () {
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 2fb7207..3ad13c7 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -784,7 +784,7 @@ class TestRepo(_TestWithRepo):
self.repo.clone_url('https', 'nobody')
== 'https://nobody@localhost:8022/scm-repo/p/test/test1/'),\
self.repo.clone_url('https', 'nobody')
- with h.push_config(self.repo.app.config.options, clone_url='https://$username@foo.com/'):
+ with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
assert_equal(
self.repo.clone_url('https', 'user'),
'https://user@foo.com/')
http://git-wip-us.apache.org/repos/asf/allura/blob/4c306365/ForgeSVN/forgesvn/tests/test_svn_app.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/test_svn_app.py b/ForgeSVN/forgesvn/tests/test_svn_app.py
index 6ea576a..7fd8545 100644
--- a/ForgeSVN/forgesvn/tests/test_svn_app.py
+++ b/ForgeSVN/forgesvn/tests/test_svn_app.py
@@ -40,7 +40,7 @@ class TestSVNApp(unittest.TestCase):
ThreadLocalORMSession.close_all()
def test_admin_menu(self):
- assert_equals(len(c.app.admin_menu()), 7)
+ assert_equals(len(c.app.admin_menu()), 6)
assert_equals(c.app.admin_menu()[0].label, 'Checkout URL')
def test_uninstall(self):