[Pkg-bazaar-commits] ./bzr/unstable r694: - weed out all remaining calls to bailout() and remove the function
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:20:45 UTC 2009
------------------------------------------------------------
revno: 694
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-06-17 17:28:53 +1000
message:
- weed out all remaining calls to bailout() and remove the function
modified:
bzrlib/commands.py
bzrlib/errors.py
bzrlib/inventory.py
bzrlib/newinventory.py
bzrlib/osutils.py
bzrlib/store.py
bzrlib/tree.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-06-15 04:18:42 +0000
+++ b/bzrlib/commands.py 2005-06-17 07:28:53 +0000
@@ -20,7 +20,7 @@
import bzrlib
from bzrlib.trace import mutter, note, log_error
-from bzrlib.errors import bailout, BzrError, BzrCheckError, BzrCommandError
+from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError
from bzrlib.osutils import quotefn
from bzrlib import Branch, Inventory, InventoryEntry, BZRDIR, \
format_date
@@ -264,19 +264,19 @@
for opt in self.takes_options:
if not opt in OPTIONS:
- bailout("Unknown option '%s' returned by external command %s"
- % (opt, path))
+ raise BzrError("Unknown option '%s' returned by external command %s"
+ % (opt, path))
# TODO: Is there any way to check takes_args is valid here?
self.takes_args = pipe.readline().split()
if pipe.close() is not None:
- bailout("Failed funning '%s --bzr-usage'" % path)
+ raise BzrError("Failed funning '%s --bzr-usage'" % path)
pipe = os.popen('%s --bzr-help' % path, 'r')
self.__doc__ = pipe.read()
if pipe.close() is not None:
- bailout("Failed funning '%s --bzr-help'" % path)
+ raise BzrError("Failed funning '%s --bzr-help'" % path)
def __call__(self, options, arguments):
Command.__init__(self, options, arguments)
@@ -646,7 +646,7 @@
b = Branch(filename)
i = b.inventory.path2id(b.relpath(filename))
if i == None:
- bailout("%r is not a versioned file" % filename)
+ raise BzrError("%r is not a versioned file" % filename)
else:
print i
@@ -663,7 +663,7 @@
inv = b.inventory
fid = inv.path2id(b.relpath(filename))
if fid == None:
- bailout("%r is not a versioned file" % filename)
+ raise BzrError("%r is not a versioned file" % filename)
for fip in inv.get_idpath(fid):
print fip
@@ -1361,7 +1361,7 @@
else:
optname = a[2:]
if optname not in OPTIONS:
- bailout('unknown long option %r' % a)
+ raise BzrError('unknown long option %r' % a)
else:
shortopt = a[1:]
if shortopt in SHORT_OPTIONS:
@@ -1375,7 +1375,7 @@
if shortopt not in SHORT_OPTIONS:
# We didn't find the multi-character name, and we
# didn't find the single char name
- bailout('unknown short option %r' % a)
+ raise BzrError('unknown short option %r' % a)
optname = SHORT_OPTIONS[shortopt]
if a[2:]:
@@ -1395,19 +1395,19 @@
if optname in opts:
# XXX: Do we ever want to support this, e.g. for -r?
- bailout('repeated option %r' % a)
+ raise BzrError('repeated option %r' % a)
optargfn = OPTIONS[optname]
if optargfn:
if optarg == None:
if not argv:
- bailout('option %r needs an argument' % a)
+ raise BzrError('option %r needs an argument' % a)
else:
optarg = argv.pop(0)
opts[optname] = optargfn(optarg)
else:
if optarg != None:
- bailout('option %r takes no argument' % optname)
+ raise BzrError('option %r takes no argument' % optname)
opts[optname] = True
else:
args.append(a)
=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py 2005-06-01 04:09:38 +0000
+++ b/bzrlib/errors.py 2005-06-17 07:28:53 +0000
@@ -62,12 +62,3 @@
Exception.__init__(self, e)
else:
Exception.__init__(self)
-
-
-
-def bailout(msg, explanation=[]):
- ex = BzrError(msg, explanation)
- import trace
- trace._tracefile.write('* raising %s\n' % ex)
- raise ex
-
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2005-05-26 01:47:47 +0000
+++ b/bzrlib/inventory.py 2005-06-17 07:28:53 +0000
@@ -27,8 +27,8 @@
except ImportError:
from elementtree.ElementTree import Element, ElementTree, SubElement
-from xml import XMLMixin
-from errors import bailout, BzrError, BzrCheckError
+from bzrlib.xml import XMLMixin
+from bzrlib.errors import BzrError, BzrCheckError
import bzrlib
from bzrlib.osutils import uuid, quotefn, splitpath, joinpath, appendpath
@@ -68,7 +68,7 @@
>>> i.add(InventoryEntry('2323', 'bye.c', 'file', '123'))
Traceback (most recent call last):
...
- BzrError: ('inventory already contains entry with id {2323}', [])
+ BzrError: inventory already contains entry with id {2323}
>>> i.add(InventoryEntry('2324', 'bye.c', 'file', '123'))
>>> i.add(InventoryEntry('2325', 'wibble', 'directory', '123'))
>>> i.path2id('src/wibble')
@@ -411,15 +411,15 @@
To add a file to a branch ready to be committed, use Branch.add,
which calls this."""
if entry.file_id in self._byid:
- bailout("inventory already contains entry with id {%s}" % entry.file_id)
+ raise BzrError("inventory already contains entry with id {%s}" % entry.file_id)
try:
parent = self._byid[entry.parent_id]
except KeyError:
- bailout("parent_id {%s} not in inventory" % entry.parent_id)
+ raise BzrError("parent_id {%s} not in inventory" % entry.parent_id)
if parent.children.has_key(entry.name):
- bailout("%s is already versioned" %
+ raise BzrError("%s is already versioned" %
appendpath(self.id2path(parent.file_id), entry.name))
self._byid[entry.file_id] = entry
@@ -432,7 +432,7 @@
The immediate parent must already be versioned"""
parts = bzrlib.osutils.splitpath(relpath)
if len(parts) == 0:
- bailout("cannot re-add root of inventory")
+ raise BzrError("cannot re-add root of inventory")
if file_id == None:
file_id = bzrlib.branch.gen_file_id(relpath)
@@ -544,7 +544,7 @@
try:
ie = self._byid[file_id]
except KeyError:
- bailout("file_id {%s} not found in inventory" % file_id)
+ raise BzrError("file_id {%s} not found in inventory" % file_id)
p.insert(0, ie.file_id)
file_id = ie.parent_id
return p
@@ -604,15 +604,15 @@
This does not move the working file."""
if not is_valid_name(new_name):
- bailout("not an acceptable filename: %r" % new_name)
+ raise BzrError("not an acceptable filename: %r" % new_name)
new_parent = self._byid[new_parent_id]
if new_name in new_parent.children:
- bailout("%r already exists in %r" % (new_name, self.id2path(new_parent_id)))
+ raise BzrError("%r already exists in %r" % (new_name, self.id2path(new_parent_id)))
new_parent_idpath = self.get_idpath(new_parent_id)
if file_id in new_parent_idpath:
- bailout("cannot move directory %r into a subdirectory of itself, %r"
+ raise BzrError("cannot move directory %r into a subdirectory of itself, %r"
% (self.id2path(file_id), self.id2path(new_parent_id)))
file_ie = self._byid[file_id]
=== modified file 'bzrlib/newinventory.py'
--- a/bzrlib/newinventory.py 2005-04-07 06:16:02 +0000
+++ b/bzrlib/newinventory.py 2005-06-17 07:28:53 +0000
@@ -38,7 +38,7 @@
if ie.text_size != None:
el.set('text_size', ('%d' % ie.text_size))
elif kind != 'directory':
- bailout('unknown InventoryEntry kind %r' % kind)
+ raise BzrError('unknown InventoryEntry kind %r' % kind)
el.tail = '\n'
parent_el.append(el)
@@ -97,7 +97,7 @@
f.write('</directory>\n')
else:
- bailout('unknown InventoryEntry kind %r' % kind)
+ raise BzrError('unknown InventoryEntry kind %r' % kind)
f.write('<inventory>\n')
f.write('<root_directory id="%s">\n' % escape_attr(inv.root.file_id))
@@ -132,7 +132,7 @@
ie.text_size = v and int(v)
ie.text_sha1 = el.get('text_sha1')
else:
- bailout("unknown inventory entry %r" % kind)
+ raise BzrError("unknown inventory entry %r" % kind)
inv_el = ElementTree().parse(f)
assert inv_el.tag == 'inventory'
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2005-05-12 02:14:35 +0000
+++ b/bzrlib/osutils.py 2005-06-17 07:28:53 +0000
@@ -19,8 +19,8 @@
import os, types, re, time, errno, sys
from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
-from errors import bailout, BzrError
-from trace import mutter
+from bzrlib.errors import BzrError
+from bzrlib.trace import mutter
import bzrlib
def make_readonly(filename):
@@ -248,7 +248,7 @@
if e:
m = _EMAIL_RE.search(e)
if not m:
- bailout("%r doesn't seem to contain a reasonable email address" % e)
+ raise BzrError("%r doesn't seem to contain a reasonable email address" % e)
return m.group(0)
return _auto_user_id()[1]
@@ -296,7 +296,7 @@
tt = time.localtime(t)
offset = local_time_offset(t)
else:
- bailout("unsupported timezone format %r",
+ raise BzrError("unsupported timezone format %r",
['options are "utc", "original", "local"'])
return (time.strftime("%a %Y-%m-%d %H:%M:%S", tt)
@@ -345,7 +345,7 @@
>>> splitpath('a/../b')
Traceback (most recent call last):
...
- BzrError: ("sorry, '..' not allowed in path", [])
+ BzrError: sorry, '..' not allowed in path
"""
assert isinstance(p, types.StringTypes)
@@ -356,7 +356,7 @@
rps = []
for f in ps:
if f == '..':
- bailout("sorry, %r not allowed in path" % f)
+ raise BzrError("sorry, %r not allowed in path" % f)
elif (f == '.') or (f == ''):
pass
else:
@@ -367,7 +367,7 @@
assert isinstance(p, list)
for f in p:
if (f == '..') or (f == None) or (f == ''):
- bailout("sorry, %r not allowed in path" % f)
+ raise BzrError("sorry, %r not allowed in path" % f)
return os.path.join(*p)
@@ -382,5 +382,5 @@
mutter('external command: %s' % `cmd`)
if os.system(cmd):
if not ignore_errors:
- bailout('command failed')
+ raise BzrError('command failed')
=== modified file 'bzrlib/store.py'
--- a/bzrlib/store.py 2005-06-11 01:35:24 +0000
+++ b/bzrlib/store.py 2005-06-17 07:28:53 +0000
@@ -95,7 +95,7 @@
p = self._path(fileid)
if os.access(p, os.F_OK) or os.access(p + '.gz', os.F_OK):
- bailout("store %r already contains id %r" % (self._basedir, fileid))
+ raise BzrError("store %r already contains id %r" % (self._basedir, fileid))
if compressed:
f = gzip.GzipFile(p + '.gz', 'wb')
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-06-14 07:52:45 +0000
+++ b/bzrlib/tree.py 2005-06-17 07:28:53 +0000
@@ -25,9 +25,9 @@
import errno
from stat import S_ISREG, S_ISDIR, ST_MODE, ST_SIZE
-from inventory import Inventory
-from trace import mutter, note
-from errors import bailout
+from bzrlib.inventory import Inventory
+from bzrlib.trace import mutter, note
+from bzrlib.errors import BzrError
import branch
import bzrlib
@@ -83,13 +83,13 @@
if ie.text_size != None:
if ie.text_size != fp['size']:
- bailout("mismatched size for file %r in %r" % (ie.file_id, self._store),
+ raise BzrError("mismatched size for file %r in %r" % (ie.file_id, self._store),
["inventory expects %d bytes" % ie.text_size,
"file is actually %d bytes" % fp['size'],
"store is probably damaged/corrupt"])
if ie.text_sha1 != fp['sha1']:
- bailout("wrong SHA-1 for file %r in %r" % (ie.file_id, self._store),
+ raise BzrError("wrong SHA-1 for file %r in %r" % (ie.file_id, self._store),
["inventory expects %s" % ie.text_sha1,
"file is actually %s" % fp['sha1'],
"store is probably damaged/corrupt"])
@@ -253,7 +253,7 @@
elif kind == 'file':
pumpfile(tree.get_file(ie.file_id), file(fullpath, 'wb'))
else:
- bailout("don't know how to export {%s} of kind %r" % (ie.file_id, kind))
+ raise BzrError("don't know how to export {%s} of kind %r" % (ie.file_id, kind))
mutter(" export {%s} kind %s to %s" % (ie.file_id, kind, fullpath))
exporters['dir'] = dir_exporter
@@ -273,7 +273,7 @@
try:
ball = tarfile.open(dest, 'w:' + compression)
except tarfile.CompressionError, e:
- bailout(str(e))
+ raise BzrError(str(e))
mutter('export version %r' % tree)
inv = tree.inventory
for dp, ie in inv.iter_entries():
@@ -294,7 +294,7 @@
item.size = _find_file_size(fileobj)
item.mode = 0644
else:
- bailout("don't know how to export {%s} of kind %r" %
+ raise BzrError("don't know how to export {%s} of kind %r" %
(ie.file_id, ie.kind))
ball.addfile(item, fileobj)
More information about the Pkg-bazaar-commits
mailing list