incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [30/48] git commit: [#5094] Fixed issue with paging not being applied correctly to repo log
Date Tue, 30 Oct 2012 17:30:06 GMT
[#5094] Fixed issue with paging not being applied correctly to repo log

Signed-off-by: Cory Johns <johnsca@geek.net>


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

Branch: refs/heads/cj/5005
Commit: 71eaa5319a74d2c617d10a8431c4941043e8958a
Parents: 3d9e0fc
Author: Cory Johns <johnsca@geek.net>
Authored: Tue Oct 16 18:10:11 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Tue Oct 16 18:10:11 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |   36 ++++++-----------
 Allura/allura/tests/model/test_repo.py           |   12 +++---
 ForgeGit/forgegit/tests/model/test_repository.py |    6 +-
 ForgeSVN/forgesvn/model/svn.py                   |    2 +-
 4 files changed, 22 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71eaa531/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 99f9ba2..5255bdb 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -212,25 +212,13 @@ class Repository(Artifact, ActivityObject):
     def compute_tree_new(self, commit, path='/'):
         return self._impl.compute_tree_new(commit, path)
 
-    def _log(self, rev, skip, max_count):
+    def _log(self, rev, skip, limit):
         head = self.commit(rev)
         if head is None: return
-        for oids in utils.chunked_iter(self.commitlog([head._id]), QSIZE):
-            oids = list(oids)
-            commits = dict(
-                (ci._id, ci) for ci in head.query.find(dict(
-                        _id={'$in': oids})))
-            for oid in oids:
-                if skip:
-                    skip -= 1
-                    continue
-                if max_count:
-                    max_count -= 1
-                    ci = commits[oid]
-                    ci.set_context(self)
-                    yield ci
-                else:
-                    break
+        for _id in self.commitlog([head._id], skip, limit):
+            ci = head.query.get(_id=_id)
+            ci.set_context(self)
+            yield ci
 
     def init_as_clone(self, source_path, source_name, source_url, copy_hooks=False):
         self.upstream_repo.name = source_name
@@ -240,7 +228,7 @@ class Repository(Artifact, ActivityObject):
         self._impl.clone_from(source, copy_hooks)
 
     def log(self, branch='master', offset=0, limit=10):
-        return list(self._log(rev=branch, skip=offset, max_count=limit))
+        return list(self._log(branch, offset, limit))
 
     def commitlog(self, commit_ids, skip=0, limit=sys.maxint):
         seen = set()
@@ -273,12 +261,6 @@ class Repository(Artifact, ActivityObject):
                 else:
                     ci = max(commits, key=lambda ci:ci_times[ci])
                 commits.remove(ci)
-                if skip:
-                    skip -= 1
-                    continue
-                else:
-                    limit -= 1
-                yield ci
                 # remove this commit from its parents children and add any childless
                 # parents to the 'ready set'
                 new_parent = None
@@ -288,6 +270,12 @@ class Repository(Artifact, ActivityObject):
                     if not children:
                         commits.add(oid)
                         new_parent = oid
+                if skip:
+                    skip -= 1
+                    continue
+                else:
+                    limit -= 1
+                    yield ci
 
         # Load all the runs to build a commit graph
         ci_times = {}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71eaa531/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index a09c8ed..93d1cb3 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -125,14 +125,14 @@ class TestRepo(_TestWithRepo):
 
     @mock.patch.object(M.repo.CommitRunDoc.m, 'get')
     def test_log(self, crd):
-        head = mock.Mock(_id=4)
-        commits = [mock.Mock(_id=i) for i in (1,3,2)]
-        commits.append(head)
-        head.query.find.return_value = commits
+        head = mock.Mock(name='commit_head', _id=3)
+        commits = dict([(i, mock.Mock(name='commit_%s'%i, _id=i)) for i in range(3)])
+        commits[3] = head
+        head.query.get = lambda _id: commits[_id]
         self.repo._impl.commit = mock.Mock(return_value=head)
-        crd.return_value = mock.Mock(commit_ids=[4, 3, 2, 1], commit_times=[4, 3, 2, 1],
parent_commit_ids=[])
+        crd.return_value = mock.Mock(commit_ids=[3, 2, 1, 0], commit_times=[4, 3, 2, 1],
parent_commit_ids=[])
         log = self.repo.log()
-        assert_equal([c._id for c in log], [4, 3, 2, 1])
+        assert_equal([c._id for c in log], [3, 2, 1, 0])
 
     def test_count_revisions(self):
         ci = mock.Mock()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71eaa531/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 684c8d6..445489f 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -62,9 +62,9 @@ class TestNewGit(unittest.TestCase):
             '1e146e67985dcd71c74de79613719bef7bddca4a/')
         all_cis = self.repo.log(self.rev._id, 0, 1000)
         assert len(all_cis) == 4
-        assert self.repo.log(self.rev._id, 1,1000) == all_cis[1:]
-        assert self.repo.log(self.rev._id, 0,3) == all_cis[:3]
-        assert self.repo.log(self.rev._id, 1,2) == all_cis[1:3]
+        assert_equal(self.repo.log(self.rev._id, 1,1000), all_cis[1:])
+        assert_equal(self.repo.log(self.rev._id, 0,3), all_cis[:3])
+        assert_equal(self.repo.log(self.rev._id, 1,2), all_cis[1:3])
         for ci in all_cis:
             ci.context()
         self.rev.tree.ls()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/71eaa531/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 1b84553..23d80eb 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -66,7 +66,7 @@ class Repository(M.Repository):
         return int(ci._id.split(':')[1])
 
     def log(self, branch='HEAD', offset=0, limit=10):
-        return list(self._log(rev=branch, skip=offset, max_count=limit))
+        return list(self._log(branch, offset, limit))
 
     def commitlog(self, commit_ids, skip=0, limit=sys.maxint):
         ci_id = commit_ids[0]


Mime
View raw message