|
a/ForgeSVN/forgesvn/svn_main.py |
|
b/ForgeSVN/forgesvn/svn_main.py |
1 |
#-*- python -*-
|
1 |
#-*- python -*-
|
2 |
import logging
|
2 |
import logging
|
|
|
3 |
from pylons import c
|
3 |
|
4 |
|
4 |
# Non-stdlib imports
|
5 |
# Non-stdlib imports
|
5 |
from ming.utils import LazyProperty
|
6 |
from ming.utils import LazyProperty
|
6 |
from ming.orm.ormsession import ThreadLocalORMSession
|
7 |
from ming.orm.ormsession import ThreadLocalORMSession
|
|
|
8 |
from tg import expose
|
|
|
9 |
from tg.decorators import without_trailing_slash
|
7 |
|
10 |
|
8 |
# Pyforge-specific imports
|
11 |
# Pyforge-specific imports
|
9 |
import allura.tasks.repo_tasks
|
12 |
import allura.tasks.repo_tasks
|
10 |
from allura.controllers.repository import RepoRootController
|
13 |
from allura.controllers.repository import RepoRootController
|
|
|
14 |
from allura.lib.decorators import require_post
|
11 |
from allura.lib.repository import RepositoryApp
|
15 |
from allura.lib.repository import RepositoryApp, RepoAdminController
|
|
|
16 |
from allura.app import SitemapEntry, ConfigOption
|
12 |
|
17 |
|
13 |
# Local imports
|
18 |
# Local imports
|
14 |
from . import model as SM
|
19 |
from . import model as SM
|
15 |
from . import version
|
20 |
from . import version
|
16 |
from .controllers import BranchBrowser
|
21 |
from .controllers import BranchBrowser
|
|
... |
|
... |
18 |
log = logging.getLogger(__name__)
|
23 |
log = logging.getLogger(__name__)
|
19 |
|
24 |
|
20 |
class ForgeSVNApp(RepositoryApp):
|
25 |
class ForgeSVNApp(RepositoryApp):
|
21 |
'''This is the SVN app for PyForge'''
|
26 |
'''This is the SVN app for PyForge'''
|
22 |
__version__ = version.__version__
|
27 |
__version__ = version.__version__
|
|
|
28 |
config_options = RepositoryApp.config_options + [
|
|
|
29 |
ConfigOption('checkout_url', str, 'trunk')
|
|
|
30 |
]
|
23 |
tool_label='SVN'
|
31 |
tool_label='SVN'
|
24 |
ordinal=4
|
32 |
ordinal=4
|
25 |
forkable=False
|
33 |
forkable=False
|
26 |
default_branch_name=''
|
34 |
default_branch_name=''
|
27 |
|
35 |
|
|
... |
|
... |
30 |
self.root = BranchBrowser()
|
38 |
self.root = BranchBrowser()
|
31 |
default_root = RepoRootController()
|
39 |
default_root = RepoRootController()
|
32 |
self.root.refresh = default_root.refresh
|
40 |
self.root.refresh = default_root.refresh
|
33 |
self.root.feed = default_root.feed
|
41 |
self.root.feed = default_root.feed
|
34 |
self.root.commit_browser = default_root.commit_browser
|
42 |
self.root.commit_browser = default_root.commit_browser
|
|
|
43 |
self.admin = SVNRepoAdminController(self)
|
35 |
|
44 |
|
36 |
@LazyProperty
|
45 |
@LazyProperty
|
37 |
def repo(self):
|
46 |
def repo(self):
|
38 |
return SM.Repository.query.get(app_config_id=self.config._id)
|
47 |
return SM.Repository.query.get(app_config_id=self.config._id)
|
39 |
|
48 |
|
|
... |
|
... |
51 |
cloned_from_path=None,
|
60 |
cloned_from_path=None,
|
52 |
cloned_from_name=None,
|
61 |
cloned_from_name=None,
|
53 |
cloned_from_url=init_from_url)
|
62 |
cloned_from_url=init_from_url)
|
54 |
else:
|
63 |
else:
|
55 |
allura.tasks.repo_tasks.init.post()
|
64 |
allura.tasks.repo_tasks.init.post()
|
|
|
65 |
|
|
|
66 |
def admin_menu(self):
|
|
|
67 |
links = super(ForgeSVNApp, self).admin_menu()
|
|
|
68 |
links.append(SitemapEntry('Checkout URL', c.project.url()+'admin/'+self.config.options.mount_point+'/' + 'checkout_url', className='admin_modal'))
|
|
|
69 |
return links
|
|
|
70 |
|
|
|
71 |
class SVNRepoAdminController(RepoAdminController):
|
|
|
72 |
|
|
|
73 |
@without_trailing_slash
|
|
|
74 |
@expose('jinja:forgesvn:templates/svn/checkout_url.html')
|
|
|
75 |
def checkout_url(self, **kw):
|
|
|
76 |
return dict(app=self.app,
|
|
|
77 |
allow_config=True,
|
|
|
78 |
checkout_url=self.app.config.options.get('checkout_url'))
|
|
|
79 |
|
|
|
80 |
@without_trailing_slash
|
|
|
81 |
@expose()
|
|
|
82 |
@require_post()
|
|
|
83 |
def set_checkout_url(self, **post_data):
|
|
|
84 |
self.app.config.options['checkout_url'] = post_data['checkout_url']
|