/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: Jelmer Vernooij
  • Date: 2018-10-20 15:02:08 UTC
  • mto: (491.6.1 breezy)
  • mto: This revision was merged to the branch mainline in revision 494.
  • Revision ID: jelmer@jelmer.uk-20181020150208-9cxsjqw6kkaeutnj
More python 3 work; down to 16 failing tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from io import BytesIO
2
 
import urllib
3
2
 
4
 
from breezy import diff
5
 
from breezy import errors
6
 
from breezy import osutils
 
3
from breezy import (
 
4
    diff,
 
5
    errors,
 
6
    osutils,
 
7
    urlutils,
 
8
    )
7
9
 
8
10
from .. import util
9
11
from ..controllers import TemplatedBranchView
15
17
    for line in difftext.splitlines():
16
18
        if len(line) == 0:
17
19
            continue
18
 
        if line.startswith('+++ ') or line.startswith('--- '):
 
20
        if line.startswith(b'+++ ') or line.startswith(b'--- '):
19
21
            continue
20
 
        if line.startswith('@@ '):
 
22
        if line.startswith(b'@@ '):
21
23
            # new chunk
22
24
            if chunk is not None:
23
25
                chunks.append(chunk)
24
26
            chunk = util.Container()
25
27
            chunk.diff = []
26
 
            split_lines = line.split(' ')[1:3]
27
 
            lines = [int(x.split(',')[0][1:]) for x in split_lines]
 
28
            split_lines = line.split(b' ')[1:3]
 
29
            lines = [int(x.split(b',')[0][1:]) for x in split_lines]
28
30
            old_lineno = lines[0]
29
31
            new_lineno = lines[1]
30
 
        elif line.startswith(' '):
 
32
        elif line.startswith(b' '):
31
33
            chunk.diff.append(util.Container(old_lineno=old_lineno,
32
34
                                             new_lineno=new_lineno,
33
35
                                             type='context',
34
36
                                             line=line[1:]))
35
37
            old_lineno += 1
36
38
            new_lineno += 1
37
 
        elif line.startswith('+'):
 
39
        elif line.startswith(b'+'):
38
40
            chunk.diff.append(util.Container(old_lineno=None,
39
41
                                             new_lineno=new_lineno,
40
42
                                             type='insert', line=line[1:]))
41
43
            new_lineno += 1
42
 
        elif line.startswith('-'):
 
44
        elif line.startswith(b'-'):
43
45
            chunk.diff.append(util.Container(old_lineno=old_lineno,
44
46
                                             new_lineno=None,
45
47
                                             type='delete', line=line[1:]))
71
73
    try:
72
74
        diff.internal_diff('', lines[compare_revid], '', lines[revid], buffer, context_lines=context_lines)
73
75
    except errors.BinaryFile:
74
 
        difftext = ''
 
76
        difftext = b''
75
77
    else:
76
78
        difftext = buffer.getvalue()
77
79
 
84
86
    supports_json = True
85
87
 
86
88
    def get_values(self, path, kwargs, headers):
87
 
        revid = urllib.unquote(self.args[0])
88
 
        compare_revid = urllib.unquote(self.args[1])
89
 
        file_id = urllib.unquote(self.args[2])
 
89
        revid = urlutils.unquote_to_bytes(self.args[0])
 
90
        compare_revid = urlutils.unquote_to_bytes(self.args[1])
 
91
        file_id = urlutils.unquote_to_bytes(self.args[2])
90
92
 
91
93
        try:
92
94
            context_lines = int(kwargs['context'])