changeset 4844:556e98fd06d2

pullrequests on different repos: default to same destination/source branch When a pull request is initiated between two different repositories, instead of using the current tip as destination branch, use the same branch as on the source repository.
author Thomas De Schampheleire <thomas.de_schampheleire@alcatel-lucent.com>
date Mon, 23 Feb 2015 21:43:45 +0100
parents 880084c63e52
children 3a3ec35466e7
files kallithea/controllers/pullrequests.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Thu Feb 19 22:46:14 2015 +0100
+++ b/kallithea/controllers/pullrequests.py	Mon Feb 23 21:43:45 2015 +0100
@@ -130,7 +130,7 @@
                 selected = n
                 branch = None
             if branch:
-                log.error('branch %r not found in %s', branch, repo)
+                log.debug('branch %r not found in %s', branch, repo)
 
         bookmarks = []
         for bookmark, bookmarkrev in repo.bookmarks.iteritems():
@@ -263,14 +263,21 @@
         c.default_cs_repo = org_repo.repo_name
         c.cs_refs, c.default_cs_ref = self._get_repo_refs(org_scm_instance, rev=org_rev, branch=branch)
 
+        default_cs_ref_type, default_cs_branch, default_cs_rev = c.default_cs_ref.split(':')
+        if default_cs_ref_type != 'branch':
+            default_cs_branch = org_repo.get_changeset(default_cs_rev).branch
+
         # add org repo to other so we can open pull request against peer branches on itself
         c.a_repos = [(org_repo.repo_name, '%s (self)' % org_repo.repo_name)]
 
-        # add parent of this fork also and select it
         if org_repo.parent:
+            # add parent of this fork also and select it.
+            # use the same branch on destination as on source, if available.
             c.a_repos.append((org_repo.parent.repo_name, '%s (parent)' % org_repo.parent.repo_name))
             c.a_repo = org_repo.parent
-            c.a_refs, c.default_a_ref = self._get_repo_refs(org_repo.parent.scm_instance)
+            c.a_refs, c.default_a_ref = self._get_repo_refs(
+                    org_repo.parent.scm_instance, branch=default_cs_branch)
+
         else:
             c.a_repo = org_repo
             c.a_refs, c.default_a_ref = self._get_repo_refs(org_scm_instance) # without rev and branch