/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/controllers/filediff_ui.py

  • Committer: Martin Pool
  • Date: 2011-11-23 08:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 461.
  • Revision ID: mbp@canonical.com-20111123083312-4stzhfv5843jxv2k
Bump version to 1.18.1; compatible with bzr 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from StringIO import StringIO
2
2
import urllib
3
3
 
4
 
from breezy import diff
5
 
from breezy import errors
6
 
from breezy import osutils
 
4
from bzrlib import diff
 
5
from bzrlib import errors
 
6
from bzrlib import osutils
7
7
 
8
8
from loggerhead import util
9
9
from loggerhead.controllers import TemplatedBranchView
53
53
    return chunks
54
54
 
55
55
 
56
 
def diff_chunks_for_file(repository, file_id, compare_revid, revid,
57
 
                         context_lines=None):
58
 
    if context_lines is None:
59
 
        context_lines = 3
 
56
def diff_chunks_for_file(repository, file_id, compare_revid, revid):
60
57
    lines = {}
61
58
    args = []
62
59
    for r in (compare_revid, revid):
68
65
        lines[r] = osutils.split_lines(''.join(bytes_iter))
69
66
    buffer = StringIO()
70
67
    try:
71
 
        diff.internal_diff('', lines[compare_revid], '', lines[revid], buffer, context_lines=context_lines)
 
68
        diff.internal_diff('', lines[compare_revid], '', lines[revid], buffer)
72
69
    except errors.BinaryFile:
73
70
        difftext = ''
74
71
    else:
87
84
        compare_revid = urllib.unquote(self.args[1])
88
85
        file_id = urllib.unquote(self.args[2])
89
86
 
90
 
        try:
91
 
            context_lines = int(kwargs['context'])
92
 
        except (KeyError, ValueError):
93
 
            context_lines = None
94
 
 
95
87
        chunks = diff_chunks_for_file(
96
 
            self._history._branch.repository, file_id, compare_revid, revid,
97
 
            context_lines=context_lines)
 
88
            self._history._branch.repository, file_id, compare_revid, revid)
98
89
 
99
90
        return {
100
91
            'chunks': chunks,