Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B10DE775 for ; Mon, 18 Feb 2013 21:01:59 +0000 (UTC) Received: (qmail 13766 invoked by uid 500); 18 Feb 2013 21:01:59 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 13747 invoked by uid 500); 18 Feb 2013 21:01:59 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 13738 invoked by uid 99); 18 Feb 2013 21:01:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Feb 2013 21:01:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B99BE82C175; Mon, 18 Feb 2013 21:01:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tvansteenburgh@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: [#5783] Only compute diffs for current page Message-Id: <20130218210158.B99BE82C175@tyr.zones.apache.org> Date: Mon, 18 Feb 2013 21:01:58 +0000 (UTC) Updated Branches: refs/heads/tv/5783 [created] 2c5550519 [#5783] Only compute diffs for current page Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/2c555051 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/2c555051 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/2c555051 Branch: refs/heads/tv/5783 Commit: 2c5550519a811bdadb0c74f683a40cf27bbfdc14 Parents: 0435184 Author: Tim Van Steenburgh Authored: Mon Feb 18 15:58:22 2013 +0000 Committer: Tim Van Steenburgh Committed: Mon Feb 18 21:00:58 2013 +0000 ---------------------------------------------------------------------- Allura/allura/controllers/repository.py | 6 ++-- Allura/allura/model/repo.py | 8 +++++- ForgeSVN/forgesvn/tests/model/test_repository.py | 19 ++++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2c555051/Allura/allura/controllers/repository.py ---------------------------------------------------------------------- diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py index 40a9bc3..14a523c 100644 --- a/Allura/allura/controllers/repository.py +++ b/Allura/allura/controllers/repository.py @@ -407,12 +407,12 @@ class CommitBrowser(BaseController): tree = self._commit.tree limit, page, start = g.handle_paging(limit, page, default=self.DEFAULT_PAGE_LIMIT) + diffs = self._commit.paged_diffs(start=start, end=start+limit) result['artifacts'] = [ (t,f) for t in ('added', 'removed', 'changed', 'copied') - for f in self._commit.diffs[t] + for f in diffs[t] if t == 'removed' or tree.get_blob_by_path(f)] - count = len(result['artifacts']) - result['artifacts'] = result['artifacts'][start:start+limit] + count = diffs['total'] result.update(dict(page=page, limit=limit, count=count)) return result http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2c555051/Allura/allura/model/repo.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py index 569cbb3..568e7f8 100644 --- a/Allura/allura/model/repo.py +++ b/Allura/allura/model/repo.py @@ -263,6 +263,9 @@ class Commit(RepoObject): @LazyProperty def diffs(self): + return self.paged_diffs() + + def paged_diffs(self, start=0, end=None): di = DiffInfoDoc.m.get(_id=self._id) if di is None: return Object(added=[], removed=[], changed=[], copied=[]) @@ -270,7 +273,7 @@ class Commit(RepoObject): removed = [] changed = [] copied = [] - for change in di.differences: + for change in di.differences[start:end]: if change.rhs_id is None: removed.append(change.name) elif change.lhs_id is None: @@ -280,7 +283,8 @@ class Commit(RepoObject): copied = self._diffs_copied(added, removed) return Object( added=added, removed=removed, - changed=changed, copied=copied) + changed=changed, copied=copied, + total=len(di.differences)) def _diffs_copied(self, added, removed): '''Return list with file renames diffs. http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2c555051/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 9006271..f3ac7bc 100644 --- a/ForgeSVN/forgesvn/tests/model/test_repository.py +++ b/ForgeSVN/forgesvn/tests/model/test_repository.py @@ -208,12 +208,21 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase): print entry.message print entry.diffs + def test_paged_diffs(self): + entry = self.repo.log(2, limit=1)[0] + self.assertEqual(entry.diffs, entry.paged_diffs()) + self.assertEqual(entry.diffs, entry.paged_diffs(start=0)) + expected = dict( + copied=[], changed=[], removed=[], + added=['/a/b', '/a/b/c'], total=4) + self.assertEqual(expected, entry.paged_diffs(start=1, end=3)) + def test_diff_create_file(self): entry = self.repo.log(1, limit=1)[0] self.assertEqual( entry.diffs, dict( copied=[], changed=[], - removed=[], added=['/README'])) + removed=[], added=['/README'], total=1)) def test_diff_create_path(self): entry = self.repo.log(2, limit=1)[0] @@ -222,21 +231,21 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase): copied=[], changed=[], removed=[], added=[ '/a', '/a/b', '/a/b/c', - '/a/b/c/hello.txt'])) + '/a/b/c/hello.txt'], total=4)) def test_diff_modify_file(self): entry = self.repo.log(3, limit=1)[0] self.assertEqual( entry.diffs, dict( copied=[], changed=['/README'], - removed=[], added=[])) + removed=[], added=[], total=1)) def test_diff_delete(self): entry = self.repo.log(4, limit=1)[0] self.assertEqual( entry.diffs, dict( copied=[], changed=[], - removed=['/a/b/c/hello.txt'], added=[])) + removed=['/a/b/c/hello.txt'], added=[], total=1)) def test_diff_copy(self): # Copies are currently only detected as 'add' @@ -244,7 +253,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase): self.assertEqual( entry.diffs, dict( copied=[], changed=[], - removed=[], added=['/b'])) + removed=[], added=['/b'], total=1)) def test_commit(self): entry = self.repo.commit(1)