]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Fix bugs caught by pychecker.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 21 Nov 2010 15:26:04 +0000 (10:26 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 21 Nov 2010 15:26:04 +0000 (10:26 -0500)
Makefile
rcs-fast-import

index 05ae43b3b844739124d22e925f465c0ccf9e5b98..218b63e7fc971d0b01e25c9d3b7b055ab8cbdbea 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,6 +23,11 @@ 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:
+       ln -f rcs-fast-import rcs-fast-import.py
+       pychecker --only --limit 50 rcs-fast-import.py
+       rm -f rcs-fast-import.py
+
 version:
        @echo $(VERS)
 
index 2f0dd5768ee1c717c1e044e77f5b200b8d764bfa..3e42b53cda295e78b43054e57ce662f0441279d2 100755 (executable)
@@ -26,8 +26,8 @@ The -V option displays the program version number and exits. -? displays
 this help and exits.
 """
 
-import sys, os, getopt, re, cStringIO, subprocess, shutil
-import time, calendar, copy, shlex, email.message, email.utils
+import sys, os, getopt, re, cStringIO, subprocess
+import time, shlex, email.message, email.utils
 
 version="0.1"
 
@@ -195,6 +195,7 @@ class FileOp:
             self.op = "deleteall"
         else:
             raise FatalException("unexpected fileop %s while parsing" % opline)
+        self.copyname = None
 
 class Commit:
     "Generic commit object."
@@ -256,7 +257,7 @@ class Passthrough:
     def __init__(self, line):
         self.text = line
 
-class FatalException:
+class FatalException(Exception):
     "Unrecoverable error."
     def __init__(self, msg):
         self.msg = msg
@@ -400,7 +401,7 @@ class Repository:
                                 if len(fields) < 3:
                                     self.error("malformed property line")
                                 elif len(fields) == 3:
-                                    self.properties[fields[1]] = True
+                                    commit.properties[fields[1]] = True
                                 else:
                                     name = fields[1]
                                     length = int(fields[2])
@@ -424,7 +425,7 @@ class Repository:
                             elif line[0] in ("C", "D", "R"):
                                 commit.fileops.append(FileOp(line, commit))
                             elif line == "filedeleteall\n":
-                                commit.fileops.append(FileOp("filedeleteall"), commit)
+                                commit.fileops.append(FileOp("filedeleteall", commit))
                             elif line[0] == "M":
                                 fileop = FileOp(line, commit)
                                 if commit.mark is None:
@@ -455,13 +456,6 @@ class Repository:
                                 # a commit subpart.
                                 continue
                             else:
-                                # Dodgy bzr autodetection hook...
-                                if not self.vcs:
-                                    if "branch-nick" in commit.properties:
-                                        for vcs in vcstypes:
-                                            if vcs.name == "bzr":
-                                                self.vcs = vcs
-                                                break
                                 pushback(line)
                                 break
                         if not (commit.mark and commit.committer):
@@ -536,12 +530,12 @@ class Repository:
     def __setitem__(self, i, v):
         self.events[i] = v
 
-def sanecheck(event, path, mode, copyfile):
+def sanecheck(event, path, mode):
     "Sanity-check an operation to see if we can cope."
     if mode == "160000":
-        raise FatalException("ignoring a submodule link %s", path)
+        raise FatalException("cannot import submodule link %s", path)
     elif mode == "120000":
-        raise FatalException("ignoring a symlink %s", path)
+        raise FatalException("cannot import a symlink %s", path)
     if not mode[-3:] in ('644', '755'):
         raise FatalException("unknown mode %s on %s", (mode, path))
 
@@ -704,7 +698,7 @@ class Generic:
             self.maketag(reset.ref, str(rev), path)
     def modify(self, event, path, mode, copyfile):
         "Perform file checkins and modifications,"
-        sanecheck(event, path, mode, copyfile)
+        sanecheck(event, path, mode)
         self.instantiate(path, copyfile)
         self.supercheckin(event, "M", path, "modify")
         #self.record("M", path)
@@ -722,7 +716,7 @@ class Generic:
         "Mark a path deleted, but don't actually remove the master."
         self.instantiate(path)
         open(path, "w").close()
-        self.supercheckin(commit, "D", path, "delete")
+        self.supercheckin(commit, "D", path, legend)
         #self.record("D", path)
     def rename(self, commit, source, target):
         "Perform RCS renames, carrying history with the rename."
@@ -825,7 +819,7 @@ if __name__ == '__main__':
                         elif op.op == "C":
                             if verbose >= DEBUG_OPS:
                                 announce("%5s C '%s' '%s'" % (event.mark, op.source, op.target))
-                            vcs.copy(commit, ops.source, op.target)
+                            vcs.copy(event, op.source, op.target)
                         else:
                             raise FatalException("unknown op type %s" % op.op)
                     vcs.postcommit(event)