allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [1/2] git commit: [#5120] Fixed branches with / in them
Date Wed, 10 Apr 2013 16:15:00 GMT
Updated Branches:
  refs/heads/cj/5120 [created] 5a72eb233


[#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/3fe91a25
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/3fe91a25
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/3fe91a25

Branch: refs/heads/cj/5120
Commit: 3fe91a25eb16dfcb38f0aab28dfb22d6de969764
Parents: fa5d7e0
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Apr 10 15:51:56 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Wed Apr 10 16:08:12 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py          |   25 +++++-----
 Allura/allura/model/repository.py                |   44 +++++------------
 ForgeGit/forgegit/controllers.py                 |    3 +-
 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 +-
 requirements-sf.txt                              |    2 +-
 9 files changed, 36 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe91a25/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index bbfb307..dca0ceb 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -56,8 +56,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')
@@ -360,21 +359,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/3fe91a25/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index f33d446..4c85552 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -158,40 +158,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):
         '''
@@ -315,8 +292,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):
@@ -430,8 +407,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/3fe91a25/ForgeGit/forgegit/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index 4a8fab7..8cf1104 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -12,5 +12,4 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if not latest:
             return dict(allow_fork=False, log=[])
-        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/3fe91a25/ForgeGit/forgegit/git_main.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/git_main.py b/ForgeGit/forgegit/git_main.py
index a7efc11..554ede7 100644
--- a/ForgeGit/forgegit/git_main.py
+++ b/ForgeGit/forgegit/git_main.py
@@ -33,7 +33,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/3fe91a25/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 5e771dc..95fdf2a 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -316,7 +316,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/3fe91a25/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 0a87b40..17b01f6 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -13,10 +13,10 @@ class BranchBrowser(repository.BranchBrowser):
     @expose('jinja:forgesvn:templates/svn/index.html')
     @with_trailing_slash
     def index(self, limit=None, page=0, count=0, **kw):
-        latest = c.app.repo.latest(branch=self._branch)
+        latest = c.app.repo.latest()
         if not latest or (latest._id.split(':')[1] == '1' and h.has_access(c.app, 'write')()):
             return dict(allow_fork=False, log=[])
-        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/3fe91a25/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 2e18b2c..34630d5 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -162,23 +162,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=True, skip_special_files=False):
         fullname = self._setup_paths()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe91a25/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 2df8ea4..d90f022 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -40,7 +40,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)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3fe91a25/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 628e1e8..0fc28a6 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -4,7 +4,7 @@ akismet==0.2.0
 amqplib==0.6.1
 kombu==1.0.4
 coverage==3.5a1-20110413
-ForgeHg==0.1.6
+ForgeHg==0.1.7
 ForgePastebin==0.2.6
 mechanize==0.2.4
 MySQL-python==1.2.3c1


Mime
View raw message