Rev 4728: (vila) Cleanup imports in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Oct 6 14:38:44 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4728 [merge]
revision-id: pqm at pqm.ubuntu.com-20091006133835-5mq5guz7d72tvpbd
parent: pqm at pqm.ubuntu.com-20091006023844-6ir77wbskeru8m3z
parent: v.ladeuil+lp at free.fr-20091006122800-g91ai739fy8aosvv
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-10-06 14:38:35 +0100
message:
  (vila) Cleanup imports
modified:
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/mutabletree.py          mutabletree.py-20060906023413-4wlkalbdpsxi2r4y-2
=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2009-09-18 15:08:09 +0000
+++ b/bzrlib/merge.py	2009-10-06 12:25:59 +0000
@@ -15,51 +15,26 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 
-import errno
-from itertools import chain
-import os
-import warnings
-
 from bzrlib import (
+    branch as _mod_branch,
+    conflicts as _mod_conflicts,
     debug,
     errors,
     graph as _mod_graph,
+    merge3,
     osutils,
     patiencediff,
+    progress,
     registry,
     revision as _mod_revision,
+    textfile,
+    trace,
+    transform,
     tree as _mod_tree,
     tsort,
+    ui,
+    versionedfile
     )
-from bzrlib.branch import Branch
-from bzrlib.conflicts import ConflictList, Conflict
-from bzrlib.errors import (BzrCommandError,
-                           BzrError,
-                           NoCommonAncestor,
-                           NoCommits,
-                           NoSuchRevision,
-                           NoSuchFile,
-                           NotBranchError,
-                           NotVersionedError,
-                           UnrelatedBranches,
-                           UnsupportedOperation,
-                           WorkingTreeNotRevision,
-                           BinaryFile,
-                           )
-from bzrlib.graph import Graph
-from bzrlib.merge3 import Merge3
-from bzrlib.osutils import rename, pathjoin
-from progress import DummyProgress, ProgressPhase
-from bzrlib.revision import (NULL_REVISION, ensure_null)
-from bzrlib.textfile import check_text_lines
-from bzrlib.trace import mutter, warning, note, is_quiet
-from bzrlib.transform import (TransformPreview, TreeTransform,
-                              resolve_conflicts, cook_conflicts,
-                              conflict_pass, FinalPaths, create_from_tree,
-                              unique_add, ROOT_PARENT)
-from bzrlib.versionedfile import PlanWeaveMerge
-from bzrlib import ui
-
 # TODO: Report back as changes are merged in
 
 
@@ -94,7 +69,7 @@
         self.show_base = False
         self.reprocess = False
         if pb is None:
-            pb = DummyProgress()
+            pb = progress.DummyProgress()
         self._pb = pb
         self.pp = None
         self.recurse = recurse
@@ -184,7 +159,7 @@
                 base_revision_id, tree.branch.last_revision())):
                 base_revision_id = None
             else:
-                warning('Performing cherrypick')
+                trace.warning('Performing cherrypick')
         merger = klass.from_revision_ids(pb, tree, other_revision_id,
                                          base_revision_id, revision_graph=
                                          revision_graph)
@@ -242,12 +217,13 @@
         if revno is None:
             tree = workingtree.WorkingTree.open_containing(location)[0]
             return tree.branch, tree
-        branch = Branch.open_containing(location, possible_transports)[0]
+        branch = _mod_branch.Branch.open_containing(
+            location, possible_transports)[0]
         if revno == -1:
             revision_id = branch.last_revision()
         else:
             revision_id = branch.get_rev_id(revno)
-        revision_id = ensure_null(revision_id)
+        revision_id = _mod_revision.ensure_null(revision_id)
         return branch, self.revision_tree(revision_id, branch)
 
     def ensure_revision_trees(self):
@@ -271,15 +247,16 @@
         if self.this_rev_id is None:
             if self.this_basis_tree.get_file_sha1(file_id) != \
                 self.this_tree.get_file_sha1(file_id):
