~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/diff_ui.py

  • Committer: Matt Nordhoff
  • Date: 2009-10-15 23:12:10 UTC
  • Revision ID: mnordhoff@mattnordhoff.com-20091015231210-rpjxtt6w3qsd6h9z
Avoid using "dict.keys()" and "dict.items()" in a couple places, in favor of "dict.iter*()".

I can't see how this could possibly break anything. Watch the universe prove me wrong!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd.
 
1
# Copyright (C) 2008  Canonical Ltd.
2
2
#                     (Authored by Martin Albisetti <argentina@gmail.com>)
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
17
17
#
18
18
 
19
19
from cStringIO import StringIO
 
20
import logging
20
21
import time
21
22
 
22
23
from paste.request import path_info_pop
23
24
 
24
25
from bzrlib.diff import show_diff_trees
25
 
from bzrlib.revision import NULL_REVISION
26
26
 
27
27
from loggerhead.controllers import TemplatedBranchView
28
28
 
 
29
log = logging.getLogger("loggerhead.controllers")
 
30
 
29
31
 
30
32
class DiffUI(TemplatedBranchView):
31
33
    """Class to output a diff for a single file or revisions."""
36
38
        z = time.time()
37
39
 
38
40
        args = []
39
 
        while True:
 
41
        while 1:
40
42
            arg = path_info_pop(environ)
41
43
            if arg is None:
42
44
                break
47
49
        revid_from = self._history.fix_revid(revid_from)
48
50
        change = self._history.get_changes([revid_from])[0]
49
51
 
50
 
        if len(args) == 2:
 
52
        if len(args) is 2:
51
53
            revid_to = self._history.fix_revid(args[1])
52
 
        elif len(change.parents) == 0:
53
 
            revid_to = NULL_REVISION
54
54
        else:
55
55
            revid_to = change.parents[0].revid
56
56
 
72
72
        filename = '%s_%s.diff' % (revno1, revno2)
73
73
        headers = [
74
74
            ('Content-Type', 'application/octet-stream'),
75
 
            ('Content-Length', str(len(content))),
76
 
            ('Content-Disposition', 'attachment; filename=%s' % (filename,)),
 
75
            ('Content-Length', len(content)),
 
76
            ('Content-Disposition', 'attachment; filename=%s' % filename),
77
77
            ]
78
78
        start_response('200 OK', headers)
79
79
        return [content]