[Pkg-bazaar-commits] ./bzr/unstable r184: pychecker fixups

mbp at sourcefrog.net mbp at sourcefrog.net
Fri Apr 10 07:44:04 UTC 2009


------------------------------------------------------------
revno: 184
committer: mbp at sourcefrog.net
timestamp: Thu 2005-04-07 00:06:32 +1000
message:
  pychecker fixups
modified:
  NEWS
  bzrlib/__init__.py
  bzrlib/branch.py
  bzrlib/check.py
  bzrlib/commands.py
  bzrlib/info.py
  bzrlib/inventory.py
  bzrlib/osutils.py
  bzrlib/revision.py
  bzrlib/store.py
  bzrlib/trace.py
  bzrlib/tree.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2005-04-06 03:55:25 +0000
+++ b/NEWS	2005-04-06 14:06:32 +0000
@@ -1,3 +1,8 @@
+bzr-0.0.4  NOT RELEASED YET
+
+
+
+
 bzr-0.0.3  2005-04-06
 
   ENHANCEMENTS:

=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2005-04-06 03:55:25 +0000
+++ b/bzrlib/__init__.py	2005-04-06 14:06:32 +0000
@@ -38,5 +38,5 @@
 
 __copyright__ = "Copyright 2005 Canonical Development Ltd."
 __author__ = "Martin Pool <mbp at canonical.com>"
-__version__ = '0.0.3'
+__version__ = '0.0.4pre'
 

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2005-04-06 03:38:35 +0000
+++ b/bzrlib/branch.py	2005-04-06 14:06:32 +0000
@@ -31,7 +31,7 @@
      joinpath, sha_string, file_kind, local_time_offset, appendpath
 from store import ImmutableStore
 from revision import Revision
-from errors import bailout
+from errors import bailout, BzrError
 from textui import show_status
 from diff import diff_trees
 
@@ -47,7 +47,7 @@
 
     Basically we keep looking up until we find the control directory or
     run into the root."""
-    if f is None:
+    if f == None:
         f = os.getcwd()
     elif hasattr(os.path, 'realpath'):
         f = os.path.realpath(f)
@@ -56,14 +56,13 @@
 
     orig_f = f
 
-    last_f = f
     while True:
         if os.path.exists(os.path.join(f, bzrlib.BZRDIR)):
             return f
         head, tail = os.path.split(f)
         if head == f:
             # reached the root, whatever that may be
-            bailout('%r is not in a branch' % orig_f)
+            raise BzrError('%r is not in a branch' % orig_f)
         f = head
     
 
@@ -624,7 +623,9 @@
         ph = self.revision_history()
         if ph:
             return ph[-1]
-
+        else:
+            return None
+        
 
     def lookup_revision(self, revno):
         """Return revision hash for revision number."""
@@ -635,7 +636,7 @@
             # list is 0-based; revisions are 1-based
             return self.revision_history()[revno-1]
         except IndexError:
-            bailout("no such revision %s" % revno)
+            raise BzrError("no such revision %s" % revno)
 
 
     def revision_tree(self, revision_id):
@@ -816,7 +817,7 @@
 
 
 
-    def show_status(branch, show_all=False):
+    def show_status(self, show_all=False):
         """Display single-line status for non-ignored working files.
 
         The list is show sorted in order by file name.
@@ -849,10 +850,8 @@
         # Interesting case: the old ID for a file has been removed,
         # but a new file has been created under that name.
 
-        old = branch.basis_tree()
-        old_inv = old.inventory
-        new = branch.working_tree()
-        new_inv = new.inventory
+        old = self.basis_tree()
+        new = self.working_tree()
 
         for fs, fid, oldname, newname, kind in diff_trees(old, new):
             if fs == 'R':

=== modified file 'bzrlib/check.py'
--- a/bzrlib/check.py	2005-03-29 00:32:52 +0000
+++ b/bzrlib/check.py	2005-04-06 14:06:32 +0000
@@ -23,7 +23,6 @@
 import sys
 from sets import Set
 
-import bzrlib
 from trace import mutter
 from errors import bailout
 import osutils
@@ -74,7 +73,7 @@
         for file_id in inv:
             if file_id in seen_ids:
                 bailout('duplicated file_id {%s} in inventory for revision {%s}'
-                        % (file_id, revid))
+                        % (file_id, rid))
             seen_ids.add(file_id)
 
         i = 0
