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

  • Committer: Martin Pool
  • Date: 2011-11-23 08:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 461.
  • Revision ID: mbp@canonical.com-20111123083312-4stzhfv5843jxv2k
Bump version to 1.18.1; compatible with bzr 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335  USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
#
18
18
 
19
19
from cStringIO import StringIO
20
20
import time
21
21
 
22
 
from paste.request import path_info_pop, parse_querystring
 
22
from paste.request import path_info_pop
23
23
 
24
 
from breezy.diff import show_diff_trees
25
 
from breezy.revision import NULL_REVISION
 
24
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
 
31
31
    """Class to output a diff for a single file or revisions."""
32
32
 
33
33
    def __call__(self, environ, start_response):
34
 
        # End of URL is now /diff/<rev_id>?context=<context_lines>
35
 
        # or /diff/<rev_id>/<rev_id>?context=<context_lines>
36
 
        # This allows users to choose how much context they want to see.
37
 
        # Old format was /diff/<rev_id>/<rev_id> or /diff/<rev_id>
 
34
        # /diff/<rev_id>/<rev_id>
38
35
        """Default method called from /diff URL."""
39
36
        z = time.time()
40
37
 
45
42
                break
46
43
            args.append(arg)
47
44
 
48
 
        numlines = 3 # This is the default.
49
 
 
50
 
        opts = parse_querystring(environ)
51
 
        for opt in opts:
52
 
            if opt[0] == 'context':
53
 
                try:
54
 
                    numlines = int(opt[1])
55
 
                except ValueError:
56
 
                    pass
57
 
 
58
45
        revid_from = args[0]
59
 
        # Convert a revno to a revid if we get a revno.
 
46
        # Convert a revno to a revid if we get a revno
60
47
        revid_from = self._history.fix_revid(revid_from)
61
48
        change = self._history.get_changes([revid_from])[0]
62
49
 
73
60
 
74
61
        diff_content_stream = StringIO()
75
62
        show_diff_trees(revtree1, revtree2, diff_content_stream,
76
 
                        old_label='', new_label='', context=numlines)
 
63
                        old_label='', new_label='')
77
64
 
78
65
        content = diff_content_stream.getvalue()
79
66
 
80
 
        self.log.info('/diff %r:%r in %r secs with %r context' % (revid_from, revid_to,
81
 
                                                  time.time() - z, numlines))
 
67
        self.log.info('/diff %r:%r in %r secs' % (revid_from, revid_to,
 
68
                                                  time.time() - z))
82
69
 
83
70
        revno1 = self._history.get_revno(revid_from)
84
71
        revno2 = self._history.get_revno(revid_to)