You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/03/05 17:24:38 UTC

[1/5] git commit: [#6301] ticket:536 track changes to merge requests

Repository: incubator-allura
Updated Branches:
  refs/heads/master 12dfe34f9 -> 2bc9d55c4


[#6301] ticket:536 track changes to merge requests


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

Branch: refs/heads/master
Commit: 01cb3c6b2553cb90cbb5eaf257974b1c793ca745
Parents: 12dfe34
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Mon Mar 3 13:19:11 2014 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 15:51:20 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 22 ++++++++++++++++----
 .../tests/functional/test_controllers.py        |  5 +++++
 2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/01cb3c6b/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index eecd563..7b0afb4 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -404,12 +404,26 @@ class MergeRequestController(object):
     def do_request_merge_edit(self, **kw):
         require_access(self.req, 'write')
         kw = self.mr_widget_edit.to_python(kw)
-        self.req.summary = kw['summary']
-        self.req.target_branch = kw['target_branch']
-        self.req.source_branch = kw['source_branch']
-        self.req.description = kw['description']
+        changes = ['Merge request %s has been modified:' % self.req.request_number,
+                'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username)]
+        if self.req.summary != kw['summary']:
+            changes.append('Summary updated: %r => %r' % (self.req.summary, kw['summary']))
+            self.req.summary = kw['summary']
+
+        if self.req.target_branch != kw['target_branch']:
+            changes.append('Target branch updated: %r => %r' % (self.req.target_branch, kw['target_branch']))
+            self.req.target_branch = kw['target_branch']
+
+        if self.req.source_branch != kw['source_branch']:
+            changes.append('Source branch updated: %r => %r' % (self.req.source_branch, kw['source_branch']))
+            self.req.source_branch = kw['source_branch']
+
+        if self.req.description != kw['description']:
+            changes.append('Description updated: %r => %r' % (self.req.description, kw['description']))
+            self.req.description = kw['description']
         with self.req.push_downstream_context():
             self.req.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
+        self.req.discussion_thread.add_post(text='\n'.join(changes))
         M.Notification.post(
             self.req, 'merge_request',
             subject='Merge request: ' + self.req.summary)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/01cb3c6b/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 999af5b..ae7c31e 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -631,6 +631,11 @@ class TestFork(_TestCase):
         assert '[5c4724]' not in r
         assert '<p>changed description</p' in r
         assert 'Merge Request #1: changed summary (open)' in r
+        assert '''<p>Merge request 1 has been modified:<br />
+Edited By: Test Admin (test-admin)<br />
+Summary updated: u'summary' =&gt; u'changed summary'<br />
+Source branch updated: u'zz' =&gt; u'master'<br />
+Description updated: u'description' =&gt; u'changed description'</p>''' in r
 
         r = self.app.get('/p/test/src-git/merge-requests')
         assert '<a href="1/">changed summary</a>' in r


[3/5] git commit: [#6301] ticket:536 fixed comment in merge requests

Posted by jo...@apache.org.
[#6301] ticket:536 fixed comment in merge requests


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

Branch: refs/heads/master
Commit: 8deb96597e44567a7f6635394ac3036d113a21ed
Parents: 01cb3c6
Author: Yuriy Arhipov <yu...@yandex.ru>
Authored: Tue Mar 4 02:39:53 2014 +0400
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 15:51:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 22 +++++++++++++-------
 .../templates/repo/merge_request_changed.html   | 21 +++++++++++++++++++
 .../tests/functional/test_controllers.py        | 14 ++++++++-----
 3 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 7b0afb4..4be5213 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -347,6 +347,7 @@ class MergeRequestController(object):
     mr_dispose_form = SCMMergeRequestDisposeWidget()
 
     def __init__(self, num):
+        self.tmpl = g.jinja2_env.get_template('allura:templates/repo/merge_request_changed.html')
         self.req = M.MergeRequest.query.get(
             app_config_id=c.app.config._id,
             request_number=int(num))
@@ -404,26 +405,28 @@ class MergeRequestController(object):
     def do_request_merge_edit(self, **kw):
         require_access(self.req, 'write')
         kw = self.mr_widget_edit.to_python(kw)
-        changes = ['Merge request %s has been modified:' % self.req.request_number,
-                'Edited By: %s (%s)' % (c.user.get_pref('display_name'), c.user.username)]
+        changes = dict()
         if self.req.summary != kw['summary']:
-            changes.append('Summary updated: %r => %r' % (self.req.summary, kw['summary']))
+            changes['Summary'] = [self.req.summary, kw['summary']]
             self.req.summary = kw['summary']
 
         if self.req.target_branch != kw['target_branch']:
-            changes.append('Target branch updated: %r => %r' % (self.req.target_branch, kw['target_branch']))
+            changes['Target branch'] = [self.req.target_branch, kw['target_branch']]
             self.req.target_branch = kw['target_branch']
 
         if self.req.source_branch != kw['source_branch']:
-            changes.append('Source branch updated: %r => %r' % (self.req.source_branch, kw['source_branch']))
+            changes['Source branch'] = [self.req.source_branch, kw['source_branch']]
             self.req.source_branch = kw['source_branch']
 
         if self.req.description != kw['description']:
-            changes.append('Description updated: %r => %r' % (self.req.description, kw['description']))
+            changes['Description'] = [self.req.description, kw['description']]
             self.req.description = kw['description']
         with self.req.push_downstream_context():
             self.req.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id
-        self.req.discussion_thread.add_post(text='\n'.join(changes))
+
+        message = self.tmpl.render(changes=changes)
+        self.req.discussion_thread.add_post(text=message, is_meta=True)
+
         M.Notification.post(
             self.req, 'merge_request',
             subject='Merge request: ' + self.req.summary)
@@ -434,7 +437,10 @@ class MergeRequestController(object):
     @validate(mr_dispose_form)
     def save(self, status=None, **kw):
         require_access(self.req, 'write')
-        self.req.status = status
+        if self.req.status != status:
+            message = self.tmpl.render(changes={'Status': [self.req.status, status]})
+            self.req.discussion_thread.add_post(text=message, is_meta=True)
+            self.req.status = status
         redirect('.')
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/Allura/allura/templates/repo/merge_request_changed.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request_changed.html b/Allura/allura/templates/repo/merge_request_changed.html
new file mode 100644
index 0000000..1c278e6
--- /dev/null
+++ b/Allura/allura/templates/repo/merge_request_changed.html
@@ -0,0 +1,21 @@
+{#-
+       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.
+-#}
+{% for field, values in changes.iteritems() %}
+- **{{ field }}**: {{ values[0] }} --> {{ values[1] }}
+{% endfor %}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8deb9659/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 ae7c31e..90230b5 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -631,11 +631,15 @@ class TestFork(_TestCase):
         assert '[5c4724]' not in r
         assert '<p>changed description</p' in r
         assert 'Merge Request #1: changed summary (open)' in r
-        assert '''<p>Merge request 1 has been modified:<br />
-Edited By: Test Admin (test-admin)<br />
-Summary updated: u'summary' =&gt; u'changed summary'<br />
-Source branch updated: u'zz' =&gt; u'master'<br />
-Description updated: u'description' =&gt; u'changed description'</p>''' in r
+        assert '''<li>
+<p><strong>Source branch</strong>: zz --&gt; master</p>
+</li>
+<li>
+<p><strong>Description</strong>: description --&gt; changed description</p>
+</li>
+<li>
+<p><strong>Summary</strong>: summary --&gt; changed summary</p>
+</li>''' in r
 
         r = self.app.get('/p/test/src-git/merge-requests')
         assert '<a href="1/">changed summary</a>' in r


[4/5] git commit: [#6301] Fixed fragile test by ensuring consistent ordering of changed fields in post

Posted by jo...@apache.org.
[#6301] Fixed fragile test by ensuring consistent ordering of changed fields in post

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: dc1b7eb809afcd9c68d646598b70cf434e83e3bf
Parents: 714cf87
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Mar 5 16:11:28 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 16:11:28 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py                |  4 ++--
 ForgeGit/forgegit/tests/functional/test_controllers.py | 12 +++++++-----
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dc1b7eb8/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index ad8a974..9cf6bfa 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -19,7 +19,7 @@ import os
 import logging
 import difflib
 from urllib import quote, unquote
-from collections import defaultdict
+from collections import defaultdict, OrderedDict
 from itertools import islice
 
 from paste.deploy.converters import asbool
@@ -405,7 +405,7 @@ class MergeRequestController(object):
     def do_request_merge_edit(self, **kw):
         require_access(self.req, 'write')
         kw = self.mr_widget_edit.to_python(kw)
-        changes = dict()
+        changes = OrderedDict()
         if self.req.summary != kw['summary']:
             changes['Summary'] = [self.req.summary, kw['summary']]
             self.req.summary = kw['summary']

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/dc1b7eb8/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 d7bc19f..5c85e2c 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -21,6 +21,7 @@ import os
 import shutil
 import tempfile
 
+from datadiff.tools import assert_equal as dd_assert_equal
 from nose.tools import assert_equal, assert_in, assert_not_in
 import tg
 import pkg_resources
@@ -632,9 +633,12 @@ class TestFork(_TestCase):
         assert '<p>changed description</p' in r
         assert 'Merge Request #1: changed summary (open)' in r
         changes = r.html.findAll('div', attrs={'class': 'markdown_content'})[-1]
-        assert unicode(changes) == """
+        dd_assert_equal(unicode(changes), """
 <div class="markdown_content"><ul>
 <li>
+<p><strong>Summary</strong>: summary --&gt; changed summary</p>
+</li>
+<li>
 <p><strong>Source branch</strong>: zz --&gt; master</p>
 </li>
 <li>
@@ -648,10 +652,8 @@ class TestFork(_TestCase):
 <span class="gd">-description</span>
 <span class="gi">+changed description</span>
 </pre></div>
-<ul>
-<li><strong>Summary</strong>: summary --&gt; changed summary</li>
-</ul></div>
-""".strip()
+</div>
+""".strip())
 
         r = self.app.get('/p/test/src-git/merge-requests')
         assert '<a href="1/">changed summary</a>' in r


[5/5] git commit: [#6301] Removed now redundant merge request notification

Posted by jo...@apache.org.
[#6301] Removed now redundant merge request notification

The merge-request-changed discussion thread post will generate a
notification, so this one is no longer needed.

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: 2bc9d55c4c05b74d54d1bbf8d275e8fd8c0745da
Parents: dc1b7eb
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Mar 5 16:23:11 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 16:23:14 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py | 4 ----
 1 file changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2bc9d55c/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 9cf6bfa..aabc467 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -426,10 +426,6 @@ class MergeRequestController(object):
 
         message = self.tmpl.render(changes=changes)
         self.req.discussion_thread.add_post(text=message, is_meta=True)
-
-        M.Notification.post(
-            self.req, 'merge_request',
-            subject='Merge request: ' + self.req.summary)
         redirect(self.req.url())
 
     @expose()


[2/5] git commit: [#6301] ticket:536 Show description changes as diff

Posted by jo...@apache.org.
[#6301] ticket:536 Show description changes as diff


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

Branch: refs/heads/master
Commit: 714cf8709033d43c9ce689383db529d092a07f05
Parents: 8deb965
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 5 16:07:59 2014 +0200
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Mar 5 15:51:21 2014 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  2 +-
 Allura/allura/lib/helpers.py                    | 10 +++++++++
 .../templates/repo/merge_request_changed.html   | 13 +++++++++++-
 .../tests/functional/test_controllers.py        | 22 +++++++++++++++-----
 4 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/714cf870/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 4be5213..ad8a974 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -419,7 +419,7 @@ class MergeRequestController(object):
             self.req.source_branch = kw['source_branch']
 
         if self.req.description != kw['description']:
-            changes['Description'] = [self.req.description, kw['description']]
+            changes['Description'] = h.unidiff(self.req.description, kw['description'])
             self.req.description = kw['description']
         with self.req.push_downstream_context():
             self.req.downstream['commit_id'] = c.app.repo.commit(kw['source_branch'])._id

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/714cf870/Allura/allura/lib/helpers.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 83992aa..d109917 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -1180,3 +1180,13 @@ def map_jinja_filter(ctx, seq, filter_name, *a, **kw):
     """
     filter_ = get_filter(ctx, filter_name)
     return [filter_(value, *a, **kw) for value in seq]
+
+
+def unidiff(old, new):
+    """Returns unified diff between `one` and `two`."""
+    return '\n'.join(difflib.unified_diff(
+        a=old.splitlines(),
+        b=new.splitlines(),
+        fromfile='old',
+        tofile='new',
+        lineterm=''))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/714cf870/Allura/allura/templates/repo/merge_request_changed.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/merge_request_changed.html b/Allura/allura/templates/repo/merge_request_changed.html
index 1c278e6..dd4059c 100644
--- a/Allura/allura/templates/repo/merge_request_changed.html
+++ b/Allura/allura/templates/repo/merge_request_changed.html
@@ -17,5 +17,16 @@
        under the License.
 -#}
 {% for field, values in changes.iteritems() %}
+{% if field == 'Description': %}
+- **{{ field }}**:
+
+Diff:
+
+~~~~
+{{ values }}
+~~~~
+
+{% else %}
 - **{{ field }}**: {{ values[0] }} --> {{ values[1] }}
-{% endfor %}
\ No newline at end of file
+{% endif %}
+{% endfor %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/714cf870/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 90230b5..d7bc19f 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -631,15 +631,27 @@ class TestFork(_TestCase):
         assert '[5c4724]' not in r
         assert '<p>changed description</p' in r
         assert 'Merge Request #1: changed summary (open)' in r
-        assert '''<li>
+        changes = r.html.findAll('div', attrs={'class': 'markdown_content'})[-1]
+        assert unicode(changes) == """
+<div class="markdown_content"><ul>
+<li>
 <p><strong>Source branch</strong>: zz --&gt; master</p>
 </li>
 <li>
-<p><strong>Description</strong>: description --&gt; changed description</p>
+<p><strong>Description</strong>:</p>
 </li>
-<li>
-<p><strong>Summary</strong>: summary --&gt; changed summary</p>
-</li>''' in r
+</ul>
+<p>Diff:</p>
+<div class="codehilite"><pre><span class="gd">--- old</span>
+<span class="gi">+++ new</span>
+<span class="gu">@@ -1 +1 @@</span>
+<span class="gd">-description</span>
+<span class="gi">+changed description</span>
+</pre></div>
+<ul>
+<li><strong>Summary</strong>: summary --&gt; changed summary</li>
+</ul></div>
+""".strip()
 
         r = self.app.get('/p/test/src-git/merge-requests')
         assert '<a href="1/">changed summary</a>' in r