[MERGE] working tree cleanups

Robert Collins robertc at robertcollins.net
Sat Jul 15 15:06:47 BST 2006


On Fri, 2006-07-14 at 09:19 -0500, John Arbash Meinel wrote:

> > 
> > === modified file 'bzrlib/workingtree.py'
> > --- bzrlib/workingtree.py	2006-07-03 18:27:35 +0000
> > +++ bzrlib/workingtree.py	2006-07-13 10:45:47 +0000
> > @@ -53,6 +53,8 @@
> >  
> >  from bzrlib import bzrdir, errors, osutils, urlutils
> >  from bzrlib.atomicfile import AtomicFile
> > +import bzrlib.branch
> > +import bzrlib.bzrdir as bzrdir
> ^^^ we already import bzrdir
> 
> from bzrlib import bzrdir
> 
> and I think that is the preferred form now. I know it will work much
> better with demandload. And I believe pyflakes complains less.

AIUI from bzrlib import bzrdir will not work unless bzrdir is already
imported by the codebase - bzrdir is an attribute of bzrlib only after
the import of the children is complete. I may be wrong here - its
possibly worth a quick test. Anyway, I'm happy to remove the 'from
bzrlib import bzrdir' instance, which is not in alphabetical order :).

> >  from bzrlib.conflicts import Conflict, ConflictList, CONFLICT_SUFFIXES
> >  from bzrlib.decorators import needs_read_lock, needs_write_lock
> >  from bzrlib.errors import (BzrCheckError,
> > @@ -95,13 +97,12 @@
> >          DEPRECATED_PARAMETER,
> >          zero_eight,
> >          )
> > -
> > -from bzrlib.textui import show_status
> > -import bzrlib.tree
> > +from bzrlib.trace import mutter, note
> >  from bzrlib.transform import build_tree
> > -from bzrlib.trace import mutter, note
> >  from bzrlib.transport import get_transport
> >  from bzrlib.transport.local import LocalTransport
> > +from bzrlib.textui import show_status
> > +import bzrlib.tree
> >  import bzrlib.ui
> >  import bzrlib.xml5
> 
> +1 to this, though.
> >  
> > @@ -268,8 +269,7 @@
> >              # share control object
> >              self._control_files = self.branch.control_files
> >          else:
> > -            # only ready for format 3
> > -            assert isinstance(self._format, WorkingTreeFormat3)
> > +            # assume all other formats have their own control files.
> >              assert isinstance(_control_files, LockableFiles), \
> >                      "_control_files must be a LockableFiles, not %r" \
> >                      % _control_files
> > @@ -1724,7 +1724,7 @@
> >            files, separate from the BzrDir format
> >          - modifies the hash cache format
> >          - is new in bzr 0.8
> > -        - uses a LockDir to guard access to the repository
> > +        - uses a LockDir to guard access for writes.
> >      """
> >  
> >      def get_format_string(self):
> > @@ -1794,7 +1794,14 @@
> >              raise NotImplementedError
> >          if not isinstance(a_bzrdir.transport, LocalTransport):
> >              raise errors.NotLocalUrl(a_bzrdir.transport.base)
> > -        control_files = self._open_control_files(a_bzrdir)
> > +        return self._open(a_bzrdir, self._open_control_files(a_bzrdir))
> > +
> > +    def _open(self, a_bzrdir, control_files):
> > +        """Open the tree itself.
> > +        
> > +        :param a_bzrdir: the dir for the tree.
> > +        :param control_files: the control files for the tree.
> > +        """
> >          return WorkingTree3(a_bzrdir.root_transport.local_abspath('.'),
> >                             _internal=True,
> >                             _format=self,
> > 
> 
> The old code wasn't returning anything. Is there a reason you changed
> that? It seems like we probably should have been returning *something*,
> though. So if you have a reason, +1.

It sure was returning something. This is the old code:
            raise NotImplementedError
        if not isinstance(a_bzrdir.transport, LocalTransport):
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
        control_files = self._open_control_files(a_bzrdir)
        return WorkingTree3(a_bzrdir.root_transport.local_abspath('.'),
                            _internal=True,
                            _format=self,


I'll hold of merging this till we have a clear consensus on the import
thing.

-Rob
-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060716/b9326913/attachment.pgp 


More information about the bazaar mailing list