diff rhodecode/controllers/pullrequests.py @ 3015:16af24982e30 beta

Multiple changes for compare system - count number of changed lines and files - add combined compare button into the old per changeset compare - fixed some logic for remote & bundle compare system - added few tests for git compare
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 18 Nov 2012 23:17:02 +0100
parents 32471bd1f4ee
children c2a206162062
line wrap: on
line diff
--- a/rhodecode/controllers/pullrequests.py	Sun Nov 18 21:27:41 2012 +0100
+++ b/rhodecode/controllers/pullrequests.py	Sun Nov 18 23:17:02 2012 +0100
@@ -51,6 +51,7 @@
 from rhodecode.model.changeset_status import ChangesetStatusModel
 from rhodecode.model.forms import PullRequestForm
 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
+from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
 log = logging.getLogger(__name__)
 
@@ -277,7 +278,9 @@
             # case we want a simple diff without incoming changesets, just
             # for review purposes. Make the diff on the forked repo, with
             # revision that is common ancestor
-            other_ref = ('rev', c.cs_ranges[-1].parents[0].raw_id)
+            other_ref = ('rev', getattr(c.cs_ranges[-1].parents[0]
+                                        if c.cs_ranges[-1].parents
+                                        else EmptyChangeset(), 'raw_id'))
             other_repo = org_repo
 
         c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges])
@@ -286,9 +289,9 @@
 
         c.org_ref = org_ref[1]
         c.other_ref = other_ref[1]
-        # diff needs to have swapped org with other to generate proper diff
-        _diff = diffs.differ(other_repo, other_ref, org_repo, org_ref,
+        _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref,
                              discovery_data)
+
         diff_processor = diffs.DiffProcessor(_diff, format='gitdiff')
         _parsed = diff_processor.prepare()