annotate rhodecode/lib/diffs.py @ 2965:d0553004e73d beta

fixed #623: Lang meta-tag doesn't work with C#/C++
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 27 Oct 2012 00:09:07 +0200
parents 5fba3778431c
children e46d0a90556e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 rhodecode.lib.diffs
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 Set of diffing helpers, previously part of vcs
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
7
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
8
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :created_on: Dec 4, 2011
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 :author: marcink
1824
89efedac4e6c 2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents: 1789
diff changeset
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
12 :original copyright: 2007-2008 by Armin Ronacher
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 :license: GPLv3, see COPYING for more details.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # This program is free software: you can redistribute it and/or modify
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # it under the terms of the GNU General Public License as published by
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # the Free Software Foundation, either version 3 of the License, or
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # (at your option) any later version.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 #
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 # This program is distributed in the hope that it will be useful,
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 # GNU General Public License for more details.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 #
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 # You should have received a copy of the GNU General Public License
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 # along with this program. If not, see <http://www.gnu.org/licenses/>.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 import re
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 import difflib
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
30 import markupsafe
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
31 import logging
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
32
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
33 from itertools import tee, imap
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
35 from mercurial import patch
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
36 from mercurial.mdiff import diffopts
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
37 from mercurial.bundlerepo import bundlerepository
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
38
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
39 from pylons.i18n.translation import _
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40
2552
e8650fbc4d4e Moved BytesIO into compat because of py25 compatibility issue
Marcin Kuzminski <marcin@python-works.com>
parents: 2478
diff changeset
41 from rhodecode.lib.compat import BytesIO
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2567
diff changeset
42 from rhodecode.lib.vcs.utils.hgcompat import localrepo
2007
324ac367a4da Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents: 1894
diff changeset
43 from rhodecode.lib.vcs.exceptions import VCSError
2233
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
44 from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2567
diff changeset
45 from rhodecode.lib.vcs.backends.base import EmptyChangeset
2233
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
46 from rhodecode.lib.helpers import escape
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2567
diff changeset
47 from rhodecode.lib.utils import make_ui
2843
ab75def5c15d fixes #567 diff non-unicode encoding missmatch
Marcin Kuzminski <marcin@python-works.com>
parents: 2801
diff changeset
48 from rhodecode.lib.utils2 import safe_unicode
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
49
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
50 log = logging.getLogger(__name__)
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
51
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
52
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
53 def wrap_to_table(str_):
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
54 return '''<table class="code-difftable">
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
55 <tr class="line no-comment">
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
56 <td class="lineno new"></td>
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
57 <td class="code no-comment"><pre>%s</pre></td>
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
58 </tr>
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
59 </table>''' % str_
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
60
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
61
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
62 def wrapped_diff(filenode_old, filenode_new, cut_off_limit=None,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
63 ignore_whitespace=True, line_context=3,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
64 enable_comments=False):
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
65 """
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
66 returns a wrapped diff into a table, checks for cut_off_limit and presents
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
67 proper message
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
68 """
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
69
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
70 if filenode_old is None:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
71 filenode_old = FileNode(filenode_new.path, '', EmptyChangeset())
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
72
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
73 if filenode_old.is_binary or filenode_new.is_binary:
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
74 diff = wrap_to_table(_('binary file'))
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
75 stats = (0, 0)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
76 size = 0
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
77
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
78 elif cut_off_limit != -1 and (cut_off_limit is None or
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
79 (filenode_old.size < cut_off_limit and filenode_new.size < cut_off_limit)):
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
80
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
81 f_gitdiff = get_gitdiff(filenode_old, filenode_new,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
82 ignore_whitespace=ignore_whitespace,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
83 context=line_context)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
84 diff_processor = DiffProcessor(f_gitdiff, format='gitdiff')
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
85
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
86 diff = diff_processor.as_html(enable_comments=enable_comments)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
87 stats = diff_processor.stat()
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
88 size = len(diff or '')
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
89 else:
2340
93243e162068 typo fix ref #461
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
90 diff = wrap_to_table(_('Changeset was too big and was cut off, use '
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
91 'diff menu to display this diff'))
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
92 stats = (0, 0)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
93 size = 0
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
94 if not diff:
2233
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
95 submodules = filter(lambda o: isinstance(o, SubModuleNode),
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
96 [filenode_new, filenode_old])
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
97 if submodules:
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
98 diff = wrap_to_table(escape('Submodule %r' % submodules[0]))
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
99 else:
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
100 diff = wrap_to_table(_('No changes detected'))
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
101
2084
feb0fccdcf83 fixed vcs issue with last_changeset for filenodes
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
102 cs1 = filenode_old.changeset.raw_id
feb0fccdcf83 fixed vcs issue with last_changeset for filenodes
Marcin Kuzminski <marcin@python-works.com>
parents: 2007
diff changeset
103 cs2 = filenode_new.changeset.raw_id
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
104
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
105 return size, cs1, cs2, diff, stats
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
106
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107
1768
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
108 def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 Returns git style diff between given ``filenode_old`` and ``filenode_new``.
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
111
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 :param ignore_whitespace: ignore whitespaces in diff
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 """
1894
0cbc3fb540b0 adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1883
diff changeset
114 # make sure we pass in default context
0cbc3fb540b0 adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1883
diff changeset
115 context = context or 3
2233
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
116 submodules = filter(lambda o: isinstance(o, SubModuleNode),
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
117 [filenode_new, filenode_old])
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
118 if submodules:
07fce1930417 fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2084
diff changeset
119 return ''
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 for filenode in (filenode_old, filenode_new):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122 if not isinstance(filenode, FileNode):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 raise VCSError("Given object should be FileNode object, not %s"
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 % filenode.__class__)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125
1894
0cbc3fb540b0 adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1883
diff changeset
126 repo = filenode_new.changeset.repository
0cbc3fb540b0 adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1883
diff changeset
127 old_raw_id = getattr(filenode_old.changeset, 'raw_id', repo.EMPTY_CHANGESET)
0cbc3fb540b0 adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1883
diff changeset
128 new_raw_id = getattr(filenode_new.changeset, 'raw_id', repo.EMPTY_CHANGESET)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129
1883
69d3c4450944 fix for latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
130 vcs_gitdiff = repo.get_diff(old_raw_id, new_raw_id, filenode_new.path,
1768
5610fd9b6803 added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 1753
diff changeset
131 ignore_whitespace, context)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 return vcs_gitdiff
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 class DiffProcessor(object):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 Give it a unified diff and it returns a list of the files that were
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 mentioned in the diff together with a dict of meta information that
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 can be used to render it in a HTML template.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141 _chunk_re = re.compile(r'@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)')
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
142 _newline_marker = '\\ No newline at end of file\n'
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
144 def __init__(self, diff, differ='diff', format='gitdiff'):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146 :param diff: a text in diff format or generator
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147 :param format: format of diff passed, `udiff` or `gitdiff`
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 if isinstance(diff, basestring):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 diff = [diff]
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152 self.__udiff = diff
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 self.__format = format
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154 self.adds = 0
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155 self.removes = 0
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 if isinstance(self.__udiff, basestring):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158 self.lines = iter(self.__udiff.splitlines(1))
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
159
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
160 elif self.__format == 'gitdiff':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
161 udiff_copy = self.copy_iterator()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162 self.lines = imap(self.escaper, self._parse_gitdiff(udiff_copy))
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164 udiff_copy = self.copy_iterator()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
165 self.lines = imap(self.escaper, udiff_copy)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
167 # Select a differ.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
168 if differ == 'difflib':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
169 self.differ = self._highlight_line_difflib
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
170 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
171 self.differ = self._highlight_line_udiff
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
172
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173 def escaper(self, string):
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
174 return markupsafe.escape(string)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
175
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
176 def copy_iterator(self):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
177 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
178 make a fresh copy of generator, we should not iterate thru
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
179 an original as it's needed for repeating operations on
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
180 this instance of DiffProcessor
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
181 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
182 self.__udiff, iterator_copy = tee(self.__udiff)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
183 return iterator_copy
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
184
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
185 def _extract_rev(self, line1, line2):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
186 """
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
187 Extract the operation (A/M/D), filename and revision hint from a line.
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
188 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
189
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
190 try:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
191 if line1.startswith('--- ') and line2.startswith('+++ '):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
192 l1 = line1[4:].split(None, 1)
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
193 old_filename = (l1[0].replace('a/', '', 1)
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
194 if len(l1) >= 1 else None)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
195 old_rev = l1[1] if len(l1) == 2 else 'old'
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
196
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
197 l2 = line2[4:].split(None, 1)
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
198 new_filename = (l2[0].replace('b/', '', 1)
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
199 if len(l1) >= 1 else None)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
200 new_rev = l2[1] if len(l2) == 2 else 'new'
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
201
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
202 filename = (old_filename
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
203 if old_filename != '/dev/null' else new_filename)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
205 operation = 'D' if new_filename == '/dev/null' else None
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
206 if not operation:
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
207 operation = 'M' if old_filename != '/dev/null' else 'A'
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
208
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
209 return operation, filename, new_rev, old_rev
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
210 except (ValueError, IndexError):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
211 pass
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
212
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
213 return None, None, None, None
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 def _parse_gitdiff(self, diffiterator):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
216 def line_decoder(l):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
217 if l.startswith('+') and not l.startswith('+++'):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
218 self.adds += 1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
219 elif l.startswith('-') and not l.startswith('---'):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220 self.removes += 1
2843
ab75def5c15d fixes #567 diff non-unicode encoding missmatch
Marcin Kuzminski <marcin@python-works.com>
parents: 2801
diff changeset
221 return safe_unicode(l)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
223 output = list(diffiterator)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
224 size = len(output)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
225
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
226 if size == 2:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
227 l = []
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
228 l.extend([output[0]])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
229 l.extend(output[1].splitlines(1))
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
230 return map(line_decoder, l)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
231 elif size == 1:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
232 return map(line_decoder, output[0].splitlines(1))
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
233 elif size == 0:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
234 return []
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
235
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
236 raise Exception('wrong size of diff %s' % size)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
237
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
238 def _highlight_line_difflib(self, line, next_):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
239 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
240 Highlight inline changes in both lines.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
241 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
242
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
243 if line['action'] == 'del':
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
244 old, new = line, next_
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
245 else:
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
246 old, new = next_, line
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
247
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
248 oldwords = re.split(r'(\W)', old['line'])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
249 newwords = re.split(r'(\W)', new['line'])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
250
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
251 sequence = difflib.SequenceMatcher(None, oldwords, newwords)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
252
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
253 oldfragments, newfragments = [], []
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
254 for tag, i1, i2, j1, j2 in sequence.get_opcodes():
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
255 oldfrag = ''.join(oldwords[i1:i2])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
256 newfrag = ''.join(newwords[j1:j2])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
257 if tag != 'equal':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
258 if oldfrag:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
259 oldfrag = '<del>%s</del>' % oldfrag
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
260 if newfrag:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
261 newfrag = '<ins>%s</ins>' % newfrag
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
262 oldfragments.append(oldfrag)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
263 newfragments.append(newfrag)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
264
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
265 old['line'] = "".join(oldfragments)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
266 new['line'] = "".join(newfragments)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
267
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
268 def _highlight_line_udiff(self, line, next_):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
269 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
270 Highlight inline changes in both lines.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
271 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
272 start = 0
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
273 limit = min(len(line['line']), len(next_['line']))
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
274 while start < limit and line['line'][start] == next_['line'][start]:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
275 start += 1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
276 end = -1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
277 limit -= start
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
278 while -end <= limit and line['line'][end] == next_['line'][end]:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
279 end -= 1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
280 end += 1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
281 if start or end:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
282 def do(l):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
283 last = end + len(l['line'])
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
284 if l['action'] == 'add':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
285 tag = 'ins'
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
286 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
287 tag = 'del'
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
288 l['line'] = '%s<%s>%s</%s>%s' % (
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
289 l['line'][:start],
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
290 tag,
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
291 l['line'][start:last],
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
292 tag,
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
293 l['line'][last:]
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
294 )
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
295 do(line)
1781
089c81cf04d9 fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents: 1772
diff changeset
296 do(next_)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
297
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
298 def _parse_udiff(self, inline_diff=True):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
299 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
300 Parse the diff an return data for the template.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
301 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
302 lineiter = self.lines
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
303 files = []
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
304 try:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
305 line = lineiter.next()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
306 while 1:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
307 # continue until we found the old file
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
308 if not line.startswith('--- '):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
309 line = lineiter.next()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
310 continue
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
311
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
312 chunks = []
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
313 stats = [0, 0]
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
314 operation, filename, old_rev, new_rev = \
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
315 self._extract_rev(line, lineiter.next())
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
316 files.append({
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
317 'filename': filename,
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
318 'old_revision': old_rev,
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
319 'new_revision': new_rev,
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
320 'chunks': chunks,
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
321 'operation': operation,
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
322 'stats': stats,
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
323 })
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
324
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
325 line = lineiter.next()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
326 while line:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
327 match = self._chunk_re.match(line)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
328 if not match:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
329 break
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
330
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
331 lines = []
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
332 chunks.append(lines)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
333
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
334 old_line, old_end, new_line, new_end = \
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
335 [int(x or 1) for x in match.groups()[:-1]]
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
336 old_line -= 1
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
337 new_line -= 1
2359
a264d898ca08 Alwas show initial context on html diffs.
Marcin Kuzminski <marcin@python-works.com>
parents: 2340
diff changeset
338 gr = match.groups()
a264d898ca08 Alwas show initial context on html diffs.
Marcin Kuzminski <marcin@python-works.com>
parents: 2340
diff changeset
339 context = len(gr) == 5
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
340 old_end += old_line
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
341 new_end += new_line
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
342
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
343 if context:
2359
a264d898ca08 Alwas show initial context on html diffs.
Marcin Kuzminski <marcin@python-works.com>
parents: 2340
diff changeset
344 # skip context only if it's first line
a264d898ca08 Alwas show initial context on html diffs.
Marcin Kuzminski <marcin@python-works.com>
parents: 2340
diff changeset
345 if int(gr[0]) > 1:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
346 lines.append({
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
347 'old_lineno': '...',
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
348 'new_lineno': '...',
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
349 'action': 'context',
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
350 'line': line,
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
351 })
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
352
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
353 line = lineiter.next()
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
354
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
355 while old_line < old_end or new_line < new_end:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
356 if line:
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
357 command = line[0]
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
358 if command in ['+', '-', ' ']:
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
359 #only modify the line if it's actually a diff
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
360 # thing
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
361 line = line[1:]
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
362 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
363 command = ' '
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
364
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
365 affects_old = affects_new = False
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
366
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
367 # ignore those if we don't expect them
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
368 if command in '#@':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
369 continue
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
370 elif command == '+':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
371 affects_new = True
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
372 action = 'add'
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
373 stats[0] += 1
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
374 elif command == '-':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
375 affects_old = True
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
376 action = 'del'
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
377 stats[1] += 1
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
378 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
379 affects_old = affects_new = True
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
380 action = 'unmod'
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
381
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
382 if line != self._newline_marker:
2360
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
383 old_line += affects_old
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
384 new_line += affects_new
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
385 lines.append({
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
386 'old_lineno': affects_old and old_line or '',
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
387 'new_lineno': affects_new and new_line or '',
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
388 'action': action,
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
389 'line': line
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
390 })
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
391
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
392 line = lineiter.next()
2567
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
393 if line == self._newline_marker:
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
394 # we need to append to lines, since this is not
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
395 # counted in the line specs of diff
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
396 lines.append({
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
397 'old_lineno': '...',
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
398 'new_lineno': '...',
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
399 'action': 'context',
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
400 'line': line
5fe0f744bec0 fixed issue #492 missing `\ No newline at end of file` test at the end of new chunk
Marcin Kuzminski <marcin@python-works.com>
parents: 2566
diff changeset
401 })
2391
91fae60bf2b6 merge with beta
Marcin Kuzminski <marcin@python-works.com>
parents: 2364 2385
diff changeset
402
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
403 except StopIteration:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
404 pass
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
405
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
406 sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation'])
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
407 if inline_diff is False:
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
408 return sorted(files, key=sorter)
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
409
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
410 # highlight inline changes
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
411 for diff_data in files:
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
412 for chunk in diff_data['chunks']:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
413 lineiter = iter(chunk)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
414 try:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
415 while 1:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
416 line = lineiter.next()
2566
d097d4bb0437 fix strikethrough issues on `No new line at end of file`
Marcin Kuzminski <marcin@python-works.com>
parents: 2552
diff changeset
417 if line['action'] not in ['unmod', 'context']:
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
418 nextline = lineiter.next()
2360
c15c3430df74 fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents: 2359
diff changeset
419 if nextline['action'] in ['unmod', 'context'] or \
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
420 nextline['action'] == line['action']:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
421 continue
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
422 self.differ(line, nextline)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
423 except StopIteration:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
424 pass
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
425
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
426 return sorted(files, key=sorter)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
427
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
428 def prepare(self, inline_diff=True):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
429 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
430 Prepare the passed udiff for HTML rendering. It'l return a list
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
431 of dicts
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
432 """
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
433 return self._parse_udiff(inline_diff=inline_diff)
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
434
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
435 def _safe_id(self, idstring):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
436 """Make a string safe for including in an id attribute.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
437
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
438 The HTML spec says that id attributes 'must begin with
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
439 a letter ([A-Za-z]) and may be followed by any number
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
440 of letters, digits ([0-9]), hyphens ("-"), underscores
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
441 ("_"), colons (":"), and periods (".")'. These regexps
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
442 are slightly over-zealous, in that they remove colons
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
443 and periods unnecessarily.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
444
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
445 Whitespace is transformed into underscores, and then
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
446 anything which is not a hyphen or a character that
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
447 matches \w (alphanumerics and underscore) is removed.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
448
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
449 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
450 # Transform all whitespace to underscore
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
451 idstring = re.sub(r'\s', "_", '%s' % idstring)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
452 # Remove everything that is not a hyphen or a member of \w
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
453 idstring = re.sub(r'(?!-)\W', "", idstring).lower()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
454 return idstring
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
455
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
456 def raw_diff(self):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
457 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
458 Returns raw string as udiff
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
459 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
460 udiff_copy = self.copy_iterator()
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
461 if self.__format == 'gitdiff':
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
462 udiff_copy = self._parse_gitdiff(udiff_copy)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
463 return u''.join(udiff_copy)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
464
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
465 def as_html(self, table_class='code-difftable', line_class='line',
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
466 new_lineno_class='lineno old', old_lineno_class='lineno new',
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
467 code_class='code', enable_comments=False, diff_lines=None):
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
468 """
2349
0edbffa9e2e2 fixed bug with inline changes highlighter.
Marcin Kuzminski <marcin@python-works.com>
parents: 2347
diff changeset
469 Return given diff as html table with customized css classes
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
470 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
471 def _link_to_if(condition, label, url):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
472 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
473 Generates a link if condition is meet or just the label if not.
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
474 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
475
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
476 if condition:
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
477 return '''<a href="%(url)s">%(label)s</a>''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
478 'url': url,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
479 'label': label
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
480 }
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
481 else:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
482 return label
2385
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
483 if diff_lines is None:
a455b2c79c85 Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents: 2360
diff changeset
484 diff_lines = self.prepare()
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
485 _html_empty = True
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
486 _html = []
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
487 _html.append('''<table class="%(table_class)s">\n''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
488 'table_class': table_class
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
489 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
490 for diff in diff_lines:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
491 for line in diff['chunks']:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
492 _html_empty = False
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
493 for change in line:
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
494 _html.append('''<tr class="%(lc)s %(action)s">\n''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
495 'lc': line_class,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
496 'action': change['action']
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
497 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
498 anchor_old_id = ''
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
499 anchor_new_id = ''
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
500 anchor_old = "%(filename)s_o%(oldline_no)s" % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
501 'filename': self._safe_id(diff['filename']),
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
502 'oldline_no': change['old_lineno']
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
503 }
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
504 anchor_new = "%(filename)s_n%(oldline_no)s" % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
505 'filename': self._safe_id(diff['filename']),
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
506 'oldline_no': change['new_lineno']
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
507 }
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
508 cond_old = (change['old_lineno'] != '...' and
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
509 change['old_lineno'])
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
510 cond_new = (change['new_lineno'] != '...' and
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
511 change['new_lineno'])
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
512 if cond_old:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
513 anchor_old_id = 'id="%s"' % anchor_old
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
514 if cond_new:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
515 anchor_new_id = 'id="%s"' % anchor_new
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
516 ###########################################################
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
517 # OLD LINE NUMBER
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
518 ###########################################################
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
519 _html.append('''\t<td %(a_id)s class="%(olc)s">''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
520 'a_id': anchor_old_id,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
521 'olc': old_lineno_class
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
522 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
523
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
524 _html.append('''%(link)s''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
525 'link': _link_to_if(True, change['old_lineno'],
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
526 '#%s' % anchor_old)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
527 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
528 _html.append('''</td>\n''')
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
529 ###########################################################
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
530 # NEW LINE NUMBER
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
531 ###########################################################
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
532
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
533 _html.append('''\t<td %(a_id)s class="%(nlc)s">''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
534 'a_id': anchor_new_id,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
535 'nlc': new_lineno_class
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
536 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
537
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
538 _html.append('''%(link)s''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
539 'link': _link_to_if(True, change['new_lineno'],
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
540 '#%s' % anchor_new)
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
541 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
542 _html.append('''</td>\n''')
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
543 ###########################################################
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
544 # CODE
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
545 ###########################################################
1787
d4a7b6c82efe code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents: 1781
diff changeset
546 comments = '' if enable_comments else 'no-comment'
1789
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
547 _html.append('''\t<td class="%(cc)s %(inc)s">''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
548 'cc': code_class,
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
549 'inc': comments
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
550 })
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
551 _html.append('''\n\t\t<pre>%(code)s</pre>\n''' % {
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
552 'code': change['line']
17caf4efe15c implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents: 1787
diff changeset
553 })
1753
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
554 _html.append('''\t</td>''')
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
555 _html.append('''\n</tr>\n''')
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
556 _html.append('''</table>''')
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
557 if _html_empty:
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
558 return None
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
559 return ''.join(_html)
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
560
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
561 def stat(self):
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
562 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
563 Returns tuple of added, and removed lines for this instance
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
564 """
1d1ccb873d00 moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
565 return self.adds, self.removes
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
566
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
567
2362
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
568 class InMemoryBundleRepo(bundlerepository):
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
569 def __init__(self, ui, path, bundlestream):
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
570 self._tempparent = None
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
571 localrepo.localrepository.__init__(self, ui, path)
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
572 self.ui.setconfig('phases', 'publish', False)
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
573
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
574 self.bundle = bundlestream
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
575
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
576 # dict with the mapping 'filename' -> position in the bundle
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
577 self.bundlefilespos = {}
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
578
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
579
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
580 def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None,
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
581 bundle_compare=False):
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
582 """
2478
8eab81115660 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2431
diff changeset
583 General differ between branches, bookmarks or separate but releated
2349
0edbffa9e2e2 fixed bug with inline changes highlighter.
Marcin Kuzminski <marcin@python-works.com>
parents: 2347
diff changeset
584 repositories
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
585
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
586 :param org_repo:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
587 :type org_repo:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
588 :param org_ref:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
589 :type org_ref:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
590 :param other_repo:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
591 :type other_repo:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
592 :param other_ref:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
593 :type other_ref:
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
594 """
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
595
2364
9d61aad859bc code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
596 bundlerepo = None
9d61aad859bc code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
597 ignore_whitespace = False
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
598 context = 3
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
599 org_repo = org_repo.scm_instance._repo
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
600 other_repo = other_repo.scm_instance._repo
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
601 opts = diffopts(git=True, ignorews=ignore_whitespace, context=context)
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
602 org_ref = org_ref[1]
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
603 other_ref = other_ref[1]
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
604
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
605 if org_repo != other_repo and bundle_compare:
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
606
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
607 common, incoming, rheads = discovery_data
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2567
diff changeset
608 other_repo_peer = localrepo.locallegacypeer(other_repo.local())
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
609 # create a bundle (uncompressed if other repo is not local)
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2567
diff changeset
610 if other_repo_peer.capable('getbundle') and incoming:
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
611 # disable repo hooks here since it's just bundle !
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
612 # patch and reset hooks section of UI config to not run any
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
613 # hooks on fetching archives with subrepos
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
614 for k, _ in other_repo.ui.configitems('hooks'):
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
615 other_repo.ui.setconfig('hooks', k, None)
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
616
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
617 unbundle = other_repo.getbundle('incoming', common=common,
2801
69420c48a0e6 fixes #550 mercurial repositories comparision failed when origin repo had
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
618 heads=None)
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
619
2552
e8650fbc4d4e Moved BytesIO into compat because of py25 compatibility issue
Marcin Kuzminski <marcin@python-works.com>
parents: 2478
diff changeset
620 buf = BytesIO()
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
621 while True:
2364
9d61aad859bc code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
622 chunk = unbundle._stream.read(1024 * 4)
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
623 if not chunk:
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
624 break
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
625 buf.write(chunk)
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2233
diff changeset
626
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
627 buf.seek(0)
2364
9d61aad859bc code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
628 # replace chunked _stream with data that can do tell() and seek()
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
629 unbundle._stream = buf
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
630
2362
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
631 ui = make_ui('db')
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
632 bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root,
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2361
diff changeset
633 bundlestream=unbundle)
2431
60dfc369df1d Improved cross-repo diff using bundlerepo
Marcin Kuzminski <marcin@python-works.com>
parents: 2391
diff changeset
634
60dfc369df1d Improved cross-repo diff using bundlerepo
Marcin Kuzminski <marcin@python-works.com>
parents: 2391
diff changeset
635 return ''.join(patch.diff(bundlerepo or org_repo,
60dfc369df1d Improved cross-repo diff using bundlerepo
Marcin Kuzminski <marcin@python-works.com>
parents: 2391
diff changeset
636 node1=org_repo[org_ref].node(),
60dfc369df1d Improved cross-repo diff using bundlerepo
Marcin Kuzminski <marcin@python-works.com>
parents: 2391
diff changeset
637 node2=other_repo[other_ref].node(),
2364
9d61aad859bc code garden
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
638 opts=opts))
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
639 else:
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
640 log.debug('running diff between %s@%s and %s@%s'
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2843
diff changeset
641 % (org_repo, org_ref, other_repo, other_ref))
2355
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
642 return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref,
29a8096820dc added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents: 2349
diff changeset
643 opts=opts))