[MERGE] Minor tree and dirstate code cleanups
Robert Collins
robertc at robertcollins.net
Fri Sep 14 03:12:00 BST 2007
On Fri, 2007-09-14 at 11:59 +1000, Ian Clatworthy wrote:
> Robert Collins wrote:
>
> > -header line = "#bazaar dirstate flat format 2", NL;
> > +header line = "#bazaar dirstate flat format N", NL;
> >
> > This is an incorrect change to make. Its not a substitution variable,
> > its is the specification for format 2.
>
> But it's up to 3 now. Is 2-> 3 ok with you?
Is it? Ok.
> > What is this:
> > @@ -275,7 +274,8 @@
> > def _directory_is_tree_reference(self, relpath):
> > # as a special case, if a directory contains control files
> > then
> > # it's a tree reference, except that the root of the tree is
> > not
> > - return relpath and osutils.isdir(self.abspath(relpath) +
> > u"/.bzr")
> > + return len(relpath) > 0 and \
> > + osutils.isdir(self.abspath(relpath) + u"/.bzr")
> >
> > change for?
>
> I was trying to make it clear that we're testing for 'not root'.
>
> relpath != ''
>
> would be equally clear or perhaps better. If relpath was 0 (very
> unlikely), the test would fail unexpectedly. It's not so much an issue
> with Python but this paranoia comes from my Perl days when a directory
> called '0' really would be evaluated as False.
>
> I'm happy to back that bit out btw - just explaining why I changed it.
if <string>: is 6 times faster than if len(string) > 0.
When the failure mode is safe, 'if thing' is very efficient.
-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: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070914/ebb48d2b/attachment.pgp
More information about the bazaar
mailing list