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

[01/16] allura git commit: [#7876] ticket:766 Add css for list display mode of projects macro

Repository: allura
Updated Branches:
  refs/heads/ib/1731 4cb21fe51 -> 4788e07ba (forced update)


[#7876] ticket:766 Add css for list display mode of projects macro


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

Branch: refs/heads/ib/1731
Commit: 42d3a612cafb0352e9a9e48dbafe2c1cb07fa251
Parents: 181bfb6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu May 14 09:52:47 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon May 18 19:58:26 2015 +0000

----------------------------------------------------------------------
 Allura/allura/nf/allura/css/site_style.css | 43 +++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/42d3a612/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index 01f6c8e..df0b932 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2484,6 +2484,49 @@ div.attachment_thumb .file_type span {
   margin: 0 0 0 -7px;
   padding: 0;
 }
+.list.card {
+  width: 740px;
+  display: inline;
+  float: left;
+  overflow: hidden;
+  *zoom: 1;
+  margin: 0 10px;
+  border-radius: 0 0 0 0;
+  border-width: 0px;
+  background: none 0 0 #fff;
+  border-bottom: 1px solid #ccc;
+  box-shadow: none;
+  height: 60px;
+  padding: 5px;
+}
+.list.card h2 {
+  font-size: 1em;
+  position: absolute;
+  top: 5px;
+  line-height: 0;
+  width: 460px;
+}
+.list.card.proj_icon h2 { left: 55px; }
+.list.card.proj_icon p.desc { left: 56px; }
+.list.card p.desc {
+  font-size: 0.85em;
+  height: 1.15em !important;
+  position: absolute;
+  top: 30px;
+  width: 460px;
+}
+.list.card .sfdl {
+  position: absolute;
+  right: 20px;
+  top: 14px;
+}
+.list.card .feature {
+  padding: 2em 3.6em .4em 2.7em;
+}
+.list.card .box.notch {
+  background-image: -webkit-gradient(linear, 67% 435%, 100% 0%, color-stop(0.9, rgb(255,255,255)), color-stop(0.9, #555));
+  background-image: -moz-linear-gradient(100% 25% 230deg,#555, rgb(255,255,255), rgb(255,255,255) 1%);
+}
 
 /* Discussion */
 #comment .row {


[15/16] allura git commit: [#1731] ticket:775 Don't show deleted post/attachments in thread view

Posted by je...@apache.org.
[#1731] ticket:775 Don't show deleted post/attachments in thread view


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

Branch: refs/heads/ib/1731
Commit: 863ca87a2cb336c795da3aa76bece248acbba3c7
Parents: 7b57bb6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 25 15:08:54 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 15:08:54 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/attachments.py       |  2 ++
 Allura/allura/controllers/discuss.py           |  2 ++
 Allura/allura/tests/functional/test_discuss.py | 38 ++++++++++++++++++---
 3 files changed, 38 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/Allura/allura/controllers/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/attachments.py b/Allura/allura/controllers/attachments.py
index a648873..c97a9d1 100644
--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -88,6 +88,8 @@ class AttachmentController(BaseController):
         if request.method == 'POST':
             self.handle_post(delete, **kw)
             redirect(request.referer)
+        if self.artifact.deleted:
+            raise exc.HTTPNotFound
         embed = False
         if self.attachment.content_type and self.attachment.content_type.startswith('image/'):
             embed = True

http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index c7fe163..1fd24a0 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -307,6 +307,8 @@ class PostController(BaseController):
                                        tags=['comment'])
             redirect(request.referer)
         elif request.method == 'GET':
+            if self.post.deleted:
+                raise exc.HTTPNotFound
             if version is not None:
                 HC = self.post.__mongometa__.history_class
                 ss = HC.query.find(

http://git-wip-us.apache.org/repos/asf/allura/blob/863ca87a/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index cd30f44..0471b48 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -18,6 +18,8 @@
 from mock import patch
 from nose.tools import assert_in, assert_not_in, assert_equal
 
+from ming.odm import session
+
 from allura.tests import TestController
 from allura import model as M
 
@@ -227,6 +229,18 @@ class TestDiscuss(TestController):
         assert 'Last edit: Test Admin less than 1 minute ago' in str(
             r.html.find('div', {'class': 'display_post'}))
 
+    def test_deleted_post(self):
+        r = self._make_post('This is a post')
+        reply_form = r.html.find(
+            'div', {'class': 'edit_post_form reply'}).find('form')
+        post_link = str(reply_form['action']).rstrip('/reply')
+        _, slug = post_link.rsplit('/', 1)
+        r = self.app.get(post_link, status=200)
+        post = M.Post.query.get(slug=slug)
+        post.deleted = True
+        session(post).flush(post)
+        r = self.app.get(post_link, status=404)
+
 
 class TestAttachment(TestController):
 
@@ -254,17 +268,21 @@ class TestAttachment(TestController):
         self.post_link = str(
             r.html.find('div', {'class': 'edit_post_form reply'}).find('form')['action'])
 
-    def test_attach(self):
-        r = self.app.post(self.post_link + 'attach',
-                          upload_files=[('file_info', 'test.txt', 'HiThere!')])
+    def attach_link(self):
         r = self.app.get(self.thread_link)
         for alink in r.html.findAll('a'):
             if 'attachment' in alink['href']:
                 alink = str(alink['href'])
-                break
+                return alink
         else:
             assert False, 'attachment link not found'
+
+    def test_attach(self):
+        r = self.app.post(self.post_link + 'attach',
+                          upload_files=[('file_info', 'test.txt', 'HiThere!')])
+        r = self.app.get(self.thread_link)
         assert '<div class="attachment_thumb">' in r
+        alink = self.attach_link()
         r = self.app.get(alink)
         assert r.content_disposition == 'attachment;filename="test.txt"', 'Attachments should force download'
         r = self.app.post(self.post_link + 'attach',
@@ -289,3 +307,15 @@ class TestAttachment(TestController):
                           upload_files=[('file_info', 'test.txt', 'HiThere!')])
         r = self.app.get(self.thread_link)
         assert "test.txt" in r
+
+    def test_deleted_post_attachment(self):
+        self.app.post(
+            self.post_link + 'attach',
+            upload_files=[('file_info', 'test.txt', 'HiThere!')])
+        alink = self.attach_link()
+        r = self.app.get(alink, status=200)
+        _, slug = self.post_link.rstrip('/reply').rsplit('/', 1)
+        post = M.Post.query.get(slug=slug)
+        post.deleted = True
+        session(post).flush(post)
+        r = self.app.get(alink, status=404)


[11/16] allura git commit: [#1731] ticket:767 Mark comments as deleted instead of actually deleting them

Posted by je...@apache.org.
[#1731] ticket:767 Mark comments as deleted instead of actually deleting them


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

Branch: refs/heads/ib/1731
Commit: 89b65ffb35f24aff0366ec2fc0ecdc1531501930
Parents: 1accce5
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 18 14:43:38 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 13:31:52 2015 +0000

----------------------------------------------------------------------
 Allura/allura/lib/markdown_extensions.py        |  3 ++-
 Allura/allura/model/discuss.py                  | 26 +++++++++++---------
 .../forgediscussion/controllers/root.py         |  1 +
 ForgeDiscussion/forgediscussion/forum_main.py   |  7 +++++-
 ForgeDiscussion/forgediscussion/site_stats.py   |  4 ++-
 ForgeImporters/forgeimporters/trac/tickets.py   |  3 ++-
 ForgeTracker/forgetracker/tracker_main.py       |  8 ++++--
 ForgeWiki/forgewiki/wiki_main.py                |  7 ++++--
 8 files changed, 40 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 055a74a..9a68e1a 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -178,7 +178,8 @@ class TracRef2(Pattern):
         comments = ticket.discussion_thread.post_class().query.find(dict(
             discussion_id=ticket.discussion_thread.discussion_id,
             thread_id=ticket.discussion_thread._id,
-            status={'$in': ['ok', 'pending']})).sort('timestamp')
+            status={'$in': ['ok', 'pending']},
+            deleted=False)).sort('timestamp')
 
         if comment_num <= comments.count():
             return comments.all()[comment_num - 1].slug

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 581eb21..aa16255 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -92,16 +92,15 @@ class Discussion(Artifact, ActivityObject):
         self.num_topics = self.thread_class().query.find(
             dict(discussion_id=self._id)).count()
         self.num_posts = self.post_class().query.find(
-            dict(discussion_id=self._id, status='ok')).count()
+            dict(discussion_id=self._id, status='ok', deleted=False)).count()
 
     @LazyProperty
     def last_post(self):
         q = self.post_class().query.find(dict(
             discussion_id=self._id,
-            status='ok'
-        ))\
-            .sort('timestamp', pymongo.DESCENDING)\
-            .limit(1)
+            status='ok',
+            deleted=False,
+        )).sort('timestamp', pymongo.DESCENDING).limit(1)
         return q.first()
 
     def url(self):
@@ -129,7 +128,7 @@ class Discussion(Artifact, ActivityObject):
         super(Discussion, self).delete()
 
     def find_posts(self, **kw):
-        q = dict(kw, discussion_id=self._id)
+        q = dict(kw, discussion_id=self._id, deleted=False)
         return self.post_class().query.find(q)
 
 
@@ -238,7 +237,9 @@ class Thread(Artifact, ActivityObject):
         return Post.query.find(dict(
             discussion_id=self.discussion_id,
             thread_id=self._id,
-            status={'$in': ['ok', 'pending']})).count()
+            status={'$in': ['ok', 'pending']},
+            deleted=False,
+        )).count()
 
     def primary(self):
         if self.ref is None:
@@ -340,12 +341,14 @@ class Thread(Artifact, ActivityObject):
 
     def update_stats(self):
         self.num_replies = self.post_class().query.find(
-            dict(thread_id=self._id, status='ok')).count() - 1
+            dict(thread_id=self._id, status='ok', deleted=False)).count() - 1
 
     @property
     def last_post(self):
         q = self.post_class().query.find(dict(
-            thread_id=self._id)).sort('timestamp', pymongo.DESCENDING)
+            thread_id=self._id,
+            deleted=False,
+        )).sort('timestamp', pymongo.DESCENDING)
         return q.first()
 
     def create_post_threads(self, posts):
