0e1913c
From 86475179c6ec5450c3039c7b1296c0b780e2e705 Mon Sep 17 00:00:00 2001
0e1913c
From: Stephen Gallagher <sgallagh@redhat.com>
0e1913c
Date: Wed, 14 May 2014 12:35:31 -0400
0e1913c
Subject: [PATCH 8/8] Properly generate parent diffs in git
0e1913c
0e1913c
The old behavior was to only populate the 'parent_base' attribute
0e1913c
if the 'base' of the review range did not show up with
0e1913c
git branch -r --contains <base>
0e1913c
0e1913c
This fails for many common environments (such as having pushed to
0e1913c
your private github repository prior to posting the review).
0e1913c
Presumably, the assumption that was made is that if the base is
0e1913c
present on a remote branch, it must be already available to
0e1913c
Review Board. With distributed version-control systems, this is
0e1913c
not a safe assumption to make.
0e1913c
0e1913c
With this change, we will always look up the merge base and
0e1913c
compare it to the review base. If they are different, we will pass
0e1913c
along the parent_base so that the parent diff can be generated
0e1913c
correctly.
0e1913c
---
0e1913c
 rbtools/clients/git.py | 9 ++++-----
0e1913c
 1 file changed, 4 insertions(+), 5 deletions(-)
0e1913c
0e1913c
diff --git a/rbtools/clients/git.py b/rbtools/clients/git.py
0e1913c
index 570ebd9aafecc9cff9ed8739d2d9bfa06bea243f..fee8b873ee16a1127e70c0678ef27b0f015d2f83 100644
0e1913c
--- a/rbtools/clients/git.py
0e1913c
+++ b/rbtools/clients/git.py
0e1913c
@@ -130,11 +130,10 @@ class GitClient(SCMClient):
0e1913c
                 raise InvalidRevisionSpecError(
0e1913c
                     'Unexpected result while parsing revision spec')
0e1913c
 
0e1913c
-            pdiff_required = not execute(
0e1913c
-                [self.git, 'branch', '-r', '--contains', result['base']])
0e1913c
-            if pdiff_required:
0e1913c
-                result['parent_base'] = self._get_merge_base(result['base'],
0e1913c
-                                                             self.upstream_branch)
0e1913c
+            parent_base = self._get_merge_base(result['base'],
0e1913c
+                                               self.upstream_branch)
0e1913c
+            if not parent_base == result['base']:
0e1913c
+                result['parent_base'] = parent_base
0e1913c
         else:
0e1913c
             raise TooManyRevisionsError
0e1913c
 
0e1913c
-- 
0e1913c
1.9.0
0e1913c