Changeset - 70309536c143
[Not reviewed]
beta
0 4 0
Mads Kiilerich - 13 years ago 2013-01-31 23:27:21
madski@unity3d.com
compare and diff: remove unused "bundle" functionality

The 'bundle' parameter was never set, incoming_changesets was thus always
False, remote_compare was thus always False, and InMemoryBundleRepo and
bundlerepo was neverused.
4 files changed with 6 insertions and 63 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
"""
 
    rhodecode.controllers.compare
 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
    compare controller for pylons showoing differences between two
 
    compare controller for pylons showing differences between two
 
    repos, branches, bookmarks or tips
 

	
 
    :created_on: May 6, 2012
 
    :author: marcink
 
    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
 
    :license: GPLv3, see COPYING for more details.
 
@@ -86,22 +86,20 @@ class CompareController(BaseRepoControll
 
    def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
 

	
 
        org_repo = c.rhodecode_db_repo.repo_name
 
        org_ref = (org_ref_type, org_ref)
 
        other_ref = (other_ref_type, other_ref)
 
        other_repo = request.GET.get('repo', org_repo)
 
        incoming_changesets = str2bool(request.GET.get('bundle', False))
 
        c.fulldiff = fulldiff = request.GET.get('fulldiff')
 
        rev_start = request.GET.get('rev_start')
 
        rev_end = request.GET.get('rev_end')
 

	
 
        c.swap_url = h.url('compare_url', repo_name=other_repo,
 
              org_ref_type=other_ref[0], org_ref=other_ref[1],
 
              other_ref_type=org_ref[0], other_ref=org_ref[1],
 
              repo=org_repo, as_form=request.GET.get('as_form'),
 
              bundle=incoming_changesets)
 
              repo=org_repo, as_form=request.GET.get('as_form'))
 

	
 
        c.org_repo = org_repo = Repository.get_by_repo_name(org_repo)
 
        c.other_repo = other_repo = Repository.get_by_repo_name(other_repo)
 

	
 
        if c.org_repo is None:
 
            log.error('Could not find org repo %s' % org_repo)
 
@@ -139,27 +137,26 @@ class CompareController(BaseRepoControll
 
        if partial:
 
            return render('compare/compare_cs.html')
 

	
 
        c.org_ref = org_ref[1]
 
        c.other_ref = other_ref[1]
 

	
 
        if not incoming_changesets and c.cs_ranges and c.org_repo != c.other_repo:
 
        if c.cs_ranges and c.org_repo != c.other_repo:
 
            # 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
 
            _org_ref = org_ref
 
            org_ref = ('rev', getattr(c.cs_ranges[0].parents[0]
 
                                      if c.cs_ranges[0].parents
 
                                      else EmptyChangeset(), 'raw_id'))
 
            log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref))
 
            other_repo = org_repo
 

	
 
        diff_limit = self.cut_off_limit if not fulldiff else None
 

	
 
        _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref,
 
                             remote_compare=incoming_changesets)
 
        _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref)
 

	
 
        diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
 
                                             diff_limit=diff_limit)
 
        _parsed = diff_processor.prepare()
 

	
 
        c.limited_diff = False
rhodecode/lib/diffs.py
Show inline comments
 
@@ -25,29 +25,21 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import re
 
import difflib
 
import logging
 
import traceback
 

	
 
from itertools import tee, imap
 

	
 
from mercurial import patch
 
from mercurial.mdiff import diffopts
 
from mercurial.bundlerepo import bundlerepository
 

	
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.lib.compat import BytesIO
 
from rhodecode.lib.vcs.utils.hgcompat import localrepo
 
from rhodecode.lib.vcs.exceptions import VCSError
 
from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 
from rhodecode.lib.helpers import escape
 
from rhodecode.lib.utils import make_ui
 
from rhodecode.lib.utils2 import safe_unicode
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def wrap_to_table(str_):
 
@@ -689,26 +681,14 @@ class DiffProcessor(object):
 
        """
 
        Returns tuple of added, and removed lines for this instance
 
        """
 
        return self.adds, self.removes
 

	
 

	
 
class InMemoryBundleRepo(bundlerepository):
 
    def __init__(self, ui, path, bundlestream):
 
        self._tempparent = None
 
        localrepo.localrepository.__init__(self, ui, path)
 
        self.ui.setconfig('phases', 'publish', False)
 

	
 
        self.bundle = bundlestream
 

	
 
        # dict with the mapping 'filename' -> position in the bundle
 
        self.bundlefilespos = {}
 

	
 

	
 
def differ(org_repo, org_ref, other_repo, other_ref,
 
           remote_compare=False, context=3, ignore_whitespace=False):
 
           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:
 
@@ -730,40 +710,7 @@ def differ(org_repo, org_ref, other_repo
 
        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
 

	
 
    elif remote_compare:
 
        opts = diffopts(git=True, ignorews=ignore_whitespace, context=context)
 
        org_repo_peer = localrepo.locallegacypeer(org_repo.local())
 
        # create a bundle (uncompressed if other repo is not local)
 
        if org_repo_peer.capable('getbundle'):
 
            # disable repo hooks here since it's just bundle !
 
            # patch and reset hooks section of UI config to not run any
 
            # hooks on fetching archives with subrepos
 
            for k, _ in org_repo.ui.configitems('hooks'):
 
                org_repo.ui.setconfig('hooks', k, None)
 
            unbundle = org_repo.getbundle('incoming', common=None,
 
                                          heads=None)
 

	
 
            buf = BytesIO()
 
            while True:
 
                chunk = unbundle._stream.read(1024 * 4)
 
                if not chunk:
 
                    break
 
                buf.write(chunk)
 

	
 
            buf.seek(0)
 
            # replace chunked _stream with data that can do tell() and seek()
 
            unbundle._stream = buf
 

	
 
            ui = make_ui('db')
 
            bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root,
 
                                            bundlestream=unbundle)
 

	
 
            return ''.join(patch.diff(bundlerepo,
 
                                      node1=other_repo[other_ref].node(),
 
                                      node2=org_repo[org_ref].node(),
 
                                      opts=opts))
 

	
 
    return ''
rhodecode/templates/pullrequests/pullrequest.html
Show inline comments
 
@@ -140,13 +140,13 @@
 
      YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none');
 
      var url = "${h.url('compare_url',
 
                         repo_name='org_repo',
 
                         org_ref_type='org_ref_type', org_ref='org_ref',
 
                         other_ref_type='other_ref_type', other_ref='other_ref',
 
                         repo='other_repo',
 
                         as_form=True, bundle=False,
 
                         as_form=True,
 
                         rev_start=request.GET.get('rev_start',''),
 
                         rev_end=request.GET.get('rev_end',''))}";
 

	
 
      var select_refs = YUQ('#pull_request_form select.refs')
 
      var rev_data = {}; // gather the org/other ref and repo here
 
      for(var i=0;i<select_refs.length;i++){
rhodecode/tests/functional/test_compare_local.py
Show inline comments
 
@@ -51,13 +51,12 @@ class TestCompareController(TestControll
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=GIT_REPO,
 
                                    org_ref_type="tag",
 
                                    org_ref=tag1,
 
                                    other_ref_type="tag",
 
                                    other_ref=tag2,
 
                                    bundle=False
 
                                    ))
 
        response.mustcontain('%s@%s -&gt; %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2))
 

	
 
        ## outgoing changesets between tags
 
        response.mustcontain('''<a href="/%s/changeset/794bbdd31545c199f74912709ea350dedcd189a2">r113:794bbdd31545</a>''' % GIT_REPO)
 
        response.mustcontain('''<a href="/%s/changeset/e36d8c5025329bdd4212bd53d4ed8a70ff44985f">r115:e36d8c502532</a>''' % GIT_REPO)
0 comments (0 inline, 0 general)