Changeset - b2575bdb847c
[Not reviewed]
beta
0 3 0
Mads Kiilerich - 13 years ago 2013-04-05 00:40:58
madski@unity3d.com
Grafted from: 51fbd52fbc58
diffs: drop diffs.differ

This function did not really add any value, it was yet another layer that was
hiding the bug that we use ref[1] without ref[0], and it had this strange
undefined behaviour for diffing across repos.

Inlining the call to .get_diff do not make the code more complex but makes it
more obvious what is going on so it can be cleaned up later.
3 files changed with 9 insertions and 35 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
@@ -161,7 +161,10 @@ class CompareController(BaseRepoControll
 

	
 
        diff_limit = self.cut_off_limit if not c.fulldiff else None
 

	
 
        _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref)
 
        log.debug('running diff between %s@%s and %s@%s'
 
                  % (org_repo.scm_instance.path, org_ref,
 
                     other_repo.scm_instance.path, other_ref))
 
        _diff = org_repo.scm_instance.get_diff(rev1=safe_str(org_ref[1]), rev2=safe_str(other_ref[1]))
 

	
 
        diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
rhodecode/controllers/pullrequests.py
Show inline comments
 
@@ -42,6 +42,7 @@ from rhodecode.lib.helpers import Page
 
from rhodecode.lib import helpers as h
 
from rhodecode.lib import diffs
 
from rhodecode.lib.utils import action_logger, jsonify
 
from rhodecode.lib.vcs.utils import safe_str
 
from rhodecode.lib.vcs.exceptions import EmptyRepositoryError
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
from rhodecode.lib.diffs import LimitedDiffContainer
 
@@ -328,7 +329,10 @@ class PullrequestsController(BaseRepoCon
 
        diff_limit = self.cut_off_limit if not fulldiff else None
 

	
 
        #we swap org/other ref since we run a simple diff on one repo
 
        _diff = diffs.differ(org_repo, other_ref, other_repo, org_ref)
 
        log.debug('running diff between %s@%s and %s@%s'
 
                  % (org_repo.scm_instance.path, org_ref,
 
                     other_repo.scm_instance.path, other_ref))
 
        _diff = org_repo.scm_instance.get_diff(rev1=safe_str(org_ref[1]), rev2=safe_str(other_ref[1]))
 

	
 
        diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
rhodecode/lib/diffs.py
Show inline comments
 
@@ -682,36 +682,3 @@ class DiffProcessor(object):
 
        Returns tuple of added, and removed lines for this instance
 
        """
 
        return self.adds, self.removes
 

	
 

	
 
def differ(org_repo, org_ref, other_repo, other_ref,
 
           context=3, ignore_whitespace=False):
 
    """
 
    General differ between branches, bookmarks, revisions of two remote or
 
    local but related repositories
 

	
 
    :param org_repo:
 
    :param org_ref:
 
    :param other_repo:
 
    :type other_repo:
 
    :type other_ref:
 
    """
 

	
 
    org_repo_scm = org_repo.scm_instance
 
    other_repo_scm = other_repo.scm_instance
 

	
 
    org_repo = org_repo_scm._repo
 
    other_repo = other_repo_scm._repo
 

	
 
    org_ref = safe_str(org_ref[1])
 
    other_ref = safe_str(other_ref[1])
 

	
 
    if org_repo_scm == other_repo_scm:
 
        log.debug('running diff between %s@%s and %s@%s'
 
                  % (org_repo.path, org_ref,
 
                     other_repo.path, other_ref))
 
        _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref,
 
            ignore_whitespace=ignore_whitespace, context=context)
 
        return _diff
 

	
 
    return '' # FIXME: when is it ever relevant to return nothing?
0 comments (0 inline, 0 general)