~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/store/text.py

  • Committer: wang
  • Date: 2006-10-29 13:41:32 UTC
  • mto: (2104.4.1 wang_65714)
  • mto: This revision was merged to the branch mainline in revision 2109.
  • Revision ID: wang@ubuntu-20061029134132-3d7f4216f20c4aef
Replace python's difflib by patiencediff because the worst case 
performance is cubic for difflib and people commiting large data 
files are often hurt by this. The worst case performance of patience is 
quadratic. Fix bug 65714.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Development Ltd
 
1
# Copyright (C) 2005 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
63
63
 
64
64
    def _try_put(self, fn, f):
65
65
        try:
66
 
            self._transport.put(fn, f, mode=self._file_mode)
 
66
            self._transport.put_file(fn, f, mode=self._file_mode)
67
67
        except NoSuchFile:
68
68
            if not self._prefixed:
69
69
                raise
71
71
                self._transport.mkdir(os.path.dirname(fn), mode=self._dir_mode)
72
72
            except FileExists:
73
73
                pass
74
 
            self._transport.put(fn, f, mode=self._file_mode)
 
74
            self._transport.put_file(fn, f, mode=self._file_mode)
75
75
 
76
76
    def _get(self, fn):
77
77
        if fn.endswith('.gz'):
114
114
        # gzip.GzipFile.read() requires a tell() function
115
115
        # but some transports return objects that cannot seek
116
116
        # so buffer them in a StringIO instead
117
 
        if hasattr(f, 'tell'):
 
117
        if getattr(f, 'tell', None) is not None:
118
118
            return gzip.GzipFile(mode='rb', fileobj=f)
119
119
        else:
120
120
            from cStringIO import StringIO