incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject git commit: [#7130] Removed inefficient next / prev links on file browse page
Date Tue, 04 Feb 2014 20:00:56 GMT
Updated Branches:
  refs/heads/cj/7130 [created] 84fb9c31a


[#7130] Removed inefficient next / prev links on file browse page

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

Branch: refs/heads/cj/7130
Commit: 84fb9c31acd420b2507c211db37867298870b09e
Parents: bfee3bc
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue Feb 4 20:00:40 2014 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue Feb 4 20:00:40 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |  3 --
 Allura/allura/model/repo.py             | 41 --------------------
 Allura/allura/templates/repo/file.html  | 16 --------
 Allura/allura/tests/unit/test_repo.py   | 56 ----------------------------
 4 files changed, 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84fb9c31/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e571734..1fb8323 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -615,13 +615,10 @@ class FileBrowser(BaseController):
             return self.diff(kw['barediff'], kw.pop('diformat', None))
         else:
             force_display = 'force' in kw
-            context = self._blob.context()
             stats = utils.generate_code_stats(self._blob)
             return dict(
                 blob=self._blob,
                 stats=stats,
-                prev=context.get('prev', None),
-                next=context.get('next', None),
                 force_display=force_display
             )
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84fb9c31/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index a137e7a..9f11cc8 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -654,29 +654,6 @@ class Blob(object):
         return self.tree.url() + h.really_unicode(self.name)
 
     @LazyProperty
-    def prev_commit(self):
-        pcid = LastCommit._prev_commit_id(self.commit, self.path().strip('/'))
-        if pcid:
-            return self.repo.commit(pcid)
-        return None
-
-    @LazyProperty
-    def next_commit(self):
-        try:
-            path = self.path()
-            cur = self.commit
-            next = cur.context()['next']
-            while next:
-                cur = next[0]
-                next = cur.context()['next']
-                other_blob = cur.get_path(path, create=False)
-                if other_blob is None or other_blob._id != self._id:
-                    return cur
-        except:
-            log.exception('Lookup next_commit')
-            return None
-
-    @LazyProperty
     def _content_type_encoding(self):
         return self.repo.guess_type(self.name)
 
@@ -708,24 +685,6 @@ class Blob(object):
     def has_image_view(self):
         return self.content_type.startswith('image/')
 
-    def context(self):
-        path = self.path()
-        prev = self.prev_commit
-        next = self.next_commit
-        if prev is not None:
-            try:
-                prev = prev.get_path(path, create=False)
-            except KeyError:
-                prev = None
-        if next is not None:
-            try:
-                next = next.get_path(path, create=False)
-            except KeyError:
-                next = None
-        return dict(
-            prev=prev,
-            next=next)
-
     def open(self):
         return self.repo.open_blob(self)
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84fb9c31/Allura/allura/templates/repo/file.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/file.html b/Allura/allura/templates/repo/file.html
index 965332b..b84c47c 100644
--- a/Allura/allura/templates/repo/file.html
+++ b/Allura/allura/templates/repo/file.html
@@ -65,22 +65,6 @@
 </script>
 {% endblock %}
 {% block content %}
-  {% if prev %}
-  <p>
-    Parent:
-    <a href="{{prev.url()}}">{{prev.commit.shorthand_id()}}</a>
-    <a href="?diff={{prev.commit._id}}">(diff)</a>
-  </p>
-  {% endif %}
-
-  {% if next %}
-  <p>
-    Child:
-    <a href="{{next.url()}}">{{next.commit.shorthand_id()}}</a>
-    <a href="{{next.url()}}?diff={{blob.commit._id}}">(diff)</a>
-  </p>
-  {% endif %}
-
   {% if blob.has_image_view %}
     <p><a href="?format=raw">Download this file</a></p>
     <img src="?format=raw" alt=""/>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/84fb9c31/Allura/allura/tests/unit/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_repo.py b/Allura/allura/tests/unit/test_repo.py
index eef8656..eee886e 100644
--- a/Allura/allura/tests/unit/test_repo.py
+++ b/Allura/allura/tests/unit/test_repo.py
@@ -146,62 +146,6 @@ class TestTree(unittest.TestCase):
 
 class TestBlob(unittest.TestCase):
 
-    def test_context_no_create(self):
-        blob = M.repo.Blob(Mock(), Mock(), Mock())
-        blob.path = Mock(return_value='path')
-        blob.prev_commit = Mock()
-        blob.next_commit = Mock()
-        blob.prev_commit.get_path.return_value = '_prev'
-        blob.next_commit.get_path.return_value = '_next'
-        context = blob.context()
-        assert_equal(context, {'prev': '_prev', 'next': '_next'})
-        blob.prev_commit.get_path.assert_called_with('path', create=False)
-        blob.next_commit.get_path.assert_called_with('path', create=False)
-
-        blob.prev_commit.get_path.side_effect = KeyError
-        blob.next_commit.get_path.side_effect = KeyError
-        context = blob.context()
-        assert_equal(context, {'prev': None, 'next': None})
-
-    @patch.object(M.repo.LastCommit, '_prev_commit_id')
-    def test_prev_commit_no_create(self, lc_pcid):
-        lc_pcid.return_value = None
-        blob = M.repo.Blob(Mock(), 'foo', 'bid')
-        blob.tree.path.return_value = '/path/'
-        pc = blob.prev_commit
-        lc_pcid.assert_called_once_with(blob.commit, 'path/foo')
-        assert not blob.repo.commit.called
-        assert_equal(pc, None)
-
-        lc_pcid.reset_mock()
-        lc_pcid.return_value = 'pcid'
-        blob = M.repo.Blob(Mock(), 'foo', 'bid')
-        blob.tree.path.return_value = '/path/'
-        blob.repo.commit.return_value = 'commit'
-        pc = blob.prev_commit
-        lc_pcid.assert_called_once_with(blob.commit, 'path/foo')
-        blob.repo.commit.assert_called_once_with('pcid')
-        assert_equal(pc, 'commit')
-
-    def test_next_commit_no_create(self):
-        blob = M.repo.Blob(MagicMock(), MagicMock(), MagicMock())
-        blob._id = 'blob1'
-        blob.path = Mock(return_value='path')
-        blob.commit.context().__getitem__.return_value = None
-        nc = blob.next_commit
-        assert_equal(nc, None)
-
-        _next = MagicMock()
-        _next.context().__getitem__.return_value = None
-        _next.get_path.return_value = Mock(_id='blob2')
-        blob = M.repo.Blob(MagicMock(), MagicMock(), MagicMock())
-        blob._id = 'blob1'
-        blob.path = Mock(return_value='path')
-        blob.commit.context().__getitem__.return_value = [_next]
-        nc = blob.next_commit
-        _next.get_path.assert_called_with('path', create=False)
-        assert_equal(nc, _next)
-
     def test_pypeline_view(self):
         blob = M.repo.Blob(Mock(), Mock(), Mock())
         blob._id = 'blob1'


Mime
View raw message