Show More
@@ -58,7 +58,7 b' class CompareController(BaseRepoControll' | |||
|
58 | 58 | :param ref: <orginal_reference>...<other_reference> |
|
59 | 59 | :type ref: str |
|
60 | 60 | """ |
|
61 | org_repo = c.rhodecode_repo.name | |
|
61 | org_repo = c.rhodecode_db_repo.repo_name | |
|
62 | 62 | |
|
63 | 63 | def org_parser(org): |
|
64 | 64 | _repo = org_repo |
@@ -70,7 +70,6 b' class CompareController(BaseRepoControll' | |||
|
70 | 70 | _repo = org_repo |
|
71 | 71 | name, val = other.split(':') |
|
72 | 72 | if _other_repo: |
|
73 | #TODO: do an actual repo loookup within rhodecode | |
|
74 | 73 | _repo = _other_repo |
|
75 | 74 | |
|
76 | 75 | return _repo, (name, val) |
@@ -86,14 +85,19 b' class CompareController(BaseRepoControll' | |||
|
86 | 85 | |
|
87 | 86 | raise HTTPNotFound |
|
88 | 87 | |
|
89 | def _get_discovery(self,org_repo, org_ref, other_repo, other_ref): | |
|
88 | def _get_discovery(self, org_repo, org_ref, other_repo, other_ref): | |
|
90 | 89 | from mercurial import discovery |
|
91 | 90 | other = org_repo._repo |
|
92 | 91 | repo = other_repo._repo |
|
92 | tip = other[org_ref[1]] | |
|
93 | log.debug('Doing discovery for %s@%s vs %s@%s' % ( | |
|
94 | org_repo, org_ref, other_repo, other_ref) | |
|
95 | ) | |
|
96 | log.debug('Filter heads are %s[%s]' % (tip, org_ref[1])) | |
|
93 | 97 | tmp = discovery.findcommonincoming( |
|
94 | 98 | repo=repo, # other_repo we check for incoming |
|
95 | 99 | remote=other, # org_repo source for incoming |
|
96 |
heads=[ |
|
|
100 | heads=[tip.node()], | |
|
97 | 101 | force=False |
|
98 | 102 | ) |
|
99 | 103 | return tmp |
@@ -123,13 +127,19 b' class CompareController(BaseRepoControll' | |||
|
123 | 127 | |
|
124 | 128 | def index(self, ref): |
|
125 | 129 | org_repo, org_ref, other_repo, other_ref = self._handle_ref(ref) |
|
130 | ||
|
126 | 131 | c.swap_url = h.url('compare_home', repo_name=other_repo, |
|
127 | 132 | ref='%s...%s' % (':'.join(other_ref), |
|
128 | 133 | ':'.join(org_ref)), |
|
129 | 134 | repo=org_repo) |
|
130 | 135 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
131 | 136 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
|
132 | tmp = self._get_discovery(org_repo.scm_instance, | |
|
137 | ||
|
138 | if c.org_repo is None or c.other_repo is None: | |
|
139 | log.error('Could not found repo %s or %s' % (org_repo, other_repo)) | |
|
140 | raise HTTPNotFound | |
|
141 | ||
|
142 | discovery_data = self._get_discovery(org_repo.scm_instance, | |
|
133 | 143 | org_ref, |
|
134 | 144 | other_repo.scm_instance, |
|
135 | 145 | other_ref) |
@@ -137,12 +147,13 b' class CompareController(BaseRepoControll' | |||
|
137 | 147 | org_ref, |
|
138 | 148 | other_repo.scm_instance, |
|
139 | 149 | other_ref, |
|
140 |
|
|
|
150 | discovery_data) | |
|
141 | 151 | |
|
142 | 152 | c.org_ref = org_ref[1] |
|
143 | 153 | c.other_ref = other_ref[1] |
|
144 | 154 | # diff needs to have swapped org with other to generate proper diff |
|
145 |
_diff = diffs.differ(other_repo, other_ref, org_repo, org_ref, |
|
|
155 | _diff = diffs.differ(other_repo, other_ref, org_repo, org_ref, | |
|
156 | discovery_data) | |
|
146 | 157 | diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') |
|
147 | 158 | _parsed = diff_processor.prepare() |
|
148 | 159 |
@@ -546,6 +546,18 b' class DiffProcessor(object):' | |||
|
546 | 546 | return self.adds, self.removes |
|
547 | 547 | |
|
548 | 548 | |
|
549 | class InMemoryBundleRepo(bundlerepository): | |
|
550 | def __init__(self, ui, path, bundlestream): | |
|
551 | self._tempparent = None | |
|
552 | localrepo.localrepository.__init__(self, ui, path) | |
|
553 | self.ui.setconfig('phases', 'publish', False) | |
|
554 | ||
|
555 | self.bundle = bundlestream | |
|
556 | ||
|
557 | # dict with the mapping 'filename' -> position in the bundle | |
|
558 | self.bundlefilespos = {} | |
|
559 | ||
|
560 | ||
|
549 | 561 | def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None): |
|
550 | 562 | """ |
|
551 | 563 | General differ between branches, bookmarks or separate but releated |
@@ -561,7 +573,7 b' def differ(org_repo, org_ref, other_repo' | |||
|
561 | 573 | :type other_ref: |
|
562 | 574 | """ |
|
563 | 575 | |
|
564 | ignore_whitespace = False | |
|
576 | bundlerepo = ignore_whitespace = False | |
|
565 | 577 | context = 3 |
|
566 | 578 | org_repo = org_repo.scm_instance._repo |
|
567 | 579 | other_repo = other_repo.scm_instance._repo |
@@ -572,8 +584,9 b' def differ(org_repo, org_ref, other_repo' | |||
|
572 | 584 | if org_repo != other_repo: |
|
573 | 585 | |
|
574 | 586 | common, incoming, rheads = discovery_data |
|
587 | ||
|
575 | 588 | # create a bundle (uncompressed if other repo is not local) |
|
576 | if other_repo.capable('getbundle'): | |
|
589 | if other_repo.capable('getbundle') and incoming: | |
|
577 | 590 | # disable repo hooks here since it's just bundle ! |
|
578 | 591 | # patch and reset hooks section of UI config to not run any |
|
579 | 592 | # hooks on fetching archives with subrepos |
@@ -593,22 +606,10 b' def differ(org_repo, org_ref, other_repo' | |||
|
593 | 606 | buf.seek(0) |
|
594 | 607 | unbundle._stream = buf |
|
595 | 608 | |
|
596 | class InMemoryBundleRepo(bundlerepository): | |
|
597 | def __init__(self, ui, path, bundlestream): | |
|
598 | self._tempparent = None | |
|
599 | localrepo.localrepository.__init__(self, ui, path) | |
|
600 | self.ui.setconfig('phases', 'publish', False) | |
|
601 | ||
|
602 | self.bundle = bundlestream | |
|
603 | ||
|
604 | # dict with the mapping 'filename' -> position in the bundle | |
|
605 | self.bundlefilespos = {} | |
|
606 | ||
|
607 | ui = make_ui('db') | |
|
608 | bundlerepo = InMemoryBundleRepo(ui, path=other_repo.root, | |
|
609 | bundlestream=unbundle) | |
|
610 | return ''.join(patch.diff(bundlerepo, node1=org_ref, node2=other_ref, | |
|
611 | opts=opts)) | |
|
609 | ui = make_ui('db') | |
|
610 | bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root, | |
|
611 | bundlestream=unbundle) | |
|
612 | return ''.join(patch.diff(bundlerepo or org_repo, node2=other_ref, opts=opts)) | |
|
612 | 613 | else: |
|
613 | 614 | return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref, |
|
614 | 615 | opts=opts)) |
@@ -25,7 +25,9 b'' | |||
|
25 | 25 | ${self.breadcrumbs()} |
|
26 | 26 | </div> |
|
27 | 27 | <!-- end box / title --> |
|
28 | %if c.repo_branches: | |
|
28 | 29 | <div class="info_box" id="compare_branches" style="clear: both;padding: 10px 19px;vertical-align: right;text-align: right;"><a href="#" class="ui-btn small">${_('Compare branches')}</a></div> |
|
30 | %endif | |
|
29 | 31 | <div class="table"> |
|
30 | 32 | <%include file='branches_data.html'/> |
|
31 | 33 | </div> |
@@ -26,9 +26,9 b'' | |||
|
26 | 26 | <div class="table"> |
|
27 | 27 | <div id="body" class="diffblock"> |
|
28 | 28 | <div class="code-header cv"> |
|
29 |
<h3 class="code-header-title">${_('Compare View')} |
|
|
29 | <h3 class="code-header-title">${_('Compare View')}</h3> | |
|
30 | 30 | <div> |
|
31 | ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} | |
|
31 | ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} <a href="${c.swap_url}">[swap]</a> | |
|
32 | 32 | </div> |
|
33 | 33 | </div> |
|
34 | 34 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now