-                raise WorkingTreeNotRevision(self.this_tree)
+                raise errors.WorkingTreeNotRevision(self.this_tree)
 
         trees = (self.this_basis_tree, self.other_tree)
         return [get_id(tree, file_id) for tree in trees]
 
     def check_basis(self, check_clean, require_commits=True):
         if self.this_basis is None and require_commits is True:
-            raise BzrCommandError("This branch has no commits."
-                                  " (perhaps you would prefer 'bzr pull')")
+            raise errors.BzrCommandError(
+                "This branch has no commits."
+                " (perhaps you would prefer 'bzr pull')")
         if check_clean:
             self.compare_basis()
             if self.this_basis != self.this_rev_id:
@@ -333,7 +310,7 @@
             self.other_rev_id = _mod_revision.ensure_null(
                 self.other_branch.last_revision())
             if _mod_revision.is_null(self.other_rev_id):
-                raise NoCommits(self.other_branch)
+                raise errors.NoCommits(self.other_branch)
             self.other_basis = self.other_rev_id
         elif other_revision[1] is not None:
             self.other_rev_id = self.other_branch.get_rev_id(other_revision[1])
@@ -342,7 +319,7 @@
             self.other_rev_id = None
             self.other_basis = self.other_branch.last_revision()
             if self.other_basis is None:
-                raise NoCommits(self.other_branch)
+                raise errors.NoCommits(self.other_branch)
         if self.other_rev_id is not None:
             self._cached_trees[self.other_rev_id] = self.other_tree
         self._maybe_fetch(self.other_branch,self.this_branch, self.other_basis)
@@ -375,17 +352,17 @@
             target.fetch(source, revision_id)
 
     def find_base(self):
-        revisions = [ensure_null(self.this_basis),
-                     ensure_null(self.other_basis)]
-        if NULL_REVISION in revisions:
-            self.base_rev_id = NULL_REVISION
+        revisions = [_mod_revision.ensure_null(self.this_basis),
+                     _mod_revision.ensure_null(self.other_basis)]
+        if _mod_revision.NULL_REVISION in revisions:
+            self.base_rev_id = _mod_revision.NULL_REVISION
             self.base_tree = self.revision_tree(self.base_rev_id)
             self._is_criss_cross = False
         else:
             lcas = self.revision_graph.find_lca(revisions[0], revisions[1])
             self._is_criss_cross = False
             if len(lcas) == 0:
-                self.base_rev_id = NULL_REVISION
+                self.base_rev_id = _mod_revision.NULL_REVISION
             elif len(lcas) == 1:
                 self.base_rev_id = list(lcas)[0]
             else: # len(lcas) > 1
@@ -400,12 +377,12 @@
                     self.base_rev_id = self.revision_graph.find_unique_lca(
                                             *lcas)
                 self._is_criss_cross = True
-            if self.base_rev_id == NULL_REVISION:
-                raise UnrelatedBranches()
+            if self.base_rev_id == _mod_revision.NULL_REVISION:
+                raise errors.UnrelatedBranches()
             if self._is_criss_cross:
