diff rhodecode/lib/diffs.py @ 2892:5fba3778431c beta

#590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs, That are far better for doing code reviews. The /compare url still uses bundle compare for full comparision including the incoming changesets. - Fixed tests
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 03 Oct 2012 18:41:57 +0200
parents ab75def5c15d
children e46d0a90556e
line wrap: on
line diff
--- a/rhodecode/lib/diffs.py	Tue Oct 02 23:24:41 2012 +0200
+++ b/rhodecode/lib/diffs.py	Wed Oct 03 18:41:57 2012 +0200
@@ -28,6 +28,7 @@
 import re
 import difflib
 import markupsafe
+import logging
 
 from itertools import tee, imap
 
@@ -46,6 +47,8 @@
 from rhodecode.lib.utils import make_ui
 from rhodecode.lib.utils2 import safe_unicode
 
+log = logging.getLogger(__name__)
+
 
 def wrap_to_table(str_):
     return '''<table class="code-difftable">
@@ -574,7 +577,8 @@
         self.bundlefilespos = {}
 
 
-def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None):
+def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None,
+           bundle_compare=False):
     """
     General differ between branches, bookmarks or separate but releated
     repositories
@@ -598,7 +602,7 @@
     org_ref = org_ref[1]
     other_ref = other_ref[1]
 
-    if org_repo != other_repo:
+    if org_repo != other_repo and bundle_compare:
 
         common, incoming, rheads = discovery_data
         other_repo_peer = localrepo.locallegacypeer(other_repo.local())
@@ -633,5 +637,7 @@
                                   node2=other_repo[other_ref].node(),
                                   opts=opts))
     else:
+        log.debug('running diff between %s@%s and %s@%s'
+                  % (org_repo, org_ref, other_repo, other_ref))
         return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref,
                                   opts=opts))