[Pkg-bazaar-commits] ./bzr/unstable r800: Merge John's import-speedup branch:
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:21:04 UTC 2009
------------------------------------------------------------
revno: 800
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Tue 2005-06-28 13:02:31 +1000
message:
Merge John's import-speedup branch:
777 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 22:20:32 -0500
revision-id: john at arbash-meinel.com-20050627032031-e82a50db3863b18e
bzr selftest was not using the correct bzr
776 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 22:20:22 -0500
revision-id: john at arbash-meinel.com-20050627032021-c9f21fde989ddaee
Add was using an old mutter
775 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 22:02:33 -0500
revision-id: john at arbash-meinel.com-20050627030233-9165cfe98fc63298
Cleaned up to be less different
774 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 21:54:53 -0500
revision-id: john at arbash-meinel.com-20050627025452-4260d0e744edef43
Allow BZR_PLUGIN_PATH='' to negate plugin loading.
773 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 21:49:34 -0500
revision-id: john at arbash-meinel.com-20050627024933-b7158f67b7b9eae5
Finished the previous cleanup (allowing load_plugins to be called twice)
772 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 21:45:08 -0500
revision-id: john at arbash-meinel.com-20050627024508-723b1df510d196fc
Work on making the tests pass. versioning.py is calling run_cmd directly, but plugins have been loaded.
771 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 21:32:29 -0500
revision-id: john at arbash-meinel.com-20050627023228-79972744d7c53e15
Got it down a little bit more by removing import of tree and inventory.
770 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 21:26:05 -0500
revision-id: john at arbash-meinel.com-20050627022604-350b9773ef622f95
Reducing the number of import from bzrlib/__init__.py and bzrlib/branch.py
769 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 20:32:25 -0500
revision-id: john at arbash-meinel.com-20050627013225-32dd044f10d23948
Updated revision.py and xml.py to include SubElement.
768 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 20:03:56 -0500
revision-id: john at arbash-meinel.com-20050627010356-ee66919e1c377faf
Minor typo
767 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 20:03:13 -0500
revision-id: john at arbash-meinel.com-20050627010312-40d024007eb85051
Caching the import
766 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 19:51:47 -0500
revision-id: john at arbash-meinel.com-20050627005147-5281c99e48ed1834
Created wrapper functions for lazy import of ElementTree
765 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 19:46:37 -0500
revision-id: john at arbash-meinel.com-20050627004636-bf432902004a94c5
Removed all of the test imports of cElementTree
764 John Arbash Meinel <john at arbash-meinel.com> Sun 2005-06-26 19:43:59 -0500
revision-id: john at arbash-meinel.com-20050627004358-d137fbe9570dd71b
Trying to make bzr startup faster.
modified:
bzrlib/__init__.py
bzrlib/add.py
bzrlib/branch.py
bzrlib/commands.py
bzrlib/inventory.py
bzrlib/newinventory.py
bzrlib/plugin.py
bzrlib/revision.py
bzrlib/selftest/__init__.py
bzrlib/tree.py
bzrlib/xml.py
-------------- next part --------------
=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py 2005-06-22 06:04:43 +0000
+++ b/bzrlib/__init__.py 2005-06-28 03:02:31 +0000
@@ -16,15 +16,8 @@
"""bzr library"""
-from inventory import Inventory, InventoryEntry
from branch import Branch, ScratchBranch, find_branch
-from osutils import format_date
-from tree import Tree
-from diff import compare_trees
-from trace import mutter, warning, open_tracefile
-from log import show_log
-from plugin import load_plugins
-import add
+from errors import BzrError
BZRDIR = ".bzr"
@@ -53,7 +46,6 @@
def get_bzr_revision():
"""If bzr is run from a branch, return (revno,revid) or None"""
- from errors import BzrError
try:
branch = Branch(__path__[0])
rh = branch.revision_history()
=== modified file 'bzrlib/add.py'
--- a/bzrlib/add.py 2005-06-15 04:14:26 +0000
+++ b/bzrlib/add.py 2005-06-28 03:02:31 +0000
@@ -68,7 +68,7 @@
print "skipping %s (can't add file of kind '%s')" % (f, kind)
continue
- bzrlib.mutter("smart add of %r, abs=%r" % (f, af))
+ mutter("smart add of %r, abs=%r" % (f, af))
if bzrlib.branch.is_control_file(af):
raise ForbiddenFileError('cannot add control file %s' % f)
@@ -82,7 +82,7 @@
else:
file_id = bzrlib.branch.gen_file_id(rf)
inv.add_path(rf, kind=kind, file_id=file_id)
- bzrlib.mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
+ mutter("added %r kind %r file_id={%s}" % (rf, kind, file_id))
count += 1
print 'added', quotefn(f)
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-06-27 01:36:22 +0000
+++ b/bzrlib/branch.py 2005-06-28 03:02:31 +0000
@@ -15,22 +15,13 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import sys, os, os.path, random, time, sha, sets, types, re, shutil, tempfile
-import traceback, socket, fnmatch, difflib, time
-from binascii import hexlify
+import sys, os
import bzrlib
-from inventory import Inventory
-from trace import mutter, note
-from tree import Tree, EmptyTree, RevisionTree
-from inventory import InventoryEntry, Inventory
-from osutils import isdir, quotefn, isfile, uuid, sha_file, username, \
- format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
- joinpath, sha_file, sha_string, file_kind, local_time_offset, appendpath
-from store import ImmutableStore
-from revision import Revision
-from errors import BzrError
-from textui import show_status
+from bzrlib.trace import mutter, note
+from bzrlib.osutils import isdir, quotefn, compact_date, rand_bytes, splitpath, \
+ sha_file, appendpath, file_kind
+from bzrlib.errors import BzrError
BZR_BRANCH_FORMAT = "Bazaar-NG branch, format 0.0.4\n"
## TODO: Maybe include checks for common corruption of newlines, etc?
@@ -174,6 +165,7 @@
In the test suite, creation of new trees is tested using the
`ScratchBranch` class.
"""
+ from bzrlib.store import ImmutableStore
if init:
self.base = os.path.realpath(base)
self._make_control()
@@ -265,7 +257,7 @@
def controlfilename(self, file_or_path):
"""Return location relative to branch."""
- if isinstance(file_or_path, types.StringTypes):
+ if isinstance(file_or_path, basestring):
file_or_path = [file_or_path]
return os.path.join(self.base, bzrlib.BZRDIR, *file_or_path)
@@ -298,6 +290,7 @@
def _make_control(self):
+ from bzrlib.inventory import Inventory
os.mkdir(self.controlfilename([]))
self.controlfile('README', 'w').write(
"This is a Bazaar-NG control directory.\n"
@@ -335,14 +328,16 @@
def read_working_inventory(self):
"""Read the working inventory."""
- before = time.time()
+ from bzrlib.inventory import Inventory
+ from time import time
+ before = time()
# ElementTree does its own conversion from UTF-8, so open in
# binary.
self.lock_read()
try:
inv = Inventory.read_xml(self.controlfile('inventory', 'rb'))
mutter("loaded inventory of %d items in %f"
- % (len(inv), time.time() - before))
+ % (len(inv), time() - before))
return inv
finally:
self.unlock()
@@ -400,10 +395,11 @@
add all non-ignored children. Perhaps do that in a
higher-level method.
"""
+ from bzrlib.textui import show_status
# TODO: Re-adding a file that is removed in the working copy
# should probably put it back with the previous ID.
- if isinstance(files, types.StringTypes):
- assert(ids is None or isinstance(ids, types.StringTypes))
+ if isinstance(files, basestring):
+ assert(ids is None or isinstance(ids, basestring))
files = [files]
if ids is not None:
ids = [ids]
@@ -478,9 +474,10 @@
is the opposite of add. Removing it is consistent with most
other tools. Maybe an option.
"""
+ from bzrlib.textui import show_status
## TODO: Normalize names
## TODO: Remove nested loops; better scalability
- if isinstance(files, types.StringTypes):
+ if isinstance(files, basestring):
files = [files]
self.lock_write()
@@ -511,6 +508,7 @@
# FIXME: this doesn't need to be a branch method
def set_inventory(self, new_inventory_list):
+ from bzrlib.inventory import Inventory, InventoryEntry
inv = Inventory()
for path, file_id, parent, kind in new_inventory_list:
name = os.path.basename(path)
@@ -556,6 +554,7 @@
def get_revision(self, revision_id):
"""Return the Revision object for a named revision"""
+ from bzrlib.revision import Revision
if not revision_id or not isinstance(revision_id, basestring):
raise ValueError('invalid revision-id: %r' % revision_id)
r = Revision.read_xml(self.revision_store[revision_id])
@@ -579,6 +578,7 @@
TODO: Perhaps for this and similar methods, take a revision
parameter which can be either an integer revno or a
string hash."""
+ from bzrlib.inventory import Inventory
i = Inventory.read_xml(self.inventory_store[inventory_id])
return i
@@ -591,6 +591,7 @@
def get_revision_inventory(self, revision_id):
"""Return inventory of a past revision."""
if revision_id == None:
+ from bzrlib.inventory import Inventory
return Inventory()
else:
return self.get_inventory(self.get_revision(revision_id).inventory_id)
@@ -763,6 +764,10 @@
True
"""
from bzrlib.progress import ProgressBar
+ try:
+ set
+ except NameError:
+ from sets import Set as set
pb = ProgressBar()
@@ -777,7 +782,7 @@
other.inventory_store.prefetch(inventory_ids)
revisions = []
- needed_texts = sets.Set()
+ needed_texts = set()
i = 0
for rev_id in revision_ids:
i += 1
@@ -829,6 +834,7 @@
`revision_id` may be None for the null revision, in which case
an `EmptyTree` is returned."""
+ from bzrlib.tree import EmptyTree, RevisionTree
# TODO: refactor this to use an existing revision object
# so we don't need to read it in twice.
if revision_id == None:
@@ -849,6 +855,7 @@
If there are no revisions yet, return an `EmptyTree`.
"""
+ from bzrlib.tree import EmptyTree, RevisionTree
r = self.last_patch()
if r == None:
return EmptyTree()
@@ -1035,9 +1042,10 @@
If any files are listed, they are created in the working copy.
"""
+ from tempfile import mkdtemp
init = False
if base is None:
- base = tempfile.mkdtemp()
+ base = mkdtemp()
init = True
Branch.__init__(self, base, init=init)
for d in dirs:
@@ -1056,9 +1064,11 @@
>>> os.path.isfile(os.path.join(clone.base, "file1"))
True
"""
- base = tempfile.mkdtemp()
+ from shutil import copytree
+ from tempfile import mkdtemp
+ base = mkdtemp()
os.rmdir(base)
- shutil.copytree(self.base, base, symlinks=True)
+ copytree(self.base, base, symlinks=True)
return ScratchBranch(base=base)
def __del__(self):
@@ -1066,10 +1076,11 @@
def destroy(self):
"""Destroy the test branch, removing the scratch directory."""
+ from shutil import rmtree
try:
if self.base:
mutter("delete ScratchBranch %s" % self.base)
- shutil.rmtree(self.base)
+ rmtree(self.base)
except OSError, e:
# Work around for shutil.rmtree failing on Windows when
# readonly files are encountered
@@ -1077,7 +1088,7 @@
for root, dirs, files in os.walk(self.base, topdown=False):
for name in files:
os.chmod(os.path.join(root, name), 0700)
- shutil.rmtree(self.base)
+ rmtree(self.base)
self.base = None
@@ -1108,6 +1119,8 @@
cope with just randomness because running uuidgen every time is
slow."""
import re
+ from binascii import hexlify
+ from time import time
# get last component
idx = name.rfind('/')
@@ -1125,4 +1138,4 @@
name = re.sub(r'[^\w.]', '', name)
s = hexlify(rand_bytes(8))
- return '-'.join((name, compact_date(time.time()), s))
+ return '-'.join((name, compact_date(time()), s))
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-06-27 06:09:34 +0000
+++ b/bzrlib/commands.py 2005-06-28 03:02:31 +0000
@@ -21,9 +21,8 @@
import bzrlib
from bzrlib.trace import mutter, note, log_error
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError
-from bzrlib.osutils import quotefn
-from bzrlib import Branch, Inventory, InventoryEntry, BZRDIR, \
- format_date
+from bzrlib.branch import find_branch
+from bzrlib import BZRDIR
plugin_cmds = {}
@@ -304,14 +303,14 @@
def run(self, all=False, show_ids=False, file_list=None):
if file_list:
- b = Branch(file_list[0])
+ b = find_branch(file_list[0])
file_list = [b.relpath(x) for x in file_list]
# special case: only one path was given and it's the root
# of the branch
if file_list == ['']:
file_list = None
else:
- b = Branch('.')
+ b = find_branch('.')
import status
status.show_status(b, show_unchanged=all, show_ids=show_ids,
specific_files=file_list)
@@ -324,7 +323,7 @@
takes_args = ['revision_id']
def run(self, revision_id):
- Branch('.').get_revision(revision_id).write_xml(sys.stdout)
+ find_branch('.').get_revision(revision_id).write_xml(sys.stdout)
class cmd_revno(Command):
@@ -332,7 +331,7 @@
This is equal to the number of revisions on this branch."""
def run(self):
- print Branch('.').revno()
+ print find_branch('.').revno()
class cmd_add(Command):
@@ -360,7 +359,8 @@
takes_options = ['verbose', 'no-recurse']
def run(self, file_list, verbose=False, no_recurse=False):
- bzrlib.add.smart_add(file_list, verbose, not no_recurse)
+ from bzrlib.add import smart_add
+ smart_add(file_list, verbose, not no_recurse)
@@ -372,15 +372,12 @@
takes_args = ['dir+']
def run(self, dir_list):
- import os
- import bzrlib.branch
-
b = None
for d in dir_list:
os.mkdir(d)
if not b:
- b = bzrlib.branch.Branch(d)
+ b = find_branch(d)
b.add([d], verbose=True)
@@ -390,7 +387,7 @@
hidden = True
def run(self, filename):
- print Branch(filename).relpath(filename)
+ print find_branch(filename).relpath(filename)
@@ -399,7 +396,7 @@
takes_options = ['revision', 'show-ids']
def run(self, revision=None, show_ids=False):
- b = Branch('.')
+ b = find_branch('.')
if revision == None:
inv = b.read_working_inventory()
else:
@@ -422,7 +419,7 @@
"""
takes_args = ['source$', 'dest']
def run(self, source_list, dest):
- b = Branch('.')
+ b = find_branch('.')
b.move([b.relpath(s) for s in source_list], b.relpath(dest))
@@ -444,7 +441,7 @@
takes_args = ['from_name', 'to_name']
def run(self, from_name, to_name):
- b = Branch('.')
+ b = find_branch('.')
b.rename_one(b.relpath(from_name), b.relpath(to_name))
@@ -473,7 +470,7 @@
from shutil import rmtree
import errno
- br_to = Branch('.')
+ br_to = find_branch('.')
stored_loc = None
try:
stored_loc = br_to.controlfile("x-pull", "rb").read().rstrip('\n')
@@ -487,6 +484,10 @@
print "Using last location: %s" % stored_loc
location = stored_loc
cache_root = tempfile.mkdtemp()
+ from bzrlib.branch import DivergedBranches
+ br_from = find_branch(location)
+ location = pull_loc(br_from)
+ old_revno = br_to.revno()
try:
from branch import find_cached_branch, DivergedBranches
br_from = find_cached_branch(location, cache_root)
@@ -521,7 +522,8 @@
def run(self, from_location, to_location=None, revision=None):
import errno
from bzrlib.merge import merge
- from branch import find_cached_branch, DivergedBranches, NoSuchRevision
+ from bzrlib.branch import DivergedBranches, NoSuchRevision, \
+ find_cached_branch, Branch
from shutil import rmtree
from meta_store import CachedStore
import tempfile
@@ -587,7 +589,7 @@
takes_args = ['dir?']
def run(self, dir='.'):
- b = Branch(dir)
+ b = find_branch(dir)
old_inv = b.basis_tree().inventory
new_inv = b.read_working_inventory()
@@ -604,7 +606,6 @@
def run(self, branch=None):
import info
- from branch import find_branch
b = find_branch(branch)
info.show_info(b)
@@ -619,7 +620,7 @@
takes_options = ['verbose']
def run(self, file_list, verbose=False):
- b = Branch(file_list[0])
+ b = find_branch(file_list[0])
b.remove([b.relpath(f) for f in file_list], verbose=verbose)
@@ -633,7 +634,7 @@
hidden = True
takes_args = ['filename']
def run(self, filename):
- b = Branch(filename)
+ b = find_branch(filename)
i = b.inventory.path2id(b.relpath(filename))
if i == None:
raise BzrError("%r is not a versioned file" % filename)
@@ -649,7 +650,7 @@
hidden = True
takes_args = ['filename']
def run(self, filename):
- b = Branch(filename)
+ b = find_branch(filename)
inv = b.inventory
fid = inv.path2id(b.relpath(filename))
if fid == None:
@@ -662,14 +663,14 @@
"""Display list of revision ids on this branch."""
hidden = True
def run(self):
- for patchid in Branch('.').revision_history():
+ for patchid in find_branch('.').revision_history():
print patchid
class cmd_directories(Command):
"""Display list of versioned directories in this branch."""
def run(self):
- for name, ie in Branch('.').read_working_inventory().directories():
+ for name, ie in find_branch('.').read_working_inventory().directories():
if name == '':
print '.'
else:
@@ -690,6 +691,7 @@
bzr commit -m 'imported project'
"""
def run(self):
+ from bzrlib.branch import Branch
Branch('.', init=True)
@@ -723,7 +725,6 @@
def run(self, revision=None, file_list=None, diff_options=None):
from bzrlib.diff import show_diff
- from bzrlib import find_branch
if file_list:
b = find_branch(file_list[0])
@@ -732,7 +733,7 @@
# just pointing to top-of-tree
file_list = None
else:
- b = Branch('.')
+ b = find_branch('.')
show_diff(b, revision, specific_files=file_list,
external_diff_options=diff_options)
@@ -747,7 +748,7 @@
TODO: Show files deleted since a previous revision, or between two revisions.
"""
def run(self, show_ids=False):
- b = Branch('.')
+ b = find_branch('.')
old = b.basis_tree()
new = b.working_tree()
@@ -769,7 +770,7 @@
hidden = True
def run(self):
import statcache
- b = Branch('.')
+ b = find_branch('.')
inv = b.read_working_inventory()
sc = statcache.update_cache(b, inv)
basis = b.basis_tree()
@@ -795,7 +796,7 @@
"""List files added in working tree."""
hidden = True
def run(self):
- b = Branch('.')
+ b = find_branch('.')
wt = b.working_tree()
basis_inv = b.basis_tree().inventory
inv = wt.inventory
@@ -817,7 +818,6 @@
takes_args = ['filename?']
def run(self, filename=None):
"""Print the branch root."""
- from branch import find_branch
b = find_branch(filename)
print getattr(b, 'base', None) or getattr(b, 'baseurl')
@@ -841,8 +841,8 @@
show_ids=False,
forward=False,
revision=None):
- from bzrlib import show_log, find_branch
- from bzrlib.log import log_formatter
+ from bzrlib.branch import find_branch
+ from bzrlib.log import log_formatter, show_log
import codecs
direction = (forward and 'forward') or 'reverse'
@@ -896,7 +896,7 @@
hidden = True
takes_args = ["filename"]
def run(self, filename):
- b = Branch(filename)
+ b = find_branch(filename)
inv = b.read_working_inventory()
file_id = inv.path2id(b.relpath(filename))
for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
@@ -910,7 +910,7 @@
"""
hidden = True
def run(self, revision=None, verbose=False):
- b = Branch('.')
+ b = find_branch('.')
if revision == None:
tree = b.working_tree()
else:
@@ -934,7 +934,8 @@
class cmd_unknowns(Command):
"""List unknown files."""
def run(self):
- for f in Branch('.').unknowns():
+ from bzrlib.osutils import quotefn
+ for f in find_branch('.').unknowns():
print quotefn(f)
@@ -962,7 +963,7 @@
from bzrlib.atomicfile import AtomicFile
import os.path
- b = Branch('.')
+ b = find_branch('.')
ifn = b.abspath('.bzrignore')
if os.path.exists(ifn):
@@ -1002,7 +1003,7 @@
See also: bzr ignore"""
def run(self):
- tree = Branch('.').working_tree()
+ tree = find_branch('.').working_tree()
for path, file_class, kind, file_id in tree.list_files():
if file_class != 'I':
continue
@@ -1026,7 +1027,7 @@
except ValueError:
raise BzrCommandError("not a valid revision-number: %r" % revno)
- print Branch('.').lookup_revision(revno)
+ print find_branch('.').lookup_revision(revno)
class cmd_export(Command):
@@ -1040,7 +1041,7 @@
takes_args = ['dest']
takes_options = ['revision', 'format']
def run(self, dest, revision=None, format='dir'):
- b = Branch('.')
+ b = find_branch('.')
if revision == None:
rh = b.revision_history()[-1]
else:
@@ -1058,7 +1059,7 @@
def run(self, filename, revision=None):
if revision == None:
raise BzrCommandError("bzr cat requires a revision number")
- b = Branch('.')
+ b = find_branch('.')
b.print_file(b.relpath(filename), int(revision))
@@ -1114,7 +1115,7 @@
import codecs
message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
- b = Branch('.')
+ b = find_branch('.')
commit(b, message, verbose=verbose, specific_files=selected_list)
@@ -1130,8 +1131,8 @@
takes_args = ['dir?']
def run(self, dir='.'):
- import bzrlib.check
- bzrlib.check.check(Branch(dir))
+ from bzrlib.check import check
+ check(find_branch(dir))
@@ -1145,7 +1146,7 @@
def run(self, dir='.'):
from bzrlib.upgrade import upgrade
- upgrade(Branch(dir))
+ upgrade(find_branch(dir))
@@ -1310,7 +1311,7 @@
hidden = True
def run(self):
import statcache
- b = Branch('.')
+ b = find_branch('.')
statcache.update_cache(b.base, b.read_working_inventory())
@@ -1586,7 +1587,8 @@
# some options like --builtin and --no-plugins have special effects
argv, master_opts = _parse_master_args(argv)
if not master_opts['no-plugins']:
- bzrlib.load_plugins()
+ from bzrlib.plugin import load_plugins
+ load_plugins()
args, opts = parse_args(argv)
@@ -1681,9 +1683,8 @@
def main(argv):
- import errno
- bzrlib.open_tracefile(argv)
+ bzrlib.trace.open_tracefile(argv)
try:
try:
@@ -1710,6 +1711,7 @@
_report_exception('interrupted', quiet=True)
return 2
except Exception, e:
+ import errno
quiet = False
if (isinstance(e, IOError)
and hasattr(e, 'errno')
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2005-06-22 08:12:31 +0000
+++ b/bzrlib/inventory.py 2005-06-28 03:02:31 +0000
@@ -22,15 +22,10 @@
import sys, os.path, types, re
-try:
- from cElementTree import Element, ElementTree, SubElement
-except ImportError:
- from elementtree.ElementTree import Element, ElementTree, SubElement
-
-from bzrlib.xml import XMLMixin
+import bzrlib
+from bzrlib.xml import XMLMixin, Element
from bzrlib.errors import BzrError, BzrCheckError
-import bzrlib
from bzrlib.osutils import uuid, quotefn, splitpath, joinpath, appendpath
from bzrlib.trace import mutter
@@ -437,7 +432,8 @@
raise BzrError("cannot re-add root of inventory")
if file_id == None:
- file_id = bzrlib.branch.gen_file_id(relpath)
+ from bzrlib.branch import gen_file_id
+ file_id = gen_file_id(relpath)
parent_path = parts[:-1]
parent_id = self.path2id(parent_path)
=== modified file 'bzrlib/newinventory.py'
--- a/bzrlib/newinventory.py 2005-06-17 07:28:53 +0000
+++ b/bzrlib/newinventory.py 2005-06-28 03:02:31 +0000
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from cElementTree import Element, ElementTree, SubElement
+from xml import ElementTree, Element
def write_inventory(inv, f):
=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py 2005-06-28 02:37:21 +0000
+++ b/bzrlib/plugin.py 2005-06-28 03:02:31 +0000
@@ -28,6 +28,7 @@
DEFAULT_PLUGIN_PATH = os.path.join(config_dir(), 'plugins')
all_plugins = []
+_loaded = False
def load_plugins():
@@ -47,9 +48,12 @@
such as *.pyd).
"""
- global all_plugins
- if all_plugins:
- return # plugins already initialized
+ global all_plugins, _loaded
+ if _loaded:
+ # People can make sure plugins are loaded, they just won't be twice
+ return
+ #raise BzrError("plugins already initialized")
+ _loaded = True
import sys, os, imp
try:
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2005-06-20 04:58:12 +0000
+++ b/bzrlib/revision.py 2005-06-28 03:02:31 +0000
@@ -17,12 +17,7 @@
-from xml import XMLMixin
-
-try:
- from cElementTree import Element, ElementTree, SubElement
-except ImportError:
- from elementtree.ElementTree import Element, ElementTree, SubElement
+from xml import XMLMixin, Element, SubElement
from errors import BzrError
=== modified file 'bzrlib/selftest/__init__.py'
--- a/bzrlib/selftest/__init__.py 2005-06-27 06:30:10 +0000
+++ b/bzrlib/selftest/__init__.py 2005-06-28 03:02:31 +0000
@@ -209,7 +209,8 @@
def selftest():
from unittest import TestLoader, TestSuite
- import bzrlib
+ import bzrlib, bzrlib.store, bzrlib.inventory, bzrlib.branch, bzrlib.osutils, bzrlib.commands
+
import bzrlib.selftest.whitebox
import bzrlib.selftest.blackbox
import bzrlib.selftest.versioning
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-06-17 07:28:53 +0000
+++ b/bzrlib/tree.py 2005-06-28 03:02:31 +0000
@@ -17,18 +17,10 @@
"""Tree classes, representing directory at point in time.
"""
-from sets import Set
-import os.path, os, fnmatch, time
-
-from osutils import pumpfile, filesize, quotefn, sha_file, \
- joinpath, splitpath, appendpath, isdir, isfile, file_kind, fingerprint_file
-import errno
-from stat import S_ISREG, S_ISDIR, ST_MODE, ST_SIZE
-
-from bzrlib.inventory import Inventory
+from osutils import pumpfile, appendpath, fingerprint_file
+
from bzrlib.trace import mutter, note
from bzrlib.errors import BzrError
-import branch
import bzrlib
@@ -150,6 +142,7 @@
class EmptyTree(Tree):
def __init__(self):
+ from bzrlib.inventory import Inventory
self._inventory = Inventory()
def has_filename(self, filename):
@@ -242,6 +235,7 @@
:note: If the export fails, the destination directory will be
left in a half-assed state.
"""
+ import os
os.mkdir(dest)
mutter('export version %r' % tree)
inv = tree.inventory
@@ -268,7 +262,8 @@
`dest` will be created holding the contents of this tree; if it
already exists, it will be clobbered, like with "tar -c".
"""
- now = time.time()
+ from time import time
+ now = time()
compression = str(compression or '')
try:
ball = tarfile.open(dest, 'w:' + compression)
=== modified file 'bzrlib/xml.py'
--- a/bzrlib/xml.py 2005-03-15 05:19:54 +0000
+++ b/bzrlib/xml.py 2005-06-28 03:02:31 +0000
@@ -24,10 +24,40 @@
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
__author__ = "Martin Pool <mbp at canonical.com>"
-try:
- from cElementTree import Element, ElementTree, SubElement
-except ImportError:
- from elementtree.ElementTree import Element, ElementTree, SubElement
+_ElementTree = None
+def ElementTree(*args, **kwargs):
+ global _ElementTree
+ if _ElementTree is None:
+ try:
+ from cElementTree import ElementTree
+ except ImportError:
+ from elementtree.ElementTree import ElementTree
+ _ElementTree = ElementTree
+ return _ElementTree(*args, **kwargs)
+
+_Element = None
+def Element(*args, **kwargs):
+ global _Element
+ if _Element is None:
+ try:
+ from cElementTree import Element
+ except ImportError:
+ from elementtree.ElementTree import Element
+ _Element = Element
+ return _Element(*args, **kwargs)
+
+
+_SubElement = None
+def SubElement(*args, **kwargs):
+ global _SubElement
+ if _SubElement is None:
+ try:
+ from cElementTree import SubElement
+ except ImportError:
+ from elementtree.ElementTree import SubElement
+ _SubElement = SubElement
+ return _SubElement(*args, **kwargs)
+
import os, time
from trace import mutter
@@ -45,5 +75,3 @@
read_xml = classmethod(read_xml)
-
-
More information about the Pkg-bazaar-commits
mailing list