| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,8 @@ Repo | |||
| 42 | 42 | * tree method now requires a Ref instance as input and defaults to the active_branche | |
| 43 | 43 | instead of master | |
| 44 | 44 | * Removed 'log' method as it as effectively the same as the 'commits' method | |
| 45 | + * 'commits' method has no max-count of returned commits anymore, it now behaves | ||
| 46 | + like git-rev-list | ||
| 45 | 47 | ||
| 46 | 48 | Diff | |
| 47 | 49 | ---- | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -197,7 +197,7 @@ def blame(self, commit, file): | |||
| 197 | 197 | # END distinguish hexsha vs other information | |
| 198 | 198 | return blames | |
| 199 | 199 | ||
| 200 | - def commits(self, start='master', path='', max_count=10, skip=0): | ||
| 200 | + def commits(self, start='master', path='', max_count=None, skip=0): | ||
| 201 | 201 | """ | |
| 202 | 202 | A list of Commit objects representing the history of a given ref/commit | |
| 203 | 203 | ||
@@ -209,7 +209,7 @@ def commits(self, start='master', path='', max_count=10, skip=0): | |||
| 209 | 209 | Commits that do not contain that path will not be returned. | |
| 210 | 210 | ||
| 211 | 211 | ``max_count`` | |
| 212 | - is the maximum number of commits to return (default 10) | ||
| 212 | + is the maximum number of commits to return (default None) | ||
| 213 | 213 | ||
| 214 | 214 | ``skip`` | |
| 215 | 215 | is the number of commits to skip (default 0) which will effectively | |
@@ -220,7 +220,10 @@ def commits(self, start='master', path='', max_count=10, skip=0): | |||
| 220 | 220 | """ | |
| 221 | 221 | options = {'max_count': max_count, | |
| 222 | 222 | 'skip': skip} | |
| 223 | - | ||
| 223 | + | ||
| 224 | + if max_count is None: | ||
| 225 | + options.pop('max_count') | ||
| 226 | + | ||
| 224 | 227 | return Commit.list_items(self, start, path, **options) | |
| 225 | 228 | ||
| 226 | 229 | def commits_between(self, frm, to): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -230,19 +230,3 @@ def test_equality(self): | |||
| 230 | 230 | assert_equal(commit1, commit2) | |
| 231 | 231 | assert_not_equal(commit2, commit3) | |
| 232 | 232 | ||
| 233 | - def test_iteration(self): | ||
| 234 | - root = self.repo.tree() | ||
| 235 | - head = self.repo.active_branch | ||
| 236 | - head_commit = self.repo.active_branch.object | ||
| 237 | - num_objs = 0 | ||
| 238 | - | ||
| 239 | - # find the first commit containing the given path - always do a full | ||
| 240 | - # iteration ( restricted to the path in question ), but in fact it should | ||
| 241 | - # return quite a lot of commits, we just take one and hence abort the operation | ||
| 242 | - | ||
| 243 | - for obj in root.traverse(): | ||
| 244 | - num_objs += 1 | ||
| 245 | - del( head_commit.tree ) # force it to clear the cache, just to make it harder | ||
| 246 | - assert obj in head_commit.tree.traverse() | ||
| 247 | - # END for each object | ||
| 248 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,38 @@ | |||
| 1 | + # test_performance.py | ||
| 2 | + # Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors | ||
| 3 | + # | ||
| 4 | + # This module is part of GitPython and is released under | ||
| 5 | + # the BSD License: http://www.opensource.org/licenses/bsd-license.php | ||
| 6 | + | ||
| 7 | + from test.testlib import * | ||
| 8 | + from git import * | ||
| 9 | + from time import time | ||
| 10 | + | ||
| 11 | + class TestPerformance(object): | ||
| 12 | + def setup(self): | ||
| 13 | + self.repo = Repo(GIT_REPO) | ||
| 14 | + | ||
| 15 | + def test_iteration(self): | ||
| 16 | + num_objs = 0 | ||
| 17 | + num_commits = 0 | ||
| 18 | + | ||
| 19 | + # find the first commit containing the given path - always do a full | ||
| 20 | + # iteration ( restricted to the path in question ), but in fact it should | ||
| 21 | + # return quite a lot of commits, we just take one and hence abort the operation | ||
| 22 | + | ||
| 23 | + st = time() | ||
| 24 | + for c in self.repo.commits(): | ||
| 25 | + num_commits += 1 | ||
| 26 | + c.author | ||
| 27 | + c.authored_date | ||
| 28 | + c.committer | ||
| 29 | + c.committed_date | ||
| 30 | + c.message | ||
| 31 | + for obj in c.tree.traverse(): | ||
| 32 | + obj.size | ||
| 33 | + num_objs += 1 | ||
| 34 | + # END for each object | ||
| 35 | + # END for each commit | ||
| 36 | + elapsed_time = time() - st | ||
| 37 | + print "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % (num_commits, num_objs, elapsed_time, num_objs/elapsed_time) | ||
| 38 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments