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