@@ -89,7 +88,7 @@
             if ie.parent_id != None:
                 if ie.parent_id not in seen_ids:
                     bailout('missing parent {%s} in inventory for revision {%s}'
-                            % (ie.parent_id, revid))
+                            % (ie.parent_id, rid))
 
             if ie.kind == 'file':
                 if ie.text_id in checked_texts:
@@ -109,7 +108,7 @@
             elif ie.kind == 'directory':
                 if ie.text_sha1 != None or ie.text_size != None or ie.text_id != None:
                     bailout('directory {%s} has text in revision {%s}'
-                            % (file_id, revid))
+                            % (file_id, rid))
 
         p('revision %d/%d file paths' % (revno, revcount))
         for path, ie in inv.iter_entries():

=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-04-06 03:43:00 +0000
+++ b/bzrlib/commands.py	2005-04-06 14:06:32 +0000
@@ -62,9 +62,7 @@
 
 
 
-import sys, os, random, time, sha, sets, types, re, shutil, tempfile
-import traceback, socket, fnmatch, difflib
-from os import path
+import sys, os, time, types, shutil, tempfile, traceback, fnmatch, difflib, os.path
 from sets import Set
 from pprint import pprint
 from stat import *
@@ -73,7 +71,7 @@
 import bzrlib
 from bzrlib.store import ImmutableStore
 from bzrlib.trace import mutter, note, log_error
-from bzrlib.errors import bailout, BzrError
+from bzrlib.errors import bailout, BzrError, BzrCheckError
 from bzrlib.osutils import quotefn, pumpfile, isdir, isfile
 from bzrlib.tree import RevisionTree, EmptyTree, WorkingTree, Tree
 from bzrlib.revision import Revision
@@ -296,14 +294,6 @@
         print fip
 
 
-def cmd_find_filename(fileid):
-    n = find_filename(fileid)
-    if n is None:
-        bailout("%s is not a live file id" % fileid)
-    else:
-        print n
-
-
 def cmd_revision_history():
     for patchid in Branch('.').revision_history():
         print patchid
@@ -363,8 +353,6 @@
         old_tree = b.revision_tree(b.lookup_revision(revision))
         
     new_tree = b.working_tree()
-    old_inv = old_tree.inventory
-    new_inv = new_tree.inventory
 
     # TODO: Options to control putting on a prefix or suffix, perhaps as a format string
     old_label = ''
@@ -381,8 +369,6 @@
     # TODO: Better to return them in sorted order I think.
     
     for file_state, fid, old_name, new_name, kind in bzrlib.diff_trees(old_tree, new_tree):
-        d = None
-
         # Don't show this by default; maybe do it if an option is passed
         # idlabel = '      {%s}' % fid
         idlabel = ''
@@ -464,7 +450,8 @@
 
 
 def cmd_load_inventory():
-    inv = Branch('.').basis_tree().inventory
+    """Load inventory for timing purposes"""
+    Branch('.').basis_tree().inventory
 
 
 
@@ -532,11 +519,11 @@
 
 
 
-def cmd_ignored(verbose=True):
+def cmd_ignored():
     """List ignored files and the patterns that matched them.
       """
     tree = Branch('.').working_tree()
-    for path, file_class, kind, id in tree.list_files():
+    for path, file_class, kind, file_id in tree.list_files():
         if file_class != 'I':
             continue
         ## XXX: Slightly inefficient since this was already calculated
@@ -644,11 +631,10 @@
 
 
 def cmd_gen_revision_id():
-    import time
     print bzrlib.branch._gen_revision_id(time.time())
 
 
-def cmd_selftest(verbose=False):
+def cmd_selftest():
     """Run internal test suite"""
     ## -v, if present, is seen by doctest; the argument is just here
     ## so our parser doesn't complain
@@ -879,7 +865,7 @@
             if args:
                 argdict[argname] = args.pop(0)
         elif ap[-1] == '*':
