Show More
@@ -3,7 +3,7 b'' | |||||
3 | rhodecode.controllers.compare |
|
3 | rhodecode.controllers.compare | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 |
compare controller for pylons show |
|
6 | compare controller for pylons showing differences between two | |
7 | repos, branches, bookmarks or tips |
|
7 | repos, branches, bookmarks or tips | |
8 |
|
8 | |||
9 | :created_on: May 6, 2012 |
|
9 | :created_on: May 6, 2012 | |
@@ -89,7 +89,6 b' class CompareController(BaseRepoControll' | |||||
89 | org_ref = (org_ref_type, org_ref) |
|
89 | org_ref = (org_ref_type, org_ref) | |
90 | other_ref = (other_ref_type, other_ref) |
|
90 | other_ref = (other_ref_type, other_ref) | |
91 | other_repo = request.GET.get('repo', org_repo) |
|
91 | other_repo = request.GET.get('repo', org_repo) | |
92 | incoming_changesets = str2bool(request.GET.get('bundle', False)) |
|
|||
93 | c.fulldiff = fulldiff = request.GET.get('fulldiff') |
|
92 | c.fulldiff = fulldiff = request.GET.get('fulldiff') | |
94 | rev_start = request.GET.get('rev_start') |
|
93 | rev_start = request.GET.get('rev_start') | |
95 | rev_end = request.GET.get('rev_end') |
|
94 | rev_end = request.GET.get('rev_end') | |
@@ -97,8 +96,7 b' class CompareController(BaseRepoControll' | |||||
97 | c.swap_url = h.url('compare_url', repo_name=other_repo, |
|
96 | c.swap_url = h.url('compare_url', repo_name=other_repo, | |
98 | org_ref_type=other_ref[0], org_ref=other_ref[1], |
|
97 | org_ref_type=other_ref[0], org_ref=other_ref[1], | |
99 | other_ref_type=org_ref[0], other_ref=org_ref[1], |
|
98 | other_ref_type=org_ref[0], other_ref=org_ref[1], | |
100 |
repo=org_repo, as_form=request.GET.get('as_form') |
|
99 | repo=org_repo, as_form=request.GET.get('as_form')) | |
101 | bundle=incoming_changesets) |
|
|||
102 |
|
100 | |||
103 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
101 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) | |
104 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
|
102 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) | |
@@ -142,7 +140,7 b' class CompareController(BaseRepoControll' | |||||
142 | c.org_ref = org_ref[1] |
|
140 | c.org_ref = org_ref[1] | |
143 | c.other_ref = other_ref[1] |
|
141 | c.other_ref = other_ref[1] | |
144 |
|
142 | |||
145 |
if |
|
143 | if c.cs_ranges and c.org_repo != c.other_repo: | |
146 | # case we want a simple diff without incoming changesets, just |
|
144 | # case we want a simple diff without incoming changesets, just | |
147 | # for review purposes. Make the diff on the forked repo, with |
|
145 | # for review purposes. Make the diff on the forked repo, with | |
148 | # revision that is common ancestor |
|
146 | # revision that is common ancestor | |
@@ -155,8 +153,7 b' class CompareController(BaseRepoControll' | |||||
155 |
|
153 | |||
156 | diff_limit = self.cut_off_limit if not fulldiff else None |
|
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 |
|
156 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) | |
159 | remote_compare=incoming_changesets) |
|
|||
160 |
|
157 | |||
161 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', |
|
158 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', | |
162 | diff_limit=diff_limit) |
|
159 | diff_limit=diff_limit) |
@@ -28,23 +28,15 b'' | |||||
28 | import re |
|
28 | import re | |
29 | import difflib |
|
29 | import difflib | |
30 | import logging |
|
30 | import logging | |
31 | import traceback |
|
|||
32 |
|
31 | |||
33 | from itertools import tee, imap |
|
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 | from pylons.i18n.translation import _ |
|
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 | from rhodecode.lib.vcs.exceptions import VCSError |
|
36 | from rhodecode.lib.vcs.exceptions import VCSError | |
44 | from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode |
|
37 | from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode | |
45 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
38 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |
46 | from rhodecode.lib.helpers import escape |
|
39 | from rhodecode.lib.helpers import escape | |
47 | from rhodecode.lib.utils import make_ui |
|
|||
48 | from rhodecode.lib.utils2 import safe_unicode |
|
40 | from rhodecode.lib.utils2 import safe_unicode | |
49 |
|
41 | |||
50 | log = logging.getLogger(__name__) |
|
42 | log = logging.getLogger(__name__) | |
@@ -692,20 +684,8 b' class DiffProcessor(object):' | |||||
692 | return self.adds, self.removes |
|
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 | def differ(org_repo, org_ref, other_repo, other_ref, |
|
687 | def differ(org_repo, org_ref, other_repo, other_ref, | |
708 |
|
|
688 | context=3, ignore_whitespace=False): | |
709 | """ |
|
689 | """ | |
710 | General differ between branches, bookmarks, revisions of two remote or |
|
690 | General differ between branches, bookmarks, revisions of two remote or | |
711 | local but related repositories |
|
691 | local but related repositories | |
@@ -733,37 +713,4 b' def differ(org_repo, org_ref, other_repo' | |||||
733 | ignore_whitespace=ignore_whitespace, context=context) |
|
713 | ignore_whitespace=ignore_whitespace, context=context) | |
734 | return _diff |
|
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 | return '' |
|
716 | return '' |
@@ -143,7 +143,7 b'' | |||||
143 | org_ref_type='org_ref_type', org_ref='org_ref', |
|
143 | org_ref_type='org_ref_type', org_ref='org_ref', | |
144 | other_ref_type='other_ref_type', other_ref='other_ref', |
|
144 | other_ref_type='other_ref_type', other_ref='other_ref', | |
145 | repo='other_repo', |
|
145 | repo='other_repo', | |
146 |
as_form=True, |
|
146 | as_form=True, | |
147 | rev_start=request.GET.get('rev_start',''), |
|
147 | rev_start=request.GET.get('rev_start',''), | |
148 | rev_end=request.GET.get('rev_end',''))}"; |
|
148 | rev_end=request.GET.get('rev_end',''))}"; | |
149 |
|
149 |
@@ -54,7 +54,6 b' class TestCompareController(TestControll' | |||||
54 | org_ref=tag1, |
|
54 | org_ref=tag1, | |
55 | other_ref_type="tag", |
|
55 | other_ref_type="tag", | |
56 | other_ref=tag2, |
|
56 | other_ref=tag2, | |
57 | bundle=False |
|
|||
58 | )) |
|
57 | )) | |
59 | response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2)) |
|
58 | response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2)) | |
60 |
|
59 |
General Comments 0
You need to be logged in to leave comments.
Login now