@@ -370,6 +373,7 @@ class Thread(Artifact, ActivityObject):
                          status={'$in': ['ok', 'pending']})
         if status:
             terms['status'] = status
+        terms['deleted'] = False
         q = self.post_class().query.find(terms)
         if style == 'threaded':
             q = q.sort('full_slug')
@@ -675,8 +679,8 @@ class Post(Message, VersionedArtifact, ActivityObject):
             return 'Re: ' + (self.subject or '(no subject)')
 
     def delete(self):
-        self.attachment_class().remove(dict(post_id=self._id))
-        super(Post, self).delete()
+        self.deleted = True
+        session(self).flush(self)
         self.thread.num_replies = max(0, self.thread.num_replies - 1)
 
     def approve(self, file_info=None, notify=True, notification_text=None):

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 7548cd0..9f6ab76 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -264,6 +264,7 @@ class RootController(BaseController, DispatchIndex, FeedController):
                     '$gte': datetime.combine(begin, time.min),
                     '$lte': datetime.combine(end, time.max),
                 },
+                'deleted': False,
             }},
             {'$group': {
                 '_id': grouping,

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeDiscussion/forgediscussion/forum_main.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index e66ec43..542b3f0 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -158,9 +158,14 @@ class ForgeDiscussionApp(Application):
             for f in forums:
                 if has_access(f, 'read')():
                     if f.url() in request.url and h.has_access(f, 'moderate')():
+                        num_moderate = DM.ForumPost.query.find({
+                            'discussion_id': f._id,
+                            'status': {'$ne': 'ok'},
+                            'deleted': False,
+                        }).count()
                         moderate_link = SitemapEntry(
                             'Moderate', "%smoderate/" % f.url(), ui_icon=g.icons['pencil'],
-                            small=DM.ForumPost.query.find({'discussion_id': f._id, 'status': {'$ne': 'ok'}}).count())
+                            small=num_moderate)
                     forum_links.append(
                         SitemapEntry(f.name, f.url(), small=f.num_topics))
             url = c.app.url + 'create_topic/'

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeDiscussion/forgediscussion/site_stats.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/site_stats.py b/ForgeDiscussion/forgediscussion/site_stats.py
index 6918137..cabb5dd 100644
--- a/ForgeDiscussion/forgediscussion/site_stats.py
+++ b/ForgeDiscussion/forgediscussion/site_stats.py
@@ -22,4 +22,6 @@ from . import model as DM
 
 def posts_24hr():
     window = datetime.utcnow() - timedelta(hours=24)
-    return DM.ForumPost.query.find({'timestamp': {'$gte': window}}).count()
+    q = {'timestamp': {'$gte': window},
+         'deleted': False}
+    return DM.ForumPost.query.find(q).count()

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeImporters/forgeimporters/trac/tickets.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/forgeimporters/trac/tickets.py b/ForgeImporters/forgeimporters/trac/tickets.py
index 177652b..466b4f7 100644
--- a/ForgeImporters/forgeimporters/trac/tickets.py
+++ b/ForgeImporters/forgeimporters/trac/tickets.py
@@ -169,7 +169,8 @@ class TracImportSupport(ImportSupport):
         comments = ticket.discussion_thread.post_class().query.find(dict(
             discussion_id=ticket.discussion_thread.discussion_id,
             thread_id=ticket.discussion_thread._id,
-            status={'$in': ['ok', 'pending']})).sort('timestamp')
+            status={'$in': ['ok', 'pending']},
+            deleted=False)).sort('timestamp')
 
         if comment <= comments.count():
             return comments.all()[comment - 1].slug

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 52e7b28..596ec54 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -354,8 +354,11 @@ class ForgeTrackerApp(Application):
         links.append(SitemapEntry('View Stats', self.config.url()
                      + 'stats', ui_icon=g.icons['stats']))
         discussion = c.app.config.discussion
