incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [20/50] git commit: [5775] ticket:404 fixed old tests
Date Thu, 05 Sep 2013 18:20:45 GMT
[5775] ticket:404 fixed old tests


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

Branch: refs/heads/cj/6596
Commit: 385611c4d50986bfce39cd36d6e1250d0b9df98e
Parents: dd57c98
Author: Anton Kasyanov <mind1master@gmail.com>
Authored: Thu Aug 1 14:50:13 2013 +0300
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Aug 29 19:00:44 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py             | 55 +++++++++++---------
 .../forgegit/tests/model/test_repository.py     | 18 ++++---
 2 files changed, 41 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/385611c4/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index f400d56..cee505f 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -301,8 +301,10 @@ class GitImplementation(M.RepositoryImplementation):
         path = path.strip('/') if path else None
         if exclude is not None:
             revs.extend(['^%s' % e for e in exclude])
-
-        for ci, refs in self._iter_commits_with_refs(revs, '--follow', '--', path):
+        args = [revs, '--', path]
+        if path:
+            args.append('--follow')
+        for ci, refs in self._iter_commits_with_refs(*args):
             if id_only:
                 yield ci.hexsha
             else:
@@ -312,30 +314,31 @@ class GitImplementation(M.RepositoryImplementation):
                     # checking for renaming in this commit
                     # log is called with follow, so there should be all commits
                     # even before renaming
-                    diffs_with_parent = ci.diff(ci.parents[0])
-                    deleted_file_diffs = []
-                    renamed = False
-                    for diff in diffs_with_parent:
-                        if not diff.b_mode and not diff.b_blob:
-                            #new file was created
-                            if diff.a_blob.name == os.path.basename(path):
-                                renamed = True
-                        if not diff.a_mode and not diff.a_blob:
-                            #file was deleted
-                            deleted_file_diffs.append(diff)
-                    if renamed:
-                        if len(deleted_file_diffs) > 1:
-                            log.info('Couldn\'t find if file was renamed: too many deletions')
-                        elif len(deleted_file_diffs) == 1:
-                            deleted_diff = deleted_file_diffs[0]
-                            renamed_from['path'] = '{}/{}'.format(
-                                os.path.dirname(path),
-                                deleted_diff.b_blob.name,
-                            )
-                            renamed_from['commit_id'] = ci.hexsha
-                            renamed_from['commit_url'] = self._repo.url_for_commit(
-                                ci.hexsha
-                            )
+                    if ci.parents:
+                        diffs_with_parent = ci.diff(ci.parents[0])
+                        deleted_file_diffs = []
+                        renamed = False
+                        for diff in diffs_with_parent:
+                            if not diff.b_mode and not diff.b_blob:
+                                #new file was created
+                                if diff.a_blob.name == os.path.basename(path):
+                                    renamed = True
+                            if not diff.a_mode and not diff.a_blob:
+                                #file was deleted
+                                deleted_file_diffs.append(diff)
+                        if renamed:
+                            if len(deleted_file_diffs) > 1:
+                                log.info('Couldn\'t find if file was renamed: too many deletions')
+                            elif len(deleted_file_diffs) == 1:
+                                deleted_diff = deleted_file_diffs[0]
+                                renamed_from['path'] = '{}/{}'.format(
+                                    os.path.dirname(path),
+                                    deleted_diff.b_blob.name,
+                                )
+                                renamed_from['commit_id'] = ci.hexsha
+                                renamed_from['commit_url'] = self._repo.url_for_commit(
+                                    ci.hexsha
+                                )
                     try:
                         node = ci.tree/path
                         size = node.size if node.type == 'blob' else None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/385611c4/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 85777e2..7d7f69b 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -240,7 +240,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Change README\n',
              'parents': ['df30427c488aeab84b2352bdf88a3b19223f9d7a'],
              'refs': ['HEAD', 'foo', 'master'],
-             'size': None},
+             'size': None,
+             'renamed_from': {}},
             {'authored': {'date': datetime.datetime(2010, 10, 7, 18, 44, 1),
                           'email': u'rcopeland@geek.net',
                           'name': u'Rick Copeland'},
@@ -251,7 +252,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Add README\n',
              'parents': ['6a45885ae7347f1cac5103b0050cc1be6a1496c8'],
              'refs': [],
-             'size': None},
+             'size': None,
+             'renamed_from': {}},
             {'authored': {'date': datetime.datetime(2010, 10, 7, 18, 43, 26),
                           'email': u'rcopeland@geek.net',
                           'name': u'Rick Copeland'},
@@ -262,7 +264,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Remove file\n',
              'parents': ['9a7df788cf800241e3bb5a849c8870f2f8259d98'],
              'refs': [],
-             'size': None},
+             'size': None,
+             'renamed_from': {}},
             {'authored': {'date': datetime.datetime(2010, 10, 7, 18, 42, 54),
                           'email': u'rcopeland@geek.net',
                           'name': u'Rick Copeland'},
@@ -273,7 +276,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Initial commit\n',
              'parents': [],
              'refs': [],
-             'size': None},
+             'size': None,
+             'renamed_from': {}},
             ])
 
     def test_log_file(self):
@@ -289,7 +293,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Change README\n',
              'parents': ['df30427c488aeab84b2352bdf88a3b19223f9d7a'],
              'refs': ['HEAD', 'foo', 'master'],
-             'size': 28},
+             'size': 28,
+             'renamed_from': {}},
             {'authored': {'date': datetime.datetime(2010, 10, 7, 18, 44, 1),
                           'email': u'rcopeland@geek.net',
                           'name': u'Rick Copeland'},
@@ -300,7 +305,8 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
              'message': u'Add README\n',
              'parents': ['6a45885ae7347f1cac5103b0050cc1be6a1496c8'],
              'refs': [],
-             'size': 15},
+             'size': 15,
+             'renamed_from': {}},
             ])
 
     def test_commit(self):


Mime
View raw message