~ubuntu-branches/ubuntu/karmic/bzr/karmic-proposed

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2008-05-12 00:14:54 UTC
  • mfrom: (1.1.42 upstream)
  • Revision ID: james.westby@ubuntu.com-20080512001454-yjpajuiocykl48p9
Tags: 1.5~rc1-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
from bzrlib import symbol_versioning
58
58
from bzrlib.symbol_versioning import (
59
59
    deprecated_function,
60
 
    one_zero,
61
60
    )
62
61
from bzrlib.trace import mutter
63
62
 
555
554
 
556
555
 
557
556
def sha_file(f):
558
 
    if getattr(f, 'tell', None) is not None:
559
 
        assert f.tell() == 0
 
557
    """Calculate the hexdigest of an open file.
 
558
 
 
559
    The file cursor should be already at the start.
 
560
    """
560
561
    s = sha.new()
561
562
    BUFSIZE = 128<<10
562
563
    while True:
750
751
 
751
752
def splitpath(p):
752
753
    """Turn string into list of parts."""
753
 
    assert isinstance(p, basestring)
754
 
 
755
754
    # split on either delimiter because people might use either on
756
755
    # Windows
757
756
    ps = re.split(r'[\\/]', p)
767
766
    return rps
768
767
 
769
768
def joinpath(p):
770
 
    assert isinstance(p, (list, tuple))
771
769
    for f in p:
772
770
        if (f == '..') or (f is None) or (f == ''):
773
771
            raise errors.BzrError("sorry, %r not allowed in path" % f)
867
865
    avoids that problem.
868
866
    """
869
867
 
870
 
    assert len(base) >= MIN_ABS_PATHLENGTH, ('Length of base must be equal or'
871
 
        ' exceed the platform minimum length (which is %d)' % 
872
 
        MIN_ABS_PATHLENGTH)
 
868
    if len(base) < MIN_ABS_PATHLENGTH:
 
869
        # must have space for e.g. a drive letter
 
870
        raise ValueError('%r is too short to calculate a relative path'
 
871
            % (base,))
873
872
 
874
873
    rp = abspath(path)
875
874