You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by he...@apache.org on 2015/04/01 23:10:18 UTC

[01/45] allura git commit: [#7841] ticket:742 Hide disabled and pending authors from wiki pages

Repository: allura
Updated Branches:
  refs/heads/hss/7072 40c1ce669 -> 0f7253c7b (forced update)


[#7841] ticket:742 Hide disabled and pending authors from wiki pages


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

Branch: refs/heads/hss/7072
Commit: 99dbd182ede3641e896119e810efdec202c8dc7d
Parents: 5c8f832
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 00:13:19 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 18 00:13:19 2015 +0200

----------------------------------------------------------------------
 ForgeWiki/forgewiki/model/wiki.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/99dbd182/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 18bfb85..c79fd16 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -234,7 +234,11 @@ class Page(VersionedArtifact, ActivityObject):
                 t[user.username] = user.id
             return t.values()
         user_ids = uniq([r.author for r in self.history().all()])
-        return User.query.find({'_id': {'$in': user_ids}}).all()
+        return User.query.find({
+            '_id': {'$in': user_ids},
+            'disabled': False,
+            'pending': False
+        }).all()
 
     def delete(self):
         Shortlink.query.remove(dict(ref_id=self.index_id()))


[07/45] allura git commit: [#7841] ticket:742 Added test for Page.authors

Posted by he...@apache.org.
[#7841] ticket:742 Added test for Page.authors


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

Branch: refs/heads/hss/7072
Commit: da74cead74895c2420b47d092b7af629f97efe0f
Parents: e887dfb
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 16:02:05 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/da74cead/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
index 5c10e50..2ab2f00 100644
--- a/ForgeWiki/forgewiki/tests/test_models.py
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -15,9 +15,15 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from pylons import tmpl_context as c
+from ming.orm import session
+
 from allura.tests import TestController
 from allura.tests import decorators as td
 from alluratest.controller import setup_global_objects
+from allura import model as M
+from allura.lib import helpers as h
+
 
 from forgewiki.model import Page
 
@@ -59,3 +65,32 @@ class TestPageSnapshots(TestController):
         page = Page.query.get(title='test-page')
         # 10 changes by each thread + initial upsert
         assert page.history().count() == 21, page.history().count()
+
+
+class TestPage(TestController):
+
+    @td.with_wiki
+    def test_authors(self):
+        user = M.User.by_username('test-user')
+        admin = M.User.by_username('test-admin')
+        with h.push_config(c, user=admin):
+            page = Page.upsert('test-admin')
+            page.text = 'admin'
+            page.commit()
+
+        with h.push_config(c, user=user):
+            page.text = 'user'
+            page.commit()
+
+        authors = page.authors()
+        assert len(authors) == 2
+        assert user in authors
+        assert admin in authors
+
+        user.disabled = True
+        session(user).flush(user)
+
+        authors = page.authors()
+        assert len(authors) == 1
+        assert user not in authors
+        assert admin in authors


[05/45] allura git commit: [#7833] ticket:741 Added script for trimming user emails

Posted by he...@apache.org.
[#7833] ticket:741 Added script for trimming user emails


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

Branch: refs/heads/hss/7072
Commit: 27f9c9fff47dd4ff9bca68198d93a8c32270ab88
Parents: c2673b6
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 11 23:28:02 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/trim_emails.py | 44 +++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/27f9c9ff/Allura/allura/scripts/trim_emails.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/trim_emails.py b/Allura/allura/scripts/trim_emails.py
new file mode 100644
index 0000000..0ce4caa
--- /dev/null
+++ b/Allura/allura/scripts/trim_emails.py
@@ -0,0 +1,44 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+import logging
+
+from allura.scripts import ScriptTask
+from allura import model as M
+from allura.lib.utils import chunked_find
+
+
+log = logging.getLogger(__name__)
+
+
+class TrimEmails(ScriptTask):
+
+    @classmethod
+    def execute(cls, options):
+        for chunk in chunked_find(M.User, {}):
+            for u in chunk:
+                log.info('Trimming emails for user %s', u.username)
+                new_addresses = [M.EmailAddress.canonical(addr) for addr in u.email_addresses]
+                u.email_addresses = new_addresses
+                if u.preferences.email_address is not None:
+                    u.preferences.email_address = M.EmailAddress.canonical(
+                        u.preferences.email_address)
+        log.info('Finished trimming emails')
+
+
+if __name__ == '__main__':
+    TrimEmails.main()


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

Posted by he...@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/b361bdf9
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b361bdf9
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b361bdf9

Branch: refs/heads/hss/7072
Commit: b361bdf9eb48fb04de329f0d4015cbb95fdef78b
Parents: c6bb4ab
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 4 13:50:08 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/b361bdf9/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index c033f44..28bf132 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -781,28 +781,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/b361bdf9/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 79005ac..c3a392a 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,


[24/45] allura git commit: [#7857] syntax fixes

Posted by he...@apache.org.
[#7857] syntax fixes


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

Branch: refs/heads/hss/7072
Commit: ca40993060183183d5c48df96d1f3198136342cb
Parents: a6b536c
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 20:53:52 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Mar 27 10:56:41 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/ca409930/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index c5643e1..94d29b0 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -282,20 +282,20 @@ class SVNImplementation(M.RepositoryImplementation):
             fail_count = 0
             returncode = -1
             set_hook('pre-revprop-change')
-            while returncode != 0 && fail_count < max_fail:
+            while returncode != 0 and fail_count < max_fail:
                 stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
                 # Sleep for 10s and bump the fail counter if svnsync didn't run clean
                 if returncode != 0:
                     time.sleep(10)
-                    fail_count++
+                    fail_count += 1
             # Reset the return code to non-zero for next command interation, but reuse the fail counter
             returncode = -1
-            while returncode != 0 && fail_count < max_fail:
+            while returncode != 0 and fail_count < max_fail:
                 stdout, stderr, returncode = self.check_call(
                     ['svnsync', '--non-interactive', 'sync', self._url])
                 if returncode != 0:
                     time.sleep(10)
-                    fail_count++
+                    fail_count += 1
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)


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

Posted by he...@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/d0dd4b75
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d0dd4b75
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d0dd4b75

Branch: refs/heads/hss/7072
Commit: d0dd4b757f7c33fc7a11a180e7cbcce8858edf42
Parents: d50d350
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:18:10 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:40 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/d0dd4b75/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/d0dd4b75/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/d0dd4b75/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index d15394f..fc50860 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -893,15 +893,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/d0dd4b75/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/d0dd4b75/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/d0dd4b75/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/d0dd4b75/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 44d625f..142ca6a 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -76,9 +76,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
@@ -366,7 +363,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
@@ -408,48 +405,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/d0dd4b75/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 7f34f45..2c86309 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'])


[25/45] allura git commit: [#7857] test fix, improve error handling and logging

Posted by he...@apache.org.
[#7857] test fix, improve error handling and logging


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

Branch: refs/heads/hss/7072
Commit: 0298eac403b32a488659e309c6fe5fb6d6ec50e7
Parents: ca40993
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 21:57:59 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Mar 27 10:56:41 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py                  | 38 +++++++++-----------
 .../forgesvn/tests/model/test_repository.py     |  2 +-
 2 files changed, 18 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0298eac4/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 94d29b0..44d625f 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -31,7 +31,7 @@ from shutil import rmtree
 
 import tg
 import pysvn
-from paste.deploy.converters import asbool
+from paste.deploy.converters import asbool, asint
 from pymongo.errors import DuplicateKeyError
 from pylons import tmpl_context as c, app_globals as g
 
@@ -232,10 +232,10 @@ class SVNImplementation(M.RepositoryImplementation):
         m = re.search(pattern, stdout)
         return m and (int(m.group('maj')) * 10 + int(m.group('min'))) >= 17
 
-    def check_call(self, cmd):
+    def check_call(self, cmd, fail_on_error=True):
         p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
         stdout, stderr = p.communicate(input='p\n')
-        if p.returncode != 0:
+        if p.returncode != 0 and fail_on_error:
             self._repo.set_status('ready')
             raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
         return stdout, stderr, p.returncode
@@ -277,25 +277,21 @@ class SVNImplementation(M.RepositoryImplementation):
                  'initialize', self._url, source_url])
             clear_hook('pre-revprop-change')
         else:
-            # retry logic
-            max_fail = 60
-            fail_count = 0
-            returncode = -1
+            def retry_cmd(cmd, fail_count=0):
+                max_fail = asint(tg.config.get('scm.import.retry_count', 50))
+                returncode = -1
+                while returncode != 0 and fail_count < max_fail:
+                    stdout, stderr, returncode = self.check_call(cmd, fail_on_error=False)
+                    if returncode != 0:
+                        fail_count += 1
+                        log.info('Attempt %s.  Error running %s Details:\n%s', fail_count, cmd, stderr)
+                        time.sleep(asint(tg.config.get('scm.import.retry_sleep_secs', 5)))
+                    if fail_count == max_fail:
+                        raise SVNCalledProcessError(cmd, returncode, stdout, stderr)
+                return fail_count
             set_hook('pre-revprop-change')
-            while returncode != 0 and fail_count < max_fail:
-                stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
-                # Sleep for 10s and bump the fail counter if svnsync didn't run clean
-                if returncode != 0:
-                    time.sleep(10)
-                    fail_count += 1
-            # Reset the return code to non-zero for next command interation, but reuse the fail counter
-            returncode = -1
-            while returncode != 0 and fail_count < max_fail:
-                stdout, stderr, returncode = self.check_call(
-                    ['svnsync', '--non-interactive', 'sync', self._url])
-                if returncode != 0:
-                    time.sleep(10)
-                    fail_count += 1
+            fail_count = retry_cmd(['svnsync', 'init', self._url, source_url])
+            fail_count = retry_cmd(['svnsync', '--non-interactive', 'sync', self._url], fail_count=fail_count)
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)

http://git-wip-us.apache.org/repos/asf/allura/blob/0298eac4/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..7f34f45 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -195,7 +195,7 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
             source_url = combo[0]
             tg.config = {'scm.svn.hotcopy': combo[1]}
             stdout = combo[2]
-            obj.check_call.return_value = stdout, ''
+            obj.check_call.return_value = stdout, '', 0
             expected = (source_url.startswith('file://') and
                         tg.config['scm.svn.hotcopy'] and
                         stdout != 'version 1.6')


[10/45] allura git commit: Merge branch 'ib/7841'

Posted by he...@apache.org.
Merge branch 'ib/7841'


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

Branch: refs/heads/hss/7072
Commit: 9c06caf76aebb22d678813e743edd8d78f82eae0
Parents: 9707395 f834843
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Mar 19 16:21:00 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 16:21:00 2015 -0400

----------------------------------------------------------------------
 ForgeWiki/forgewiki/model/wiki.py        |  6 ++++-
 ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[30/45] allura git commit: [#7837] ticket:736 Rewrite Commit.added_paths

Posted by he...@apache.org.
[#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/d50d3509
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/d50d3509
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/d50d3509

Branch: refs/heads/hss/7072
Commit: d50d3509ca2faed9bd6abf16566f296d5a3e7e8f
Parents: 78ee673
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 15:01:25 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:40 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/d50d3509/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 9255c66..d15394f 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1235,7 +1235,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:
@@ -1245,13 +1245,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):


[14/45] allura git commit: [#7830] ticket:729 One-click merge for git

Posted by he...@apache.org.
[#7830] ticket:729 One-click merge for git


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

Branch: refs/heads/hss/7072
Commit: 121ebed71e8395f3a436bbecc88d180f0e3b7108
Parents: 9c06caf
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Feb 18 17:00:27 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:29 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 13 ++++++++
 Allura/allura/model/repository.py               | 24 +++++++++++++++
 Allura/allura/templates/repo/merge_request.html | 26 ++++++++++++++++
 ForgeGit/forgegit/model/git_repo.py             | 32 ++++++++++++++++++++
 4 files changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/121ebed7/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index a3c1541..78bff44 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -441,6 +441,19 @@ class MergeRequestController(object):
             self.req.status = status
         redirect('.')
 
+    @expose()
+    @require_post()
+    def merge(self):
+        require_access(c.app, 'write')
+        if self.req.status != 'open' or not self.req.can_merge():
+            raise exc.HTTPNotFound
+        ok = self.req.merge()
+        if ok:
+            flash('Merged successfully', 'ok')
+        else:
+            flash('Merge failed. Please, merge manually', 'error')
+        redirect(self.req.url())
+
 
 class RefsController(object):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/121ebed7/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 0030aa5..5e4a171 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -805,6 +805,30 @@ class MergeRequest(VersionedArtifact, ActivityObject):
                 self.request_number, self.project.name, self.app.repo.name))
         return result
 
+    def can_merge(self):
+        if not self.app.forkable:
+            return False
+        try:
+            result = self.app.repo.can_merge(self)
+        except:
+            log.exception(
+                "Can't determine if merge request %s can be merged",
+                self.url())
+            return False
+        return result
+
+    def merge(self):
+        if not self.app.forkable:
+            return False
+        try:
+            self.app.repo.merge(self)
+        except:
+            log.exception("Can't merge merge request %s", self.url())
+            return False
+        self.status = 'merged'
+        session(self).flush(self)
+        return True
+
 
 # Basic commit information
 # One of these for each commit in the physical repo on disk. The _id is the

http://git-wip-us.apache.org/repos/asf/allura/blob/121ebed7/Allura/allura/templates/repo/merge_request.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html
index 3c79654..060b5b9 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -44,6 +44,25 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 
     <div>{{g.markdown.convert(req.description)}}</div>
 
+    {% if req.status == 'open' and c.app.forkable and h.has_access(c.app, 'write')() %}
+      {% set can_merge = req.can_merge() %}
+      <div class="grid-19">
+        <form action="merge" method="POST">
+          {{ lib.csrf_token() }}
+          <input type="submit" value="Merge"{% if not can_merge %}disabled="disabled"{% endif %}>
+          {% if can_merge %}
+            <div class="merge-ok">
+              Merge request has no conflicts. You can merge automatically.
+            </div>
+          {% else %}
+            <div class="merge-conflicts">
+              Merge request has conflicts. Follow manual instructions below to merge.
+            </div>
+          {% endif %}
+        </form>
+      </div>
+    {% endif %}
+
     {{ c.log_widget.display(value=req.commits, app=downstream_app) }}
 
     <div class="grid-19"><a href="#discussion_holder">Discuss</a></div>
@@ -87,3 +106,10 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
         count=count)}}
   </div>
 {% endblock %}
+
+{% block extra_css %}
+<style type="text/css">
+  .merge-ok { color: green; }
+  .merge-conflicts { color: red; }
+</style>
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/121ebed7/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 7fda67a..831da5b 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -19,6 +19,7 @@ import os
 import shutil
 import string
 import logging
+import tempfile
 from datetime import datetime
 
 import tg
@@ -95,6 +96,37 @@ class Repository(M.Repository):
             merge_request.downstream.commit_id,
         )
 
+    def can_merge(self, mr):
+        """
+        Given merge request `mr` determine if it can be merged w/o conflicts.
+        """
+        g = self._impl._git.git
+        # http://stackoverflow.com/a/6283843
+        # fetch source branch
+        g.fetch(mr.downstream_repo_url, mr.source_branch)
+        # find merge base
+        merge_base = g.merge_base(mr.downstream.commit_id, mr.target_branch)
+        # print out merge result, but don't actually touch anything
+        merge_tree = g.merge_tree(
+            merge_base, mr.target_branch, mr.downstream.commit_id)
+        return '+<<<<<<<' not in merge_tree
+
+    def merge(self, mr):
+        g = self._impl._git.git
+        # can't merge in bare repo, so need to clone
+        tmp_path = tempfile.mkdtemp()
+        tmp_repo = git.Repo.clone_from(
+            self.clone_url('rw'),
+            to_path=tmp_path,
+            bare=False)
+        tmp_repo = GitImplementation(Object(full_fs_path=tmp_path))._git
+        tmp_repo.git.fetch('origin', mr.target_branch)
+        tmp_repo.git.checkout(mr.target_branch)
+        tmp_repo.git.fetch(mr.downstream_repo_url, mr.source_branch)
+        tmp_repo.git.merge(mr.downstream.commit_id)
+        tmp_repo.git.push('origin', mr.target_branch)
+        shutil.rmtree(tmp_path, ignore_errors=True)
+
     def rev_to_commit_id(self, rev):
         return self._impl.rev_parse(rev).hexsha
 


[37/45] allura git commit: [#7837] ticket:738 Implement paged_diffs for SVN

Posted by he...@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/0b5bc0a4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0b5bc0a4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0b5bc0a4

Branch: refs/heads/hss/7072
Commit: 0b5bc0a4dac53496dc38a6e83ec2a621a0ec82f8
Parents: 0a5c8fd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 13:46:16 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/0b5bc0a4/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 142ca6a..c033f44 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -780,5 +780,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()


[09/45] allura git commit: Merge branch 'ib/7841' of https://git-wip-us.apache.org/repos/asf/allura into ib/7841

Posted by he...@apache.org.
Merge branch 'ib/7841' of https://git-wip-us.apache.org/repos/asf/allura into ib/7841


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

Branch: refs/heads/hss/7072
Commit: f8348437a9c36dbc18e88ce868ed9fedd17ae36c
Parents: da74cea d1164fd
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Thu Mar 19 16:08:10 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 16:08:10 2015 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------



[45/45] allura git commit: [#7072] User can't access personal subscriptions page [ss6565]

Posted by he...@apache.org.
[#7072] User can't access personal subscriptions page [ss6565]


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

Branch: refs/heads/hss/7072
Commit: 0f7253c7b802690667b7028daa6d4fc8f43ac161
Parents: 758b51b
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Wed Apr 1 17:09:40 2015 -0400
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Wed Apr 1 17:09:40 2015 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0f7253c7/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index e874a17..1aa2d08 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -860,7 +860,7 @@ class SubscriptionsController(BaseController):
             project = projects.get(mb.project_id, None)
             app_config = app_index.get(mb.app_config_id, None)
             if project is None:
-                mb.m.delete()
+                mb.query.delete()
                 continue
             if app_config is None:
                 continue


[18/45] allura git commit: [#7820] ticket:747 Validate URLs when configuring external link tool

Posted by he...@apache.org.
[#7820] ticket:747 Validate URLs when configuring external link tool


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

Branch: refs/heads/hss/7072
Commit: 53b5577a36005cbd938bc16fa38cb0795eab4dd1
Parents: e146bbe
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 19 14:12:03 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 23 19:43:48 2015 +0000

----------------------------------------------------------------------
 ForgeLink/forgelink/link_main.py                | 19 ++++-
 .../forgelink/templates/app_admin_options.html  | 77 ++++++++++++++++++++
 .../forgelink/tests/functional/test_root.py     | 47 ++++++++++++
 3 files changed, 142 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/53b5577a/ForgeLink/forgelink/link_main.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/link_main.py b/ForgeLink/forgelink/link_main.py
index bb55a3e..bfcf9f9 100644
--- a/ForgeLink/forgelink/link_main.py
+++ b/ForgeLink/forgelink/link_main.py
@@ -23,11 +23,12 @@ import json
 from tg import expose, redirect, flash, jsonify
 from pylons import tmpl_context as c
 from pylons import request
+from formencode import validators as fev
 
 # Pyforge-specific imports
 from allura.app import Application, ConfigOption, SitemapEntry, DefaultAdminController
 from allura.lib import helpers as h
-from allura.lib.security import require_access
+from allura.lib.security import require_access, has_access
 from allura.lib.utils import permanent_redirect
 from allura import model as M
 from allura.controllers import BaseController
@@ -128,6 +129,22 @@ class LinkAdminController(DefaultAdminController):
         flash('External link URL updated.')
         redirect(c.project.url() + 'admin/tools')
 
+    @expose('jinja:forgelink:templates/app_admin_options.html')
+    def options(self):
+        return dict(
+            app=self.app,
+            allow_config=has_access(self.app, 'configure')())
+
+    @expose('json:')
+    def set_url(self, **kw):
+        validator = fev.URL(not_empty=True, add_http=True)
+        try:
+            url = validator.to_python(kw.get('url'))
+        except fev.Invalid as e:
+            return {'status': 'error', 'errors': {'url': e.msg}}
+        self.app.config.options['url'] = url
+        return {'status': 'ok'}
+
 
 class RootRestController(BaseController):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/53b5577a/ForgeLink/forgelink/templates/app_admin_options.html
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/templates/app_admin_options.html b/ForgeLink/forgelink/templates/app_admin_options.html
new file mode 100644
index 0000000..a62dfa7
--- /dev/null
+++ b/ForgeLink/forgelink/templates/app_admin_options.html
@@ -0,0 +1,77 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
+<!DOCTYPE html>
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+<form id="set-url-form" method="post" action="{{c.project.url()}}admin/{{app.config.options.mount_point}}/set_url">
+  <label for="url" class="grid-4">url</label>
+  <div class="grid-9">
+    {% if not allow_config %}
+      {{app.config.options.get('url', '')}}
+    {% else %}
+      <input id="url" name="url" value="{{app.config.options.get('url', '')}}">
+    {% endif %}
+  </div>
+  <div class="grid-4">&nbsp;</div><div id='url-error' class='grid-9'></div>
+  {% if allow_config %}
+    <div class="grid-13">&nbsp;</div>
+    <hr>
+    <div class="grid-13">&nbsp;</div>
+    <div class="grid-13">
+      <input type="submit" value="Save" id="save" />
+      <a href="#" class="close">Cancel</a>
+    </div>
+  {% endif %}
+  {{lib.csrf_token()}}
+</form>
+
+<script type="text/javascript">
+$(function() {
+  $('#save').on('click', function(e) {
+    e.preventDefault();
+    var form = $('#set-url-form');
+    var button = $(this);
+    var input = form.find('input[name="url"]')
+    var url_error = $('#url-error');
+    var url = input.val();
+    var csrf = $.cookie('_session_id');
+    button.prop('disabled', true);
+    input.prop('disabled', true);
+    url_error.text('');
+    $.post(
+      form.attr('action'),
+      {'_session_id': csrf, 'url': url},
+      function(data) {
+        if (data['status'] == 'ok') {
+          location.reload();
+        } else {
+          url_error.text(data['errors']['url']);
+        }
+        button.prop('disabled', false);
+        input.prop('disabled', false);
+      });
+  });
+});
+</script>
+
+<style type="text/css">
+#url-error {
+  margin-left: 15px;
+  color: #f33;
+}
+</style>

http://git-wip-us.apache.org/repos/asf/allura/blob/53b5577a/ForgeLink/forgelink/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeLink/forgelink/tests/functional/test_root.py b/ForgeLink/forgelink/tests/functional/test_root.py
index ca57244..e4fc656 100644
--- a/ForgeLink/forgelink/tests/functional/test_root.py
+++ b/ForgeLink/forgelink/tests/functional/test_root.py
@@ -15,6 +15,9 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from nose.tools import assert_equal
+
+from allura import model as M
 from allura.tests import decorators as td
 from alluratest.controller import TestController
 
@@ -58,3 +61,47 @@ class TestRootController(TestController):
         response = self.app.get('/link/help')
         # HACK: support for remote redirects is limited in follow()
         assert 'http://www.google.de/search?q=help' in response
+
+    @td.with_link
+    def test_set_url_validation(self):
+        r = self.app.post('/p/test/admin/link/set_url', {})
+        expected = {'status': 'error',
+                    'errors': {'url': u'Please enter a value'}}
+        assert_equal(r.json, expected)
+
+        r = self.app.post('/p/test/admin/link/set_url', {'url': ''})
+        expected = {'status': 'error',
+                    'errors': {'url': u'Please enter a value'}}
+        assert_equal(r.json, expected)
+
+        r = self.app.post('/p/test/admin/link/set_url', {'url': 'bad url'})
+        expected = {'status': 'error',
+                    'errors': {'url': u'That is not a valid URL'}}
+        assert_equal(r.json, expected)
+
+        p = M.Project.query.get(shortname='test')
+        link = p.app_instance('link')
+        assert_equal(link.config.options.get('url'), None)
+
+    @td.with_link
+    def test_set_url(self):
+        data = {'url': 'http://example.com'}  # http
+        r = self.app.post('/p/test/admin/link/set_url', data)
+        assert_equal(r.json, {'status': 'ok'})
+        p = M.Project.query.get(shortname='test')
+        link = p.app_instance('link')
+        assert_equal(link.config.options.get('url'), 'http://example.com')
+
+        data = {'url': 'https://google.com'}  # https
+        r = self.app.post('/p/test/admin/link/set_url', data)
+        assert_equal(r.json, {'status': 'ok'})
+        p = M.Project.query.get(shortname='test')
+        link = p.app_instance('link')
+        assert_equal(link.config.options.get('url'), 'https://google.com')
+
+        data = {'url': 'lmgtfy.com'}  # http is added if not provided
+        r = self.app.post('/p/test/admin/link/set_url', data)
+        assert_equal(r.json, {'status': 'ok'})
+        p = M.Project.query.get(shortname='test')
+        link = p.app_instance('link')
+        assert_equal(link.config.options.get('url'), 'http://lmgtfy.com')


[03/45] allura git commit: [#7072] Improve /auth/subscriptions performance by avoiding mongo query in a loop (subscribed() method)

Posted by he...@apache.org.
[#7072] Improve /auth/subscriptions performance by avoiding mongo query in a loop (subscribed() method)


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

Branch: refs/heads/hss/7072
Commit: 269703c5c510c6f9f0f58470fd9536172f0e5a24
Parents: 5c8f832
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Wed Mar 18 12:51:58 2015 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Mar 18 21:38:07 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/auth.py | 66 ++++++++++++++++++++++------------
 1 file changed, 44 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/269703c5/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 0bfe966..e874a17 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -829,6 +829,7 @@ class UserAvailabilityController(BaseController):
 
 
 class SubscriptionsController(BaseController):
+    """ Gives users the ability to manage subscriptions to tools. """
 
     def _check_security(self):
         require_authenticated()
@@ -836,21 +837,25 @@ class SubscriptionsController(BaseController):
     @with_trailing_slash
     @expose('jinja:allura:templates/user_subs.html')
     def index(self, **kw):
+        """ The subscription selection page in user preferences.
+
+        Builds up a list of dictionaries, each containing subscription
+        information about a tool.
+        """
         c.form = F.subscription_form
         c.revoke_access = F.oauth_revocation_form
+
         subscriptions = []
-        mailboxes = M.Mailbox.query.find(
-            dict(user_id=c.user._id, is_flash=False))
-        mailboxes = list(mailboxes.ming_cursor)
-        project_collection = M.Project.query.mapper.collection
-        app_collection = M.AppConfig.query.mapper.collection
+        mailboxes = list(M.Mailbox.query.find(
+            dict(user_id=c.user._id, is_flash=False)))
         projects = dict(
-            (p._id, p) for p in project_collection.m.find(dict(
+            (p._id, p) for p in M.Project.query.find(dict(
                 _id={'$in': [mb.project_id for mb in mailboxes]})))
         app_index = dict(
-            (ac._id, ac) for ac in app_collection.m.find(dict(
+            (ac._id, ac) for ac in M.AppConfig.query.find(dict(
                 _id={'$in': [mb.app_config_id for mb in mailboxes]})))
 
+        # Add the tools that are already subscribed to by the user.
         for mb in mailboxes:
             project = projects.get(mb.project_id, None)
             app_config = app_index.get(mb.app_config_id, None)
@@ -859,8 +864,11 @@ class SubscriptionsController(BaseController):
                 continue
             if app_config is None:
                 continue
+
             subscriptions.append(dict(
                 subscription_id=mb._id,
+                project_id=project._id,
+                app_config_id=mb.app_config_id,
                 project_name=project.name,
                 mount_point=app_config.options['mount_point'],
                 artifact_title=dict(
@@ -871,24 +879,38 @@ class SubscriptionsController(BaseController):
                 artifact=mb.artifact_index_id,
                 subscribed=True))
 
+        # Dictionary of all projects projects accessible based on a users credentials (user_roles).
         my_projects = dict((p._id, p) for p in c.user.my_projects())
-        my_tools = app_collection.m.find(dict(
+
+        # Dictionary containing all tools (subscribed and un-subscribed).
+        my_tools = M.AppConfig.query.find(dict(
             project_id={'$in': my_projects.keys()}))
+
+        # Dictionary containing all the currently subscribed tools for a given user.
+        my_tools_subscriptions = dict(
+            (mb.app_config_id, mb) for mb in M.Mailbox.query.find(dict(
+                user_id=c.user._id,
+                project_id={'$in': projects.keys()},
+                app_config_id={'$in': app_index.keys()},
+                artifact_index_id=None)))
+
+        # Add the remaining tools that are eligible for subscription.
         for tool in my_tools:
-            p_id = tool.project_id
-            subscribed = M.Mailbox.subscribed(
-                project_id=p_id, app_config_id=tool._id)
-            if not subscribed:
-                subscriptions.append(dict(
-                    tool_id=tool._id,
-                    project_id=p_id,
-                    project_name=my_projects[p_id].name,
-                    mount_point=tool.options['mount_point'],
-                    artifact_title='No subscription',
-                    topic=None,
-                    type=None,
-                    frequency=None,
-                    artifact=None))
+            if tool['_id'] in my_tools_subscriptions:
+                continue  # We have already subscribed to this tool.
+
+            subscriptions.append(
+                dict(tool_id=tool._id,
+                     user_id=c.user._id,
+                     project_id=tool.project_id,
+                     project_name=my_projects[tool.project_id].name,
+                     mount_point=tool.options['mount_point'],
+                     artifact_title='No subscription',
+                     topic=None,
+                     type=None,
+                     frequency=None,
+                     artifact=None))
+
         subscriptions.sort(key=lambda d: (d['project_name'], d['mount_point']))
         provider = plugin.AuthenticationProvider.get(request)
         menu = provider.account_navigation()


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

Posted by he...@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/02879be3
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/02879be3
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/02879be3

Branch: refs/heads/hss/7072
Commit: 02879be348331df7a01bb3f4d0f680c8ce1b8735
Parents: b361bdf
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 4 16:31:03 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:42 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/02879be3/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 84dd40d..3ffb2a2 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'),
@@ -760,12 +751,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()
@@ -839,12 +827,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()
@@ -873,12 +858,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/02879be3/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 c3a392a..8fa8314 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()


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

Posted by he...@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/78ee673f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/78ee673f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/78ee673f

Branch: refs/heads/hss/7072
Commit: 78ee673f5508764a2b7a89baca6954715ef2bb85
Parents: ffc64c3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 14:37:40 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:40 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/78ee673f/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 867a6d2..9255c66 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:
@@ -1104,25 +1115,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/78ee673f/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 8841f52..e1d16e8 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -600,6 +600,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


[21/45] allura git commit: [#7817] Replace "mount point" field with URL field, on tool creation forms

Posted by he...@apache.org.
[#7817] Replace "mount point" field with URL field, on tool creation forms


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

Branch: refs/heads/hss/7072
Commit: 1f1a2c5c401bd35bfcef209346d4fed612e60e26
Parents: b233388
Author: Heith Seewald <hs...@slashdotmedia.com>
Authored: Mon Mar 23 16:50:51 2015 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Mar 25 15:53:49 2015 +0000

----------------------------------------------------------------------
 .../ext/admin/templates/project_tools.html      | 49 ++++++++++++++++++--
 1 file changed, 44 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1f1a2c5c/Allura/allura/ext/admin/templates/project_tools.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/admin/templates/project_tools.html b/Allura/allura/ext/admin/templates/project_tools.html
index a51f750..ca372ce 100644
--- a/Allura/allura/ext/admin/templates/project_tools.html
+++ b/Allura/allura/ext/admin/templates/project_tools.html
@@ -26,6 +26,7 @@
 {% block header %}Tools{% endblock %}
 
 {% block content %}
+{% set full_url = h.absurl(c.project.url()) %}
   <h3>Click to install</h3>
   <div class="nested-grid-container">
     {% for tool in installable_tools %}
@@ -46,10 +47,14 @@
   <form method="post" action="update_mounts?limit={{limit}}&page={{page}}" id="install_form" style="display:none">
     <input type="hidden" name="new.ordinal" value="{{total_mounts}}"/>
     <input type="hidden" name="new.ep_name" class="new_ep_name">
-    <label class="grid-13">Label</label>
-    <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label"></div>
-    <label class="grid-13">Mount Point</label>
-    <div class="grid-13"><input type="text" name="new.mount_point" class="new_mount_point"></div>
+    <label class="grid-13" for="new.mount_label">Label</label>
+    <div class="grid-13"><input type="text" name="new.mount_label" class="new_mount_label" title="This will be the name displayed in your project toolbar.">
+    </div>
+      <label class="grid-13" for="new.mount_point">Url Path</label>
+      <div class="grid-13">
+        <input id="id_url_input" type="text" name="new.mount_point" title="The url for this tool relative to {{ full_url }} " class="new_mount_point">
+       <p><span id="full-url-preview" data-url="{{full_url}}"></span></p>
+    </div>
     <div class="grid-13">
       <small>
         * The mount point is the name of the tool as it will appear in a URL.
@@ -172,13 +177,40 @@
 {% endblock %}
 
 {% block extra_js %}
-<script type="text/javascript">
+<script>
     var defaults = {
         {% for tool in installable_tools %}
         '{{tool.name}}':{'default_label':'{{tool.app.default_mount_label}}','default_mount':'{{tool.app.default_mount_point}}'}{% if not loop.last %},{% endif %}
         {% endfor %}
     };
 </script>
+<script>
+/* Real-time preview of a Url Path (aka mount point). */
+
+    var url_preview = $('#full-url-preview'); // "Preview Url Path" displayed on when creating a new tool.
+    var full_url = $(url_preview).data().url; // Full url path of current project.
+
+    // Update the url path preview as they type.
+    $('#id_url_input').keyup(function(){
+        url_preview.html(full_url + '<strong class="url-keyword">' + $(this).val() + "</strong>");
+    });
+
+    // Set url_preview to the Url Path Defaults when creating a new tool.
+    $('.installable_tool').find('a').on('click', function () {
+        // Add the link tool's 'nice name'.
+        defaults['external link'] = defaults.link
+        var tool_name = $.trim($(this).text().toLowerCase());
+
+        // If a tool has a default url path, use it for an initial preview.
+        if (defaults[tool_name]) {
+            url_preview.html(full_url + '<strong class="url-keyword">' + defaults[tool_name].default_mount + "</strong>");
+        }
+        else {
+            // No defaults for this tool, so we use the base url to ensure the url_preview is reset.
+            url_preview.html(full_url);
+        }
+    });
+</script>
 {% endblock %}
 
 {% block extra_css %}
@@ -195,5 +227,12 @@ div.isnt_sorted > ul.deck {
 #configure_grouping_form input[name=grouping_threshold] {
     width: 1.5em;
 }
+#full-url-preview{
+  color: white;
+  font-size: small;
+}
+#full-url-preview .url-keyword{
+  color: orange;
+}
 </style>
 {% endblock %}


[42/45] allura git commit: [#7837] ticket:750 Handle copied in svn

Posted by he...@apache.org.
[#7837] ticket:750 Handle copied in svn


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

Branch: refs/heads/hss/7072
Commit: 5fc0458959a2041351292c65b2e3649bbe10efb0
Parents: 6d9c49d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Mar 27 16:19:19 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:42 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py        |  5 ++++-
 Allura/allura/templates/repo/commit.html |  2 +-
 ForgeSVN/forgesvn/model/svn.py           | 17 +++++++++++++++--
 3 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5fc04589/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index fb9a04e..edebeb4 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1107,7 +1107,10 @@ class Commit(RepoObject, ActivityObject):
 
     def paged_diffs(self, start=0, end=None):
         diffs = self.repo.paged_diffs(self._id, start, end)
-        diffs['copied'] = self._diffs_copied(diffs['added'], diffs['removed'])
+        if not diffs.get('copied'):
+            diffs['copied'] = []
+        copied = self._diffs_copied(diffs['added'], diffs['removed'])
+        diffs['copied'].extend(copied)
         return Object(
             added=diffs['added'],
             removed=diffs['removed'],

http://git-wip-us.apache.org/repos/asf/allura/blob/5fc04589/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 9c6342f..98afbba 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -148,7 +148,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                   <span class="empty-diff">File was removed.</span>
                 {% elif type == 'copied' %}
                   {% if file.ratio == 1 %}
-                    <span class="empty-diff">File was renamed.</span>
+                    <span class="empty-diff">File was copied or renamed.</span>
                   {% else %}
                     {{g.highlight(file.diff, lexer='diff')}}
                   {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/5fc04589/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index f37c1e2..cf70b7d 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -781,7 +781,13 @@ class SVNImplementation(M.RepositoryImplementation):
         return []
 
     def paged_diffs(self, commit_id, start=0, end=None):
-        result = {'added': [], 'removed': [], 'changed': [], 'total': 0}
+        result = {
+            'added': [],
+            'removed': [],
+            'changed': [],
+            'copied': [],
+            'total': 0,
+        }
         rev = self._revision(commit_id)
         try:
             log_info = self._svn.log(
@@ -798,7 +804,14 @@ class SVNImplementation(M.RepositoryImplementation):
         paths = log_info[0].changed_paths
         result['total'] = len(paths)
         for p in paths[start:end]:
-            if p['action'] == 'A':
+            if p['copyfrom_path'] is not None:
+                result['copied'].append({
+                    'new': h.really_unicode(p.path),
+                    'old': h.really_unicode(p.copyfrom_path),
+                    'ratio': 1,
+                    'diff': '',
+                })
+            elif p['action'] == 'A':
                 result['added'].append(h.really_unicode(p.path))
             elif p['action'] == 'D':
                 result['removed'].append(h.really_unicode(p.path))


[08/45] allura git commit: [#7841] ticket:742 Hide disabled and pending authors from wiki pages

Posted by he...@apache.org.
[#7841] ticket:742 Hide disabled and pending authors from wiki pages


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

Branch: refs/heads/hss/7072
Commit: e887dfb590badea3d6f893ae17c12a256eeac0c6
Parents: 269703c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 00:13:19 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 14:51:21 2015 -0400

----------------------------------------------------------------------
 ForgeWiki/forgewiki/model/wiki.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e887dfb5/ForgeWiki/forgewiki/model/wiki.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/model/wiki.py b/ForgeWiki/forgewiki/model/wiki.py
index 18bfb85..c79fd16 100644
--- a/ForgeWiki/forgewiki/model/wiki.py
+++ b/ForgeWiki/forgewiki/model/wiki.py
@@ -234,7 +234,11 @@ class Page(VersionedArtifact, ActivityObject):
                 t[user.username] = user.id
             return t.values()
         user_ids = uniq([r.author for r in self.history().all()])
-        return User.query.find({'_id': {'$in': user_ids}}).all()
+        return User.query.find({
+            '_id': {'$in': user_ids},
+            'disabled': False,
+            'pending': False
+        }).all()
 
     def delete(self):
         Shortlink.query.remove(dict(ref_id=self.index_id()))


[11/45] allura git commit: [#7830] ticket:733 Don't catch exception in merge task

Posted by he...@apache.org.
[#7830] ticket:733 Don't catch exception in merge task

So that merge task will get 'error' status and proper message will be displayed
to the user.


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

Branch: refs/heads/hss/7072
Commit: 0efaa304c5ffd5e31086d92c4272bbae950b4fec
Parents: 02a3fca
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 26 13:16:23 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:29 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/repo_tasks.py | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0efaa304/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index e50f9d2..e873694 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -160,10 +160,6 @@ def merge(merge_request_id):
     from allura import model as M
     log = logging.getLogger(__name__)
     mr = M.MergeRequest.query.get(_id=merge_request_id)
-    try:
-        mr.app.repo.merge(mr)
-    except:
-        log.exception("Can't merge merge request %s", mr.url())
-        return
+    mr.app.repo.merge(mr)
     mr.status = 'merged'
     session(mr).flush(mr)


[23/45] allura git commit: [#7857] document scm.import.retry_* in development.ini

Posted by he...@apache.org.
[#7857] document scm.import.retry_* in development.ini


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

Branch: refs/heads/hss/7072
Commit: b42fa1aff48bf367c904c8ecf8624e30d58971cb
Parents: 0298eac
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Mar 26 16:21:41 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Mar 27 10:56:41 2015 +0000

----------------------------------------------------------------------
 Allura/development.ini | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b42fa1af/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index ba06cc5..2f60f2f 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -238,6 +238,11 @@ scm.repos.tarball.root = /usr/share/nginx/www/
 scm.repos.tarball.url_prefix = http://localhost/
 scm.repos.tarball.zip_binary = /usr/bin/zip
 
+; SCM imports (currently just SVN) will retry if it fails
+; You can control the number of tries and delay between tries here:
+;scm.import.retry_count = 50
+;scm.import.retry_sleep_secs = 5
+
 bulk_export_path = /tmp/bulk_export/{nbhd}/{project}
 bulk_export_filename = {project}-backup-{date:%Y-%m-%d-%H%M%S}.zip
 bulk_export_download_instructions = Sample instructions for {project}


[43/45] allura git commit: [#7837] ticket:750 List directories in the commit info

Posted by he...@apache.org.
[#7837] ticket:750 List directories in the commit info


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

Branch: refs/heads/hss/7072
Commit: 44dda6b208347e8249a997fd9576329371c88cc5
Parents: 5fc0458
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Mar 27 16:35:59 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:42 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py  |  6 +++---
 Allura/allura/templates/repo/commit.html | 16 +++++++++++-----
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/44dda6b2/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 8d8cfff..c08ec99 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -538,9 +538,9 @@ class CommitBrowser(BaseController):
                                              default=self.DEFAULT_PAGE_LIMIT)
         diffs = self._commit.paged_diffs(start=start, end=start + limit)
         result['artifacts'] = [
-            (t, f) for t in ('added', 'removed', 'changed', 'copied')
-            for f in diffs[t]
-            if t == 'removed' or tree.get_blob_by_path(f)]
+            (t, f, 'blob' if tree.get_blob_by_path(f) else 'tree')
+            for t in ('added', 'removed', 'changed', 'copied')
+            for f in diffs[t]]
         count = diffs['total']
         result.update(dict(page=page, limit=limit, count=count))
         return result

http://git-wip-us.apache.org/repos/asf/allura/blob/44dda6b2/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index 98afbba..4870332 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -113,7 +113,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
 {{c.page_list.display(page=page, limit=limit, count=count)}}
 <table>
   <tbody>
-    {% for type, file in artifacts %}
+    {% for type, file, _ in artifacts %}
     <tr>
         <td>{{ type }}</td>
         <td><a href="#diff-{{loop.index}}">
@@ -128,13 +128,17 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
   </tbody>
 </table>
 
-{% for type, file in artifacts %}
+{% for type, file, obj_type in artifacts %}
         <div class="inline-diff">
             <h6>
             {% if type in ('added', 'changed') %}
-                <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
-                <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?diff={{prev[0]._id if prev else ''}}">Diff</a>
-                <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                {% if obj_type == 'tree' %}
+                    <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
+                {% else %}
+                    <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
+                    <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?diff={{prev[0]._id if prev else ''}}">Diff</a>
+                    <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                {% endif %}
             {% elif type == 'removed' %}
                 <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
             {% elif type == 'copied' %}
@@ -152,6 +156,8 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                   {% else %}
                     {{g.highlight(file.diff, lexer='diff')}}
                   {% endif %}
+                {% elif obj_type == 'tree' %}
+                    <span class="empty-diff">Directory.</span>
                 {% else %}
                     <img src="{{g.forge_static('images/spinner.gif')}}" class="loading_icon" alt="Loading..."/>
                     <script type="text/javascript">


[22/45] allura git commit: [#7857] initial contribution from David Burley

Posted by he...@apache.org.
[#7857] initial contribution from David Burley


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

Branch: refs/heads/hss/7072
Commit: a6b536c0b89f734713ffa2febaa30863c0c78402
Parents: 1f1a2c5
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Mar 20 20:52:09 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Fri Mar 27 10:56:40 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a6b536c0/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 92dc292..c5643e1 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -21,6 +21,7 @@ import shutil
 import string
 import logging
 import subprocess
+import time
 from subprocess import Popen, PIPE
 from hashlib import sha1
 from cStringIO import StringIO
@@ -226,7 +227,7 @@ class SVNImplementation(M.RepositoryImplementation):
                 source_url.startswith('file://')):
             return False
         # check for svn version 1.7 or later
-        stdout, stderr = self.check_call(['svn', '--version'])
+        stdout, stderr, returncode = self.check_call(['svn', '--version'])
         pattern = r'version (?P<maj>\d+)\.(?P<min>\d+)'
         m = re.search(pattern, stdout)
         return m and (int(m.group('maj')) * 10 + int(m.group('min'))) >= 17
@@ -237,7 +238,7 @@ class SVNImplementation(M.RepositoryImplementation):
         if p.returncode != 0:
             self._repo.set_status('ready')
             raise SVNCalledProcessError(cmd, p.returncode, stdout, stderr)
-        return stdout, stderr
+        return stdout, stderr, p.returncode
 
     def clone_from(self, source_url):
         '''Initialize a repo as a clone of another using svnsync'''
@@ -276,10 +277,25 @@ class SVNImplementation(M.RepositoryImplementation):
                  'initialize', self._url, source_url])
             clear_hook('pre-revprop-change')
         else:
+            # retry logic
+            max_fail = 60
+            fail_count = 0
+            returncode = -1
             set_hook('pre-revprop-change')
-            self.check_call(['svnsync', 'init', self._url, source_url])
-            self.check_call(
-                ['svnsync', '--non-interactive', 'sync', self._url])
+            while returncode != 0 && fail_count < max_fail:
+                stdout, stderr, returncode = self.check_call(['svnsync', 'init', self._url, source_url])
+                # Sleep for 10s and bump the fail counter if svnsync didn't run clean
+                if returncode != 0:
+                    time.sleep(10)
+                    fail_count++
+            # Reset the return code to non-zero for next command interation, but reuse the fail counter
+            returncode = -1
+            while returncode != 0 && fail_count < max_fail:
+                stdout, stderr, returncode = self.check_call(
+                    ['svnsync', '--non-interactive', 'sync', self._url])
+                if returncode != 0:
+                    time.sleep(10)
+                    fail_count++
             clear_hook('pre-revprop-change')
 
         log.info('... %r cloned', self._repo)


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

Posted by he...@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/0e737f18
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0e737f18
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0e737f18

Branch: refs/heads/hss/7072
Commit: 0e737f18fb799fadc9ca1be744d8d9de12303e01
Parents: d0dd4b7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:29:30 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:40 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/0e737f18/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index fc50860..a7c6a31 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1237,7 +1237,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/0e737f18/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index e1d16e8..b713cb0 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -600,7 +600,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',


[32/45] allura git commit: [#7837] ticket:736 Fix LCD tests

Posted by he...@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/9857cdb0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/9857cdb0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/9857cdb0

Branch: refs/heads/hss/7072
Commit: 9857cdb098e04a7bba6a27f9c92e346ea120d462
Parents: a2c5446
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 17:39:43 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/9857cdb0/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 669f940..8b406da 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


[27/45] allura git commit: [#7837] ticket:736 s/NotImplemented/NotImplementedError/

Posted by he...@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/a2c54460
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a2c54460
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a2c54460

Branch: refs/heads/hss/7072
Commit: a2c54460d1681d045087f0960427e57641545de7
Parents: 0e737f1
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 2 16:34:06 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:40 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/a2c54460/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index a7c6a31..fb9a04e 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):
         '''


[26/45] allura git commit: [#7862] remove amqp/rabbitmq references, and async.py which could occasionally cause import issues from gitdb looking for another async package

Posted by he...@apache.org.
[#7862] remove amqp/rabbitmq references, and async.py which could occasionally cause import issues from gitdb looking for another async package


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

Branch: refs/heads/hss/7072
Commit: ffc64c39ea5bc6185c53b5fb1272d3b4343077fd
Parents: b42fa1a
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Mar 26 21:54:06 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 14:57:47 2015 +0000

----------------------------------------------------------------------
 Allura/allura/command/smtp_server.py         |  2 +-
 Allura/allura/command/taskd.py               | 13 +-----
 Allura/allura/lib/app_globals.py             | 20 ---------
 Allura/allura/lib/async.py                   | 49 -----------------------
 Allura/allura/model/monq_model.py            |  5 ---
 Allura/allura/tests/test_commands.py         |  1 -
 Allura/development.ini                       | 15 +------
 Allura/docs/getting_started/installation.rst | 23 -----------
 Allura/docs/platform/email.rst               |  3 --
 Allura/docs/platform/platform.rst            |  9 +----
 10 files changed, 5 insertions(+), 135 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/command/smtp_server.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/smtp_server.py b/Allura/allura/command/smtp_server.py
index eb2a98f..40008d7 100644
--- a/Allura/allura/command/smtp_server.py
+++ b/Allura/allura/command/smtp_server.py
@@ -33,7 +33,7 @@ class SMTPServerCommand(base.Command):
     min_args = 1
     max_args = 1
     usage = '<ini file>'
-    summary = 'Handle incoming emails, routing them to RabbitMQ'
+    summary = 'Handle incoming emails, routing them to taskd'
     parser = command.Command.standard_parser(verbose=True)
     parser.add_option('-c', '--context', dest='context',
                       help=('The context of the message (path to the project'

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/command/taskd.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/taskd.py b/Allura/allura/command/taskd.py
index 40d795a..409e701 100644
--- a/Allura/allura/command/taskd.py
+++ b/Allura/allura/command/taskd.py
@@ -114,12 +114,6 @@ class TaskdCommand(base.Command):
                     'Unexpected http response from taskd request: %s.  Headers: %s',
                     status, headers)
 
-        def waitfunc_amqp():
-            try:
-                return pylons.app_globals.amq_conn.queue.get(timeout=poll_interval)
-            except Queue.Empty:
-                return None
-
         def waitfunc_noq():
             time.sleep(poll_interval)
 
@@ -131,14 +125,9 @@ class TaskdCommand(base.Command):
                     raise StopIteration
             return waitfunc_checks_running
 
-        if pylons.app_globals.amq_conn:
-            waitfunc = waitfunc_amqp
-        else:
-            waitfunc = waitfunc_noq
+        waitfunc = waitfunc_noq
         waitfunc = check_running(waitfunc)
         while self.keep_running:
-            if pylons.app_globals.amq_conn:
-                pylons.app_globals.amq_conn.reset()
             try:
                 while self.keep_running:
                     self.task = M.MonQTask.get(

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index fc49749..30bfbf3 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -61,7 +61,6 @@ from allura.lib import gravatar, plugin, utils
 from allura.lib import helpers as h
 from allura.lib.widgets import analytics
 from allura.lib.security import Credentials
-from allura.lib.async import Connection, MockAMQ
 from allura.lib.solr import MockSOLR, make_solr_from_config
 from allura.lib.zarkov_helpers import ZarkovClient
 
@@ -339,21 +338,6 @@ class Globals(object):
                     return []
             return NullActivityStreamDirector()
 
-    @LazyProperty
-    def amq_conn(self):
-        if asbool(config.get('amqp.enabled', 'true')):
-            if asbool(config.get('amqp.mock')):
-                return MockAMQ(self)
-            else:
-                return Connection(
-                    hostname=config.get('amqp.hostname', 'localhost'),
-                    port=asint(config.get('amqp.port', 5672)),
-                    userid=config.get('amqp.userid', 'testuser'),
-                    password=config.get('amqp.password', 'testpw'),
-                    vhost=config.get('amqp.vhost', 'testvhost'))
-        else:
-            return None
-
     def post_event(self, topic, *args, **kwargs):
         allura.tasks.event_tasks.event.post(topic, *args, **kwargs)
 
@@ -634,7 +618,3 @@ class Icon(object):
     def __init__(self, char, css):
         self.char = char
         self.css = css
-
-
-def connect_amqp(config):
-    return

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/lib/async.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/async.py b/Allura/allura/lib/async.py
deleted file mode 100644
index d299160..0000000
--- a/Allura/allura/lib/async.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#       Licensed to the Apache Software Foundation (ASF) under one
-#       or more contributor license agreements.  See the NOTICE file
-#       distributed with this work for additional information
-#       regarding copyright ownership.  The ASF licenses this file
-#       to you under the Apache License, Version 2.0 (the
-#       "License"); you may not use this file except in compliance
-#       with the License.  You may obtain a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#       Unless required by applicable law or agreed to in writing,
-#       software distributed under the License is distributed on an
-#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-#       KIND, either express or implied.  See the License for the
-#       specific language governing permissions and limitations
-#       under the License.
-
-import logging
-from Queue import Queue
-
-log = logging.getLogger(__name__)
-
-
-class Connection(object):
-
-    def __init__(self, hostname, port, userid, password, vhost):
-        import kombu
-        self._conn_proto = kombu.BrokerConnection(
-            hostname=hostname,
-            port=port,
-            userid=userid,
-            password=password,
-            virtual_host=vhost)
-        self._connection_pool = self._conn_proto.Pool(preload=1, limit=None)
-        self.reset()
-
-    def reset(self):
-        self._conn = self._connection_pool.acquire()
-        self.queue = self._conn.SimpleQueue('task')
-
-
-class MockAMQ(object):
-
-    def __init__(self, globals):
-        self.globals = globals
-        self.reset()
-
-    def reset(self):
-        self.queue = Queue()

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/model/monq_model.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/monq_model.py b/Allura/allura/model/monq_model.py
index be22769..7f25a4f 100644
--- a/Allura/allura/model/monq_model.py
+++ b/Allura/allura/model/monq_model.py
@@ -169,11 +169,6 @@ class MonQTask(MappedClass):
             context=context,
             time_queue=datetime.utcnow() + timedelta(seconds=delay))
         session(obj).flush(obj)
-        try:
-            if g.amq_conn:
-                g.amq_conn.queue.put('')
-        except:
-            log.warning('Error putting to amq_conn', exc_info=True)
         return obj
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 73b419a..1c298c5 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -39,7 +39,6 @@ class EmptyClass(object):
 
 def setUp(self):
     """Method called by nose before running each test"""
-    # setup_basic_test(app_name='main_with_amqp')
     setup_basic_test()
     setup_global_objects()
 

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/development.ini
----------------------------------------------------------------------
diff --git a/Allura/development.ini b/Allura/development.ini
index 2f60f2f..bda8d37 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -289,14 +289,8 @@ ming.zarkov.auto_ensure_indexes = False
 
 stats.sample_rate = 1
 
-# Async setup
+; Taskd setup
 monq.poll_interval=2
-amqp.enabled = false
-# amqp.hostname = localhost
-# amqp.port = 5672
-# amqp.userid = testuser
-# amqp.password = testpw
-# amqp.vhost = testvhost
 
 # SOLR setup
 solr.server = http://localhost:8983/solr
@@ -399,7 +393,7 @@ override_root = task ; TurboGears will use controllers/task.py as root controlle
 # http://docs.python.org/lib/logging-config-fileformat.html
 
 [loggers]
-keys = root, allura, sqlalchemy, paste, amqp, pylons, taskdstatus, timermiddleware, tmw_details
+keys = root, allura, sqlalchemy, paste, pylons, taskdstatus, timermiddleware, tmw_details
 
 [handlers]
 keys = console, stats, taskdstatus, timermiddleware
@@ -430,11 +424,6 @@ level = INFO
 qualname = paste
 handlers =
 
-[logger_amqp]
-level = INFO
-qualname = amqplib
-handlers =
-
 [logger_pylons]
 level = INFO
 qualname = pylons

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/docs/getting_started/installation.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/getting_started/installation.rst b/Allura/docs/getting_started/installation.rst
index 3d3321a..9c08692 100644
--- a/Allura/docs/getting_started/installation.rst
+++ b/Allura/docs/getting_started/installation.rst
@@ -82,26 +82,3 @@ Allura records will be automatically created the first time they log in.
 
 Note: if you want users to register new accounts into your LDAP system via Allura, you should turn
 off :samp:`autoregister` and turn on :samp:`allow_user_registration`
-
-Enabling RabbitMQ
-^^^^^^^^^^^^^^^^^
-
-For faster notification of background jobs, you can use RabbitMQ.  Assuming a base setup from the INSTALL, run these commands
-to install rabbitmq and set it up:
-
-.. code-block:: bash
-
-    sudo aptitude install rabbitmq-server
-    sudo rabbitmqctl add_user testuser testpw
-    sudo rabbitmqctl add_vhost testvhost
-    sudo rabbitmqctl set_permissions -p testvhost testuser ""  ".*" ".*"
-    pip install amqplib==0.6.1 kombu==1.0.4
-
-Then edit Allura/development.ini and change `amqp.enabled = false` to `amqp.enabled = true` and uncomment the other `amqp` settings.
-
-If your `paster taskd` process is still running, restart it:
-
-.. code-block:: bash
-
-    pkill -f taskd
-    nohup paster taskd development.ini > /var/log/allura/taskd.log &
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/docs/platform/email.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/platform/email.rst b/Allura/docs/platform/email.rst
index 754a278..59f5e94 100644
--- a/Allura/docs/platform/email.rst
+++ b/Allura/docs/platform/email.rst
@@ -46,9 +46,6 @@ If you were working with the bug tracker directly on the TurboGears project::
 
     bug.142@turbogears.sf.net
 
-The Allura platform allows you to setup other message types, such as commit
-messages, to go into amqp with the same routing information, and turn into
-"messages" just like e-mail.
 
 Email Content Handling
 ----------------------

http://git-wip-us.apache.org/repos/asf/allura/blob/ffc64c39/Allura/docs/platform/platform.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/platform/platform.rst b/Allura/docs/platform/platform.rst
index 7e64755..f12299c 100644
--- a/Allura/docs/platform/platform.rst
+++ b/Allura/docs/platform/platform.rst
@@ -40,8 +40,7 @@ complex requirements for data storage and extensibility.  So, we needed a
 
 We were very impressed by the general message architecture of Roundup, but we
 wanted to extend it from just email messages to include scm commits, and we
-added a message bus (RabbitMQ which we'll talk about in a second), to make
-it fast.
+added a message bus, to make it fast.
 
 .. image:: ../_static/images/messages.png
    :alt: Message Architecture
@@ -74,12 +73,6 @@ Not only that but Rick Copeland had built a couple of custom Object
 and he whipped up Ming, which backed on MongoDB and gave us exactly
 what we needed.
 
-As I mentioned before we also needed a fast, flexible message bus and queuing
-system. RabbitMQ was (lightning) fast, (shockingly) flexible, but not super
-easy to use. Fortunately we didn't have to roll our own wrapper here, as
-the Python community already whipped up Carrot, and Celery, which made
-working with the RabbitMQ based AMQP bus a LOT easer.
-
 
 Application Tools
 -----------------


[02/45] allura git commit: [#7841] ticket:742 Added test for Page.authors

Posted by he...@apache.org.
[#7841] ticket:742 Added test for Page.authors


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

Branch: refs/heads/hss/7072
Commit: d1164fd0fd80fc6546ab5f750cdae0066cea1982
Parents: 99dbd18
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Wed Mar 18 16:02:05 2015 +0200
Committer: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Committed: Wed Mar 18 16:02:05 2015 +0200

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/test_models.py | 35 +++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d1164fd0/ForgeWiki/forgewiki/tests/test_models.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/test_models.py b/ForgeWiki/forgewiki/tests/test_models.py
index 5c10e50..2ab2f00 100644
--- a/ForgeWiki/forgewiki/tests/test_models.py
+++ b/ForgeWiki/forgewiki/tests/test_models.py
@@ -15,9 +15,15 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from pylons import tmpl_context as c
+from ming.orm import session
+
 from allura.tests import TestController
 from allura.tests import decorators as td
 from alluratest.controller import setup_global_objects
+from allura import model as M
+from allura.lib import helpers as h
+
 
 from forgewiki.model import Page
 
@@ -59,3 +65,32 @@ class TestPageSnapshots(TestController):
         page = Page.query.get(title='test-page')
         # 10 changes by each thread + initial upsert
         assert page.history().count() == 21, page.history().count()
+
+
+class TestPage(TestController):
+
+    @td.with_wiki
+    def test_authors(self):
+        user = M.User.by_username('test-user')
+        admin = M.User.by_username('test-admin')
+        with h.push_config(c, user=admin):
+            page = Page.upsert('test-admin')
+            page.text = 'admin'
+            page.commit()
+
+        with h.push_config(c, user=user):
+            page.text = 'user'
+            page.commit()
+
+        authors = page.authors()
+        assert len(authors) == 2
+        assert user in authors
+        assert admin in authors
+
+        user.disabled = True
+        session(user).flush(user)
+
+        authors = page.authors()
+        assert len(authors) == 1
+        assert user not in authors
+        assert admin in authors


[40/45] allura git commit: [#7837] ticket:749 Handle "R" action for svn

Posted by he...@apache.org.
[#7837] ticket:749 Handle "R" action for svn


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

Branch: refs/heads/hss/7072
Commit: 6d9c49db472dadcc9f3a498adf2c143f2eaa5983
Parents: 02879be
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 16 10:50:48 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:42 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/6d9c49db/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 28bf132..f37c1e2 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -790,6 +790,8 @@ class SVNImplementation(M.RepositoryImplementation):
                 revision_end=rev,
                 discover_changed_paths=True)
         except pysvn.ClientError:
+            log.info('Error getting paged_diffs log of %s on %s',
+                     commit_id, self._url, exc_info=True)
             return result
         if len(log_info) == 0:
             return result
@@ -800,7 +802,12 @@ class SVNImplementation(M.RepositoryImplementation):
                 result['added'].append(h.really_unicode(p.path))
             elif p['action'] == 'D':
                 result['removed'].append(h.really_unicode(p.path))
-            elif p['action'] == 'M':
+            elif p['action'] in ['M', 'R']:
+                # 'R' means 'Replaced', i.e.
+                # svn rm aaa.txt
+                # echo "Completely new aaa!" > aaa.txt
+                # svn add aaa.txt
+                # svn commit -m "Replace aaa.txt"
                 result['changed'].append(h.really_unicode(p.path))
         return result
 


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

Posted by he...@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/2ae15ffb
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2ae15ffb
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2ae15ffb

Branch: refs/heads/hss/7072
Commit: 2ae15ffbfa7b68fdb843239293f7fc8a7b225a00
Parents: 9857cdb
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 08:03:40 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/2ae15ffb/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index b713cb0..ab0189e 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -606,7 +606,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)


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

Posted by he...@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/96ac7a67
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/96ac7a67
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/96ac7a67

Branch: refs/heads/hss/7072
Commit: 96ac7a67c201e99f0571f908d58a6312ca8d9571
Parents: 2ae15ff
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 10:06:55 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/96ac7a67/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index ab0189e..3b3b9e9 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -610,11 +610,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':


[04/45] allura git commit: [#7833] ticket:741 Strip email addresses in EmailAddress collection as well

Posted by he...@apache.org.
[#7833] ticket:741 Strip email addresses in EmailAddress collection as well


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

Branch: refs/heads/hss/7072
Commit: 97073958155edf5af5b245d4feb31f7fa35bccb4
Parents: 27f9c9f
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Fri Mar 13 19:09:37 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/scripts/trim_emails.py | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/97073958/Allura/allura/scripts/trim_emails.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/trim_emails.py b/Allura/allura/scripts/trim_emails.py
index 0ce4caa..f847224 100644
--- a/Allura/allura/scripts/trim_emails.py
+++ b/Allura/allura/scripts/trim_emails.py
@@ -17,6 +17,8 @@
 
 import logging
 
+from ming.orm import session
+
 from allura.scripts import ScriptTask
 from allura import model as M
 from allura.lib.utils import chunked_find
@@ -37,6 +39,14 @@ class TrimEmails(ScriptTask):
                 if u.preferences.email_address is not None:
                     u.preferences.email_address = M.EmailAddress.canonical(
                         u.preferences.email_address)
+                session(u).flush(u)
+        for chunk in chunked_find(M.EmailAddress, {}):
+            for a in chunk:
+                log.info('Trimming email address entry %s', a.email)
+                a.email = M.EmailAddress.canonical(a.email)
+                session(a).flush(a)
+        M.main_orm_session.flush()
+        M.main_orm_session.clear()
         log.info('Finished trimming emails')
 
 


[20/45] allura git commit: Allow a default url to be passed to gravatar macro (e.g. for a custom theme)

Posted by he...@apache.org.
Allow a default url to be passed to gravatar macro (e.g. for a custom theme)


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

Branch: refs/heads/hss/7072
Commit: b233388cd4f611abd2ef0a08c057566acba1dee3
Parents: cde1ffc
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Mar 23 22:01:35 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 23 22:01:35 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py                   | 7 +++++--
 Allura/allura/templates/jinja_master/lib.html | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b233388c/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index f7e8c91..98dc4ec 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -615,7 +615,7 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self)
 
     @memoize
-    def icon_url(self):
+    def icon_url(self, gravatar_default_url=None):
         icon_url = None
         try:
             private_project = self.private_project()
@@ -626,7 +626,10 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         if private_project and private_project.icon:
             icon_url = self.url() + 'user_icon'
         elif self.preferences.email_address:
-            icon_url = g.gravatar(self.preferences.email_address)
+            gravatar_args = {}
+            if gravatar_default_url:
+                gravatar_args['d'] = gravatar_default_url
+            icon_url = g.gravatar(self.preferences.email_address, **gravatar_args)
         return icon_url
 
     @classmethod

http://git-wip-us.apache.org/repos/asf/allura/blob/b233388c/Allura/allura/templates/jinja_master/lib.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index e4b1eb3..78ab9c0 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -52,10 +52,10 @@
   {% endif %}
 {%- endmacro %}
 
-{% macro gravatar(user, size, className) -%}
+{% macro gravatar(user, size, className, gravatar_default_url=None) -%}
   {% set display_name = h.really_unicode(user.display_name) %}
   {% if user.icon_url() %}
-    <img src="{{user.icon_url()}}"
+    <img src="{{user.icon_url(gravatar_default_url)}}"
          alt="{{display_name}}"
          title="{{display_name}}"
          class="emboss{% if size %} x{{size}}{% endif %}{% if className %} {{className}}{% endif %}">


[44/45] allura git commit: [#7837] guarantee a good stable order of diff lists

Posted by he...@apache.org.
[#7837] guarantee a good stable order of diff lists


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

Branch: refs/heads/hss/7072
Commit: 758b51bc8c25a1951745ae36d0104d185f560170
Parents: 710df69
Author: Dave Brondsema <da...@brondsema.net>
Authored: Mon Mar 30 16:36:37 2015 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Mon Mar 30 16:36:37 2015 -0400

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


http://git-wip-us.apache.org/repos/asf/allura/blob/758b51bc/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index edebeb4..362f725 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -1112,10 +1112,10 @@ class Commit(RepoObject, ActivityObject):
         copied = self._diffs_copied(diffs['added'], diffs['removed'])
         diffs['copied'].extend(copied)
         return Object(
-            added=diffs['added'],
-            removed=diffs['removed'],
-            changed=diffs['changed'],
-            copied=diffs['copied'],
+            added=sorted(diffs['added']),
+            removed=sorted(diffs['removed']),
+            changed=sorted(diffs['changed']),
+            copied=sorted(diffs['copied']),
             total=diffs['total'])
 
     def _diffs_copied(self, added, removed):


[15/45] allura git commit: [#7830] ticket:744 Use full_fs_path instead of clone_url for merge

Posted by he...@apache.org.
[#7830] ticket:744 Use full_fs_path instead of clone_url for merge


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

Branch: refs/heads/hss/7072
Commit: 88742194f5bc56370d1cfea28bf163a314e9cf68
Parents: 2b4f69f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Mar 6 10:08:34 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:30 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/88742194/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 831da5b..62e0604 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -103,7 +103,7 @@ class Repository(M.Repository):
         g = self._impl._git.git
         # http://stackoverflow.com/a/6283843
         # fetch source branch
-        g.fetch(mr.downstream_repo_url, mr.source_branch)
+        g.fetch(mr.downstream_repo.full_fs_path, mr.source_branch)
         # find merge base
         merge_base = g.merge_base(mr.downstream.commit_id, mr.target_branch)
         # print out merge result, but don't actually touch anything
@@ -116,13 +116,13 @@ class Repository(M.Repository):
         # can't merge in bare repo, so need to clone
         tmp_path = tempfile.mkdtemp()
         tmp_repo = git.Repo.clone_from(
-            self.clone_url('rw'),
+            self.full_fs_path,
             to_path=tmp_path,
             bare=False)
         tmp_repo = GitImplementation(Object(full_fs_path=tmp_path))._git
         tmp_repo.git.fetch('origin', mr.target_branch)
         tmp_repo.git.checkout(mr.target_branch)
-        tmp_repo.git.fetch(mr.downstream_repo_url, mr.source_branch)
+        tmp_repo.git.fetch(mr.downstream_repo.full_fs_path, mr.source_branch)
         tmp_repo.git.merge(mr.downstream.commit_id)
         tmp_repo.git.push('origin', mr.target_branch)
         shutil.rmtree(tmp_path, ignore_errors=True)

http://git-wip-us.apache.org/repos/asf/allura/blob/88742194/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 d79fc7b..325a6ea 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -593,7 +593,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         assert_equals(payload, expected_payload)
 
     def test_can_merge(self):
-        mr = mock.Mock(downstream_repo_url='downstream-url',
+        mr = mock.Mock(downstream_repo=Object(full_fs_path='downstream-url'),
                        source_branch='source-branch',
                        target_branch='target-branch',
                        downstream=mock.Mock(commit_id='cid'))
@@ -615,7 +615,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
     @mock.patch('forgegit.model.git_repo.GitImplementation', autospec=True)
     @mock.patch('forgegit.model.git_repo.shutil', autospec=True)
     def test_merge(self, shutil, GitImplementation, git, tempfile):
-        mr = mock.Mock(downstream_repo_url='downstream-url',
+        mr = mock.Mock(downstream_repo=Object(full_fs_path='downstream-url'),
                        source_branch='source-branch',
                        target_branch='target-branch',
                        downstream=mock.Mock(commit_id='cid'))
@@ -623,7 +623,7 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         self.repo._impl._git.git = _git
         self.repo.merge(mr)
         git.Repo.clone_from.assert_called_once_with(
-            self.repo.clone_url('rw'),
+            self.repo.full_fs_path,
             to_path=tempfile.mkdtemp.return_value,
             bare=False)
         tmp_repo = GitImplementation.return_value._git


[41/45] allura git commit: [#7837] ticket:750 Fix tests

Posted by he...@apache.org.
[#7837] ticket:750 Fix tests


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

Branch: refs/heads/hss/7072
Commit: 710df69e3276b3b0d9d7e084c7bdf30700d596c2
Parents: 44dda6b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 30 11:25:15 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:42 2015 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/tests/model/test_repository.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/710df69e/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 8fa8314..92ccaf5 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -405,12 +405,10 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
                 removed=['/a/b/c/hello.txt'], added=[], total=1))
 
     def test_diff_copy(self):
-        # Copies are currently only detected as 'add'
         entry = self.repo.commit(self.repo.log(5, id_only=True).next())
-        self.assertEqual(
-            entry.diffs, dict(
-                copied=[], changed=[],
-                removed=[], added=['/b'], total=1))
+        assert_equals(dict(entry.diffs), dict(
+                copied=[{'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1}],
+                changed=[], removed=[], added=[], total=1))
 
     def test_commit(self):
         entry = self.repo.commit(1)
@@ -609,10 +607,12 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
                 'committer': {'name': u'rick446',
                               'email': u'',
                               'username': u''},
-                'added': [u'/b'],
+                'added': [],
                 'removed': [],
                 'modified': [],
-                'copied': []
+                'copied': [
+                    {'new': u'/b', 'old': u'/a', 'diff': '', 'ratio': 1},
+                ],
             }],
             'repository': {
                 'name': u'SVN',


[38/45] allura git commit: [#7837] ticket:738 Fix some tests

Posted by he...@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/c6bb4ab7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/c6bb4ab7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/c6bb4ab7

Branch: refs/heads/hss/7072
Commit: c6bb4ab7ba30c948399392e7b693c5b2f3cdec02
Parents: 0b5bc0a
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 13:46:52 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/c6bb4ab7/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 2c86309..79005ac 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)


[12/45] allura git commit: [#7830] ticket:729 Add tests

Posted by he...@apache.org.
[#7830] ticket:729 Add tests


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

Branch: refs/heads/hss/7072
Commit: 02a3fca193c95e436f0b18023c6e8ab2d12bb6f8
Parents: b0a908c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 19 15:53:48 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:29 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_repo.py          | 38 ++++++++++++++++
 Allura/allura/tests/test_tasks.py               | 11 +++++
 .../forgegit/tests/model/test_repository.py     | 46 ++++++++++++++++++++
 3 files changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/02a3fca1/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..669f940 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -713,3 +713,41 @@ class TestModelCache(unittest.TestCase):
         session.assert_called_once_with(tree1)
         session.return_value.flush.assert_called_once_with(tree1)
         session.return_value.expunge.assert_called_once_with(tree1)
+
+
+class TestMergeRequest(object):
+
+    def setUp(self):
+        setup_basic_test()
+        setup_global_objects()
+        self.mr = M.MergeRequest(app_config=mock.Mock(_id=ObjectId()))
+        self.mr.app = mock.Mock(forkable=True)
+
+    def test_can_merge(self):
+        assert_equal(self.mr.can_merge(),
+                     self.mr.app.repo.can_merge.return_value)
+        self.mr.app.repo.can_merge.assert_called_once_with(self.mr)
+
+        self.mr.app.reset_mock()
+        self.mr.app.forkable = False
+        assert_equal(self.mr.can_merge(), False)
+        assert_equal(self.mr.app.repo.can_merge.called, False)
+
+    @mock.patch('allura.tasks.repo_tasks.merge', autospec=True)
+    def test_merge(self, merge_task):
+        self.mr.merge_task_status = lambda: None
+        self.mr.merge()
+        merge_task.post.assert_called_once_with(self.mr._id)
+
+        merge_task.reset_mock()
+        self.mr.merge_task_status = lambda: 'ready'
+        self.mr.merge()
+        assert_equal(merge_task.post.called, False)
+
+    def test_merge_task_status(self):
+        from allura.tasks import repo_tasks
+        assert_equal(self.mr.merge_task_status(), None)
+        repo_tasks.merge.post(self.mr._id)
+        assert_equal(self.mr.merge_task_status(), 'ready')
+        M.MonQTask.run_ready()
+        assert_equal(self.mr.merge_task_status(), 'complete')

http://git-wip-us.apache.org/repos/asf/allura/blob/02a3fca1/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index 13d5c17..d822229 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -64,6 +64,17 @@ class TestRepoTasks(unittest.TestCase):
         assert_equal(post_event.call_args[0][2], None)
         # ignore args[3] which is a traceback string
 
+    @mock.patch('allura.tasks.repo_tasks.session', autospec=True)
+    @mock.patch.object(M, 'MergeRequest', autospec=True)
+    def test_merge(self, MR, session):
+        mr = mock.Mock(_id='_id')
+        MR.query.get.return_value = mr
+        repo_tasks.merge(mr._id)
+        mr.app.repo.merge.assert_called_once_with(mr)
+        assert_equal(mr.status, 'merged')
+        session.assert_called_once_with(mr)
+        session.return_value.flush.assert_called_once_with(mr)
+
 
 class TestEventTasks(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/02a3fca1/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..d79fc7b 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -592,6 +592,52 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         }
         assert_equals(payload, expected_payload)
 
+    def test_can_merge(self):
+        mr = mock.Mock(downstream_repo_url='downstream-url',
+                       source_branch='source-branch',
+                       target_branch='target-branch',
+                       downstream=mock.Mock(commit_id='cid'))
+        git = mock.Mock()
+        git.merge_tree.return_value = 'clean merge'
+        self.repo._impl._git.git = git
+        assert_equal(self.repo.can_merge(mr), True)
+        git.fetch.assert_called_once_with('downstream-url', 'source-branch')
+        git.merge_base.assert_called_once_with('cid', 'target-branch')
+        git.merge_tree.assert_called_once_with(
+            git.merge_base.return_value,
+            'target-branch',
+            'cid')
+        git.merge_tree.return_value = '+<<<<<<<'
+        assert_equal(self.repo.can_merge(mr), False)
+
+    @mock.patch('forgegit.model.git_repo.tempfile', autospec=True)
+    @mock.patch('forgegit.model.git_repo.git', autospec=True)
+    @mock.patch('forgegit.model.git_repo.GitImplementation', autospec=True)
+    @mock.patch('forgegit.model.git_repo.shutil', autospec=True)
+    def test_merge(self, shutil, GitImplementation, git, tempfile):
+        mr = mock.Mock(downstream_repo_url='downstream-url',
+                       source_branch='source-branch',
+                       target_branch='target-branch',
+                       downstream=mock.Mock(commit_id='cid'))
+        _git = mock.Mock()
+        self.repo._impl._git.git = _git
+        self.repo.merge(mr)
+        git.Repo.clone_from.assert_called_once_with(
+            self.repo.clone_url('rw'),
+            to_path=tempfile.mkdtemp.return_value,
+            bare=False)
+        tmp_repo = GitImplementation.return_value._git
+        assert_equal(
+            tmp_repo.git.fetch.call_args_list,
+            [mock.call('origin', 'target-branch'),
+             mock.call('downstream-url', 'source-branch')])
+        tmp_repo.git.checkout.assert_called_once_with('target-branch')
+        tmp_repo.git.merge.assert_called_once_with('cid')
+        tmp_repo.git.push.assert_called_once_with('origin', 'target-branch')
+        shutil.rmtree.assert_called_once_with(
+            tempfile.mkdtemp.return_value,
+            ignore_errors=True)
+
 
 class TestGitImplementation(unittest.TestCase):
 


[16/45] allura git commit: [#7830] ticket:733 Temporary fix for the case when downstream repo has no new commits from upstream

Posted by he...@apache.org.
[#7830] ticket:733 Temporary fix for the case when downstream repo has no new commits from upstream

In the case of Mercurial, log raises Exception. It might happen after automerge
of merge request. Will be fixed more rigorously in [#7836].


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

Branch: refs/heads/hss/7072
Commit: 2b4f69ffe5503f100aa623a05de36e6377545900
Parents: 0efaa30
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 26 14:20:16 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:30 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2b4f69ff/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index d866598..867a6d2 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -775,10 +775,16 @@ class MergeRequest(VersionedArtifact, ActivityObject):
                 commit = rev._id
             else:
                 commit = self.app.repo.head
-            return list(c.app.repo.log(
-                self.downstream.commit_id,
-                exclude=commit,
-                id_only=False))
+            try:
+                return list(c.app.repo.log(
+                    self.downstream.commit_id,
+                    exclude=commit,
+                    id_only=False))
+            except Exception:
+                log.exception(
+                    "Can't get commits for merge request",
+                    self.url())
+                return []
 
     @classmethod
     def upsert(cls, **kw):


[36/45] allura git commit: [#7837] ticket:736 Add test for paged_diffs for git

Posted by he...@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/0a5c8fde
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0a5c8fde
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0a5c8fde

Branch: refs/heads/hss/7072
Commit: 0a5c8fde2815caa64d36e7ffae85aa0096295227
Parents: 96ac7a6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 3 11:32:05 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Mar 30 19:20:41 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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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/0a5c8fde/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 a9de6ba..84dd40d 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -647,6 +647,51 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             tempfile.mkdtemp.return_value,
             ignore_errors=True)
 
+    @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):
 


[06/45] allura git commit: [#7833] ticket:741 Added .strip() to EmailAddress.canonical

Posted by he...@apache.org.
[#7833] ticket:741 Added .strip() to EmailAddress.canonical


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

Branch: refs/heads/hss/7072
Commit: c2673b61721ea0b0d042a2a5dad802ca0f884249
Parents: 269703c
Author: Aleksey 'LXj' Alekseyev <go...@gmail.com>
Authored: Tue Mar 10 20:55:06 2015 +0200
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Thu Mar 19 18:37:45 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            | 2 +-
 Allura/allura/tests/model/test_auth.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/c2673b61/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 0b92443..f7e8c91 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -169,7 +169,7 @@ class EmailAddress(MappedClass):
         if mo:
             addr = mo.group(1)
         if '@' in addr:
-            user, domain = addr.split('@')
+            user, domain = addr.strip().split('@')
             return '%s@%s' % (user, domain.lower())
         else:
             return None

http://git-wip-us.apache.org/repos/asf/allura/blob/c2673b61/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 12db982..eb7416c 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -103,6 +103,8 @@ def test_email_address_canonical():
                  'nobody@example.com')
     assert_equal(M.EmailAddress.canonical('I Am Nobody <no...@example.com>'),
                  'nobody@example.com')
+    assert_equal(M.EmailAddress.canonical('  nobody@example.com\t'),
+                 'nobody@example.com')
     assert_equal(M.EmailAddress.canonical('invalid'), None)
 
 @with_setup(setUp)


[19/45] allura git commit: [#7843] ticket:743 Handle quotes in filenames on commit view

Posted by he...@apache.org.
[#7843] ticket:743 Handle quotes in filenames on commit view


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

Branch: refs/heads/hss/7072
Commit: cde1ffce8314d7b3cc78a685b21acb663ae86c16
Parents: 53b5577
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 18 16:36:29 2015 +0000
Committer: Heith Seewald <hs...@slashdotmedia.com>
Committed: Mon Mar 23 17:10:32 2015 -0400

----------------------------------------------------------------------
 Allura/allura/templates/repo/commit.html | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/cde1ffce/Allura/allura/templates/repo/commit.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/commit.html b/Allura/allura/templates/repo/commit.html
index dd0dafe..9c6342f 100644
--- a/Allura/allura/templates/repo/commit.html
+++ b/Allura/allura/templates/repo/commit.html
@@ -132,15 +132,15 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
         <div class="inline-diff">
             <h6>
             {% if type in ('added', 'changed') %}
-                <a href="{{commit.url()}}tree/{{h.really_unicode(file)}}">{{h.really_unicode(file)}}</a>
-                <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.really_unicode(file)}}?diff={{prev[0]._id if prev else ''}}">Diff</a>
-                <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.really_unicode(file)}}?barediff={{prev[0]._id if prev else ''}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
+                <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
+                <a class="commit-diff-link" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?diff={{prev[0]._id if prev else ''}}">Diff</a>
+                <a class="commit-diff-link switch-diff-format-link" data-diformat="{{session.diformat}}" data-diffid="diff-{{loop.index}}" href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}">Switch to {{'unified' if session.diformat == 'sidebyside' else 'side-by-side'}} view</a>
             {% elif type == 'removed' %}
-                <a href="{{prev[0].url()}}tree/{{h.really_unicode(file)}}">{{h.really_unicode(file)}}</a>
+                <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file))}}">{{h.really_unicode(file)}}</a>
             {% elif type == 'copied' %}
-                <a href="{{prev[0].url()}}tree/{{h.really_unicode(file.old)}}">{{h.really_unicode(file.old)}}</a>
+                <a href="{{prev[0].url()}}tree/{{h.urlquote(h.really_unicode(file.old))}}">{{h.really_unicode(file.old)}}</a>
                 to
-                <a href="{{commit.url()}}tree/{{h.really_unicode(file.new)}}">{{h.really_unicode(file.new)}}</a>
+                <a href="{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file.new))}}">{{h.really_unicode(file.new)}}</a>
             {% endif %}
             </h6>
             <div id="diff-{{loop.index}}" class="inline-diff-body">
@@ -157,7 +157,7 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
                     <script type="text/javascript">
                       diff_queue.push({
                         selector: '#diff-{{loop.index}}',
-                        url: '{{commit.url()}}tree/{{h.really_unicode(file)}}?barediff={{prev[0]._id if prev else ''}}'
+                        url: '{{commit.url()}}tree/{{h.urlquote(h.really_unicode(file))}}?barediff={{prev[0]._id if prev else ''}}'
                       });
                     </script>
                 {% endif %}


[17/45] allura git commit: [#7830] ticket:744 Change author and message for merge commit

Posted by he...@apache.org.
[#7830] ticket:744 Change author and message for merge commit


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

Branch: refs/heads/hss/7072
Commit: e146bbe899ffa1673ec540a7cd7a16a97a68457e
Parents: 8874219
Author: Igor Bondarenko <je...@gmail.com>
Authored: Fri Mar 6 11:24:08 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:30 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py              | 10 +++++++++-
 ForgeGit/forgegit/tests/model/test_repository.py | 13 +++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e146bbe8/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 62e0604..8841f52 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -123,7 +123,15 @@ class Repository(M.Repository):
         tmp_repo.git.fetch('origin', mr.target_branch)
         tmp_repo.git.checkout(mr.target_branch)
         tmp_repo.git.fetch(mr.downstream_repo.full_fs_path, mr.source_branch)
-        tmp_repo.git.merge(mr.downstream.commit_id)
+        author = h.really_unicode(c.user.display_name or c.user.username)
+        tmp_repo.git.config('user.name', author)
+        tmp_repo.git.config('user.email', '')
+        msg = u'Merge {} branch {} into {}\n\n{}'.format(
+            mr.downstream_repo.url(),
+            mr.source_branch,
+            mr.target_branch,
+            h.absurl(mr.url()))
+        tmp_repo.git.merge(mr.downstream.commit_id, '-m', msg)
         tmp_repo.git.push('origin', mr.target_branch)
         shutil.rmtree(tmp_path, ignore_errors=True)
 

http://git-wip-us.apache.org/repos/asf/allura/blob/e146bbe8/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 325a6ea..a9de6ba 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -615,9 +615,12 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
     @mock.patch('forgegit.model.git_repo.GitImplementation', autospec=True)
     @mock.patch('forgegit.model.git_repo.shutil', autospec=True)
     def test_merge(self, shutil, GitImplementation, git, tempfile):
-        mr = mock.Mock(downstream_repo=Object(full_fs_path='downstream-url'),
+        mr = mock.Mock(downstream_repo=mock.Mock(
+                           full_fs_path='downstream-url',
+                           url=lambda: 'downstream-repo-url'),
                        source_branch='source-branch',
                        target_branch='target-branch',
+                       url=lambda: '/merge-request/1/',
                        downstream=mock.Mock(commit_id='cid'))
         _git = mock.Mock()
         self.repo._impl._git.git = _git
@@ -632,7 +635,13 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             [mock.call('origin', 'target-branch'),
              mock.call('downstream-url', 'source-branch')])
         tmp_repo.git.checkout.assert_called_once_with('target-branch')
-        tmp_repo.git.merge.assert_called_once_with('cid')
+        assert_equal(
+            tmp_repo.git.config.call_args_list,
+            [mock.call('user.name', 'Test Admin'),
+             mock.call('user.email', '')])
+        msg = u'Merge downstream-repo-url branch source-branch into target-branch'
+        msg += u'\n\nhttp://localhost/merge-request/1/'
+        tmp_repo.git.merge.assert_called_once_with('cid', '-m', msg)
         tmp_repo.git.push.assert_called_once_with('origin', 'target-branch')
         shutil.rmtree.assert_called_once_with(
             tempfile.mkdtemp.return_value,


[13/45] allura git commit: [#7830] ticket:729 Move actual merge to background task

Posted by he...@apache.org.
[#7830] ticket:729 Move actual merge to background task


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

Branch: refs/heads/hss/7072
Commit: b0a908cd291dd99068edd550897fc11cf6ce40ff
Parents: 121ebed
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Feb 19 12:14:52 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Fri Mar 20 20:40:29 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 11 +--
 Allura/allura/model/repository.py               | 27 ++++---
 Allura/allura/tasks/repo_tasks.py               | 15 ++++
 Allura/allura/templates/repo/merge_request.html | 82 +++++++++++++++++---
 4 files changed, 107 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/b0a908cd/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 78bff44..8d8cfff 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -366,6 +366,7 @@ class MergeRequestController(object):
         return dict(
             downstream_app=downstream_app,
             req=self.req,
+            status=self.req.merge_task_status(),
             page=page,
             limit=limit,
             count=self.req.discussion_thread.post_count)
@@ -447,13 +448,13 @@ class MergeRequestController(object):
         require_access(c.app, 'write')
         if self.req.status != 'open' or not self.req.can_merge():
             raise exc.HTTPNotFound
-        ok = self.req.merge()
-        if ok:
-            flash('Merged successfully', 'ok')
-        else:
-            flash('Merge failed. Please, merge manually', 'error')
+        self.req.merge()
         redirect(self.req.url())
 
+    @expose('json:')
+    def merge_task_status(self):
+        return {'status': self.req.merge_task_status()}
+
 
 class RefsController(object):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/b0a908cd/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 5e4a171..d866598 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -23,7 +23,7 @@ import string
 import re
 from subprocess import Popen, PIPE
 from hashlib import sha1
-from datetime import datetime
+from datetime import datetime, timedelta
 from time import time
 from collections import defaultdict, OrderedDict
 from urlparse import urljoin
@@ -818,16 +818,21 @@ class MergeRequest(VersionedArtifact, ActivityObject):
         return result
 
     def merge(self):
-        if not self.app.forkable:
-            return False
-        try:
-            self.app.repo.merge(self)
-        except:
-            log.exception("Can't merge merge request %s", self.url())
-            return False
-        self.status = 'merged'
-        session(self).flush(self)
-        return True
+        in_progress = self.merge_task_status() in ['ready', 'busy']
+        if self.app.forkable and not in_progress:
+            from allura.tasks import repo_tasks
+            repo_tasks.merge.post(self._id)
+
+    def merge_task_status(self):
+        task = MonQTask.query.find({
+            'state': {'$in': ['busy', 'complete', 'error', 'ready']},  # needed to use index
+            'task_name': 'allura.tasks.repo_tasks.merge',
+            'args': [self._id],
+            'time_queue': {'$gt': datetime.utcnow() - timedelta(days=1)}, # constrain on index further
+        }).sort('_id', -1).limit(1).first()
+        if task:
+            return task.state
+        return None
 
 
 # Basic commit information

http://git-wip-us.apache.org/repos/asf/allura/blob/b0a908cd/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index 61cac83..e50f9d2 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -20,6 +20,7 @@ import logging
 import traceback
 
 from pylons import tmpl_context as c, app_globals as g
+from ming.odm import session
 
 from allura.lib.decorators import task
 from allura.lib.repository import RepositoryApp
@@ -152,3 +153,17 @@ def tarball(revision, path):
         log.warn(
             'Skipped creation of snapshot: %s:%s because revision is not specified' %
             (c.project.shortname, c.app.config.options.mount_point))
+
+
+@task
+def merge(merge_request_id):
+    from allura import model as M
+    log = logging.getLogger(__name__)
+    mr = M.MergeRequest.query.get(_id=merge_request_id)
+    try:
+        mr.app.repo.merge(mr)
+    except:
+        log.exception("Can't merge merge request %s", mr.url())
+        return
+    mr.status = 'merged'
+    session(mr).flush(mr)

http://git-wip-us.apache.org/repos/asf/allura/blob/b0a908cd/Allura/allura/templates/repo/merge_request.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request.html b/Allura/allura/templates/repo/merge_request.html
index 060b5b9..1520270 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -33,6 +33,19 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 {% endblock %}
 
 {% block content %}
+  <div class="grid-19">
+    <div id="task_status">
+      {% if status == 'complete' %}
+        <h2 class="complete">Merged</h2>
+      {% else %}
+        <img src="{{g.forge_static('images/spinner.gif')}}" class="spinner" style="display:none"/>
+        <h2 class="busy ready">Merging...</h2>
+        <h2 class="complete">Merged</h2>
+        <h2 class="fail">Something went wrong. Please, merge manually</h2>
+      {% endif %}
+    </div>
+  </div>
+
   {% if req.downstream_repo %}
     <p>
       <a href="{{req.creator_url}}">{{req.creator_name}}</a>
@@ -49,7 +62,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
       <div class="grid-19">
         <form action="merge" method="POST">
           {{ lib.csrf_token() }}
-          <input type="submit" value="Merge"{% if not can_merge %}disabled="disabled"{% endif %}>
+          <input type="submit" value="Merge"{% if not can_merge or status in ('ready', 'busy') %}disabled="disabled"{% endif %}>
           {% if can_merge %}
             <div class="merge-ok">
               Merge request has no conflicts. You can merge automatically.
@@ -68,14 +81,16 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
     <div class="grid-19"><a href="#discussion_holder">Discuss</a></div>
 
     {% if h.has_access(c.app, 'write')() %}
-       <div class="grid-19">To merge the commits, please execute the following commands in your working
-         copy: </div>
-       <div class="grid-19"><textarea
-          style="width:80%; height:60px;"
-          readonly
-          >{{ c.app.repo.merge_command(req) | safe }}</textarea></div>
-      {{ c.mr_dispose_form.display(action="save", value=dict(status=req.status)) }}
-       <br style="clear:both">
+      <div class="grid-19">
+        To merge the commits, please execute the following commands in your working copy:
+      </div>
+      <div class="grid-19">
+        <textarea style="width:80%; height:60px;" readonly>{{ c.app.repo.merge_command(req) | safe }}</textarea>
+      </div>
+      {% if status not in ('ready', 'busy') %}
+        {{ c.mr_dispose_form.display(action="save", value=dict(status=req.status)) }}
+        <br style="clear:both">
+      {% endif %}
     {% endif %}
   {% else %}
     <p>
@@ -83,12 +98,10 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
       <a href="{{req.creator_url}}">{{req.creator_name}}</a>
       is deleted
     </p>
-
     <div>{{g.markdown.convert(req.description)}}</div>
-
     {% if h.has_access(c.app, 'write')() %}
       {{ c.mr_dispose_form.display(action="save", value=dict(status=req.status)) }}
-       <br style="clear:both">
+      <br style="clear:both">
     {% endif %}
   {% endif %}
 
@@ -111,5 +124,50 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 <style type="text/css">
   .merge-ok { color: green; }
   .merge-conflicts { color: red; }
+
+  #task_status { margin: 0 10px; }
+  #task_status h2 { display: none; }
+  #task_status .{{ status }} { display: inline-block; }
+  #task_status h2.complete { color: #C6D880; }
+  #task_status h2.busy, #task_status h2.busy { color: #003565; }
+  #task_status h2.fail { color: #f33; }
 </style>
 {% endblock %}
+
+{% block extra_js %}
+{{ super() }}
+<script type="text/javascript">
+$(function() {
+    {% if status in ('ready', 'busy') %}
+        $('.spinner').show();
+        var delay = 500;
+        function check_status() {
+          $.get("{{request.path.rstrip('/') + '/merge_task_status'}}", function(data) {
+                if (data.status === 'complete') {
+                    $('.spinner').hide();
+                    $('#task_status h2').hide();
+                    $('#task_status h2.complete').show();
+                    location.reload();
+                } else {
+                    if (data.status === 'ready' || data.status === 'busy') {
+                        // keep waiting
+                        $('#task_status h2').hide();
+                        $('#task_status h2.busy').show();
+                    } else {
+                        // something went wrong
+                        $('.spinner').hide();
+                        $('#task_status h2').hide();
+                        $('#task_status h2.fail').show();
+                    }
+                    if (delay < 60000){
+                        delay = delay * 2;
+                    }
+                    window.setTimeout(check_status, delay);
+                }
+            });
+        }
+        window.setTimeout(check_status, delay);
+    {% endif %}
+});
+</script>
+{% endblock %}