Show More
@@ -3,7 +3,7 b'' | |||
|
3 | 3 | rhodecode.controllers.compare |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 |
compare controller for pylons show |
|
|
6 | compare controller for pylons showing differences between two | |
|
7 | 7 | repos, branches, bookmarks or tips |
|
8 | 8 | |
|
9 | 9 | :created_on: May 6, 2012 |
@@ -89,7 +89,6 b' class CompareController(BaseRepoControll' | |||
|
89 | 89 | org_ref = (org_ref_type, org_ref) |
|
90 | 90 | other_ref = (other_ref_type, other_ref) |
|
91 | 91 | other_repo = request.GET.get('repo', org_repo) |
|
92 | incoming_changesets = str2bool(request.GET.get('bundle', False)) | |
|
93 | 92 | c.fulldiff = fulldiff = request.GET.get('fulldiff') |
|
94 | 93 | rev_start = request.GET.get('rev_start') |
|
95 | 94 | rev_end = request.GET.get('rev_end') |
@@ -97,8 +96,7 b' class CompareController(BaseRepoControll' | |||
|
97 | 96 | c.swap_url = h.url('compare_url', repo_name=other_repo, |
|
98 | 97 | org_ref_type=other_ref[0], org_ref=other_ref[1], |
|
99 | 98 | other_ref_type=org_ref[0], other_ref=org_ref[1], |
|
100 |
repo=org_repo, as_form=request.GET.get('as_form') |
|
|
101 | bundle=incoming_changesets) | |
|
99 | repo=org_repo, as_form=request.GET.get('as_form')) | |
|
102 | 100 | |
|
103 | 101 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
104 | 102 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
@@ -142,7 +140,7 b' class CompareController(BaseRepoControll' | |||
|
142 | 140 | c.org_ref = org_ref[1] |
|
143 | 141 | c.other_ref = other_ref[1] |
|
144 | 142 | |
|
145 |
if |
|
|
143 | if c.cs_ranges and c.org_repo != c.other_repo: | |
|
146 | 144 | # case we want a simple diff without incoming changesets, just |
|
147 | 145 | # for review purposes. Make the diff on the forked repo, with |
|
148 | 146 | # revision that is common ancestor |
@@ -155,8 +153,7 b' class CompareController(BaseRepoControll' | |||
|
155 | 153 | |
|
156 | 154 | diff_limit = self.cut_off_limit if not fulldiff else None |
|
157 | 155 | |
|
158 |
_diff = diffs.differ(org_repo, org_ref, other_repo, other_ref |
|
|
159 | remote_compare=incoming_changesets) | |
|
156 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) | |
|
160 | 157 | |
|
161 | 158 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', |
|
162 | 159 | diff_limit=diff_limit) |
@@ -28,23 +28,15 b'' | |||
|
28 | 28 | import re |
|
29 | 29 | import difflib |
|
30 | 30 | import logging |
|
31 | import traceback | |
|
32 | 31 | |
|
33 | 32 | from itertools import tee, imap |
|
34 | 33 | |
|
35 | from mercurial import patch | |
|
36 | from mercurial.mdiff import diffopts | |
|
37 | from mercurial.bundlerepo import bundlerepository | |
|
38 | ||
|
39 | 34 | from pylons.i18n.translation import _ |
|
40 | 35 | |
|
41 | from rhodecode.lib.compat import BytesIO | |
|
42 | from rhodecode.lib.vcs.utils.hgcompat import localrepo | |
|
43 | 36 | from rhodecode.lib.vcs.exceptions import VCSError |
|
44 | 37 | from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode |
|
45 | 38 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
46 | 39 | from rhodecode.lib.helpers import escape |
|
47 | from rhodecode.lib.utils import make_ui | |
|
48 | 40 | from rhodecode.lib.utils2 import safe_unicode |
|
49 | 41 | |
|
50 | 42 | log = logging.getLogger(__name__) |
@@ -692,20 +684,8 b' class DiffProcessor(object):' | |||
|
692 | 684 | return self.adds, self.removes |
|
693 | 685 | |
|
694 | 686 | |
|
695 | class InMemoryBundleRepo(bundlerepository): | |
|
696 | def __init__(self, ui, path, bundlestream): | |
|
697 | self._tempparent = None | |
|
698 | localrepo.localrepository.__init__(self, ui, path) | |
|
699 | self.ui.setconfig('phases', 'publish', False) | |
|
700 | ||
|
701 | self.bundle = bundlestream | |
|
702 | ||
|
703 | # dict with the mapping 'filename' -> position in the bundle | |
|
704 | self.bundlefilespos = {} | |
|
705 | ||
|
706 | ||
|
707 | 687 | def differ(org_repo, org_ref, other_repo, other_ref, |
|
708 |
|
|
|
688 | context=3, ignore_whitespace=False): | |
|
709 | 689 | """ |
|
710 | 690 | General differ between branches, bookmarks, revisions of two remote or |
|
711 | 691 | local but related repositories |
@@ -733,37 +713,4 b' def differ(org_repo, org_ref, other_repo' | |||
|
733 | 713 | ignore_whitespace=ignore_whitespace, context=context) |
|
734 | 714 | return _diff |
|
735 | 715 | |
|
736 | elif remote_compare: | |
|
737 | opts = diffopts(git=True, ignorews=ignore_whitespace, context=context) | |
|
738 | org_repo_peer = localrepo.locallegacypeer(org_repo.local()) | |
|
739 | # create a bundle (uncompressed if other repo is not local) | |
|
740 | if org_repo_peer.capable('getbundle'): | |
|
741 | # disable repo hooks here since it's just bundle ! | |
|
742 | # patch and reset hooks section of UI config to not run any | |
|
743 | # hooks on fetching archives with subrepos | |
|
744 | for k, _ in org_repo.ui.configitems('hooks'): | |
|
745 | org_repo.ui.setconfig('hooks', k, None) | |
|
746 | unbundle = org_repo.getbundle('incoming', common=None, | |
|
747 | heads=None) | |
|
748 | ||
|
749 | buf = BytesIO() | |
|
750 | while True: | |
|
751 | chunk = unbundle._stream.read(1024 * 4) | |
|
752 | if not chunk: | |
|
753 | break | |
|
754 | buf.write(chunk) | |
|
755 | ||
|
756 | buf.seek(0) | |
|
757 | # replace chunked _stream with data that can do tell() and seek() | |
|
758 | unbundle._stream = buf | |
|
759 | ||
|
760 | ui = make_ui('db') | |
|
761 | bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root, | |
|
762 | bundlestream=unbundle) | |
|
763 | ||
|
764 | return ''.join(patch.diff(bundlerepo, | |
|
765 | node1=other_repo[other_ref].node(), | |
|
766 | node2=org_repo[org_ref].node(), | |
|
767 | opts=opts)) | |
|
768 | ||
|
769 | 716 | return '' |
@@ -143,7 +143,7 b'' | |||
|
143 | 143 | org_ref_type='org_ref_type', org_ref='org_ref', |
|
144 | 144 | other_ref_type='other_ref_type', other_ref='other_ref', |
|
145 | 145 | repo='other_repo', |
|
146 |
as_form=True, |
|
|
146 | as_form=True, | |
|
147 | 147 | rev_start=request.GET.get('rev_start',''), |
|
148 | 148 | rev_end=request.GET.get('rev_end',''))}"; |
|
149 | 149 |
General Comments 0
You need to be logged in to leave comments.
Login now