]> thyrsus.com Git - rcs-fast-import.git/commitdiff
pylint cleanup.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 5 Dec 2012 22:12:58 +0000 (17:12 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 5 Dec 2012 22:12:58 +0000 (17:12 -0500)
Makefile
rcs-fast-import

index 01a16e6f54ba21351e2a9caeabd297bd60fb2776..e88086bfc0d5e50bc166333c0e209c96432a1be6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 #
 # makefile for rcs-fast-import
 #
-VERS=$(shell sed <rcs-fast-import -n -e '/version=\(.*\)/s//\1/p')
+VERS=$(shell sed <rcs-fast-import -n -e '/version *= *\(.*\)/s//\1/p')
 
 SOURCES = README COPYING NEWS rcs-fast-import rcs-fast-import.xml Makefile control
 
@@ -23,11 +23,9 @@ rcs-fast-import-$(VERS).tar.gz: $(SOURCES) rcs-fast-import.1
        (cd ..; tar -czvf rcs-fast-import/rcs-fast-import-$(VERS).tar.gz `cat rcs-fast-import/MANIFEST`)
        @(cd ..; rm rcs-fast-import-$(VERS))
 
-pychecker:
-       @echo "Expect four messages about unknown methods checkin and maketag."
-       @ln -f rcs-fast-import rcs-fast-import.py
-       @-pychecker --quiet --only --limit 50 rcs-fast-import.py
-       @rm -f rcs-fast-import.py rcs-fast-import.pyc
+PYLINTOPTS = --rcfile=/dev/null --reports=n --include-ids=y --disable="C0103,C0111,C0301,C0323,R0902,R0903,R0912,R0913,R0914,R0915,W0141,W0333,W0142,W0621,E1101"
+pylint:
+       @pylint --output-format=parseable $(PYLINTOPTS) rcs-fast-import
 
 version:
        @echo $(VERS)
index 369625f3c845bd212a45744b5669b35321dd4fcf..cce9b7733e603fde5d8fc127ce49c68724023e8d 100755 (executable)
@@ -29,7 +29,7 @@ this help and exits.
 import sys, os, getopt, re, cStringIO, subprocess
 import time, shlex, email.message, email.utils
 
-version="0.1"
+version = "0.1"
 
 #
 # Generic import-stream machinery swiped from reposurgeon begins here.
@@ -52,6 +52,8 @@ class Baton:
             self.stream = sys.stdout
         else:
             self.stream = None
+        self.count = 0
+        self.time = 0
     def __enter__(self):
         if self.stream:
             self.stream.write(self.prompt + "...")
@@ -214,10 +216,10 @@ class Commit:
         self.childbranches = []      # Count of child branches at this point.
     def children(self):
         "Get a list of this commit's children."
-        return filter(lambda e:self.mark in e.parent_marks,self.repo.commits()) 
+        return filter(lambda e:self.mark in e.parent_marks, self.repo.commits()) 
     def parents(self):
         "Get a list of this commit's parents."
-        return filter(lambda e:e.mark in self.parent_marks,self.repo.commits()) 
+        return filter(lambda e:e.mark in self.parent_marks, self.repo.commits()) 
     def is_tip(self):
         "Is this commit a branch tip?"
         # Added for rcs-fast-import
@@ -260,6 +262,7 @@ class Passthrough:
 class FatalException(Exception):
     "Unrecoverable error."
     def __init__(self, msg):
+        Exception.__init__(self)
         self.msg = msg
 
 class Repository:
@@ -320,7 +323,6 @@ class Repository:
             with Baton("rcs-fast-import:", enable=progress) as baton:
                 self.import_line = 0
                 linebuffers = []
-                ncommits = 0
                 def read_data(dp, line=None):
                     if not line:
                         line = readline()
@@ -378,7 +380,6 @@ class Repository:
                         commit = Commit(self)
                         commit.branch = line.split()[1]
                         self.branches.add(commit.branch)
-                        ncommits += 1
                         while True:
                             line = readline()
                             if not line:
@@ -530,7 +531,7 @@ class Repository:
     def __setitem__(self, i, v):
         self.events[i] = v
 
-def sanecheck(event_unused, path, mode):
+def sanecheck(_event, path, mode):
     "Sanity-check an operation to see if we can cope."
     if mode == "160000":
         raise FatalException("cannot import submodule link %s" % path)
@@ -670,12 +671,12 @@ class Generic:
             try:
                 os.link(copyfile, path)
             except OSError, e:
-                raise FatalException("refusing to step on %s: %s." % (path,`e`))
+                raise FatalException("refusing to step on %s: %s." % (path, `e`))
         return rcsdir
     def masterfiles(self):
         "List all masters."
         res = []
-        for root, dirs, files in os.walk(os.getcwd(), topdown=False):
+        for root, _dirs, files in os.walk(os.getcwd(), topdown=False):
             if root.endswith(os.sep + self.__class__.repodirectory):
                 for name in files:
                     res.append(os.path.join(root, name))
@@ -686,9 +687,9 @@ class Generic:
     def supercheckin(self, commit, op, path, legend):
         "You knew the job was dangerous when you took it."
         if self.roundtrip:
-            comment = event.email_out()
+            comment = commit.email_out()
         else:
-            comment = event.comment
+            comment = commit.comment
         rev = self.make_tip(commit, path)
         do_or_die(self.checkin(commit, comment, op, path, rev), legend)
         loud_remove(path)
@@ -766,17 +767,17 @@ if __name__ == '__main__':
     checkout_mode = None
     roundtrip = True
     for (switch, val) in options:
-       if (switch == '-?'):
-           print __doc__
+        if (switch == '-?'):
+            print __doc__
             raise SystemExit, 0
         elif switch == '-p':
             roundtrip = False
         elif switch in ('-l', '-u'):
             checkout_mode = switch
-       elif (switch == '-v'):
-           verbose += 1
-       elif (switch == '-V'):
-           print "rcs-fast-import version %s" % version
+        elif (switch == '-v'):
+            verbose += 1
+        elif (switch == '-V'):
+            print "rcs-fast-import version %s" % version
 
     vcs = RCS()
     vcs.roundtrip = roundtrip 
@@ -811,7 +812,7 @@ if __name__ == '__main__':
                         elif op.op in ("D", "deleteall"):
                             if verbose >= DEBUG_OPS:
                                 announce("%5s D %s" % (event.mark, op.path))
-                            vcs.delete(op.path)
+                            vcs.delete(event, op.path)
                         elif op.op == "R":
                             if verbose >= DEBUG_OPS:
                                 announce("%5s R '%s' '%s'" % (event.mark, op.source, op.target))