You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/08/08 16:03:50 UTC

[4/4] git commit: [#5177] Fixed default values for source and target_branch when creating a merge request

[#5177] Fixed default values for source and target_branch when creating a merge request

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/c68f4eec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/c68f4eec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/c68f4eec

Branch: refs/heads/cj/5177
Commit: c68f4eec30dc75447089e29c0b1a739b826d7f7a
Parents: 6711c10
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Thu Aug 8 14:03:29 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Aug 8 14:03:29 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         | 14 +++++++++++---
 Allura/allura/lib/repository.py                 |  5 ++++-
 Allura/allura/templates/repo/request_merge.html |  2 +-
 3 files changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c68f4eec/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index aaf9f6a..36b4bdc 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -162,9 +162,16 @@ class RepoRootController(BaseController, FeedController):
     def request_merge(self, branch=None, **kw):
         security.require(security.has_access(c.app.repo, 'admin'))
         c.form = self.mr_widget
-        if branch is None:
-            source_branch=c.app.default_branch_name
-        return dict(source_branch=source_branch)
+        if branch in c.form.source_branches:
+            source_branch = branch
+        else:
+            source_branch = c.app.default_branch_name
+        with c.app.repo.push_upstream_context():
+            target_branch = c.app.default_branch_name
+        return {
+                'source_branch': source_branch,
+                'target_branch': target_branch,
+            }
 
     @expose()
     @require_post()
@@ -417,6 +424,7 @@ class CommitBrowser(BaseController):
     def __init__(self, revision):
         self._revision = revision
         self._commit = c.app.repo.commit(revision)
+        c.revision = revision
         if self._commit is None:
             raise exc.HTTPNotFound
         self.tree = self.TreeBrowserClass(self._commit, tree=self._commit.tree)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c68f4eec/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 83df6b2..65b68c8 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -127,7 +127,10 @@ class RepositoryApp(Application):
                     self.repo.upstream_repo.name)
                 ]
             if not c.app.repo.is_empty() and has_access(c.app.repo, 'admin'):
-                links.append(SitemapEntry('Request Merge', c.app.url + 'request_merge',
+                merge_url = c.app.url + 'request_merge'
+                if getattr(c, 'revision', None):
+                    merge_url = merge_url + '?branch=' + h.urlquote(c.revision)
+                links.append(SitemapEntry('Request Merge', merge_url,
                              ui_icon=g.icons['merge'],
                              ))
             pending_upstream_merges = self.repo.pending_upstream_merges()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/c68f4eec/Allura/allura/templates/repo/request_merge.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/request_merge.html b/Allura/allura/templates/repo/request_merge.html
index 02b9061..a55a67c 100644
--- a/Allura/allura/templates/repo/request_merge.html
+++ b/Allura/allura/templates/repo/request_merge.html
@@ -29,5 +29,5 @@
 {% block header %}Request merge of {{c.app.config.options.mount_label}} {% endblock %}
 
 {% block content %}
-  {{ c.form.display(action='do_request_merge', value=dict(source_branch=source_branch))}}
+  {{ c.form.display(action='do_request_merge', value=dict(source_branch=source_branch, target_branch=target_branch))}}
 {% endblock %}