You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/10/02 18:29:47 UTC

[3/7] git commit: [#5775] ticket:433 Allura Code Viewer: "copied from" improvements

[#5775] ticket:433 Allura Code Viewer: "copied from" improvements


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

Branch: refs/heads/master
Commit: b96a01104b954682789e4a15218541844d4c5c70
Parents: 2080fae
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Fri Sep 27 12:32:14 2013 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Oct 2 15:40:30 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py              |  2 +-
 ForgeSVN/forgesvn/model/svn.py                   | 15 +++++++++++++--
 ForgeSVN/forgesvn/tests/model/test_repository.py |  6 ++++++
 3 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b96a0110/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 29af6c7..955c9b3 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -393,7 +393,7 @@ class GitImplementation(M.RepositoryImplementation):
                     renamed = {}
                     if len(commit_lines) > 1:  # merge commits don't have any --name-status output
                         name_stat_parts = commit_lines[1].split(' ')
-                        if name_stat_parts[0] == 'R100':
+                        if name_stat_parts[0] in ['R100', 'R096']:
                             renamed['from'] = name_stat_parts[1]
                             renamed['to'] = name_stat_parts[2]
                     yield (git.Commit(self._git, gitdb.util.hex_to_bin(hexsha)), refs, renamed)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b96a0110/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 089572c..ec8d991 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -535,7 +535,7 @@ class SVNImplementation(M.RepositoryImplementation):
         while revno > exclude:
             rev = pysvn.Revision(pysvn.opt_revision_kind.number, revno)
             try:
-                logs = self._svn.log(url, revision_start=rev, limit=page_size,
+                logs = self._svn.log(url, revision_start=rev, peg_revision=rev, limit=page_size,
                     discover_changed_paths=True)
             except pysvn.ClientError as e:
                 if 'Unable to connect' in e.message:
@@ -553,6 +553,16 @@ class SVNImplementation(M.RepositoryImplementation):
                 return  # we didn't get a full page, don't bother calling SVN again
             revno = ci.revision.number - 1
 
+    def _check_changed_path(self, changed_path, path):
+        if (changed_path['copyfrom_path'] and
+                    changed_path['path'] and
+                    path and
+                    (len(changed_path['path']) < len(path)) and
+                    path.startswith(changed_path['path'])):
+                changed_path['copyfrom_path'] = changed_path['copyfrom_path'] + path[len(changed_path['path']):]
+                changed_path['path'] = path
+        return changed_path
+
     def _map_log(self, ci, url, path=None):
         revno = ci.revision.number
         try:
@@ -562,6 +572,7 @@ class SVNImplementation(M.RepositoryImplementation):
         rename_details = {}
         changed_paths = ci.get('changed_paths', [])
         for changed_path in changed_paths:
+            changed_path = self._check_changed_path(changed_path, path)
             if changed_path['copyfrom_path'] and changed_path['path'] == path and changed_path['action'] == 'A':
                 rename_details['path'] = changed_path['copyfrom_path']
                 rename_details['commit_url'] = self._repo.url_for_commit(
@@ -719,7 +730,7 @@ class SVNImplementation(M.RepositoryImplementation):
         url = '/'.join([self._url, path.strip('/')])
         rev = pysvn.Revision(pysvn.opt_revision_kind.number, self._revno(self.rev_parse(rev)))
         try:
-            info = self._svn.list(url, revision=rev, dirent_fields=pysvn.SVN_DIRENT_KIND)[0][0]
+            info = self._svn.list(url, revision=rev, peg_revision=rev, dirent_fields=pysvn.SVN_DIRENT_KIND)[0][0]
             return info.kind == pysvn.node_kind.file
         except pysvn.ClientError:
             return False

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b96a0110/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 2ed5de3..2a69339 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -1050,3 +1050,9 @@ class TestRename(unittest.TestCase):
             entry['rename_details']['commit_url'],
             self.repo.url_for_commit(2)  # previous revision
         )
+
+    def test_check_changed_path(self):
+        changed_path = {'copyfrom_path':'/test/path', 'path':'/test/path2'}
+        result = self.repo._impl._check_changed_path(changed_path, '/test/path2/file.txt')
+        assert_equal({'path': '/test/path2/file.txt', 'copyfrom_path': '/test/path/file.txt'}, result)
+