-        pending_mod_count = M.Post.query.find(
-            {'discussion_id': discussion._id, 'status': 'pending'}).count()
+        pending_mod_count = M.Post.query.find({
+            'discussion_id': discussion._id,
+            'status': 'pending',
+            'deleted': False,
+        }).count()
         if pending_mod_count and has_access(discussion, 'moderate')():
             links.append(
                 SitemapEntry(
@@ -1022,6 +1025,7 @@ class RootController(BaseController, FeedController):
         q = dict(
             discussion_id=c.app.config.discussion_id,
             status='ok',
+            deleted=False,
         )
         if when is not None:
             q['timestamp'] = {'$gte': when}

http://git-wip-us.apache.org/repos/asf/allura/blob/89b65ffb/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 5f15779..a87ce8d 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -231,8 +231,11 @@ The wiki uses [Markdown](%s) syntax.
         links += [SitemapEntry('Browse Pages', self.url + 'browse_pages/'),
                   SitemapEntry('Browse Labels', self.url + 'browse_tags/')]
         discussion = c.app.config.discussion
-        pending_mod_count = M.Post.query.find(
-            {'discussion_id': discussion._id, 'status': 'pending'}).count() if discussion else 0
+        pending_mod_count = M.Post.query.find({
+            'discussion_id': discussion._id,
+            'status': 'pending',
+            'deleted': False
+        }).count() if discussion else 0
         if pending_mod_count and h.has_access(discussion, 'moderate')():
             links.append(
                 SitemapEntry(


[03/16] allura git commit: [#7836] ticket:739 Show error to a user if can't find merge base

Posted by je...@apache.org.
[#7836] ticket:739 Show error to a user if can't find merge base


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

Branch: refs/heads/ib/1731
Commit: 1fda8a764cbb22872a750ec02bba6fe9be2e0fd2
Parents: e48f236
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 5 14:11:05 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:16 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  8 +++++++-
 Allura/allura/templates/repo/merge_request.html | 12 ++++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1fda8a76/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index b630e77..d94b253 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -368,7 +368,7 @@ class MergeRequestController(object):
         c.mr_dispose_form = self.mr_dispose_form
         with self.req.push_downstream_context():
             downstream_app = c.app
-        return dict(
+        result = dict(
             downstream_app=downstream_app,
             req=self.req,
             can_merge=self.req.can_merge(),
@@ -377,6 +377,12 @@ class MergeRequestController(object):
             page=page,
             limit=limit,
             count=self.req.discussion_thread.post_count)
+        try:
+            result['commits'] = self.req.commits
+        except:
+            result['commits'] = []
+            result['error'] = True
+        return result
 
     @property
     def mr_widget_edit(self):

http://git-wip-us.apache.org/repos/asf/allura/blob/1fda8a76/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 f87a894..3f5e894 100644
--- a/Allura/allura/templates/repo/merge_request.html
+++ b/Allura/allura/templates/repo/merge_request.html
@@ -56,7 +56,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
   {% if req.downstream_repo %}
     <p>
       <a href="{{req.creator_url}}">{{req.creator_name}}</a>
-      asked you to merge {{h.text.plural(req.commits|count, 'commit', 'commits')}}
+      asked you to merge {{h.text.plural(commits|count, 'commit', 'commits')}}
       from <a href="{{req.downstream_url}}">{{req.downstream_url}}</a>
       to {{ req.target_branch }},
       {{lib.abbr_date(req.mod_date)}}
@@ -64,6 +64,14 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
 
     <div>{{g.markdown.convert(req.description)}}</div>
 
+    {% if error %}
+      <div class='grid-19 error'>
+        Can't find commits to merge. Please checkout
+        <a href="{{req.downstream_url}}">{{req.downstream_url}}</a>
+        and follow the instructions to merge manually.
+      </div>
+    {% endif %}
+
     {% if req.merge_allowed(c.user) %}
       <div class="grid-19">
         <form action="merge" method="POST">
@@ -82,7 +90,7 @@ Merge Request #{{req.request_number}}: {{req.summary}} ({{req.status}})
       </div>
     {% endif %}
 
-    {{ c.log_widget.display(value=req.commits, app=downstream_app) }}
+    {{ c.log_widget.display(value=commits, app=downstream_app) }}
 
     <div class="grid-19"><a href="#discussion_holder">Discuss</a></div>
 


[06/16] allura git commit: [#7836] ticket:739 Log exception

Posted by je...@apache.org.
[#7836] ticket:739 Log exception


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

Branch: refs/heads/ib/1731
Commit: f0bede1f8dea49b7b69f10b5f8838223934cb436
Parents: 0e36507
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Apr 6 14:37:48 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:16 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f0bede1f/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index d94b253..8fd2047 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -379,7 +379,11 @@ class MergeRequestController(object):
             count=self.req.discussion_thread.post_count)
         try:
             result['commits'] = self.req.commits
-        except:
+        except Exception:
+            log.info(
+                "Can't get commits for merge request %s",
+                self.req.url(),
+                exc_info=True)
             result['commits'] = []
             result['error'] = True
         return result


[07/16] allura git commit: [#7836] ticket:739 Add/fix tests

Posted by je...@apache.org.
[#7836] ticket:739 Add/fix tests


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

Branch: refs/heads/ib/1731
Commit: 26d80abb6f370a121b25bfa9d933d1810d63e53c
Parents: d98da98
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 22 09:40:12 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:17 2015 +0000

----------------------------------------------------------------------
 .../tests/functional/test_controllers.py        |  6 ++---
 .../forgegit/tests/model/test_repository.py     | 28 +++++++++++++++++++-
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/26d80abb/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 9dd4852..9de228a 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -695,10 +695,10 @@ class TestFork(_TestCase):
         r = self.app.get('/p/test/src-git/merge-requests').follow()
         assert '<a href="1/">changed summary</a>' in r
 
-    @patch.object(GM.Repository, 'merge_base', autospec=True)
-    def test_merge_base_error(self, merge_base):
+    @patch.object(GM.Repository, 'merge_request_commits', autospec=True)
+    def test_merge_request_commits_error(self, mr_commits):
         r, mr_num = self._request_merge()
-        merge_base.side_effect = Exception
+        mr_commits.side_effect = Exception
         r = self.app.get('/p/test/src-git/merge-requests/%s/' % mr_num)
         err = r.html.find('div', attrs={'class': 'grid-19 error'})
         assert_in("Can't find commits to merge", err.getText())

http://git-wip-us.apache.org/repos/asf/allura/blob/26d80abb/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 b8506c9..e516f35 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -693,9 +693,35 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
             source_branch='zz',
             target_branch='master',
         )
-        res = self.repo.merge_base(mr)
+        res = self.repo._impl.merge_base(mr)
         assert_equal(res, '1e146e67985dcd71c74de79613719bef7bddca4a')
 
+    def test_merge_request_commits(self):
+        mr = M.MergeRequest(
+            downstream={
+                'commit_id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
+            },
+            source_branch='zz',
+            target_branch='master',
+        )
+        res = self.repo.merge_request_commits(mr)
+        expected = [
+            {'authored': {
+                'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
+                'email': u'cjohns@slashdotmedia.com',
+                'name': u'Cory Johns'},
+             'committed': {
+                 'date': datetime.datetime(2013, 3, 28, 18, 54, 16),
+                 'email': u'cjohns@slashdotmedia.com',
+                 'name': u'Cory Johns'},
+             'id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
+             'message': u'Not repo root\n',
+             'parents': ['1e146e67985dcd71c74de79613719bef7bddca4a'],
+             'refs': ['zz'],
+             'rename_details': {},
+             'size': None}]
+        assert_equals(res, expected)
+
 
 class TestGitImplementation(unittest.TestCase):
 


[13/16] allura git commit: [#1731] ticket:767 Fix tests

Posted by je...@apache.org.
[#1731] ticket:767 Fix tests


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

Branch: refs/heads/ib/1731
Commit: e51d62958c2c61f9fc9ca247fd2eb971b9272d65
Parents: da4094d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 18 16:38:25 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 13:31:53 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_discuss.py                    | 3 ++-
 .../unit/controllers/test_discussion_moderation_controller.py     | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e51d6295/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 31e454e..cd30f44 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -171,7 +171,8 @@ class TestDiscuss(TestController):
         post = M.Post.query.find().first()
         assert post.status == 'ok'
         self.app.post(post_link + 'moderate', params=dict(delete='delete'))
-        assert M.Post.query.find().count() == 0
+        assert M.Post.query.find().count() == 1
+        assert M.Post.query.find({'deleted': False}).count() == 0
 
     @patch.object(M.Thread, 'is_spam')
     def test_feed_does_not_include_comments_held_for_moderation(self, is_spam):

http://git-wip-us.apache.org/repos/asf/allura/blob/e51d6295/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
index e6dc38d..e604222 100644
--- a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
+++ b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
@@ -68,7 +68,7 @@ class TestWhenModerating(WithDatabase):
         ThreadLocalORMSession.flush_all()
 
     def get_post(self):
-        return model.Post.query.get(slug='mypost')
+        return model.Post.query.get(slug='mypost', deleted=False)
 
 
 class TestIndexWithNoPosts(WithDatabase):


[04/16] allura git commit: [#7836] ticket:739 Find merge base for merge request and use it to determine what commits will be merged

Posted by je...@apache.org.
[#7836] ticket:739 Find merge base for merge request and use it to determine what commits will be merged


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

Branch: refs/heads/ib/1731
Commit: e48f2361b6910d10b891418ff0cb7fa7d8d0e59e
Parents: 42d3a61
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 5 13:54:42 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:16 2015 +0000

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


http://git-wip-us.apache.org/repos/asf/allura/blob/e48f2361/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index e4583e5..9162117 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -321,6 +321,10 @@ class RepositoryImplementation(object):
         """
         raise NotImplementedError('paged_diffs')
 
+    def merge_base(self, mr):
+        """Given MergeRequest :param mr: find common ancestor for the merge"""
+        raise NotImplementedError('merge_base')
+
 
 class Repository(Artifact, ActivityObject):
     BATCH_SIZE = 100
@@ -713,6 +717,10 @@ class Repository(Artifact, ActivityObject):
             self.set_default_branch(branch_name)
         return branch_name
 
+    def merge_base(self, mr):
+        """Given MergeRequest :param mr: find common ancestor for the merge"""
+        return self._impl.merge_base(mr)
+
 
 class MergeRequest(VersionedArtifact, ActivityObject):
     statuses = ['open', 'merged', 'rejected']
@@ -780,21 +788,11 @@ class MergeRequest(VersionedArtifact, ActivityObject):
 
     def _commits(self):
         with self.push_downstream_context():
-            rev = self.app.repo.latest(branch=self.target_branch)
-            if rev:
-                commit = rev._id
-            else:
-                commit = self.app.repo.head
-            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 []
+            base = c.app.repo.merge_base(self)
+            return list(c.app.repo.log(
+                self.downstream.commit_id,
+                exclude=base,
+                id_only=False))
 
     @classmethod
     def upsert(cls, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/e48f2361/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 3b3b9e9..5994cd2 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -631,6 +631,14 @@ class GitImplementation(M.RepositoryImplementation):
             'total': total,
         }
 
+    def merge_base(self, mr):
+        # We don't need to fetch latest commits from target branch here,
+        # because merge base will always be a commit that both repos have
+        # seen
+        return self._git.git.merge_base(
+            mr.downstream.commit_id,
+            mr.target_branch)
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE = 4096


[09/16] allura git commit: [#7836] ticket:739 Get rid of svn test for merge requests

Posted by je...@apache.org.
[#7836] ticket:739 Get rid of svn test for merge requests

They don't make any sense, since we don't support forking & merging for svn


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

Branch: refs/heads/ib/1731
Commit: 1accce536bb54b828599bf9d3573c79bb2e7b514
Parents: 26d80ab
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 22 09:41:26 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:17 2015 +0000

----------------------------------------------------------------------
 .../forgesvn/tests/model/test_repository.py     | 59 --------------------
 1 file changed, 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1accce53/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 6276df8..744d30a 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -838,16 +838,6 @@ class TestRepo(_TestWithRepo):
                 self.repo.clone_url('https', 'user'),
                 'https://user@foo.com/')
 
-    def test_merge_request(self):
-        M.MergeRequest.upsert(app_config_id=c.app.config._id, status='open')
-        M.MergeRequest.upsert(app_config_id=c.app.config._id, status='closed')
-        session(M.MergeRequest).flush()
-        session(M.MergeRequest).clear()
-        assert self.repo.merge_requests_by_statuses('open').count() == 1
-        assert self.repo.merge_requests_by_statuses('closed').count() == 1
-        assert self.repo.merge_requests_by_statuses(
-            'open', 'closed').count() == 2
-
     def test_guess_type(self):
         assert self.repo.guess_type('foo.txt') == ('text/plain', None)
         assert self.repo.guess_type('foo.gbaer') == (
@@ -932,55 +922,6 @@ class TestRepo(_TestWithRepo):
             M.Project.app_instance = old_app_instance
 
 
-class TestMergeRequest(_TestWithRepoAndCommit):
-
-    def setUp(self):
-        super(TestMergeRequest, self).setUp()
-        c.project.install_app('svn', 'test2')
-        h.set_context('test', 'test2', neighborhood='Projects')
-        self.repo2 = M.Repository(name='test2', tool='svn')
-        self.repo2._impl = mock.Mock(spec=M.RepositoryImplementation())
-        self.repo2._impl.log = lambda *a, **kw: (['foo'], [])
-        self.repo2._impl.all_commit_ids = lambda *a, **kw: []
-        self.repo2._impl._repo = self.repo2
-        self.repo2.init_as_clone('/p/test/', 'test1', '/p/test/test1/')
-        ThreadLocalORMSession.flush_all()
-        ThreadLocalORMSession.close_all()
-
-    def test_upsert(self):
-        h.set_context('test', 'test1', neighborhood='Projects')
-        mr = M.MergeRequest.upsert(
-            downstream=ming.base.Object(
-                project_id=c.project._id,
-                mount_point='test2',
-                commit_id='foo:2'),
-            target_branch='foobranch',
-            summary='summary',
-            description='description')
-        u = M.User.by_username('test-admin')
-        assert_equal(mr.creator, u)
-        assert_equal(mr.creator_name,  u.get_pref('display_name'))
-        assert_equal(mr.creator_url,  u.url())
-        assert_equal(mr.downstream_url,  '/p/test/test2/')
-        assert_equal(mr.downstream_repo_url,
-                     'http://svn.localhost/p/test/test2/')
-        with mock.patch('forgesvn.model.svn.SVNLibWrapper') as _svn,\
-                mock.patch('forgesvn.model.svn.SVNImplementation._map_log') as _map_log:
-            mr.app.repo._impl.head = 1
-            _svn().log.return_value = [mock.Mock(revision=mock.Mock(number=2))]
-            _map_log.return_value = 'bar'
-            assert_equal(mr.commits,  ['bar'])
-            # can't do assert_called_once_with because pysvn.Revision doesn't
-            # compare nicely
-            assert_equal(_svn().log.call_count, 1)
-            assert_equal(_svn().log.call_args[0],
-                         ('file:///tmp/svn/p/test/test2',))
-            assert_equal(_svn().log.call_args[1]['revision_start'].number, 2)
-            assert_equal(_svn().log.call_args[1]['limit'], 25)
-            _map_log.assert_called_once_with(
-                _svn().log.return_value[0], 'file:///tmp/svn/p/test/test2', None)
-
-
 class TestRepoObject(_TestWithRepoAndCommit):
 
     def test_upsert(self):


[05/16] allura git commit: [#7836] ticket:739 Add/fix some tests

Posted by je...@apache.org.
[#7836] ticket:739 Add/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/a96649cd
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a96649cd
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a96649cd

Branch: refs/heads/ib/1731
Commit: a96649cdf1e6428bc84fc7ae0d53af7971114f82
Parents: 1fda8a7
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 5 15:57:23 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:16 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/tests/functional/test_controllers.py |  8 ++++++++
 ForgeGit/forgegit/tests/model/test_repository.py       | 11 +++++++++++
 ForgeSVN/forgesvn/model/svn.py                         |  4 ++++
 3 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/a96649cd/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 7458ba8..9dd4852 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -695,6 +695,14 @@ class TestFork(_TestCase):
         r = self.app.get('/p/test/src-git/merge-requests').follow()
         assert '<a href="1/">changed summary</a>' in r
 
+    @patch.object(GM.Repository, 'merge_base', autospec=True)
+    def test_merge_base_error(self, merge_base):
+        r, mr_num = self._request_merge()
+        merge_base.side_effect = Exception
+        r = self.app.get('/p/test/src-git/merge-requests/%s/' % mr_num)
+        err = r.html.find('div', attrs={'class': 'grid-19 error'})
+        assert_in("Can't find commits to merge", err.getText())
+
 
 class TestDiff(TestController):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/a96649cd/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 dbc12b0..b8506c9 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -685,6 +685,17 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         }
         assert_equals(diffs, expected)
 
+    def test_merge_base(self):
+        mr = M.MergeRequest(
+            downstream={
+                'commit_id': '5c47243c8e424136fd5cdd18cd94d34c66d1955c',
+            },
+            source_branch='zz',
+            target_branch='master',
+        )
+        res = self.repo.merge_base(mr)
+        assert_equal(res, '1e146e67985dcd71c74de79613719bef7bddca4a')
+
 
 class TestGitImplementation(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/allura/blob/a96649cd/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index cd410e3..53b4190 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -91,6 +91,10 @@ class Repository(M.Repository):
     def rev_to_commit_id(self, rev):
         return self._impl.rev_parse(rev)
 
+    def merge_base(self, mr):
+        rev = self.latest(branch=mr.target_branch)
+        return rev._id if rev else self.head
+
 
 class SVNCalledProcessError(Exception):
 


[10/16] allura git commit: [#7836] ticket:739 Use c.app in the merge_request_commits for git

Posted by je...@apache.org.
[#7836] ticket:739 Use c.app in the merge_request_commits for git

It executes in the downstream context, so we need to use downstream app to
generate a list of commits. If we don't do that, we will see empty list on the
first request to the page (right after user creates merge request).


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

Branch: refs/heads/ib/1731
Commit: d98da988f9f365ff80f43434076b37974936824e
Parents: d1310c6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Apr 21 14:01:17 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:17 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d98da988/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 99c5afe..aeb5734 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -643,7 +643,7 @@ class GitImplementation(M.RepositoryImplementation):
         Must be called within mr.push_downstream_context()
         """
         base = self.merge_base(mr)
-        return list(mr.app.repo.log(
+        return list(c.app.repo.log(
             mr.downstream.commit_id,
             exclude=base,
             id_only=False))


[14/16] allura git commit: [#1731] ticket:775 Add --dry-run and --tool to script

Posted by je...@apache.org.
[#1731] ticket:775 Add --dry-run and --tool to script


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

Branch: refs/heads/ib/1731
Commit: 7b57bb6e10803ba921767523ad60bdb4ca9bd004
Parents: e51d629
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 25 14:13:40 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 14:13:40 2015 +0000

----------------------------------------------------------------------
 .../allura/scripts/create_deleted_comments.py   | 44 ++++++++++++++++++--
 1 file changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7b57bb6e/Allura/allura/scripts/create_deleted_comments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/create_deleted_comments.py b/Allura/allura/scripts/create_deleted_comments.py
index b0e7260..509752c 100644
--- a/Allura/allura/scripts/create_deleted_comments.py
+++ b/Allura/allura/scripts/create_deleted_comments.py
@@ -15,6 +15,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import sys
 import argparse
 import logging
 
@@ -22,7 +23,7 @@ from ming.odm import session
 from pylons import tmpl_context as c
 
 from allura.scripts import ScriptTask
-from allura.model import Post
+from allura import model as M
 from allura.lib.utils import chunked_find
 from forgediscussion.model import ForumPost
 
@@ -34,11 +35,14 @@ class CreateDeletedComments(ScriptTask):
 
     @classmethod
     def execute(cls, options):
-        models = [Post, ForumPost]
+        models = [M.Post, ForumPost]
+        app_config_id = cls.get_tool_id(options.tool)
         # Find all posts that have parent_id, but does not have actual parent
         # and create fake parent for them
         for model in models:
-            for chunk in chunked_find(model, {'parent_id': {'$ne': None}}):
+            q = {'parent_id': {'$ne': None},
+                 'app_config_id': app_config_id}
+            for chunk in chunked_find(model, q):
                 for post in chunk:
                     if not post.parent:
                         log.info('Creating deleted parent for %s %s',
@@ -59,7 +63,27 @@ class CreateDeletedComments(ScriptTask):
                             slug=slug,
                             full_slug=full_slug,
                         )
-                        session(deleted_post).flush(deleted_post)
+                        if options.dry_run:
+                            session(deleted_post).expunge(deleted_post)
+                        else:
+                            session(deleted_post).flush(deleted_post)
+
+    @classmethod
+    def get_tool_id(cls, tool):
+        _n, _p, _mount = tool.split('/')
+        n = M.Neighborhood.query.get(url_prefix='/{}/'.format(_n))
+        if not n:
+            log.error('Can not find neighborhood %s', _n)
+            sys.exit(1)
+        p = M.Project.query.get(neighborhood_id=n._id, shortname=_p)
+        if not p:
+            log.error('Can not find project %s', _p)
+            sys.exit(1)
+        t = p.app_instance(_mount)
+        if not t:
+            log.error('Can not find tool with mount point %s', _mount)
+            sys.exit(1)
+        return t.config._id
 
     @classmethod
     def parser(cls):
@@ -67,6 +91,18 @@ class CreateDeletedComments(ScriptTask):
             description='Create comments marked as deleted in place of '
                         'actually deleted parent comments (ticket:#1731)'
         )
+        parser.add_argument(
+            '--dry-run',
+            action='store_true',
+            dest='dry_run',
+            default=False,
+            help='Show comments that will be created, but do not actually '
+                 'create anything',
+        )
+        parser.add_argument(
+            '-t', '--tool',
+            required=True,
+            help='Create comments only in specified tool, e.g. p/test/wiki')
         return parser
 
 


[08/16] allura git commit: [#7836] ticket:739 Delegate MergeRequest._commits to repo implementation

Posted by je...@apache.org.
[#7836] ticket:739 Delegate MergeRequest._commits to repo implementation

This way we can implement it for Hg, which is quite different from Git (merge
base + log approach doesn't work for it).


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

Branch: refs/heads/ib/1731
Commit: d1310c61cd9cde87067b32622978a7fe9aee7937
Parents: f0bede1
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Apr 21 10:53:50 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:17 2015 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py   | 18 +++++++-----------
 ForgeGit/forgegit/model/git_repo.py | 12 ++++++++++++
 ForgeSVN/forgesvn/model/svn.py      |  4 ----
 3 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 9162117..ec623a3 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -321,9 +321,9 @@ class RepositoryImplementation(object):
         """
         raise NotImplementedError('paged_diffs')
 
-    def merge_base(self, mr):
-        """Given MergeRequest :param mr: find common ancestor for the merge"""
-        raise NotImplementedError('merge_base')
+    def merge_request_commits(self, mr):
+        """Given MergeRequest :param mr: return list of commits to be merged"""
+        raise NotImplementedError('merge_request_commits')
 
 
 class Repository(Artifact, ActivityObject):
@@ -717,9 +717,9 @@ class Repository(Artifact, ActivityObject):
             self.set_default_branch(branch_name)
         return branch_name
 
-    def merge_base(self, mr):
-        """Given MergeRequest :param mr: find common ancestor for the merge"""
-        return self._impl.merge_base(mr)
+    def merge_request_commits(self, mr):
+        """Given MergeRequest :param mr: return list of commits to be merged"""
+        return self._impl.merge_request_commits(mr)
 
 
 class MergeRequest(VersionedArtifact, ActivityObject):
@@ -788,11 +788,7 @@ class MergeRequest(VersionedArtifact, ActivityObject):
 
     def _commits(self):
         with self.push_downstream_context():
-            base = c.app.repo.merge_base(self)
-            return list(c.app.repo.log(
-                self.downstream.commit_id,
-                exclude=base,
-                id_only=False))
+            return c.app.repo.merge_request_commits(self)
 
     @classmethod
     def upsert(cls, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index a0f3f5a..99c5afe 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -636,6 +636,18 @@ class GitImplementation(M.RepositoryImplementation):
         g.fetch(mr.app.repo.full_fs_path, mr.target_branch)
         return g.merge_base(mr.downstream.commit_id, 'FETCH_HEAD')
 
+    def merge_request_commits(self, mr):
+        """
+        Return list of commits to be merged
+
+        Must be called within mr.push_downstream_context()
+        """
+        base = self.merge_base(mr)
+        return list(mr.app.repo.log(
+            mr.downstream.commit_id,
+            exclude=base,
+            id_only=False))
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE = 4096

http://git-wip-us.apache.org/repos/asf/allura/blob/d1310c61/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 53b4190..cd410e3 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -91,10 +91,6 @@ class Repository(M.Repository):
     def rev_to_commit_id(self, rev):
         return self._impl.rev_parse(rev)
 
-    def merge_base(self, mr):
-        rev = self.latest(branch=mr.target_branch)
-        return rev._id if rev else self.head
-
 
 class SVNCalledProcessError(Exception):
 


[02/16] allura git commit: [#7836] ticket:739 Fetch target branch before finding merge base

Posted by je...@apache.org.
[#7836] ticket:739 Fetch target branch before finding merge base

Because if we don't, we get 0 commits if target branch name and source branch
name are the same, even if branches actually differ.


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

Branch: refs/heads/ib/1731
Commit: 0e365071cf76e24727fd5e2ade6c08a3df2bea17
Parents: a96649c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 5 16:34:20 2015 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed May 20 19:43:16 2015 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0e365071/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 5994cd2..a0f3f5a 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -632,12 +632,9 @@ class GitImplementation(M.RepositoryImplementation):
         }
 
     def merge_base(self, mr):
-        # We don't need to fetch latest commits from target branch here,
-        # because merge base will always be a commit that both repos have
-        # seen
-        return self._git.git.merge_base(
-            mr.downstream.commit_id,
-            mr.target_branch)
+        g = self._git.git
+        g.fetch(mr.app.repo.full_fs_path, mr.target_branch)
+        return g.merge_base(mr.downstream.commit_id, 'FETCH_HEAD')
 
 
 class _OpenedGitBlob(object):


[16/16] allura git commit: [#1731] ticket:775 Don't show deleted posts in moderation list

Posted by je...@apache.org.
[#1731] ticket:775 Don't show deleted posts in moderation list


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

Branch: refs/heads/ib/1731
Commit: 4788e07bad797a4bc8acfacff9fdbd54708aa247
Parents: 863ca87
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 25 15:21:11 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 15:21:11 2015 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py                          | 3 ++-
 .../unit/controllers/test_discussion_moderation_controller.py | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4788e07b/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index 1fd24a0..2d9807e 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -435,7 +435,8 @@ class ModerationController(BaseController):
         c.post_filter = WidgetConfig.post_filter
         c.moderate_posts = WidgetConfig.moderate_posts
         query = dict(
-            discussion_id=self.discussion._id)
+            discussion_id=self.discussion._id,
+            deleted=False)
         if status != '-':
             query['status'] = status
         if flag:

http://git-wip-us.apache.org/repos/asf/allura/blob/4788e07b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
index e604222..5f88b0a 100644
--- a/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
+++ b/Allura/allura/tests/unit/controllers/test_discussion_moderation_controller.py
@@ -17,7 +17,7 @@
 
 from nose.tools import assert_equal
 from mock import Mock, patch
-from ming.orm import ThreadLocalORMSession
+from ming.orm import ThreadLocalORMSession, session
 
 from allura.tests.unit import WithDatabase
 from allura.tests.unit.factories import create_post, create_discussion
@@ -98,6 +98,11 @@ class TestIndexWithAPostInTheDiscussion(WithDatabase):
         assert self.template_variables['pgnum'] == 1
         assert self.template_variables['pages'] == 1
 
+    def test_deleted_post_not_shown(self):
+        self.post.deleted = True
+        session(self.post).flush(self.post)
+        assert self.template_variables['posts'].all() == []
+
 
 def show_moderation_index(discussion, **kwargs_for_controller):
     discussion_controller = Mock()


[12/16] allura git commit: [#1731] ticket:767 Add script to re-create 'fake' deleted parents

Posted by je...@apache.org.
[#1731] ticket:767 Add script to re-create 'fake' deleted parents


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

Branch: refs/heads/ib/1731
Commit: da4094d4d456903d5052f7722485d19b32e0234d
Parents: 89b65ff
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon May 18 16:10:09 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon May 25 13:31:52 2015 +0000

----------------------------------------------------------------------
 .../allura/scripts/create_deleted_comments.py   | 74 ++++++++++++++++++++
 1 file changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/da4094d4/Allura/allura/scripts/create_deleted_comments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/scripts/create_deleted_comments.py b/Allura/allura/scripts/create_deleted_comments.py
new file mode 100644
index 0000000..b0e7260
--- /dev/null
+++ b/Allura/allura/scripts/create_deleted_comments.py
@@ -0,0 +1,74 @@
+#       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 argparse
+import logging
+
+from ming.odm import session
+from pylons import tmpl_context as c
+
+from allura.scripts import ScriptTask
+from allura.model import Post
+from allura.lib.utils import chunked_find
+from forgediscussion.model import ForumPost
+
+
+log = logging.getLogger(__name__)
+
+
+class CreateDeletedComments(ScriptTask):
+
+    @classmethod
+    def execute(cls, options):
+        models = [Post, ForumPost]
+        # Find all posts that have parent_id, but does not have actual parent
+        # and create fake parent for them
+        for model in models:
+            for chunk in chunked_find(model, {'parent_id': {'$ne': None}}):
+                for post in chunk:
+                    if not post.parent:
+                        log.info('Creating deleted parent for %s %s',
+                                 model.__mongometa__.name, post._id)
+                        c.project = post.app_config.project
+                        slug = post.slug.rsplit('/', 1)[0]
+                        full_slug = post.full_slug.rsplit('/', 1)[0]
+                        author = c.project.admins()[0]
+                        deleted_post = model(
+                            _id=post.parent_id,
+                            deleted=True,
+                            text="Automatically created in place of deleted post",
+                            app_id=post.app_id,
+                            app_config_id=post.app_config_id,
+                            discussion_id=post.discussion_id,
+                            thread_id=post.thread_id,
+                            author_id=author._id,
+                            slug=slug,
+                            full_slug=full_slug,
+                        )
+                        session(deleted_post).flush(deleted_post)
+
+    @classmethod
+    def parser(cls):
+        parser = argparse.ArgumentParser(
+            description='Create comments marked as deleted in place of '
+                        'actually deleted parent comments (ticket:#1731)'
+        )
+        return parser
+
+
+if __name__ == '__main__':
+    CreateDeletedComments.main()