-                warning('Warning: criss-cross merge encountered.  See bzr'
-                        ' help criss-cross.')
-                mutter('Criss-cross lcas: %r' % lcas)
+                trace.warning('Warning: criss-cross merge encountered.  See bzr'
+                              ' help criss-cross.')
+                trace.mutter('Criss-cross lcas: %r' % lcas)
                 interesting_revision_ids = [self.base_rev_id]
                 interesting_revision_ids.extend(lcas)
                 interesting_trees = dict((t.get_revision_id(), t)
@@ -421,14 +398,14 @@
                 self.base_tree = self.revision_tree(self.base_rev_id)
         self.base_is_ancestor = True
         self.base_is_other_ancestor = True
-        mutter('Base revid: %r' % self.base_rev_id)
+        trace.mutter('Base revid: %r' % self.base_rev_id)
 
     def set_base(self, base_revision):
         """Set the base revision to use for the merge.
 
         :param base_revision: A 2-list containing a path and revision number.
         """
-        mutter("doing merge() with no base_revision specified")
+        trace.mutter("doing merge() with no base_revision specified")
         if base_revision == [None, None]:
             self.find_base()
         else:
@@ -454,13 +431,14 @@
         if self.merge_type.supports_reprocess:
             kwargs['reprocess'] = self.reprocess
         elif self.reprocess:
-            raise BzrError("Conflict reduction is not supported for merge"
-                                  " type %s." % self.merge_type)
+            raise errors.BzrError(
+                "Conflict reduction is not supported for merge"
+                " type %s." % self.merge_type)
         if self.merge_type.supports_show_base:
             kwargs['show_base'] = self.show_base
         elif self.show_base:
-            raise BzrError("Showing base is not supported for this"
-                           " merge type. %s" % self.merge_type)
+            raise errors.BzrError("Showing base is not supported for this"
+                                  " merge type. %s" % self.merge_type)
         if (not getattr(self.merge_type, 'supports_reverse_cherrypick', True)
             and not self.base_is_other_ancestor):
             raise errors.CannotReverseCherrypick()
@@ -515,10 +493,11 @@
         finally:
             self.this_tree.unlock()
         if len(merge.cooked_conflicts) == 0:
-            if not self.ignore_zero and not is_quiet():
-                note("All changes applied successfully.")
+            if not self.ignore_zero and not trace.is_quiet():
+                trace.note("All changes applied successfully.")
         else:
-            note("%d conflicts encountered." % len(merge.cooked_conflicts))
+            trace.note("%d conflicts encountered."
+                       % len(merge.cooked_conflicts))
 
         return len(merge.cooked_conflicts)
 
@@ -553,7 +532,7 @@
 
     def __init__(self, working_tree, this_tree, base_tree, other_tree,
                  interesting_ids=None, reprocess=False, show_base=False,
-                 pb=DummyProgress(), pp=None, change_reporter=None,
+                 pb=progress.DummyProgress(), pp=None, change_reporter=None,
                  interesting_files=None, do_merge=True,
                  cherrypick=False, lca_trees=None):
         """Initialize the merger object and perform the merge.
@@ -605,7 +584,7 @@
         self.change_reporter = change_reporter
         self.cherrypick = cherrypick
         if self.pp is None:
-            self.pp = ProgressPhase("Merge phase", 3, self.pb)
+            self.pp = progress.ProgressPhase("Merge phase", 3, self.pb)
         if do_merge:
             self.do_merge()
 
@@ -614,7 +593,7 @@
         self.base_tree.lock_read()
         self.other_tree.lock_read()
         try:
-            self.tt = TreeTransform(self.this_tree, self.pb)
+            self.tt = transform.TreeTransform(self.this_tree, self.pb)
             try:
                 self.pp.next_phase()
                 self._compute_transform()
@@ -623,7 +602,7 @@
                 self.write_modified(results)
                 try:
                     self.this_tree.add_conflicts(self.cooked_conflicts)
-                except UnsupportedOperation:
+                except errors.UnsupportedOperation:
                     pass
             finally:
                 self.tt.finalize()
@@ -636,7 +615,7 @@
     def make_preview_transform(self):
         self.base_tree.lock_read()
         self.other_tree.lock_read()
-        self.tt = TransformPreview(self.this_tree)
+        self.tt = transform.TransformPreview(self.this_tree)
         try:
             self.pp.next_phase()
             self._compute_transform()
@@ -672,8 +651,8 @@
         self.pp.next_phase()
         child_pb = ui.ui_factory.nested_progress_bar()
         try:
-            fs_conflicts = resolve_conflicts(self.tt, child_pb,
-                lambda t, c: conflict_pass(t, c, self.other_tree))
+            fs_conflicts = transform.resolve_conflicts(self.tt, child_pb,
+                lambda t, c: transform.conflict_pass(t, c, self.other_tree))
         finally:
             child_pb.finished()
         if self.change_reporter is not None:
@@ -682,7 +661,7 @@
                 self.tt.iter_changes(), self.change_reporter)
         self.cook_conflicts(fs_conflicts)
         for conflict in self.cooked_conflicts:
-            warning(conflict)
+            trace.warning(conflict)
 
     def _entries3(self):
         """Gather data about files modified between three trees.
@@ -890,7 +869,7 @@
     def fix_root(self):
         try:
             self.tt.final_kind(self.tt.root)
-        except NoSuchFile:
+        except errors.NoSuchFile:
             self.tt.cancel_deletion(self.tt.root)
         if self.tt.final_file_id(self.tt.root) is None:
             self.tt.version_file(self.tt.tree_file_id(self.tt.root),
@@ -903,7 +882,7 @@
             return
         try:
             self.tt.final_kind(other_root)
-        except NoSuchFile:
+        except errors.NoSuchFile:
             return
         if self.other_tree.inventory.root.file_id in self.this_tree.inventory:
             # the other tree's root is a non-root in the current tree
@@ -1162,8 +1141,8 @@
                 self.tt.delete_contents(trans_id)
             if file_id in self.other_tree:
                 # OTHER changed the file
-                create_from_tree(self.tt, trans_id,
-                                 self.other_tree, file_id)
+                transform.create_from_tree(self.tt, trans_id,
+                                           self.other_tree, file_id)
                 if not file_in_this:
                     self.tt.version_file(file_id, trans_id)
                 return "modified"
@@ -1180,14 +1159,14 @@
                 # have agreement that output should be a file.
                 try:
                     self.text_merge(file_id, trans_id)
-                except BinaryFile:
+                except errors.BinaryFile:
                     return contents_conflict()
                 if file_id not in self.this_tree:
                     self.tt.version_file(file_id, trans_id)
                 try:
                     self.tt.tree_kind(trans_id)
                     self.tt.delete_contents(trans_id)
-                except NoSuchFile:
+                except errors.NoSuchFile:
                     pass
                 return "modified"
             else:
@@ -1211,8 +1190,8 @@
             base_lines = []
         other_lines = self.get_lines(self.other_tree, file_id)
         this_lines = self.get_lines(self.this_tree, file_id)
-        m3 = Merge3(base_lines, this_lines, other_lines,
-                    is_cherrypick=self.cherrypick)
+        m3 = merge3.Merge3(base_lines, this_lines, other_lines,
+                           is_cherrypick=self.cherrypick)
         start_marker = "!START OF MERGE CONFLICT!" + "I HOPE THIS IS UNIQUE"
         if self.show_base is True:
             base_marker = '|' * 7
@@ -1273,7 +1252,7 @@
         """Emit a single conflict file."""
         name = name + '.' + suffix
         trans_id = self.tt.create_path(name, parent_id)
-        create_from_tree(self.tt, trans_id, tree, file_id, lines)
+        transform.create_from_tree(self.tt, trans_id, tree, file_id, lines)
         return trans_id
 
     def merge_executable(self, file_id, file_status):
@@ -1303,7 +1282,7 @@
         try:
             if self.tt.final_kind(trans_id) != "file":
                 return
-        except NoSuchFile:
+        except errors.NoSuchFile:
             return
         if winner == "this":
             executability = this_executable
@@ -1320,10 +1299,10 @@
 
     def cook_conflicts(self, fs_conflicts):
         """Convert all conflicts into a form that doesn't depend on trans_id"""
-        from conflicts import Conflict
         name_conflicts = {}
-        self.cooked_conflicts.extend(cook_conflicts(fs_conflicts, self.tt))
-        fp = FinalPaths(self.tt)
+        self.cooked_conflicts.extend(transform.cook_conflicts(
+                fs_conflicts, self.tt))
+        fp = transform.FinalPaths(self.tt)
         for conflict in self._raw_conflicts:
             conflict_type = conflict[0]
             if conflict_type in ('name conflict', 'parent conflict'):
@@ -1331,8 +1310,8 @@
                 conflict_args = conflict[2:]
                 if trans_id not in name_conflicts:
                     name_conflicts[trans_id] = {}
-                unique_add(name_conflicts[trans_id], conflict_type,
-                           conflict_args)
+                transform.unique_add(name_conflicts[trans_id], conflict_type,
+                                     conflict_args)
             if conflict_type == 'contents conflict':
                 for trans_id in conflict[1]:
                     file_id = self.tt.final_file_id(trans_id)
@@ -1343,13 +1322,15 @@
                     if path.endswith(suffix):
                         path = path[:-len(suffix)]
                         break
-                c = Conflict.factory(conflict_type, path=path, file_id=file_id)
+                c = _mod_conflicts.Conflict.factory(conflict_type,
+                                                    path=path, file_id=file_id)
                 self.cooked_conflicts.append(c)
             if conflict_type == 'text conflict':
                 trans_id = conflict[1]
                 path = fp.get_path(trans_id)
                 file_id = self.tt.final_file_id(trans_id)
-                c = Conflict.factory(conflict_type, path=path, file_id=file_id)
+                c = _mod_conflicts.Conflict.factory(conflict_type,
+                                                    path=path, file_id=file_id)
                 self.cooked_conflicts.append(c)
 
         for trans_id, conflicts in name_conflicts.iteritems():
@@ -1370,14 +1351,15 @@
             if this_parent is not None and this_name is not None:
                 this_parent_path = \
                     fp.get_path(self.tt.trans_id_file_id(this_parent))
-                this_path = pathjoin(this_parent_path, this_name)
+                this_path = osutils.pathjoin(this_parent_path, this_name)
             else:
                 this_path = "<deleted>"
             file_id = self.tt.final_file_id(trans_id)
-            c = Conflict.factory('path conflict', path=this_path,
-                                 conflict_path=other_path, file_id=file_id)
+            c = _mod_conflicts.Conflict.factory('path conflict', path=this_path,
+                                                conflict_path=other_path,
+                                                file_id=file_id)
             self.cooked_conflicts.append(c)
-        self.cooked_conflicts.sort(key=Conflict.sort_key)
+        self.cooked_conflicts.sort(key=_mod_conflicts.Conflict.sort_key)
 
 
 class WeaveMerger(Merge3Merger):
@@ -1404,8 +1386,8 @@
             name = self.tt.final_name(trans_id) + '.plan'
             contents = ('%10s|%s' % l for l in plan)
             self.tt.new_file(name, self.tt.final_parent(trans_id), contents)
-        textmerge = PlanWeaveMerge(plan, '<<<<<<< TREE\n',
-            '>>>>>>> MERGE-SOURCE\n')
+        textmerge = versionedfile.PlanWeaveMerge(plan, '<<<<<<< TREE\n',
+                                                 '>>>>>>> MERGE-SOURCE\n')
         return textmerge.merge_lines(self.reprocess)
 
     def text_merge(self, file_id, trans_id):
@@ -1417,7 +1399,7 @@
         lines = list(lines)
         # Note we're checking whether the OUTPUT is binary in this case,
         # because we don't want to get into weave merge guts.
-        check_text_lines(lines)
+        textfile.check_text_lines(lines)
         self.tt.create_file(lines, trans_id)
         if conflicts:
             self._raw_conflicts.append(('text conflict', trans_id))
@@ -1447,8 +1429,8 @@
             name = self.tt.final_name(trans_id) + '.plan'
             contents = ('%10s|%s' % l for l in plan)
             self.tt.new_file(name, self.tt.final_parent(trans_id), contents)
-        textmerge = PlanWeaveMerge(plan, '<<<<<<< TREE\n',
-            '>>>>>>> MERGE-SOURCE\n')
+        textmerge = versionedfile.PlanWeaveMerge(plan, '<<<<<<< TREE\n',
+                                                 '>>>>>>> MERGE-SOURCE\n')
         return textmerge.merge_lines(self.reprocess)
 
 
@@ -1456,7 +1438,7 @@
     """Three-way merger using external diff3 for text merging"""
 
     def dump_file(self, temp_dir, name, tree, file_id):
-        out_path = pathjoin(temp_dir, name)
+        out_path = osutils.pathjoin(temp_dir, name)
         out_file = open(out_path, "wb")
         try:
             in_file = tree.get_file(file_id)
@@ -1474,13 +1456,13 @@
         import bzrlib.patch
         temp_dir = osutils.mkdtemp(prefix="bzr-")
         try:
-            new_file = pathjoin(temp_dir, "new")
+            new_file = osutils.pathjoin(temp_dir, "new")
             this = self.dump_file(temp_dir, "this", self.this_tree, file_id)
             base = self.dump_file(temp_dir, "base", self.base_tree, file_id)
             other = self.dump_file(temp_dir, "other", self.other_tree, file_id)
             status = bzrlib.patch.diff3(new_file, this, base, other)
             if status not in (0, 1):
-                raise BzrError("Unhandled diff3 exit code")
+                raise errors.BzrError("Unhandled diff3 exit code")
             f = open(new_file, 'rb')
             try:
                 self.tt.create_file(f, trans_id)
@@ -1504,7 +1486,7 @@
                 other_rev_id=None,
                 interesting_files=None,
                 this_tree=None,
-                pb=DummyProgress(),
+                pb=progress.DummyProgress(),
                 change_reporter=None):
     """Primary interface for merging.
 
@@ -1513,8 +1495,8 @@
                      branch.get_revision_tree(base_revision))'
         """
     if this_tree is None:
-        raise BzrError("bzrlib.merge.merge_inner requires a this_tree "
-            "parameter as of bzrlib version 0.8.")
+        raise errors.BzrError("bzrlib.merge.merge_inner requires a this_tree "
+                              "parameter as of bzrlib version 0.8.")
     merger = Merger(this_branch, other_tree, base_tree, this_tree=this_tree,
                     pb=pb, change_reporter=change_reporter)
     merger.backup_files = backup_files
@@ -1738,7 +1720,7 @@
         super(_PlanMerge, self).__init__(a_rev, b_rev, vf, key_prefix)
         self.a_key = self._key_prefix + (self.a_rev,)
         self.b_key = self._key_prefix + (self.b_rev,)
-        self.graph = Graph(self.vf)
+        self.graph = _mod_graph.Graph(self.vf)
         heads = self.graph.heads((self.a_key, self.b_key))
         if len(heads) == 1:
             # one side dominates, so we can just return its values, yay for
@@ -1749,8 +1731,8 @@
                 other = b_rev
             else:
                 other = a_rev
-            mutter('found dominating revision for %s\n%s > %s', self.vf,
-                   self._head_key[-1], other)
+            trace.mutter('found dominating revision for %s\n%s > %s', self.vf,
+                         self._head_key[-1], other)
             self._weave = None
         else:
             self._head_key = None
@@ -1770,7 +1752,7 @@
         while True:
             next_lcas = self.graph.find_lca(*cur_ancestors)
             # Map a plain NULL_REVISION to a simple no-ancestors
-            if next_lcas == set([NULL_REVISION]):
+            if next_lcas == set([_mod_revision.NULL_REVISION]):
                 next_lcas = ()
             # Order the lca's based on when they were merged into the tip
             # While the actual merge portion of weave merge uses a set() of
@@ -1788,8 +1770,9 @@
             elif len(next_lcas) > 2:
                 # More than 2 lca's, fall back to grabbing all nodes between
                 # this and the unique lca.
-                mutter('More than 2 LCAs, falling back to all nodes for:'
-                       ' %s, %s\n=> %s', self.a_key, self.b_key, cur_ancestors)
+                trace.mutter('More than 2 LCAs, falling back to all nodes for:'
+                             ' %s, %s\n=> %s',
+                             self.a_key, self.b_key, cur_ancestors)
                 cur_lcas = next_lcas
                 while len(cur_lcas) > 1:
                     cur_lcas = self.graph.find_lca(*cur_lcas)
@@ -1798,7 +1781,7 @@
                     unique_lca = None
                 else:
                     unique_lca = list(cur_lcas)[0]
-                    if unique_lca == NULL_REVISION:
+                    if unique_lca == _mod_revision.NULL_REVISION:
                         # find_lca will return a plain 'NULL_REVISION' rather
                         # than a key tuple when there is no common ancestor, we
                         # prefer to just use None, because it doesn't confuse
@@ -1827,8 +1810,8 @@
             # We remove NULL_REVISION because it isn't a proper tuple key, and
             # thus confuses things like _get_interesting_texts, and our logic
             # to add the texts into the memory weave.
-            if NULL_REVISION in parent_map:
-                parent_map.pop(NULL_REVISION)
+            if _mod_revision.NULL_REVISION in parent_map:
+                parent_map.pop(_mod_revision.NULL_REVISION)
         else:
             interesting = set()
             for tip in tip_keys:
@@ -1986,7 +1969,7 @@
         lcas = graph.find_lca(key_prefix + (a_rev,), key_prefix + (b_rev,))
         self.lcas = set()
         for lca in lcas:
-            if lca == NULL_REVISION:
+            if lca == _mod_revision.NULL_REVISION:
                 self.lcas.add(lca)
             else:
                 self.lcas.add(lca[-1])

=== modified file 'bzrlib/mutabletree.py'
--- a/bzrlib/mutabletree.py	2009-09-28 02:02:30 +0000
+++ b/bzrlib/mutabletree.py	2009-10-06 12:25:59 +0000
@@ -28,21 +28,17 @@
 from bzrlib import (
     add,
     bzrdir,
+    errors,
     hooks,
+    osutils,
+    revisiontree,
     symbol_versioning,
+    trace,
+    tree,
     )
-from bzrlib.osutils import dirname
-from bzrlib.revisiontree import RevisionTree
-from bzrlib.trace import mutter, warning
 """)
 
-from bzrlib import (
-    errors,
-    osutils,
-    tree,
-    )
 from bzrlib.decorators import needs_read_lock, needs_write_lock
-from bzrlib.osutils import splitpath
 
 
 def needs_tree_write_lock(unbound):
@@ -130,7 +126,7 @@
             # generic constraint checks:
             if self.is_control_filename(f):
                 raise errors.ForbiddenControlFileError(filename=f)
-            fp = splitpath(f)
+            fp = osutils.splitpath(f)
         # fill out file kinds for all files [not needed when we stop
         # caring about the instantaneous file kind within a uncommmitted tree
         #
@@ -390,8 +386,8 @@
         # perform the canonicalization in bulk.
         for filepath in osutils.canonical_relpaths(self.basedir, file_list):
             rf = _FastPath(filepath)
-            # validate user parameters. Our recursive code avoids adding new files
-            # that need such validation
+            # validate user parameters. Our recursive code avoids adding new
+            # files that need such validation
             if self.is_control_filename(rf.raw_path):
                 raise errors.ForbiddenControlFileError(filename=rf.raw_path)
 
@@ -403,10 +399,10 @@
             else:
                 if not InventoryEntry.versionable_kind(kind):
                     raise errors.BadFileKindError(filename=abspath, kind=kind)
-            # ensure the named path is added, so that ignore rules in the later directory
-            # walk dont skip it.
-            # we dont have a parent ie known yet.: use the relatively slower inventory
-            # probing method
+            # ensure the named path is added, so that ignore rules in the later
+            # directory walk dont skip it.
+            # we dont have a parent ie known yet.: use the relatively slower
+            # inventory probing method
             versioned = inv.has_filename(rf.raw_path)
             if versioned:
                 continue
@@ -443,10 +439,11 @@
             kind = osutils.file_kind(abspath)
 
             if not InventoryEntry.versionable_kind(kind):
-                warning("skipping %s (can't add file of kind '%s')", abspath, kind)
+                trace.warning("skipping %s (can't add file of kind '%s')",
+                              abspath, kind)
                 continue
             if illegalpath_re.search(directory.raw_path):
-                warning("skipping %r (contains \\n or \\r)" % abspath)
+                trace.warning("skipping %r (contains \\n or \\r)" % abspath)
                 continue
 
             if parent_ie is not None:
@@ -475,14 +472,15 @@
                 pass
                 # mutter("%r is already versioned", abspath)
             elif sub_tree:
-                # XXX: This is wrong; people *might* reasonably be trying to add
-                # subtrees as subtrees.  This should probably only be done in formats
-                # which can represent subtrees, and even then perhaps only when
-                # the user asked to add subtrees.  At the moment you can add them
-                # specially through 'join --reference', which is perhaps
-                # reasonable: adding a new reference is a special operation and
-                # can have a special behaviour.  mbp 20070306
-                mutter("%r is a nested bzr tree", abspath)
+                # XXX: This is wrong; people *might* reasonably be trying to
+                # add subtrees as subtrees.  This should probably only be done
+                # in formats which can represent subtrees, and even then
+                # perhaps only when the user asked to add subtrees.  At the
+                # moment you can add them specially through 'join --reference',
+                # which is perhaps reasonable: adding a new reference is a
+                # special operation and can have a special behaviour.  mbp
+                # 20070306
+                trace.mutter("%r is a nested bzr tree", abspath)
             else:
                 _add_one(self, inv, parent_ie, directory, kind, action)
                 added.append(directory.raw_path)
@@ -495,7 +493,7 @@
                     # without the parent ie, use the relatively slower inventory
                     # probing method
                     this_id = inv.path2id(
-                            self._fix_case_of_inventory_path(directory.raw_path))
+                        self._fix_case_of_inventory_path(directory.raw_path))
                     if this_id is None:
                         this_ie = None
                     else:
@@ -510,7 +508,7 @@
                     # faster - its impossible for a non root dir to have a
                     # control file.
                     if self.is_control_filename(subp):
-                        mutter("skip control directory %r", subp)
+                        trace.mutter("skip control directory %r", subp)
                     elif subf in this_ie.children:
                         # recurse into this already versioned subdir.
                         dirs_to_add.append((_FastPath(subp, subf), this_ie))
@@ -572,7 +570,8 @@
         inventory = basis.inventory._get_mutable_inventory()
         basis.unlock()
         inventory.apply_delta(delta)
-        rev_tree = RevisionTree(self.branch.repository, inventory, new_revid)
+        rev_tree = revisiontree.RevisionTree(self.branch.repository,
+                                             inventory, new_revid)
         self.set_parent_trees([(new_revid, rev_tree)])
 
 
@@ -661,8 +660,8 @@
         # there are a limited number of dirs we can be nested under, it should
         # generally find it very fast and not recurse after that.
         added = _add_one_and_parent(tree, inv, None,
-            _FastPath(dirname(path.raw_path)), 'directory', action)
-        parent_id = inv.path2id(dirname(path.raw_path))
+            _FastPath(osutils.dirname(path.raw_path)), 'directory', action)
+        parent_id = inv.path2id(osutils.dirname(path.raw_path))
         parent_ie = inv[parent_id]
     _add_one(tree, inv, parent_ie, path, kind, action)
     return added + [path.raw_path]




More information about the bazaar-commits mailing list