You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/03/05 11:35:28 UTC

[01/13] allura git commit: [#7837] ticket:736 Rewrite Commit.added_paths

Repository: allura
Updated Branches:
  refs/heads/ib/7837 [created] c4e2ddc59


[#7837] ticket:736 Rewrite Commit.added_paths


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

Branch: refs/heads/ib/7837
Commit: 0036ae62972a4207f32c0747b6df47edbcf23e9f
Parents: 7f2a9a5
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 15:01:25 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:36 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0036ae62/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 833d93e..75e9e0a 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1200,7 +1200,7 @@ class Commit(RepoObject, ActivityObject):
         Leading and trailing slashes are removed, and
         the list is complete, meaning that if a directory
         with subdirectories is added, all of the child
-        paths are included (this relies on the DiffInfoDoc
+        paths are included (this relies on the :meth paged_diffs:
         being complete).
 
         Example:
@@ -1210,13 +1210,10 @@ class Commit(RepoObject, ActivityObject):
             the file /foo/bar/baz/qux.txt, this would return:
             ['foo/bar', 'foo/bar/baz', 'foo/bar/baz/qux.txt']
         '''
-        diff_info = DiffInfoDoc.m.get(_id=self._id)
-        diffs = set()
-        if diff_info:
-            for d in diff_info.differences:
-                if d.lhs_id is None:
-                    diffs.add(d.name.strip('/'))
-        return diffs
+        paths = set()
+        for path in self.paged_diffs(self._id)['added']:
+            paths.add(path.strip('/'))
+        return paths
 
     @LazyProperty
     def info(self):


[05/13] allura git commit: [#7837] ticket:736 Wipe out all the traces of DiffInfoDoc

Posted by je...@apache.org.
[#7837] ticket:736 Wipe out all the traces of DiffInfoDoc


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

Branch: refs/heads/ib/7837
Commit: 61a60193f0e7a6638c7fc571e50b82cd0fb24c80
Parents: 0036ae6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:18:10 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:37 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repo.py                     |  2 +-
 Allura/allura/model/repo_refresh.py             | 75 +-------------------
 Allura/allura/model/repository.py               |  9 ---
 Allura/allura/scripts/refresh_last_commits.py   | 24 +------
 Allura/allura/scripts/refreshrepo.py            |  7 --
 Allura/test-light.py                            |  3 +-
 ForgeSVN/forgesvn/model/svn.py                  | 47 +-----------
 .../forgesvn/tests/model/test_repository.py     |  7 --
 8 files changed, 7 insertions(+), 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/allura/model/repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo.py b/Allura/allura/model/repo.py
index 645fdc5..f041116 100644
--- a/Allura/allura/model/repo.py
+++ b/Allura/allura/model/repo.py
@@ -21,6 +21,6 @@
 
 from .repository import SUser, SObjType
 from .repository import QSIZE, README_RE, VIEWABLE_EXTENSIONS, PYPELINE_EXTENSIONS, DIFF_SIMILARITY_THRESHOLD
-from .repository import CommitDoc, TreeDoc, LastCommitDoc, TreesDoc, DiffInfoDoc, CommitRunDoc
+from .repository import CommitDoc, TreeDoc, LastCommitDoc, TreesDoc, CommitRunDoc
 from .repository import RepoObject, Commit, Tree, Blob, LastCommit
 from .repository import ModelCache

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index d8ef050..1711bc3 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -31,7 +31,7 @@ from ming.orm import mapper, session, ThreadLocalORMSession
 
 from allura.lib import utils
 from allura.lib import helpers as h
-from allura.model.repository import CommitDoc, TreeDoc, TreesDoc, DiffInfoDoc
+from allura.model.repository import CommitDoc, TreeDoc, TreesDoc
 from allura.model.repository import CommitRunDoc
 from allura.model.repository import Commit, Tree, LastCommit, ModelCache
 from allura.model.index import ArtifactReferenceDoc, ShortlinkDoc
@@ -110,19 +110,10 @@ def refresh_repo(repo, all_commits=False, notify=True, new_clone=False):
 
     # Compute diffs
     cache = {}
-    # For some SCMs, we don't want to pre-compute the diffs because that
+    # For some SCMs, we don't want to pre-compute the LCDs because that
     # would be too expensive, so we skip them here and do them on-demand
     # with caching.
     if repo._refresh_precompute:
-        for i, oid in enumerate(commit_ids):
-            cid = CommitDoc.m.find(dict(_id=oid), validate=False).next()
-            ci = mapper(Commit).create(cid, dict(instrument=False))
-            ci.set_context(repo)
-            compute_diffs(repo._id, cache, ci)
-            if (i + 1) % 100 == 0:
-                log.info('Compute diffs %d: %s', (i + 1), ci._id)
-
-    if repo._refresh_precompute:
         model_cache = ModelCache()
         lcid_cache = {}
         for i, oid in enumerate(reversed(commit_ids)):
@@ -368,68 +359,6 @@ def unknown_commit_ids(all_commit_ids):
     return result
 
 
-def compute_diffs(repo_id, tree_cache, rhs_ci):
-    '''compute simple differences between a commit and its first parent'''
-    if rhs_ci.tree_id is None:
-        return tree_cache
-
-    def _update_cache(lhs_tree_ids, rhs_tree_ids):
-        # crazy cache logic that I'm not certain I understand
-        new_tree_ids = [
-            tid for tid in chain(lhs_tree_ids, rhs_tree_ids)
-            if tid not in tree_cache]
-        tree_index = dict(
-            (t._id, t) for t in TreeDoc.m.find(dict(_id={'$in': new_tree_ids}), validate=False))
-        tree_index.update(tree_cache)
-        rhs_tree_ids_set = set(rhs_tree_ids)
-        tree_cache.clear()
-        tree_cache.update(
-            (id, t) for id, t in tree_index.iteritems() if id in rhs_tree_ids_set)
-        return tree_index
-
-    empty_tree = Object(_id=None, tree_ids=[], blob_ids=[], other_ids=[])
-    commit_info = get_commit_info(rhs_ci)
-    differences = []
-    rhs_treesdoc = TreesDoc.m.get(_id=rhs_ci._id)
-    if not rhs_treesdoc:
-        # FIXME: These sometimes don't exist for unknown reasons; they should
-        # be auto-gen'ed
-        log.error('Missing TreesDoc: %s', rhs_ci)
-        return tree_cache
-    for lhs_cid in rhs_ci.parent_ids:
-        lhs_ci = CommitDoc.m.get(_id=lhs_cid)
-        if lhs_ci is None:
-            log.error(
-                'Commit ID referenced as parent but not found: %s parent of %s', lhs_cid, rhs_ci)
-            continue
-        lhs_treesdoc = TreesDoc.m.get(_id=lhs_cid)
-        if not lhs_treesdoc:
-            # FIXME: These sometimes don't exist for unknown reasons; they
-            # should be auto-gen'ed
-            log.error('Missing TreesDoc: %s', rhs_ci)
-            continue
-        tree_index = _update_cache(
-            lhs_treesdoc.tree_ids, rhs_treesdoc.tree_ids)
-        rhs_tree = tree_index[rhs_ci.tree_id]
-        lhs_tree = tree_index.get(lhs_ci.tree_id, empty_tree)
-        for name, lhs_id, rhs_id in _diff_trees(lhs_tree, rhs_tree, tree_index):
-            differences.append(
-                dict(name=name, lhs_id=lhs_id, rhs_id=rhs_id))
-    if not rhs_ci.parent_ids:
-        # no parents, so everything in rhs is new
-        tree_index = _update_cache([], rhs_treesdoc.tree_ids)
-        rhs_tree = tree_index[rhs_ci.tree_id]
-        for name, lhs_id, rhs_id in _diff_trees(empty_tree, rhs_tree, tree_index):
-            differences.append(
-                dict(name=name, lhs_id=lhs_id, rhs_id=rhs_id))
-    # Build the diffinfo
-    di = DiffInfoDoc(dict(
-        _id=rhs_ci._id,
-        differences=differences))
-    di.m.save()
-    return tree_cache
-
-
 def send_notifications(repo, commit_ids):
     '''Create appropriate notification and feed objects for a refresh'''
     from allura.model import Feed, Notification

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 75e9e0a..58633bc 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -858,15 +858,6 @@ TreesDoc = collection(
     Field('_id', str),
     Field('tree_ids', [str]))
 
-# Information about which things were added/removed in  commit
-# DiffInfoDoc._id = CommitDoc._id
-DiffInfoDoc = collection(
-    'repo_diffinfo', main_doc_session,
-    Field('_id', str),
-    Field(
-        'differences',
-        [dict(name=str, lhs_id=str, rhs_id=str)]))
-
 # List of commit runs (a run is a linear series of single-parent commits)
 # CommitRunDoc.commit_ids = [ CommitDoc._id, ... ]
 CommitRunDoc = collection(

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/allura/scripts/refresh_last_commits.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/refresh_last_commits.py b/Allura/allura/scripts/refresh_last_commits.py
index 4673a2a..095fafb 100644
--- a/Allura/allura/scripts/refresh_last_commits.py
+++ b/Allura/allura/scripts/refresh_last_commits.py
@@ -70,8 +70,6 @@ class RefreshLastCommits(ScriptTask):
                             'project(s) being refreshed before doing the refresh.')
         parser.add_argument('--dry-run', action='store_true', dest='dry_run',
                             default=False, help='Log names of projects that would have their ')
-        parser.add_argument('--diffs', action='store_true', dest='diffs',
-                            default=False, help='Refresh / clean diffs as well as LCDs')
         parser.add_argument('--limit', action='store', type=int, dest='limit',
                             default=False, help='Limit of how many commits to process')
         return parser
@@ -118,7 +116,7 @@ class RefreshLastCommits(ScriptTask):
                         ci_ids = list(
                             reversed(list(c.app.repo.all_commit_ids())))
                         if options.clean:
-                            cls._clean(ci_ids, options.diffs)
+                            cls._clean(ci_ids)
 
                         log.info('Refreshing all last commits in %r',
                                  c.app.repo)
@@ -138,16 +136,6 @@ class RefreshLastCommits(ScriptTask):
     def refresh_repo_lcds(cls, commit_ids, options):
         tree_cache = {}
         timings = []
-        if options.diffs:
-            print 'Processing diffs'
-            for i, commit_id in enumerate(commit_ids):
-                commit = M.repository.Commit.query.get(_id=commit_id)
-                with time(timings):
-                    M.repo_refresh.compute_diffs(
-                        c.app.repo._id, tree_cache, commit)
-                if i % 1000 == 0:
-                    cls._print_stats(i, timings, 1000)
-
         model_cache = M.repository.ModelCache(
             max_instances={M.repository.LastCommit: 4000},
             max_queries={M.repository.LastCommit: 4000},
@@ -171,15 +159,7 @@ class RefreshLastCommits(ScriptTask):
         ThreadLocalORMSession.flush_all()
 
     @classmethod
-    def _clean(cls, commit_ids, clean_diffs):
-        if clean_diffs:
-            # delete DiffInfoDocs
-            i = M.repository.DiffInfoDoc.m.find(
-                dict(_id={'$in': commit_ids})).count()
-            log.info("Deleting %i DiffInfoDoc docs for %i commits...",
-                     i, len(commit_ids))
-            M.repository.DiffInfoDoc.m.remove(dict(_id={'$in': commit_ids}))
-
+    def _clean(cls, commit_ids):
         # delete LastCommitDocs
         i = M.repository.LastCommitDoc.m.find(
             dict(commit_id={'$in': commit_ids})).count()

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/allura/scripts/refreshrepo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/refreshrepo.py b/Allura/allura/scripts/refreshrepo.py
index 08f3fcc..a336b0d 100644
--- a/Allura/allura/scripts/refreshrepo.py
+++ b/Allura/allura/scripts/refreshrepo.py
@@ -118,13 +118,6 @@ class RefreshRepo(ScriptTask):
                                 M.repository.LastCommitDoc.m.remove(
                                     dict(commit_ids={'$in': ci_ids_chunk}))
 
-                            i = M.repository.DiffInfoDoc.m.find(
-                                {"_id": {"$in": ci_ids_chunk}}).count()
-                            if i:
-                                log.info("Deleting %i DiffInfoDoc docs...", i)
-                                M.repository.DiffInfoDoc.m.remove(
-                                    {"_id": {"$in": ci_ids_chunk}})
-
                             i = M.repository.CommitRunDoc.m.find(
                                 {"commit_ids": {"$in": ci_ids_chunk}}).count()
                             if i:

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/Allura/test-light.py
----------------------------------------------------------------------
diff --git a/Allura/test-light.py b/Allura/test-light.py
index be218b9..f095214 100644
--- a/Allura/test-light.py
+++ b/Allura/test-light.py
@@ -20,7 +20,7 @@ import sys
 from pylons import tmpl_context as c
 
 from allura.lib import helpers as h
-from allura.model.repository import CommitDoc, TreeDoc, TreesDoc, DiffInfoDoc
+from allura.model.repository import CommitDoc, TreeDoc, TreesDoc
 from allura.model.repository import LastCommitDoc, CommitRunDoc
 from allura.model.repo_refresh import refresh_repo
 
@@ -35,7 +35,6 @@ def main():
     CommitDoc.m.remove({})
     TreeDoc.m.remove({})
     TreesDoc.m.remove({})
-    DiffInfoDoc.m.remove({})
     LastCommitDoc.m.remove({})
     CommitRunDoc.m.remove({})
 

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 92dc292..420cc76 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -75,9 +75,6 @@ class Repository(M.Repository):
                                        'checkout_url'),
                                    dest_path=self.suggested_clone_dest_path()))
 
-    def compute_diffs(self):
-        return
-
     def latest(self, branch=None):
         if self._impl is None:
             return None
@@ -354,7 +351,7 @@ class SVNImplementation(M.RepositoryImplementation):
             oid for oid in oids if oid not in seen_oids]
 
     def refresh_commit_info(self, oid, seen_object_ids, lazy=True):
-        from allura.model.repository import CommitDoc, DiffInfoDoc
+        from allura.model.repository import CommitDoc
         ci_doc = CommitDoc.m.get(_id=oid)
         if ci_doc and lazy:
             return False
@@ -396,48 +393,6 @@ class SVNImplementation(M.RepositoryImplementation):
             except DuplicateKeyError:
                 if lazy:
                     return False
-        # Save diff info
-        di = DiffInfoDoc.make(dict(_id=ci_doc._id, differences=[]))
-        for path in log_entry.changed_paths:
-            if path.action in ('A', 'M', 'R'):
-                try:
-                    rhs_info = self._svn.info2(
-                        self._url + h.really_unicode(path.path),
-                        revision=self._revision(ci_doc._id),
-                        recurse=False)[0][1]
-                    rhs_id = self._obj_oid(ci_doc._id, rhs_info)
-                except pysvn.ClientError, e:
-                    # pysvn will sometimes misreport deleted files (D) as
-                    # something else (like A), causing info2() to raise a
-                    # ClientError since the file doesn't exist in this
-                    # revision. Set lrhs_id = None to treat like a deleted file
-                    log.info('This error was handled gracefully and logged '
-                             'for informational purposes only:\n' + str(e))
-                    rhs_id = None
-            else:
-                rhs_id = None
-            if ci_doc.parent_ids and path.action in ('D', 'M', 'R'):
-                try:
-                    lhs_info = self._svn.info2(
-                        self._url + h.really_unicode(path.path),
-                        revision=self._revision(ci_doc.parent_ids[0]),
-                        recurse=False)[0][1]
-                    lhs_id = self._obj_oid(ci_doc._id, lhs_info)
-                except pysvn.ClientError, e:
-                    # pysvn will sometimes report new files as 'M'odified,
-                    # causing info2() to raise ClientError since the file
-                    # doesn't exist in the parent revision. Set lhs_id = None
-                    # to treat like a newly added file.
-                    log.info('This error was handled gracefully and logged '
-                             'for informational purposes only:\n' + str(e))
-                    lhs_id = None
-            else:
-                lhs_id = None
-            di.differences.append(dict(
-                name=h.really_unicode(path.path),
-                lhs_id=lhs_id,
-                rhs_id=rhs_id))
-        di.m.save()
         return True
 
     def compute_tree_new(self, commit, tree_path='/'):

http://git-wip-us.apache.org/repos/asf/allura/blob/61a60193/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 eb952e1..c16559f 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -1052,8 +1052,6 @@ class TestCommit(_TestWithRepo):
         self.repo._impl.commit = mock.Mock(return_value=self.ci)
         self.repo._impl.open_blob = self._unique_blobs()
         M.repo_refresh.refresh_commit_trees(self.ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, self.ci)
-        # self.ci.compute_diffs()
         assert_equal(self.ci.diffs.added,
                      ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (self.ci.diffs.copied
@@ -1064,7 +1062,6 @@ class TestCommit(_TestWithRepo):
         ci.parent_ids = ['foo']
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
         assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (ci.diffs.copied
                 == ci.diffs.changed
@@ -1080,7 +1077,6 @@ class TestCommit(_TestWithRepo):
         ci.parent_ids = ['foo']
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
         assert_equal(ci.diffs.added, ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'])
         assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (ci.diffs.copied
@@ -1104,7 +1100,6 @@ class TestCommit(_TestWithRepo):
 
         self.repo._impl.commit = mock.Mock(return_value=self.ci)
         M.repo_refresh.refresh_commit_trees(self.ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, self.ci)
         assert_equal(self.ci.diffs.added,
                      ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (self.ci.diffs.copied
@@ -1122,7 +1117,6 @@ class TestCommit(_TestWithRepo):
         ci.parent_ids = ['foo']
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
         assert_equal(ci.diffs.added, ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'])
         assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
         assert (ci.diffs.copied
@@ -1138,7 +1132,6 @@ class TestCommit(_TestWithRepo):
         ci.parent_ids = ['bar']
         self._make_log(ci)
         M.repo_refresh.refresh_commit_trees(ci, {})
-        M.repo_refresh.compute_diffs(self.repo._id, {}, ci)
         assert_equal(ci.diffs.added, [])
         assert_equal(ci.diffs.changed, [])
         assert_equal(ci.diffs.removed, ['b/a/a'])


[06/13] allura git commit: [#7837] ticket:736 Add usefull diff-tree options

Posted by je...@apache.org.
[#7837] ticket:736 Add usefull diff-tree options

- `--root` to show initial commit as a big creation event
- `-t` to show tree entry itself as well as subtrees.
  Commit.added_paths relies on this


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

Branch: refs/heads/ib/7837
Commit: 7cb590b359f7fcdd1f5e162c46d21d78763b8d9f
Parents: 0843d53
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 08:03:40 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:38 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7cb590b3/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index c2b1983..4d8ffc1 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -566,7 +566,10 @@ class GitImplementation(M.RepositoryImplementation):
             '--no-commit-id',
             '--name-status',
             '--no-renames',
-            '-r',
+            '--root',
+            # show tree entry itself as well as subtrees (Commit.added_paths
+            # relies on this)
+            '-t',
             commit_id)
         files = files.splitlines()
         total = len(files)


[09/13] allura git commit: [#7837] ticket:738 Fix some tests

Posted by je...@apache.org.
[#7837] ticket:738 Fix some tests


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

Branch: refs/heads/ib/7837
Commit: 1b4748bb7940d298d2d59dd1f4e6e05d9f1fb037
Parents: c9497d8
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 13:46:52 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:39 2015 +0000

----------------------------------------------------------------------
 .../forgesvn/tests/model/test_repository.py     | 122 +++++++++++++------
 1 file changed, 86 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1b4748bb/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 c16559f..103e586 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -774,7 +774,6 @@ class _TestWithRepo(_Test):
         self.repo._impl.all_commit_ids = lambda *a, **kw: []
         self.repo._impl.commit().symbolic_ids = None
         ThreadLocalORMSession.flush_all()
-        # ThreadLocalORMSession.close_all()
 
 
 class _TestWithRepoAndCommit(_TestWithRepo):
@@ -1048,41 +1047,6 @@ class TestCommit(_TestWithRepo):
         from cStringIO import StringIO
         return lambda blob: StringIO(str(blobs[blob.path()]))
 
-    def test_compute_diffs(self):
-        self.repo._impl.commit = mock.Mock(return_value=self.ci)
-        self.repo._impl.open_blob = self._unique_blobs()
-        M.repo_refresh.refresh_commit_trees(self.ci, {})
-        assert_equal(self.ci.diffs.added,
-                     ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
-        assert (self.ci.diffs.copied
-                == self.ci.diffs.changed
-                == self.ci.diffs.removed
-                == [])
-        ci, isnew = self._make_commit('bar')
-        ci.parent_ids = ['foo']
-        self._make_log(ci)
-        M.repo_refresh.refresh_commit_trees(ci, {})
-        assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
-        assert (ci.diffs.copied
-                == ci.diffs.changed
-                == ci.diffs.added
-                == [])
-        ci, isnew = self._make_commit(
-            'baz',
-            b=dict(
-                a=dict(
-                    a='',
-                    b='',),
-                b=''))
-        ci.parent_ids = ['foo']
-        self._make_log(ci)
-        M.repo_refresh.refresh_commit_trees(ci, {})
-        assert_equal(ci.diffs.added, ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'])
-        assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
-        assert (ci.diffs.copied
-                == ci.diffs.changed
-                == [])
-
     def test_diffs_file_renames(self):
         def open_blob(blob):
             blobs = {
@@ -1099,6 +1063,12 @@ class TestCommit(_TestWithRepo):
         self.repo._impl.open_blob = open_blob
 
         self.repo._impl.commit = mock.Mock(return_value=self.ci)
+        self.repo._impl.paged_diffs.return_value = {
+            'added': ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'],
+            'changed': [],
+            'removed': [],
+            'total': 5,
+        }
         M.repo_refresh.refresh_commit_trees(self.ci, {})
         assert_equal(self.ci.diffs.added,
                      ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
@@ -1116,6 +1086,12 @@ class TestCommit(_TestWithRepo):
                 b=''))
         ci.parent_ids = ['foo']
         self._make_log(ci)
+        self.repo._impl.paged_diffs.return_value = {
+            'added': ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'],
+            'changed': [],
+            'removed': ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'],
+            'total': 10,
+        }
         M.repo_refresh.refresh_commit_trees(ci, {})
         assert_equal(ci.diffs.added, ['b', 'b/a', 'b/a/a', 'b/a/b', 'b/b'])
         assert_equal(ci.diffs.removed, ['a', 'a/a', 'a/a/a', 'a/a/b', 'a/b'])
@@ -1131,6 +1107,12 @@ class TestCommit(_TestWithRepo):
                 c=''))
         ci.parent_ids = ['bar']
         self._make_log(ci)
+        self.repo._impl.paged_diffs.return_value = {
+            'added': ['b/c', 'b/a/z'],
+            'changed': [],
+            'removed': ['b/a/b', 'b/b', 'b/a/a'],
+            'total': 10,
+        }
         M.repo_refresh.refresh_commit_trees(ci, {})
         assert_equal(ci.diffs.added, [])
         assert_equal(ci.diffs.changed, [])
@@ -1188,3 +1170,71 @@ class TestRename(unittest.TestCase):
             changed_path, '/test/path2/file.txt')
         assert_equal({'path': '/test/path2/file.txt',
                      'copyfrom_path': '/test/path/file.txt'}, result)
+
+
+class TestDirectRepoAccess(object):
+
+    def setUp(self):
+        setup_basic_test()
+        self.setup_with_tools()
+
+    @with_svn
+    def setup_with_tools(self):
+        setup_global_objects()
+        h.set_context('test', 'src', neighborhood='Projects')
+        repo_dir = pkg_resources.resource_filename(
+            'forgesvn', 'tests/data/')
+        self.repo = SM.Repository(
+            name='testsvn',
+            fs_path=repo_dir,
+            url_path='/test/',
+            tool='svn',
+            status='creating')
+        self.repo.refresh()
+        self.rev = self.repo.commit('HEAD')
+        ThreadLocalORMSession.flush_all()
+        ThreadLocalORMSession.close_all()
+
+    def test_paged_diffs(self):
+        diffs = self.rev.diffs
+        expected = {
+            'added': [u'ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
+            'removed': [],
+            'changed': [],
+            'copied': [],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)
+
+        _id = self.repo._impl._oid(2)
+        diffs = self.repo.commit(_id).diffs
+        expected = {
+            'added': [u'a/b/c/hello.txt', u'a/b/c', u'a/b', u'a'],
+            'removed': [],
+            'changed': [],
+            'copied': [],
+            'total': 4,
+        }
+        assert_equals(diffs, expected)
+
+        _id = self.repo._impl._oid(3)
+        diffs = self.repo.commit(_id).diffs
+        expected = {
+            'added': [],
+            'removed': [],
+            'changed': [u'README'],
+            'copied': [],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)
+
+        _id = self.repo._impl._oid(4)
+        diffs = self.repo.commit(_id).diffs
+        expected = {
+            'added': [],
+            'removed': ['a/b/c/hello.txt'],
+            'changed': [],
+            'copied': [],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)


[02/13] allura git commit: [#7837] ticket:736 Rewrite Commit.paged_diffs for Git

Posted by je...@apache.org.
[#7837] ticket:736 Rewrite Commit.paged_diffs for Git


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

Branch: refs/heads/ib/7837
Commit: 7f2a9a5a41d4688363c74e5921d2d4db5223a576
Parents: 0126faa
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 14:37:40 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:36 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py   | 36 ++++++++++++++++----------------
 ForgeGit/forgegit/model/git_repo.py | 25 ++++++++++++++++++++++
 2 files changed, 43 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7f2a9a5a/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 0030aa5..833d93e 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -313,6 +313,14 @@ class RepositoryImplementation(object):
         """
         raise NotImplemented('get_changes')
 
+    def paged_diffs(self, commit_id, start=0, end=None):
+        """
+        Returns files touched by the commit, grouped by status (added, removed,
+        and changed) and the total number of such files.  Paginates according
+        to :param start: and :param end:.
+        """
+        raise NotImplemented('paged_diffs')
+
 
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE = 100
@@ -485,6 +493,9 @@ class Repository(Artifact, ActivityObject):
     def set_default_branch(self, name):
         return self._impl.set_default_branch(name)
 
+    def paged_diffs(self, commit_id, start=0, end=None):
+        return self._impl.paged_diffs(commit_id, start, end)
+
     def _log(self, rev, skip, limit):
         head = self.commit(rev)
         if head is None:
@@ -1069,25 +1080,14 @@ class Commit(RepoObject, ActivityObject):
         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=[], total=0)
-        added = []
-        removed = []
-        changed = []
-        copied = []
-        for change in di.differences[start:end]:
-            if change.rhs_id is None:
-                removed.append(change.name)
-            elif change.lhs_id is None:
-                added.append(change.name)
-            else:
-                changed.append(change.name)
-        copied = self._diffs_copied(added, removed)
+        diffs = self.repo.paged_diffs(self._id, start, end)
+        diffs['copied'] = self._diffs_copied(diffs['added'], diffs['removed'])
         return Object(
-            added=added, removed=removed,
-            changed=changed, copied=copied,
-            total=len(di.differences))
+            added=diffs['added'],
+            removed=diffs['removed'],
+            changed=diffs['changed'],
+            copied=diffs['copied'],
+            total=diffs['total'])
 
     def _diffs_copied(self, added, removed):
         '''Return list with file renames diffs.

http://git-wip-us.apache.org/repos/asf/allura/blob/7f2a9a5a/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 7fda67a..c5bec04 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -560,6 +560,31 @@ class GitImplementation(M.RepositoryImplementation):
             pretty='format:',
             max_count=1).splitlines()[1:]
 
+    def paged_diffs(self, commit_id, start, end):
+        added, removed, changed = [], [], []
+        files = self._git.git.diff_tree(
+            '--no-commit-id',
+            '--name-status',
+            '--no-renames',
+            '-r',
+            commit_id)
+        files = files.splitlines()
+        total = len(files)
+        for f in files[start:end]:
+            status, name = f.split('\t', 1)
+            if status == 'A':
+                added.append(name)
+            elif status == 'D':
+                removed.append(name)
+            elif status == 'M':
+                changed.append(name)
+        return {
+            'added': added,
+            'removed': removed,
+            'changed': changed,
+            'total': total,
+        }
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE = 4096


[08/13] allura git commit: [#7837] ticket:736 Fix LCD tests

Posted by je...@apache.org.
[#7837] ticket:736 Fix LCD tests


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

Branch: refs/heads/ib/7837
Commit: 0843d535fb464d9c0cff037aa695896b4a76c03d
Parents: d9a1367
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 17:39:43 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:38 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_repo.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0843d535/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 9e2af07..9d65c20 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -136,7 +136,16 @@ class TestLastCommit(unittest.TestCase):
         setup_basic_test()
         setup_global_objects()
         self.repo = mock.Mock(
-            'repo', _commits=OrderedDict(), _last_commit=None)
+            name='repo',
+            _commits=OrderedDict(),
+            _last_commit=None,
+            spec=M.Repository)
+        self.repo.paged_diffs.return_value = {
+            'added': [],
+            'removed': [],
+            'changed': [],
+            'total': 0,
+        }
         self.repo.shorthand_for_commit = lambda _id: _id[:6]
         self.repo.rev_to_commit_id = lambda rev: rev
         self.repo.log = self._log


[03/13] allura git commit: [#7837] ticket:736 s/NotImplemented/NotImplementedError/

Posted by je...@apache.org.
[#7837] ticket:736 s/NotImplemented/NotImplementedError/

Because NotImplemented raises NotImplementedType is not callable, and that's
not the intention here.


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

Branch: refs/heads/ib/7837
Commit: d9a13673f4602d3dceb73f98434feddb828da635
Parents: 5904caa
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:34:06 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:37 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 44 +++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d9a13673/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 04fe6cc..8d03f8f 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -93,13 +93,13 @@ class RepositoryImplementation(object):
         raise NotImplementedError('init')
 
     def clone_from(self, source_url):  # pragma no cover
-        raise NotImplemented('clone_from')
+        raise NotImplementedError('clone_from')
 
     def commit(self, revision):  # pragma no cover
-        raise NotImplemented('commit')
+        raise NotImplementedError('commit')
 
     def all_commit_ids(self):  # pragma no cover
-        raise NotImplemented('all_commit_ids')
+        raise NotImplementedError('all_commit_ids')
 
     def new_commits(self, all_commits=False):  # pragma no cover
         '''Return a list of native commits in topological order (heads first).
@@ -107,21 +107,21 @@ class RepositoryImplementation(object):
         "commit" is a repo-native object, NOT a Commit object.
         If all_commits is False, only return commits not already indexed.
         '''
-        raise NotImplemented('new_commits')
+        raise NotImplementedError('new_commits')
 
     def commit_parents(self, commit):  # pragma no cover
         '''Return a list of native commits for the parents of the given (native)
         commit'''
-        raise NotImplemented('commit_parents')
+        raise NotImplementedError('commit_parents')
 
     def refresh_commit_info(self, oid, lazy=True):  # pragma no cover
         '''Refresh the data in the commit with id oid'''
-        raise NotImplemented('refresh_commit_info')
+        raise NotImplementedError('refresh_commit_info')
 
     def _setup_hooks(self, source_path=None):  # pragma no cover
         '''Install a hook in the repository that will ping the refresh url for
         the repo.  Optionally provide a path from which to copy existing hooks.'''
-        raise NotImplemented('_setup_hooks')
+        raise NotImplementedError('_setup_hooks')
 
     # pragma no cover
     def log(self, revs=None, path=None, exclude=None, id_only=True, **kw):
@@ -144,31 +144,31 @@ class RepositoryImplementation(object):
         If id_only is True, returns only the commit ID (which can be faster),
         otherwise it returns detailed information about each commit.
         """
-        raise NotImplemented('log')
+        raise NotImplementedError('log')
 
     def compute_tree_new(self, commit, path='/'):  # pragma no cover
         '''Used in hg and svn to compute a git-like-tree lazily with the new models'''
-        raise NotImplemented('compute_tree')
+        raise NotImplementedError('compute_tree')
 
     def open_blob(self, blob):  # pragma no cover
         '''Return a file-like object that contains the contents of the blob'''
-        raise NotImplemented('open_blob')
+        raise NotImplementedError('open_blob')
 
     def blob_size(self, blob):
         '''Return a blob size in bytes'''
-        raise NotImplemented('blob_size')
+        raise NotImplementedError('blob_size')
 
     def tarball(self, revision, path=None):
         '''Create a tarball for the revision'''
-        raise NotImplemented('tarball')
+        raise NotImplementedError('tarball')
 
     def is_empty(self):
         '''Determine if the repository is empty by checking the filesystem'''
-        raise NotImplemented('is_empty')
+        raise NotImplementedError('is_empty')
 
     def is_file(self, path, rev=None):
         '''Determine if the repository is a file by checking the filesystem'''
-        raise NotImplemented('is_file')
+        raise NotImplementedError('is_file')
 
     @classmethod
     def shorthand_for_commit(cls, oid):
@@ -176,7 +176,7 @@ class RepositoryImplementation(object):
 
     def symbolics_for_commit(self, commit):
         '''Return symbolic branch and tag names for a commit.'''
-        raise NotImplemented('symbolics_for_commit')
+        raise NotImplementedError('symbolics_for_commit')
 
     def url_for_commit(self, commit, url_type='ci'):
         'return an URL, given either a commit or object id'
@@ -218,19 +218,19 @@ class RepositoryImplementation(object):
 
     @property
     def head(self):
-        raise NotImplemented('head')
+        raise NotImplementedError('head')
 
     @property
     def heads(self):
-        raise NotImplemented('heads')
+        raise NotImplementedError('heads')
 
     @property
     def branches(self):
-        raise NotImplemented('branches')
+        raise NotImplementedError('branches')
 
     @property
     def tags(self):
-        raise NotImplemented('tags')
+        raise NotImplementedError('tags')
 
     def last_commit_ids(self, commit, paths):
         '''
@@ -311,7 +311,7 @@ class RepositoryImplementation(object):
         """
         Return the list of files changed by a given commit.
         """
-        raise NotImplemented('get_changes')
+        raise NotImplementedError('get_changes')
 
     def paged_diffs(self, commit_id, start=0, end=None):
         """
@@ -319,7 +319,7 @@ class RepositoryImplementation(object):
         and changed) and the total number of such files.  Paginates according
         to :param start: and :param end:.
         """
-        raise NotImplemented('paged_diffs')
+        raise NotImplementedError('paged_diffs')
 
 
 class Repository(Artifact, ActivityObject):
@@ -677,7 +677,7 @@ class Repository(Artifact, ActivityObject):
         self._impl.tarball(revision, path)
 
     def rev_to_commit_id(self, rev):
-        raise NotImplemented('rev_to_commit_id')
+        raise NotImplementedError('rev_to_commit_id')
 
     def set_status(self, status):
         '''


[13/13] allura git commit: [#7837] ticket:738 Fix repo initialization in tests

Posted by je...@apache.org.
[#7837] ticket:738 Fix repo initialization in tests

The problem with previous configuration is in the following:

1. `with_tool` installs app, which creates Repository model
2. test setup in most places creates *another* Repository model in a context of
   app installed by `with_tool`. This makes two Repositories linked to one app.
3. `app.repo` returns first Repository from the DB for app, which can be any of
   those two, depending on test run

That's why some tests, that depend on `app.repo` have failed occasionally (e.g.
`test_webhook_payload` for both git and svn)

Fixed all the tests I found to avoid this problems in the future. It took me
awhile to figure out what's wrong.


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

Branch: refs/heads/ib/7837
Commit: c4e2ddc59dede810be10c928e4e11b259bba53d3
Parents: 5249a8d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 4 16:31:03 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 17:36:02 2015 +0000

----------------------------------------------------------------------
 .../forgegit/tests/model/test_repository.py     | 46 ++++---------
 .../forgesvn/tests/model/test_repository.py     | 68 ++++++++------------
 2 files changed, 41 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c4e2ddc5/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 62ba264..2d00ff8 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -62,12 +62,6 @@ class TestNewGit(unittest.TestCase):
         c.app.repo.fs_path = repo_dir
         c.app.repo.name = 'testgit.git'
         self.repo = c.app.repo
-        # self.repo = GM.Repository(
-        #     name='testgit.git',
-        #     fs_path=repo_dir,
-        #     url_path = '/test/',
-        #     tool = 'git',
-        #     status = 'creating')
         self.repo.refresh()
         self.rev = self.repo.commit('master')
         ThreadLocalORMSession.flush_all()
@@ -141,12 +135,9 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         h.set_context('test', 'src-git', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data')
-        self.repo = GM.Repository(
-            name='testgit.git',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='git',
-            status='creating')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.name = 'testgit.git'
+        self.repo = c.app.repo
         self.repo.refresh()
         ThreadLocalORMSession.flush_all()
         ThreadLocalORMSession.close_all()
@@ -526,10 +517,10 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
     def test_clone_url(self):
         assert_equal(
             self.repo.clone_url('rw', 'nobody'),
-            'ssh://nobody@localhost:8022/scm-repo/test/testgit')
+            'ssh://nobody@localhost:8022/scm-repo/p/test/testgit')
         assert_equal(
             self.repo.clone_url('https', 'nobody'),
-            'https://nobody@localhost:8022/scm-repo/test/testgit')
+            'https://nobody@localhost:8022/scm-repo/p/test/testgit')
         with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
             assert_equal(
                 self.repo.clone_url('https', 'user'),
@@ -705,12 +696,9 @@ class TestGitCommit(unittest.TestCase):
         h.set_context('test', 'src-git', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data')
-        self.repo = GM.Repository(
-            name='testgit.git',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='git',
-            status='creating')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.name = 'testgit.git'
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
@@ -784,12 +772,9 @@ class TestGitHtmlView(unittest.TestCase):
         h.set_context('test', 'src-git', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data')
-        self.repo = GM.Repository(
-            name='testmime.git',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='git',
-            status='creating')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.name = 'testmime.git'
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
@@ -818,12 +803,9 @@ class TestGitRename(unittest.TestCase):
         h.set_context('test', 'src-git', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgegit', 'tests/data')
-        self.repo = GM.Repository(
-            name='testrename.git',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='git',
-            status='creating')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.name = 'testrename.git'
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()

http://git-wip-us.apache.org/repos/asf/allura/blob/c4e2ddc5/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 c572aaa..24044bb 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -61,12 +61,9 @@ class TestNewRepo(unittest.TestCase):
         h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgesvn', 'tests/data/')
-        self.repo = SM.Repository(
-            name='testsvn',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
+        c.app.repo.name = 'testsvn'
+        c.app.repo.fs_path = repo_dir
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
@@ -118,25 +115,23 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
     @with_tool('test', 'SVN', 'svn-tags', 'SVN with tags')
     def setup_with_tools(self):
         setup_global_objects()
-        h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgesvn', 'tests/data/')
-        self.repo = SM.Repository(
-            name='testsvn',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
-        self.repo.refresh()
-        self.svn_tags = SM.Repository(
-            name='testsvn-trunk-tags-branches',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
-        self.svn_tags.refresh()
-        ThreadLocalORMSession.flush_all()
-        ThreadLocalORMSession.close_all()
+        with h.push_context('test', 'src', neighborhood='Projects'):
+            c.app.repo.name = 'testsvn'
+            c.app.repo.fs_path = repo_dir
+            self.repo = c.app.repo
+            self.repo.refresh()
+            ThreadLocalORMSession.flush_all()
+            ThreadLocalORMSession.close_all()
+        with h.push_context('test', 'svn-tags', neighborhood='Projects'):
+            c.app.repo.name = 'testsvn-trunk-tags-branches'
+            c.app.repo.fs_path = repo_dir
+            self.svn_tags = c.app.repo
+            self.svn_tags.refresh()
+            ThreadLocalORMSession.flush_all()
+            ThreadLocalORMSession.close_all()
+        h.set_context('test', 'src', neighborhood='Projects')
 
     def test_init(self):
         repo = SM.Repository(
@@ -640,12 +635,9 @@ class TestSVNRev(unittest.TestCase):
         h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgesvn', 'tests/data/')
-        self.repo = SM.Repository(
-            name='testsvn',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
+        c.app.repo.name = 'testsvn'
+        c.app.repo.fs_path = repo_dir
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit(1)
         ThreadLocalORMSession.flush_all()
@@ -1145,12 +1137,9 @@ class TestRename(unittest.TestCase):
         h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgesvn', 'tests/data/')
-        self.repo = SM.Repository(
-            name='testsvn-rename',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
+        c.app.repo.name = 'testsvn-rename'
+        c.app.repo.fs_path = repo_dir
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()
@@ -1185,12 +1174,9 @@ class TestDirectRepoAccess(object):
         h.set_context('test', 'src', neighborhood='Projects')
         repo_dir = pkg_resources.resource_filename(
             'forgesvn', 'tests/data/')
-        self.repo = SM.Repository(
-            name='testsvn',
-            fs_path=repo_dir,
-            url_path='/test/',
-            tool='svn',
-            status='creating')
+        c.app.repo.name = 'testsvn'
+        c.app.repo.fs_path = repo_dir
+        self.repo = c.app.repo
         self.repo.refresh()
         self.rev = self.repo.commit('HEAD')
         ThreadLocalORMSession.flush_all()


[04/13] allura git commit: [#7837] ticket:736 Fix paged_diffs call with wrong params

Posted by je...@apache.org.
[#7837] ticket:736 Fix paged_diffs call with wrong params


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

Branch: refs/heads/ib/7837
Commit: 5904caa8c055ca5de8744e53a5c7d4633155bf55
Parents: 61a6019
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:29:30 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:37 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py   | 2 +-
 ForgeGit/forgegit/model/git_repo.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5904caa8/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 58633bc..04fe6cc 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1202,7 +1202,7 @@ class Commit(RepoObject, ActivityObject):
             ['foo/bar', 'foo/bar/baz', 'foo/bar/baz/qux.txt']
         '''
         paths = set()
-        for path in self.paged_diffs(self._id)['added']:
+        for path in self.paged_diffs()['added']:
             paths.add(path.strip('/'))
         return paths
 

http://git-wip-us.apache.org/repos/asf/allura/blob/5904caa8/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index c5bec04..c2b1983 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -560,7 +560,7 @@ class GitImplementation(M.RepositoryImplementation):
             pretty='format:',
             max_count=1).splitlines()[1:]
 
-    def paged_diffs(self, commit_id, start, end):
+    def paged_diffs(self, commit_id, start=0, end=None):
         added, removed, changed = [], [], []
         files = self._git.git.diff_tree(
             '--no-commit-id',


[12/13] allura git commit: [#7837] ticket:738 Rewrite paged_diffs using log instead of diff_summarize

Posted by je...@apache.org.
[#7837] ticket:738 Rewrite paged_diffs using log instead of diff_summarize

To be consistent with previous behavior we stick with `log` call.
Because results can differ. I don't sure why, but on test repo for example:

$ svn diff --summarize -r4:5
A       b/b/c
A       b/b
A       b

$ svn log -v -r 5
------------------------------------------------------------------------
r5 | rick446 | 2010-11-18 20:14:21 +0000 (Чтв, 18 Лис 2010) | 1 line
Changed paths:
   A /b (from /a:4)

Copied a => b
------------------------------------------------------------------------


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

Branch: refs/heads/ib/7837
Commit: 5249a8d1ce72ed66ddbccc507fbce4dab8e86163
Parents: 1b4748b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 4 13:50:08 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:40 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                  | 43 ++++++++++----------
 .../forgesvn/tests/model/test_repository.py     | 11 ++---
 2 files changed, 27 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5249a8d1/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index b588847..a98b256 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -769,28 +769,27 @@ class SVNImplementation(M.RepositoryImplementation):
         return []
 
     def paged_diffs(self, commit_id, start=0, end=None):
-        added, removed, changed, total = [], [], [], 0
+        result = {'added': [], 'removed': [], 'changed': [], 'total': 0}
         rev = self._revision(commit_id)
-        prev_rev = self._revision(self._oid(rev.number - 1))
-        summary = self._svn.diff_summarize(
-            self._url,
-            prev_rev,
-            self._url,
-            rev)
-        total = len(summary)
-        for s in summary:
-            if s.summarize_kind == pysvn.diff_summarize_kind.added:
-                added.append(h.really_unicode(s.path))
-            elif s.summarize_kind == pysvn.diff_summarize_kind.delete:
-                removed.append(h.really_unicode(s.path))
-            elif s.summarize_kind == pysvn.diff_summarize_kind.modified:
-                changed.append(h.really_unicode(s.path))
-        return {
-            'added': added,
-            'removed': removed,
-            'changed': changed,
-            'total': total,
-        }
-
+        try:
+            log_info = self._svn.log(
+                self._url,
+                revision_start=rev,
+                revision_end=rev,
+                discover_changed_paths=True)
+        except pysvn.ClientError:
+            return result
+        if len(log_info) == 0:
+            return result
+        paths = log_info[0].changed_paths
+        result['total'] = len(paths)
+        for p in paths[start:end]:
+            if p['action'] == 'A':
+                result['added'].append(h.really_unicode(p.path))
+            elif p['action'] == 'D':
+                result['removed'].append(h.really_unicode(p.path))
+            elif p['action'] == 'M':
+                result['changed'].append(h.really_unicode(p.path))
+        return result
 
 Mapper.compile_all()

http://git-wip-us.apache.org/repos/asf/allura/blob/5249a8d1/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 103e586..c572aaa 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -373,7 +373,8 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         actual = entry.paged_diffs(start=1, end=3)
         self.assertEqual(expected, actual)
 
-        empty = M.repository.Commit().paged_diffs()
+        fake_id = self.repo._impl._oid(100)
+        empty = M.repository.Commit(_id=fake_id, repo=self.repo).paged_diffs()
         self.assertEqual(sorted(actual.keys()), sorted(empty.keys()))
 
     def test_diff_create_file(self):
@@ -1198,7 +1199,7 @@ class TestDirectRepoAccess(object):
     def test_paged_diffs(self):
         diffs = self.rev.diffs
         expected = {
-            'added': [u'ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
+            'added': [u'/ЗРЯЧИЙ_ТА_ПОБАЧИТЬ'],
             'removed': [],
             'changed': [],
             'copied': [],
@@ -1209,7 +1210,7 @@ class TestDirectRepoAccess(object):
         _id = self.repo._impl._oid(2)
         diffs = self.repo.commit(_id).diffs
         expected = {
-            'added': [u'a/b/c/hello.txt', u'a/b/c', u'a/b', u'a'],
+            'added': [u'/a', u'/a/b', u'/a/b/c', u'/a/b/c/hello.txt'],
             'removed': [],
             'changed': [],
             'copied': [],
@@ -1222,7 +1223,7 @@ class TestDirectRepoAccess(object):
         expected = {
             'added': [],
             'removed': [],
-            'changed': [u'README'],
+            'changed': [u'/README'],
             'copied': [],
             'total': 1,
         }
@@ -1232,7 +1233,7 @@ class TestDirectRepoAccess(object):
         diffs = self.repo.commit(_id).diffs
         expected = {
             'added': [],
-            'removed': ['a/b/c/hello.txt'],
+            'removed': ['/a/b/c/hello.txt'],
             'changed': [],
             'copied': [],
             'total': 1,


[11/13] allura git commit: [#7837] ticket:738 Implement paged_diffs for SVN

Posted by je...@apache.org.
[#7837] ticket:738 Implement paged_diffs for SVN


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

Branch: refs/heads/ib/7837
Commit: c9497d848317fe90377cc4fe212c5ee31bb1d99f
Parents: 455293f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 13:46:16 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:39 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c9497d84/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 420cc76..b588847 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -768,5 +768,29 @@ class SVNImplementation(M.RepositoryImplementation):
     def tags(self):
         return []
 
+    def paged_diffs(self, commit_id, start=0, end=None):
+        added, removed, changed, total = [], [], [], 0
+        rev = self._revision(commit_id)
+        prev_rev = self._revision(self._oid(rev.number - 1))
+        summary = self._svn.diff_summarize(
+            self._url,
+            prev_rev,
+            self._url,
+            rev)
+        total = len(summary)
+        for s in summary:
+            if s.summarize_kind == pysvn.diff_summarize_kind.added:
+                added.append(h.really_unicode(s.path))
+            elif s.summarize_kind == pysvn.diff_summarize_kind.delete:
+                removed.append(h.really_unicode(s.path))
+            elif s.summarize_kind == pysvn.diff_summarize_kind.modified:
+                changed.append(h.really_unicode(s.path))
+        return {
+            'added': added,
+            'removed': removed,
+            'changed': changed,
+            'total': total,
+        }
+
 
 Mapper.compile_all()


[10/13] allura git commit: [#7837] ticket:736 Add test for paged_diffs for git

Posted by je...@apache.org.
[#7837] ticket:736 Add test for paged_diffs for git


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

Branch: refs/heads/ib/7837
Commit: 455293f7f2df61779d2477fbff1558cf15413f92
Parents: 5115e75
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 11:32:05 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:39 2015 +0000

----------------------------------------------------------------------
 .../forgegit/tests/data/weird-chars.git/HEAD    |   1 +
 .../forgegit/tests/data/weird-chars.git/config  |   4 +
 .../tests/data/weird-chars.git/description      |   1 +
 .../weird-chars.git/hooks/applypatch-msg.sample |  15 ++
 .../weird-chars.git/hooks/commit-msg.sample     |  24 +++
 .../weird-chars.git/hooks/post-commit.sample    |   8 +
 .../weird-chars.git/hooks/post-receive.sample   |  15 ++
 .../weird-chars.git/hooks/post-update.sample    |   8 +
 .../weird-chars.git/hooks/pre-applypatch.sample |  14 ++
 .../weird-chars.git/hooks/pre-commit.sample     |  46 +++++
 .../weird-chars.git/hooks/pre-rebase.sample     | 169 +++++++++++++++++++
 .../hooks/prepare-commit-msg.sample             |  36 ++++
 .../data/weird-chars.git/hooks/update.sample    | 128 ++++++++++++++
 .../tests/data/weird-chars.git/info/exclude     |   6 +
 .../14/e25154c2e7addd2e4dcb9fa072df661840e9bf   | Bin 0 -> 54 bytes
 .../40/7950e8fba4dbc108ffbce0128ed1085c52cfd7   | Bin 0 -> 174 bytes
 .../44/72674e5deda58af0fa8418ee77d599a81bbff7   | Bin 0 -> 132 bytes
 .../69/18fd3efd7bec78a39615551804c23b3f53b378   | Bin 0 -> 31 bytes
 .../ae/f65927d195599a98fa3dbe767eca28a7280020   | Bin 0 -> 35 bytes
 .../af/aa6d93eb5661fb04f8e10e9ba1039b7441a6c7   |   3 +
 .../cc/6e400fabace25ba9b365ee6192ce21eeae01de   | Bin 0 -> 27 bytes
 .../e8/172443bd0c44858b3fb6cbe4beb71ad077e85b   |   2 +
 .../f3/de6a0e7601cdde326054a1cc708afdc1dbe70b   |   3 +
 .../ff/540eaa0c1dab74090eff8fa678f27152415305   | Bin 0 -> 50 bytes
 .../data/weird-chars.git/refs/heads/master      |   1 +
 .../forgegit/tests/model/test_repository.py     |  45 +++++
 26 files changed, 529 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/HEAD
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/HEAD b/ForgeGit/forgegit/tests/data/weird-chars.git/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/config
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/config b/ForgeGit/forgegit/tests/data/weird-chars.git/config
new file mode 100644
index 0000000..07d359d
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/config
@@ -0,0 +1,4 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = true

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/description
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/description b/ForgeGit/forgegit/tests/data/weird-chars.git/description
new file mode 100644
index 0000000..498b267
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/applypatch-msg.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/applypatch-msg.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/applypatch-msg.sample
new file mode 100755
index 0000000..8b2a2fe
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/applypatch-msg.sample
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message taken by
+# applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.  The hook is
+# allowed to edit the commit message file.
+#
+# To enable this hook, rename this file to "applypatch-msg".
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/commit-msg" &&
+	exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
+:

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/commit-msg.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/commit-msg.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/commit-msg.sample
new file mode 100755
index 0000000..b58d118
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/commit-msg.sample
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# An example hook script to check the commit log message.
+# Called by "git commit" with one argument, the name of the file
+# that has the commit message.  The hook should exit with non-zero
+# status after issuing an appropriate message if it wants to stop the
+# commit.  The hook is allowed to edit the commit message file.
+#
+# To enable this hook, rename this file to "commit-msg".
+
+# Uncomment the below to add a Signed-off-by line to the message.
+# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
+# hook is more suited to it.
+#
+# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
+
+# This example catches duplicate Signed-off-by lines.
+
+test "" = "$(grep '^Signed-off-by: ' "$1" |
+	 sort | uniq -c | sed -e '/^[ 	]*1[ 	]/d')" || {
+	echo >&2 Duplicate Signed-off-by lines.
+	exit 1
+}

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-commit.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-commit.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-commit.sample
new file mode 100755
index 0000000..2266821
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-commit.sample
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script that is called after a successful
+# commit is made.
+#
+# To enable this hook, rename this file to "post-commit".
+
+: Nothing

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-receive.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-receive.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-receive.sample
new file mode 100755
index 0000000..e48346e
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-receive.sample
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# An example hook script for the "post-receive" event.
+#
+# The "post-receive" script is run after receive-pack has accepted a pack
+# and the repository has been updated.  It is passed arguments in through
+# stdin in the form
+#  <oldrev> <newrev> <refname>
+# For example:
+#  aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
+#
+# see contrib/hooks/ for a sample, or uncomment the next line and
+# rename the file to "post-receive".
+
+#. /usr/share/git-core/contrib/hooks/post-receive-email

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-update.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-update.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-update.sample
new file mode 100755
index 0000000..ec17ec1
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/post-update.sample
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+# An example hook script to prepare a packed repository for use over
+# dumb transports.
+#
+# To enable this hook, rename this file to "post-update".
+
+exec git update-server-info

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-applypatch.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-applypatch.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-applypatch.sample
new file mode 100755
index 0000000..b1f187c
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-applypatch.sample
@@ -0,0 +1,14 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed
+# by applypatch from an e-mail message.
+#
+# The hook should exit with non-zero status after issuing an
+# appropriate message if it wants to stop the commit.
+#
+# To enable this hook, rename this file to "pre-applypatch".
+
+. git-sh-setup
+test -x "$GIT_DIR/hooks/pre-commit" &&
+	exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
+:

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-commit.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-commit.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-commit.sample
new file mode 100755
index 0000000..b187c4b
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-commit.sample
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# An example hook script to verify what is about to be committed.
+# Called by "git commit" with no arguments.  The hook should
+# exit with non-zero status after issuing an appropriate message if
+# it wants to stop the commit.
+#
+# To enable this hook, rename this file to "pre-commit".
+
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+	against=HEAD
+else
+	# Initial commit: diff against an empty tree object
+	against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+# If you want to allow non-ascii filenames set this variable to true.
+allownonascii=$(git config hooks.allownonascii)
+
+# Cross platform projects tend to avoid non-ascii filenames; prevent
+# them from being added to the repository. We exploit the fact that the
+# printable range starts at the space character and ends with tilde.
+if [ "$allownonascii" != "true" ] &&
+	# Note that the use of brackets around a tr range is ok here, (it's
+	# even required, for portability to Solaris 10's /usr/bin/tr), since
+	# the square bracket bytes happen to fall in the designated range.
+	test "$(git diff --cached --name-only --diff-filter=A -z $against |
+	  LC_ALL=C tr -d '[ -~]\0')"
+then
+	echo "Error: Attempt to add a non-ascii file name."
+	echo
+	echo "This can cause problems if you want to work"
+	echo "with people on other platforms."
+	echo
+	echo "To be portable it is advisable to rename the file ..."
+	echo
+	echo "If you know what you are doing you can disable this"
+	echo "check using:"
+	echo
+	echo "  git config hooks.allownonascii true"
+	echo
+	exit 1
+fi
+
+exec git diff-index --check --cached $against --

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-rebase.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-rebase.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-rebase.sample
new file mode 100755
index 0000000..9773ed4
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/pre-rebase.sample
@@ -0,0 +1,169 @@
+#!/bin/sh
+#
+# Copyright (c) 2006, 2008 Junio C Hamano
+#
+# The "pre-rebase" hook is run just before "git rebase" starts doing
+# its job, and can prevent the command from running by exiting with
+# non-zero status.
+#
+# The hook is called with the following parameters:
+#
+# $1 -- the upstream the series was forked from.
+# $2 -- the branch being rebased (or empty when rebasing the current branch).
+#
+# This sample shows how to prevent topic branches that are already
+# merged to 'next' branch from getting rebased, because allowing it
+# would result in rebasing already published history.
+
+publish=next
+basebranch="$1"
+if test "$#" = 2
+then
+	topic="refs/heads/$2"
+else
+	topic=`git symbolic-ref HEAD` ||
+	exit 0 ;# we do not interrupt rebasing detached HEAD
+fi
+
+case "$topic" in
+refs/heads/??/*)
+	;;
+*)
+	exit 0 ;# we do not interrupt others.
+	;;
+esac
+
+# Now we are dealing with a topic branch being rebased
+# on top of master.  Is it OK to rebase it?
+
+# Does the topic really exist?
+git show-ref -q "$topic" || {
+	echo >&2 "No such branch $topic"
+	exit 1
+}
+
+# Is topic fully merged to master?
+not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
+if test -z "$not_in_master"
+then
+	echo >&2 "$topic is fully merged to master; better remove it."
+	exit 1 ;# we could allow it, but there is no point.
+fi
+
+# Is topic ever merged to next?  If so you should not be rebasing it.
+only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
+only_next_2=`git rev-list ^master           ${publish} | sort`
+if test "$only_next_1" = "$only_next_2"
+then
+	not_in_topic=`git rev-list "^$topic" master`
+	if test -z "$not_in_topic"
+	then
+		echo >&2 "$topic is already up-to-date with master"
+		exit 1 ;# we could allow it, but there is no point.
+	else
+		exit 0
+	fi
+else
+	not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
+	/usr/bin/perl -e '
+		my $topic = $ARGV[0];
+		my $msg = "* $topic has commits already merged to public branch:\n";
+		my (%not_in_next) = map {
+			/^([0-9a-f]+) /;
+			($1 => 1);
+		} split(/\n/, $ARGV[1]);
+		for my $elem (map {
+				/^([0-9a-f]+) (.*)$/;
+				[$1 => $2];
+			} split(/\n/, $ARGV[2])) {
+			if (!exists $not_in_next{$elem->[0]}) {
+				if ($msg) {
+					print STDERR $msg;
+					undef $msg;
+				}
+				print STDERR " $elem->[1]\n";
+			}
+		}
+	' "$topic" "$not_in_next" "$not_in_master"
+	exit 1
+fi
+
+exit 0
+
+################################################################
+
+This sample hook safeguards topic branches that have been
+published from being rewound.
+
+The workflow assumed here is:
+
+ * Once a topic branch forks from "master", "master" is never
+   merged into it again (either directly or indirectly).
+
+ * Once a topic branch is fully cooked and merged into "master",
+   it is deleted.  If you need to build on top of it to correct
+   earlier mistakes, a new topic branch is created by forking at
+   the tip of the "master".  This is not strictly necessary, but
+   it makes it easier to keep your history simple.
+
+ * Whenever you need to test or publish your changes to topic
+   branches, merge them into "next" branch.
+
+The script, being an example, hardcodes the publish branch name
+to be "next", but it is trivial to make it configurable via
+$GIT_DIR/config mechanism.
+
+With this workflow, you would want to know:
+
+(1) ... if a topic branch has ever been merged to "next".  Young
+    topic branches can have stupid mistakes you would rather
+    clean up before publishing, and things that have not been
+    merged into other branches can be easily rebased without
+    affecting other people.  But once it is published, you would
+    not want to rewind it.
+
+(2) ... if a topic branch has been fully merged to "master".
+    Then you can delete it.  More importantly, you should not
+    build on top of it -- other people may already want to
+    change things related to the topic as patches against your
+    "master", so if you need further changes, it is better to
+    fork the topic (perhaps with the same name) afresh from the
+    tip of "master".
+
+Let's look at this example:
+
+		   o---o---o---o---o---o---o---o---o---o "next"
+		  /       /           /           /
+		 /   a---a---b A     /           /
+		/   /               /           /
+	       /   /   c---c---c---c B         /
+	      /   /   /             \         /
+	     /   /   /   b---b C     \       /
+	    /   /   /   /             \     /
+    ---o---o---o---o---o---o---o---o---o---o---o "master"
+
+
+A, B and C are topic branches.
+
+ * A has one fix since it was merged up to "next".
+
+ * B has finished.  It has been fully merged up to "master" and "next",
+   and is ready to be deleted.
+
+ * C has not merged to "next" at all.
+
+We would want to allow C to be rebased, refuse A, and encourage
+B to be deleted.
+
+To compute (1):
+
+	git rev-list ^master ^topic next
+	git rev-list ^master        next
+
+	if these match, topic has not merged in next at all.
+
+To compute (2):
+
+	git rev-list master..topic
+
+	if this is empty, it is fully merged to "master".

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/prepare-commit-msg.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/prepare-commit-msg.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/prepare-commit-msg.sample
new file mode 100755
index 0000000..f093a02
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/prepare-commit-msg.sample
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# An example hook script to prepare the commit log message.
+# Called by "git commit" with the name of the file that has the
+# commit message, followed by the description of the commit
+# message's source.  The hook's purpose is to edit the commit
+# message file.  If the hook fails with a non-zero status,
+# the commit is aborted.
+#
+# To enable this hook, rename this file to "prepare-commit-msg".
+
+# This hook includes three examples.  The first comments out the
+# "Conflicts:" part of a merge commit.
+#
+# The second includes the output of "git diff --name-status -r"
+# into the message, just before the "git status" output.  It is
+# commented because it doesn't cope with --amend or with squashed
+# commits.
+#
+# The third example adds a Signed-off-by line to the message, that can
+# still be edited.  This is rarely a good idea.
+
+case "$2,$3" in
+  merge,)
+    /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
+
+# ,|template,)
+#   /usr/bin/perl -i.bak -pe '
+#      print "\n" . `git diff --cached --name-status -r`
+#	 if /^#/ && $first++ == 0' "$1" ;;
+
+  *) ;;
+esac
+
+# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
+# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/update.sample
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/update.sample b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/update.sample
new file mode 100755
index 0000000..71ab04e
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/hooks/update.sample
@@ -0,0 +1,128 @@
+#!/bin/sh
+#
+# An example hook script to blocks unannotated tags from entering.
+# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
+#
+# To enable this hook, rename this file to "update".
+#
+# Config
+# ------
+# hooks.allowunannotated
+#   This boolean sets whether unannotated tags will be allowed into the
+#   repository.  By default they won't be.
+# hooks.allowdeletetag
+#   This boolean sets whether deleting tags will be allowed in the
+#   repository.  By default they won't be.
+# hooks.allowmodifytag
+#   This boolean sets whether a tag may be modified after creation. By default
+#   it won't be.
+# hooks.allowdeletebranch
+#   This boolean sets whether deleting branches will be allowed in the
+#   repository.  By default they won't be.
+# hooks.denycreatebranch
+#   This boolean sets whether remotely creating branches will be denied
+#   in the repository.  By default this is allowed.
+#
+
+# --- Command line
+refname="$1"
+oldrev="$2"
+newrev="$3"
+
+# --- Safety check
+if [ -z "$GIT_DIR" ]; then
+	echo "Don't run this script from the command line." >&2
+	echo " (if you want, you could supply GIT_DIR then run" >&2
+	echo "  $0 <ref> <oldrev> <newrev>)" >&2
+	exit 1
+fi
+
+if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
+	echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
+	exit 1
+fi
+
+# --- Config
+allowunannotated=$(git config --bool hooks.allowunannotated)
+allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
+denycreatebranch=$(git config --bool hooks.denycreatebranch)
+allowdeletetag=$(git config --bool hooks.allowdeletetag)
+allowmodifytag=$(git config --bool hooks.allowmodifytag)
+
+# check for no description
+projectdesc=$(sed -e '1q' "$GIT_DIR/description")
+case "$projectdesc" in
+"Unnamed repository"* | "")
+	echo "*** Project description file hasn't been set" >&2
+	exit 1
+	;;
+esac
+
+# --- Check types
+# if $newrev is 0000...0000, it's a commit to delete a ref.
+zero="0000000000000000000000000000000000000000"
+if [ "$newrev" = "$zero" ]; then
+	newrev_type=delete
+else
+	newrev_type=$(git cat-file -t $newrev)
+fi
+
+case "$refname","$newrev_type" in
+	refs/tags/*,commit)
+		# un-annotated tag
+		short_refname=${refname##refs/tags/}
+		if [ "$allowunannotated" != "true" ]; then
+			echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
+			echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
+			exit 1
+		fi
+		;;
+	refs/tags/*,delete)
+		# delete tag
+		if [ "$allowdeletetag" != "true" ]; then
+			echo "*** Deleting a tag is not allowed in this repository" >&2
+			exit 1
+		fi
+		;;
+	refs/tags/*,tag)
+		# annotated tag
+		if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
+		then
+			echo "*** Tag '$refname' already exists." >&2
+			echo "*** Modifying a tag is not allowed in this repository." >&2
+			exit 1
+		fi
+		;;
+	refs/heads/*,commit)
+		# branch
+		if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
+			echo "*** Creating a branch is not allowed in this repository" >&2
+			exit 1
+		fi
+		;;
+	refs/heads/*,delete)
+		# delete branch
+		if [ "$allowdeletebranch" != "true" ]; then
+			echo "*** Deleting a branch is not allowed in this repository" >&2
+			exit 1
+		fi
+		;;
+	refs/remotes/*,commit)
+		# tracking branch
+		;;
+	refs/remotes/*,delete)
+		# delete tracking branch
+		if [ "$allowdeletebranch" != "true" ]; then
+			echo "*** Deleting a tracking branch is not allowed in this repository" >&2
+			exit 1
+		fi
+		;;
+	*)
+		# Anything else (is there anything else?)
+		echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
+		exit 1
+		;;
+esac
+
+# --- Finished
+exit 0

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/info/exclude
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/info/exclude b/ForgeGit/forgegit/tests/data/weird-chars.git/info/exclude
new file mode 100644
index 0000000..a5196d1
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/info/exclude
@@ -0,0 +1,6 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/14/e25154c2e7addd2e4dcb9fa072df661840e9bf
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/14/e25154c2e7addd2e4dcb9fa072df661840e9bf b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/14/e25154c2e7addd2e4dcb9fa072df661840e9bf
new file mode 100644
index 0000000..4fba3d1
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/14/e25154c2e7addd2e4dcb9fa072df661840e9bf differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/40/7950e8fba4dbc108ffbce0128ed1085c52cfd7
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/40/7950e8fba4dbc108ffbce0128ed1085c52cfd7 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/40/7950e8fba4dbc108ffbce0128ed1085c52cfd7
new file mode 100644
index 0000000..298634f
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/40/7950e8fba4dbc108ffbce0128ed1085c52cfd7 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/44/72674e5deda58af0fa8418ee77d599a81bbff7
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/44/72674e5deda58af0fa8418ee77d599a81bbff7 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/44/72674e5deda58af0fa8418ee77d599a81bbff7
new file mode 100644
index 0000000..fa3dd3a
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/44/72674e5deda58af0fa8418ee77d599a81bbff7 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/69/18fd3efd7bec78a39615551804c23b3f53b378
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/69/18fd3efd7bec78a39615551804c23b3f53b378 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/69/18fd3efd7bec78a39615551804c23b3f53b378
new file mode 100644
index 0000000..21c099e
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/69/18fd3efd7bec78a39615551804c23b3f53b378 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ae/f65927d195599a98fa3dbe767eca28a7280020
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ae/f65927d195599a98fa3dbe767eca28a7280020 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ae/f65927d195599a98fa3dbe767eca28a7280020
new file mode 100644
index 0000000..67ac5bc
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ae/f65927d195599a98fa3dbe767eca28a7280020 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/af/aa6d93eb5661fb04f8e10e9ba1039b7441a6c7
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/af/aa6d93eb5661fb04f8e10e9ba1039b7441a6c7 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/af/aa6d93eb5661fb04f8e10e9ba1039b7441a6c7
new file mode 100644
index 0000000..26ad91e
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/af/aa6d93eb5661fb04f8e10e9ba1039b7441a6c7
@@ -0,0 +1,3 @@
+x��A!=�
+�&�aYc�7��2Ê
+$d����>��N��"�?�`�`8��}$"dKi9���Vk8lYů<�Џ}ֽ7��ۻ�ˋ��Fx�k,�S��:���+�
�hfԤ�U�߽*�����9�
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/cc/6e400fabace25ba9b365ee6192ce21eeae01de
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/cc/6e400fabace25ba9b365ee6192ce21eeae01de b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/cc/6e400fabace25ba9b365ee6192ce21eeae01de
new file mode 100644
index 0000000..78a8539
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/cc/6e400fabace25ba9b365ee6192ce21eeae01de differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/e8/172443bd0c44858b3fb6cbe4beb71ad077e85b
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/e8/172443bd0c44858b3fb6cbe4beb71ad077e85b b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/e8/172443bd0c44858b3fb6cbe4beb71ad077e85b
new file mode 100644
index 0000000..536b875
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/e8/172443bd0c44858b3fb6cbe4beb71ad077e85b
@@ -0,0 +1,2 @@
+x+)JMU042f040031Qrut�u��MaX�-R����Y3~��+�;��\�A��<�$C�� 19U�����L���5��WnN}�8��u���*/��paDžM�]l��·�Gvu	'���e�
+��Y�o6
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/f3/de6a0e7601cdde326054a1cc708afdc1dbe70b
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/f3/de6a0e7601cdde326054a1cc708afdc1dbe70b b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/f3/de6a0e7601cdde326054a1cc708afdc1dbe70b
new file mode 100644
index 0000000..5ef2159
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/f3/de6a0e7601cdde326054a1cc708afdc1dbe70b
@@ -0,0 +1,3 @@
+x��=
+1��s��’_AD�,<D^�f#K��Cx+;��{#��b��`|N�-T(5)="E�M	�y��� #�<��]`Ơ�@ήǮP��\3��
+�9�1�Gƅ�PI{-|��K��nv�ֹ?����%�]�]r��9-)WBK˅dt�jH]�˂��d�Cot����=����hʵ�/�R�
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ff/540eaa0c1dab74090eff8fa678f27152415305
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ff/540eaa0c1dab74090eff8fa678f27152415305 b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ff/540eaa0c1dab74090eff8fa678f27152415305
new file mode 100644
index 0000000..1a595f0
Binary files /dev/null and b/ForgeGit/forgegit/tests/data/weird-chars.git/objects/ff/540eaa0c1dab74090eff8fa678f27152415305 differ

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master b/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
new file mode 100644
index 0000000..ff3a92b
--- /dev/null
+++ b/ForgeGit/forgegit/tests/data/weird-chars.git/refs/heads/master
@@ -0,0 +1 @@
+f3de6a0e7601cdde326054a1cc708afdc1dbe70b

http://git-wip-us.apache.org/repos/asf/allura/blob/455293f7/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 231e479..62ba264 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -592,6 +592,51 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         }
         assert_equals(payload, expected_payload)
 
+    @td.with_tool('test', 'Git', 'src-weird', 'Git', type='git')
+    def test_paged_diffs(self):
+        # setup
+        h.set_context('test', 'src-weird', neighborhood='Projects')
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data')
+        repo = GM.Repository(
+            name='weird-chars.git',
+            fs_path=repo_dir,
+            url_path='/src-weird/',
+            tool='git',
+            status='creating')
+        repo.refresh()
+        ThreadLocalORMSession.flush_all()
+        ThreadLocalORMSession.close_all()
+
+        # spaces and unicode filenames
+        diffs = repo.paged_diffs('407950e8fba4dbc108ffbce0128ed1085c52cfd7')
+        expected = {
+            'added': [u'with space.txt', u'привіт.txt'],
+            'removed': [],
+            'changed': [],
+            'total': 2,
+        }
+        assert_equals(diffs, expected)
+
+        diffs = repo.paged_diffs('f3de6a0e7601cdde326054a1cc708afdc1dbe70b')
+        expected = {
+            'added': [],
+            'removed': [],
+            'changed': [u'привіт.txt'],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)
+
+        # initial commit is special, but must work too
+        diffs = repo.paged_diffs('afaa6d93eb5661fb04f8e10e9ba1039b7441a6c7')
+        expected = {
+            'added': [u'README.md'],
+            'removed': [],
+            'changed': [],
+            'total': 1,
+        }
+        assert_equals(diffs, expected)
+
 
 class TestGitImplementation(unittest.TestCase):
 


[07/13] allura git commit: [#7837] ticket:736 Fix filenames with whitespaces and/or unicode

Posted by je...@apache.org.
[#7837] ticket:736 Fix filenames with whitespaces and/or unicode


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

Branch: refs/heads/ib/7837
Commit: 5115e7533e0850a5509dff1ecaa3f9dc0dc15121
Parents: 7cb590b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 10:06:55 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Mar 4 16:58:38 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5115e753/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 4d8ffc1..7f5847a 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -570,11 +570,14 @@ class GitImplementation(M.RepositoryImplementation):
             # show tree entry itself as well as subtrees (Commit.added_paths
             # relies on this)
             '-t',
+            '-z',  # don't escape filenames and use \x00 as fields delimiter
             commit_id)
-        files = files.splitlines()
-        total = len(files)
-        for f in files[start:end]:
-            status, name = f.split('\t', 1)
+        files = files.split('\x00')[:-1]
+        # files = ['A', 'filename', 'D', 'another filename', ...]
+        total = len(files) / 2
+        for i in range(1, len(files), 2):
+            status = files[i-1]
+            name = h.really_unicode(files[i])
             if status == 'A':
                 added.append(name)
             elif status == 'D':