~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/diff_ui.py

  • Committer: Michael Hudson
  • Date: 2008-09-29 21:35:13 UTC
  • Revision ID: michael.hudson@canonical.com-20080929213513-ools0krfn8l9wwf0
clean up flakes and whitespace in diff_ui.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from cStringIO import StringIO
20
20
import logging
21
21
import time
22
 
import sys
23
22
 
24
 
from paste import httpexceptions
25
23
from paste.request import path_info_pop
26
24
 
27
 
from loggerhead import history
28
 
from loggerhead import util
29
 
from loggerhead.templatefunctions import templatefunctions
30
 
 
31
 
import bzrlib
32
 
from bzrlib import branch
33
25
from bzrlib.diff import show_diff_trees
34
26
 
35
27
 
36
28
log = logging.getLogger("loggerhead.controllers")
37
29
 
38
30
class DiffUI(object):
39
 
    """
 
31
    """Class to output a diff for a single file or revisions."""
40
32
 
41
 
    Class to output a diff for a single file or revisions.
42
 
    """
43
 
    
44
33
    def __init__(self, branch, history):
45
34
        self._branch = branch
46
35
        self._history = history
47
36
        self.log = history.log
48
37
 
49
 
    
50
38
    def __call__(self, environ, start_response):
51
39
        # /diff/<rev_id>/<rev_id>
52
 
        """
53
 
        Default method called from /diff URL.
54
 
        """
55
 
 
 
40
        """Default method called from /diff URL."""
56
41
        z = time.time()
57
 
        
 
42
 
58
43
        args = []
59
44
        while 1:
60
45
            arg = path_info_pop(environ)
70
55
        if len(args) is 2:
71
56
            revid_to = self._history.fix_revid(args[1])
72
57
        else:
73
 
            revid_to = change.parents[0].revid 
 
58
            revid_to = change.parents[0].revid
74
59
 
75
60
 
76
61
        repo = self._branch.branch.repository
77
62
        revtree1 = repo.revision_tree(revid_from)
78
63
        revtree2 = repo.revision_tree(revid_to)
79
 
        
 
64
 
80
65
        diff_content_stream = StringIO()
81
 
        show_diff_trees(revtree1, revtree2, diff_content_stream, 
 
66
        show_diff_trees(revtree1, revtree2, diff_content_stream,
82
67
                        old_label='', new_label='')
83
68
 
84
69
        content = diff_content_stream.getvalue()
85
70
 
86
 
        self.log.info('/diff %r:%r in %r secs' % (revid_from, revid_to, 
 
71
        self.log.info('/diff %r:%r in %r secs' % (revid_from, revid_to,
87
72
                                                  time.time() - z))
88
73
 
89
74
        revno1 = self._history.get_revno(revid_from)