~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: Martin Pool
  • Date: 2008-04-24 07:22:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3415.
  • Revision ID: mbp@sourcefrog.net-20080424072253-opmjij7xfy38w27f
Remove every assert statement from bzrlib!

Depending on the context they are:

 * turned into an explicit if/raise of either AssertionError 
   or something more specific -- particularly where they protect
   programming interfaces, complex invariants, or data file integrity
 * removed, if they're redundant with a later check, not protecting
   a meaningful invariant
 * turned into a selftest method on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    
76
76
    This assumes that both paths are already fully specified file:// URLs.
77
77
    """
78
 
    assert len(base) >= MIN_ABS_FILEURL_LENGTH, ('Length of base must be equal or'
79
 
        ' exceed the platform minimum url length (which is %d)' % 
80
 
        MIN_ABS_FILEURL_LENGTH)
81
 
 
 
78
    if len(base) < MIN_ABS_FILEURL_LENGTH:
 
79
        raise ValueError('Length of base must be equal or'
 
80
            ' exceed the platform minimum url length (which is %d)' %
 
81
            MIN_ABS_FILEURL_LENGTH)
82
82
    base = local_path_from_url(base)
83
83
    path = local_path_from_url(path)
84
84
    return escape(osutils.relpath(base, path))
574
574
    :return: A unicode string which can be safely encoded into the 
575
575
         specified encoding.
576
576
    """
577
 
    assert encoding is not None, 'you cannot specify None for the display encoding.'
 
577
    if encoding is None:
 
578
        raise ValueError('you cannot specify None for the display encoding')
578
579
    if url.startswith('file://'):
579
580
        try:
580
581
            path = local_path_from_url(url)