/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/changelog_ui.py

  • Committer: Ubuntu One Auto Copilot
  • Author(s): Jelmer Vernooij
  • Date: 2023-02-01 10:38:17 UTC
  • mfrom: (543.2.1 lp:loggerhead)
  • Revision ID: otto-copilot@canonical.com-20230201103817-h68q8zmdvm7u1vv4
Sort Python import definitions

Merged from https://code.launchpad.net/~jelmer/loggerhead/isort/+merge/436635

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335  USA
19
19
#
20
20
 
21
 
import urllib
22
 
 
23
 
import simplejson
24
 
 
 
21
import json
 
22
 
 
23
from breezy import osutils, urlutils
25
24
from paste.httpexceptions import HTTPServerError
26
25
 
27
 
from loggerhead import util
28
 
from loggerhead.controllers import TemplatedBranchView
 
26
from .. import util
 
27
from ..controllers import TemplatedBranchView
29
28
 
30
29
 
31
30
class ChangeLogUI(TemplatedBranchView):
32
31
 
33
 
    template_path = 'loggerhead.templates.changelog'
 
32
    template_name = 'changelog'
34
33
 
35
34
    def get_values(self, path, kwargs, headers):
36
35
        history = self._history
37
36
        revid = self.get_revid()
38
 
        filter_file_id = kwargs.get('filter_file_id', None)
 
37
        filter_path = kwargs.get('filter_path', path)
39
38
        query = kwargs.get('q', None)
40
39
        start_revid = history.fix_revid(kwargs.get('start_revid', None))
41
40
        orig_start_revid = start_revid
42
 
        pagesize = 20#int(config.get('pagesize', '20'))
 
41
        pagesize = 20  #int(config.get('pagesize', '20'))
43
42
        search_failed = False
44
43
 
45
 
        if filter_file_id is None and path is not None:
46
 
            filter_file_id = history.get_file_id(revid, path)
47
 
 
48
44
        try:
49
45
            revid, start_revid, revid_list = history.get_view(
50
 
                revid, start_revid, filter_file_id, query,
 
46
                revid, start_revid, filter_path, query,
51
47
                extra_rev_count=pagesize+1)
52
48
            util.set_context(kwargs)
53
49
 
67
63
            data = {}
68
64
            for i, c in enumerate(changes):
69
65
                c.index = i
70
 
                data[str(i)] = urllib.quote(urllib.quote(c.revid, safe=''))
 
66
                data[str(i)] = urlutils.quote(urlutils.quote_from_bytes(c.revid, safe=''))
71
67
        except:
72
68
            self.log.exception('Exception fetching changes')
73
69
            raise HTTPServerError('Could not fetch changes')
74
70
 
75
71
        navigation = util.Container(
76
72
            pagesize=pagesize, revid=revid, start_revid=start_revid,
77
 
            revid_list=revid_list, filter_file_id=filter_file_id,
 
73
            revid_list=revid_list, filter_path=filter_path,
78
74
            scan_url='/changes', branch=self._branch, feed=True, history=history)
79
75
        if query is not None:
80
76
            navigation.query = query
97
93
            'branch': self._branch,
98
94
            'changes': changes,
99
95
            'show_tag_col': show_tag_col,
100
 
            'data': simplejson.dumps(data),
 
96
            'data': json.dumps(data),
101
97
            'util': util,
102
98
            'history': history,
103
99
            'revid': revid,
104
100
            'navigation': navigation,
105
 
            'filter_file_id': filter_file_id,
 
101
            'filter_path': filter_path,
106
102
            'start_revid': start_revid,
107
103
            'viewing_from': (orig_start_revid is not None) and
108
104
                            (orig_start_revid != history.last_revid),