/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:
15
15
#
16
16
# You should have received a copy of the GNU General Public License
17
17
# along with this program; if not, write to the Free Software
18
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335  USA
19
19
#
20
20
 
21
 
import urllib
22
 
 
23
 
try:
24
 
    import simplejson
25
 
except ImportError:
26
 
    import json as simplejson
27
 
 
 
21
import json
 
22
 
 
23
from breezy import osutils, urlutils
28
24
from paste.httpexceptions import HTTPServerError
29
25
 
30
 
from loggerhead import util
31
 
from loggerhead.controllers import TemplatedBranchView
 
26
from .. import util
 
27
from ..controllers import TemplatedBranchView
32
28
 
33
29
 
34
30
class ChangeLogUI(TemplatedBranchView):
35
31
 
36
 
    template_path = 'loggerhead.templates.changelog'
 
32
    template_name = 'changelog'
37
33
 
38
34
    def get_values(self, path, kwargs, headers):
39
35
        history = self._history
40
36
        revid = self.get_revid()
41
 
        filter_file_id = kwargs.get('filter_file_id', None)
 
37
        filter_path = kwargs.get('filter_path', path)
42
38
        query = kwargs.get('q', None)
43
39
        start_revid = history.fix_revid(kwargs.get('start_revid', None))
44
40
        orig_start_revid = start_revid
45
 
        pagesize = 20#int(config.get('pagesize', '20'))
 
41
        pagesize = 20  #int(config.get('pagesize', '20'))
46
42
        search_failed = False
47
43
 
48
 
        if filter_file_id is None and path is not None:
49
 
            filter_file_id = history.get_file_id(revid, path)
50
 
 
51
44
        try:
52
45
            revid, start_revid, revid_list = history.get_view(
53
 
                revid, start_revid, filter_file_id, query)
 
46
                revid, start_revid, filter_path, query,
 
47
                extra_rev_count=pagesize+1)
54
48
            util.set_context(kwargs)
55
49
 
56
50
            if (query is not None) and (len(revid_list) == 0):
69
63
            data = {}
70
64
            for i, c in enumerate(changes):
71
65
                c.index = i
72
 
                data[str(i)] = urllib.quote(urllib.quote(c.revid, safe=''))
 
66
                data[str(i)] = urlutils.quote(urlutils.quote_from_bytes(c.revid, safe=''))
73
67
        except:
74
68
            self.log.exception('Exception fetching changes')
75
69
            raise HTTPServerError('Could not fetch changes')
76
70
 
77
71
        navigation = util.Container(
78
72
            pagesize=pagesize, revid=revid, start_revid=start_revid,
79
 
            revid_list=revid_list, filter_file_id=filter_file_id,
 
73
            revid_list=revid_list, filter_path=filter_path,
80
74
            scan_url='/changes', branch=self._branch, feed=True, history=history)
81
75
        if query is not None:
82
76
            navigation.query = query
99
93
            'branch': self._branch,
100
94
            'changes': changes,
101
95
            'show_tag_col': show_tag_col,
102
 
            'data': simplejson.dumps(data),
 
96
            'data': json.dumps(data),
103
97
            'util': util,
104
98
            'history': history,
105
99
            'revid': revid,
106
100
            'navigation': navigation,
107
 
            'filter_file_id': filter_file_id,
 
101
            'filter_path': filter_path,
108
102
            'start_revid': start_revid,
109
103
            'viewing_from': (orig_start_revid is not None) and
110
104
                            (orig_start_revid != history.last_revid),