-            assert 0
+            raise BzrError("arg form %r not implemented yet" % ap)
         elif ap[-1] == '+':
             if not args:
                 bailout("command %r needs one or more %s"
@@ -974,6 +960,8 @@
         #stats.strip_dirs()
         stats.sort_stats('time')
         stats.print_stats(20)
+
+        return ret
     else:
         return cmd_handler(**cmdargs) or 0
 

=== modified file 'bzrlib/info.py'
--- a/bzrlib/info.py	2005-03-28 02:40:49 +0000
+++ b/bzrlib/info.py	2005-04-06 14:06:32 +0000
@@ -31,7 +31,7 @@
     def plural(n, base='', pl=None):
         if n == 1:
             return base
-        elif pl is not None:
+        elif pl == None:
             return pl
         else:
             return 's'

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2005-04-06 03:38:35 +0000
+++ b/bzrlib/inventory.py	2005-04-06 14:06:32 +0000
@@ -35,7 +35,7 @@
     from elementtree.ElementTree import Element, ElementTree, SubElement
 
 from xml import XMLMixin
-from errors import bailout
+from errors import bailout, BzrError
 
 import bzrlib
 from bzrlib.osutils import uuid, quotefn, splitpath, joinpath, appendpath
@@ -392,12 +392,12 @@
         'hello.c'
         """
         if file_id == None:
-            bailout("can't look up file_id None")
+            raise BzrError("can't look up file_id None")
             
         try:
             return self._byid[file_id]
         except KeyError:
-            bailout("file_id {%s} not in inventory" % file_id)
+            raise BzrError("file_id {%s} not in inventory" % file_id)
 
 
     def get_child(self, parent_id, filename):

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2005-04-06 12:21:15 +0000
+++ b/bzrlib/osutils.py	2005-04-06 14:06:32 +0000
@@ -263,7 +263,7 @@
     >>> splitpath('a/.b')
     ['a', '.b']
     >>> splitpath('a/../b')
-    Traeceback (most recent call last):
+    Traceback (most recent call last):
     ...
     BzrError: ("sorry, '..' not allowed in path", [])
     """

=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py	2005-03-12 07:38:31 +0000
+++ b/bzrlib/revision.py	2005-04-06 14:06:32 +0000
@@ -1,5 +1,4 @@
-#! /usr/bin/env python
-# -*- coding: UTF-8 -*-
+# (C) 2005 Canonical
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,6 +24,8 @@
 except ImportError:
     from elementtree.ElementTree import Element, ElementTree, SubElement
 
+from errors import BzrError
+
 
 class Revision(XMLMixin):
     """Single revision on a branch.
@@ -41,12 +42,13 @@
         self.timestamp = None
         self.message = None
         self.timezone = None
+        self.committer = None
+        self.precursor = None
         self.__dict__.update(args)
 
 
     def __repr__(self):
-        if self.revision_id:
-            return "<Revision id %s>" % self.revision_id
+        return "<Revision id %s>" % self.revision_id
 
         
     def to_element(self):
@@ -70,7 +72,7 @@
     def from_element(cls, elt):
         # <changeset> is deprecated...
         if elt.tag not in ('revision', 'changeset'):
-            bailout("unexpected tag in revision file: %r" % elt)
+            raise BzrError("unexpected tag in revision file: %r" % elt)
 
         cs = cls(committer = elt.get('committer'),
                  timestamp = float(elt.get('timestamp')),

=== modified file 'bzrlib/store.py'
--- a/bzrlib/store.py	2005-04-04 10:35:13 +0000
+++ b/bzrlib/store.py	2005-04-06 14:06:32 +0000
@@ -1,5 +1,4 @@
-#! /usr/bin/env python
-# -*- coding: UTF-8 -*-
+
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by

=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py	2005-04-04 13:57:54 +0000
+++ b/bzrlib/trace.py	2005-04-06 14:06:32 +0000
@@ -33,7 +33,7 @@
 _tracefile = None
 
 # used to have % (os.environ['USER'], time.time(), os.getpid()), 'w')
-
+_starttime = None
 
 # If false, notes also go to stdout; should replace this with --silent
 # at some point.

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2005-04-06 03:38:35 +0000
+++ b/bzrlib/tree.py	2005-04-06 14:06:32 +0000
@@ -78,7 +78,7 @@
         fp = fingerprint_file(f)
         f.seek(0)
         
-        if ie.text_size is not None:
+        if ie.text_size != None:
             if ie.text_size != fp['size']:
                 bailout("mismatched size for file %r in %r" % (ie.file_id, self._store),
                         ["inventory expects %d bytes" % ie.text_size,
@@ -121,7 +121,7 @@
             elif kind == 'file':
                 pumpfile(self.get_file(ie.file_id), file(fullpath, 'wb'))
             else:
-                bailout("don't know how to export {%s} of kind %r", fid, kind)
+                bailout("don't know how to export {%s} of kind %r" % (fid, kind))
             mutter("  export {%s} kind %s to %s" % (ie.file_id, kind, fullpath))
 
 



More information about the Pkg-bazaar-commits mailing list