incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [47/50] [abbrv] git commit: [#5120] Fixed branches with / in them
Date Tue, 23 Apr 2013 16:42:51 GMT
[#5120] Fixed branches with / in them

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/cj/5120
Commit: 28b8a143a7aaf5603c5bacd9d83975a8949b306a
Parents: 8d64c44
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Apr 10 15:51:56 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Apr 23 13:35:53 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py          |   25 +++++-----
 Allura/allura/model/repository.py                |   44 +++++------------
 ForgeGit/forgegit/controllers.py                 |    4 +-
 ForgeGit/forgegit/git_main.py                    |    2 +-
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 ForgeSVN/forgesvn/controllers.py                 |    4 +-
 ForgeSVN/forgesvn/model/svn.py                   |   17 ++-----
 ForgeSVN/forgesvn/svn_main.py                    |    2 +-
 8 files changed, 36 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e073f1a..80605be 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -73,8 +73,7 @@ class RepoRootController(BaseController):
     def index(self, offset=0, branch=None, **kw):
         if branch is None:
             branch=c.app.default_branch_name
-        redirect(url(quote('%s%s/' % (
-                        branch, c.app.END_OF_REF_ESCAPE))))
+        redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
 
     @with_trailing_slash
     @expose('jinja:allura:templates/repo/forks.html')
@@ -377,21 +376,23 @@ class RefsController(object):
         self.BranchBrowserClass = BranchBrowserClass
 
     @expose()
-    def _lookup(self, *parts):
-        parts = map(unquote, parts)
-        ref = []
-        while parts:
-            part = parts.pop(0)
-            ref.append(part)
-            if part.endswith(c.app.END_OF_REF_ESCAPE):
-                break
-        ref = '/'.join(ref)[:-1]
-        return self.BranchBrowserClass(ref), parts
+    def _lookup(self, ref, *remainder):
+        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        if EOR in remainder:
+            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            ref = '/'.join((ci,) + remainder[:i])
+            remainder = remainder[i+1:]
+        return self.BranchBrowserClass(ref), remainder
 
 class CommitsController(object):
 
     @expose()
     def _lookup(self, ci, *remainder):
+        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        if EOR in remainder:
+            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            ci = '/'.join((ci,) + remainder[:i])
+            remainder = remainder[i+1:]
         return CommitBrowser(ci), remainder
 
 class BranchBrowser(BaseController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index cae4ce0..8a95993 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -179,40 +179,17 @@ class RepositoryImplementation(object):
         tags = [t.name for t in self._repo.repo_tags if t.object_id == commit._id]
         return branches, tags
 
-    def url_for_symbolic(self, commit):
-        if isinstance(commit, basestring):
-            object_id = commit
-        else:
-            object_id = commit._id
-
-        if self._repo.commit(object_id).symbolic_ids:
-            rev = None
-            branches, tags = self._repo.commit(object_id).symbolic_ids
-            for branch in branches:
-                last_commit = self._repo.latest(branch)
-                if last_commit and (object_id == last_commit._id):
-                    rev = branch
-                    break
-
-            for tag in tags:
-                last_commit = self._repo.latest(tag)
-                if last_commit and (object_id == last_commit._id):
-                    rev = tag
-                    break
-
-            if rev:
-                object_id = quote(rev, safe='')
-
-        return '%sci/%s/' % (self._repo.url(), object_id)
-
-    def url_for_commit(self, commit):
+    def url_for_commit(self, commit, url_type='ci'):
         'return an URL, given either a commit or object id'
         if isinstance(commit, basestring):
             object_id = commit
         else:
             object_id = commit._id
 
-        return '%sci/%s/' % (self._repo.url(), object_id)
+        if '/' in object_id:
+            object_id = os.path.join(object_id, self._repo.app.END_OF_REF_ESCAPE)
+
+        return os.path.join(self._repo.url(), url_type, object_id) + '/'
 
     def _setup_paths(self, create_repo_dir=True):
         '''
@@ -336,8 +313,8 @@ class Repository(Artifact, ActivityObject):
         return self._impl.shorthand_for_commit(oid)
     def symbolics_for_commit(self, commit):
         return self._impl.symbolics_for_commit(commit)
-    def url_for_commit(self, commit):
-        return self._impl.url_for_commit(commit)
+    def url_for_commit(self, commit, url_type='ci'):
+        return self._impl.url_for_commit(commit, url_type)
     def compute_tree_new(self, commit, path='/'):
         return self._impl.compute_tree_new(commit, path)
     def commits(self, path=None, rev=None, skip=None, limit=None):
@@ -453,8 +430,11 @@ class Repository(Artifact, ActivityObject):
         for oid in self.commitlog([ci._id]): result += 1
         return result
 
-    def latest(self, branch='master'):
-        if self._impl is None: return None
+    def latest(self, branch=None):
+        if self._impl is None:
+            return None
+        if branch is None:
+            branch = self.app.default_branch_name
         try:
             return self.commit(branch)
         except: # pragma no cover

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/ForgeGit/forgegit/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index 320cc9b..93e9364 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -21,6 +21,7 @@ from pylons import tmpl_context as c
 
 from allura.controllers import repository
 
+
 class BranchBrowser(repository.BranchBrowser):
 
     @expose('jinja:forgegit:templates/git/index.html')
@@ -30,5 +31,4 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
-
+        redirect(c.app.repo.url_for_commit(self._branch) + 'tree/')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/ForgeGit/forgegit/git_main.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/git_main.py b/ForgeGit/forgegit/git_main.py
index 7e3a79e..85219f8 100644
--- a/ForgeGit/forgegit/git_main.py
+++ b/ForgeGit/forgegit/git_main.py
@@ -50,7 +50,7 @@ class ForgeGitApp(RepositoryApp):
     """
     ordinal=2
     forkable=True
-    default_branch_name='ref/master'
+    default_branch_name='master'
 
     def __init__(self, project, config):
         super(ForgeGitApp, self).__init__(project, config)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/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 18de668..46c2daa 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -349,7 +349,7 @@ class TestGitCommit(unittest.TestCase):
 
     def test_url(self):
         assert self.rev.url().endswith('ca4a/')
-        assert self.repo._impl.url_for_symbolic(self.rev._id).endswith('master/'), self.repo._impl.url_for_symbolic(self.rev._id)
+        assert self.repo._impl.url_for_commit('master').endswith('master/'), self.repo._impl.url_for_commit('master')
 
     def test_committer_url(self):
         assert self.rev.committer_url is None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 83537a9..2e39fc7 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -20,7 +20,7 @@ from tg.decorators import with_trailing_slash
 from pylons import tmpl_context as c
 
 from allura.controllers import repository
-from allura.lib import helpers as h
+
 
 class BranchBrowser(repository.BranchBrowser):
 
@@ -34,7 +34,7 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
+        redirect(c.app.repo.url_for_commit(c.app.default_branch_name) + 'tree/')
 
     @expose()
     def _lookup(self, rev, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index fc9879c..53e6239 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -179,23 +179,14 @@ class SVNImplementation(M.RepositoryImplementation):
     def shorthand_for_commit(self, oid):
         return '[r%d]' % self._revno(oid)
 
-    def url_for_symbolic(self, commit):
+    def url_for_commit(self, commit, url_type=None):
         if isinstance(commit, basestring):
             object_id = commit
         else:
             object_id = commit._id
-        if self._repo.latest()._id == object_id:
-            return '%sHEAD/' % self._repo.url()
-        return '%s%d/' % (
-            self._repo.url(), self._revno(object_id))
-
-    def url_for_commit(self, commit):
-        if isinstance(commit, basestring):
-            object_id = commit
-        else:
-            object_id = commit._id
-        return '%s%d/' % (
-            self._repo.url(), self._revno(object_id))
+        if ':' in object_id:
+            object_id = str(self._revno(object_id))
+        return os.path.join(self._repo.url(), object_id) + '/'
 
     def init(self, default_dirs=False, skip_special_files=False):
         fullname = self._setup_paths()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/28b8a143/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 0e8a900..cca94f7 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -57,7 +57,7 @@ class ForgeSVNApp(RepositoryApp):
     """
     ordinal=4
     forkable=False
-    default_branch_name=''
+    default_branch_name='HEAD'
 
     def __init__(self, project, config):
         super(ForgeSVNApp, self).__init__(project, config)


Mime
View raw message