Changeset - 2d35bbff7c35
[Not reviewed]
codereview
0 1 0
Marcin Kuzminski - 14 years ago 2012-05-08 02:10:49
marcin@python-works.com
simplified compare url logic for outside repos
1 file changed with 3 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
@@ -39,44 +39,41 @@ log = logging.getLogger(__name__)
 
class CompareController(BaseRepoController):
 

	
 
    @LoginRequired()
 
    @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(CompareController, self).__before__()
 

	
 
    def _handle_ref(self, ref):
 
        """
 
        Parse the org...other string
 
        Possible formats are `(branch|book|tag):<name>...(branch|book|tag):<othername>`
 
        or using a repo <empty>...(repo:</rhodecode/path/to/other)
 

	
 

	
 
        :param ref: <orginal_reference>...<other_reference>
 
        :type ref: str
 
        """
 
        org_repo = c.rhodecode_repo.name
 

	
 
        def org_parser(org):
 
            _repo = org_repo
 
            name, val = org.split(':')
 
            return _repo, (name, val)
 

	
 
        def other_parser(other):
 
            _other_repo = request.GET.get('repo')
 
            _repo = org_repo
 
            name, val = other.split(':')
 
            if 'repo' in other:
 
                _repo = val
 
                name = 'branch'
 
                val = c.rhodecode_repo.DEFAULT_BRANCH_NAME
 
            if _other_repo:
 
                _repo = _other_repo #TODO: do an actual repo loookup within rhodecode
 

	
 
            return _repo, (name, val)
 

	
 
        if '...' in ref:
 
            try:
 
                org, other = ref.split('...')
 
                org_repo, org_ref = org_parser(org)
 
                other_repo, other_ref = other_parser(other)
 
                return org_repo, org_ref, other_repo, other_ref
 
            except:
 
                log.error(traceback.format_exc())
 

	
0 comments (0 inline, 0 general)