From 6b05d7e52a6792d614110703a10be886b5f96a30 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 10 Nov 2014 16:07:56 -0500 Subject: [PATCH] Code is pyjint clean. Regression test passs. --- Makefile | 2 +- src | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 5471614..10a34e7 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ src-$(VERS).tar.gz: $(SOURCES) src.1 COMMON_PYLINT = --rcfile=/dev/null --reports=n \ --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \ --dummy-variables-rgx='^_' -PYLINTOPTS = "C0103,C0301,C0302,C0326,C1001,C0111,R0903,R0912,R0915,W0110,W0141,W0311,W0312,W0603" +PYLINTOPTS = "C0103,C0301,C0302,C0326,C1001,C0111,R0903,R0201,R0912,R0914,R0915,W0110,W0141,W0232,W0311,W0312,W0603,W0511,W0613" pylint: @pylint $(COMMON_PYLINT) --disable=$(PYLINTOPTS) src diff --git a/src b/src index 895f9f3..b5b7ff2 100755 --- a/src +++ b/src @@ -24,7 +24,7 @@ # This code uses magic tags with a 0 in the second-to-last slot to designate # branches. It's the same format as CVS sticky tags. # -import sys, os, subprocess, time, calendar, stat, glob +import sys, os, subprocess, time, calendar, stat, glob, shutil version=0.3 @@ -318,7 +318,7 @@ class CommandContext: except ValueError: croak("malformed revision spec: %s" % revspec) if require_empty and not self.is_empty(): - croak("%s doesn't take a revision spec" % legend) + croak("%s doesn't take a revision spec" % cmd) if not self.args: try: masters = os.listdir(repodir) @@ -529,7 +529,7 @@ def checkout_method(*args): # Changes the access and modification times # Later, src status will see this. Alas, # there's a tiny race window here. - os.utime(backend.master(arg, None)) + os.utime(backend.master(arg), None) if not quiet and len(args) > 1: announce("%s <- %d" % (arg, ctx.start)) @@ -593,6 +593,8 @@ def cat_method(*args): def diff_method(*args): "Dump diffs between revisions to standard output." ctx = CommandContext("diff", args) + if type(args) == type(()): + args = list(args) diffopts = "-u" while args and args[0].startswith("-"): diffopts += " " + args.pop(0) @@ -669,8 +671,9 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method): if not ctx.is_empty(): croak("can't accept a revision-spec when %s renaming." % legend) # In the case of a branch, we want to change only the tag reference. - backend.tag_set(newname, self.symbols[name], arg) - backend.tag_delete(name, arg) + for arg in ctx.args: + backend.set_tag(newname, metadata.symbols[name], metadata, arg) + backend.delete_tag(name, arg) if not args: croak("%s setting requires a name argument" % legend) name = args.pop(0) @@ -692,7 +695,7 @@ def tag_method(*args): def tag_set_validate(ctx, metadata, name): ctx.resolve(metadata) if name in metadata.symbols: - croak("%s %s already set." % (legend, name)) + croak("tag %s already set.") if ctx.is_empty(): ctx.start = metadata.tip().revno return metadata.revno_to_rcs(ctx.start) @@ -702,7 +705,7 @@ def tag_method(*args): def branch_method(*args): "Inspect, create, and delete branches." - def branch_set_validate(ctx, metadata, name): + def branch_set_validate(ctx, _metadata, _name): if not ctx.is_empty(): croak("cannot accept a revision after a branch name") tag_helper(args, "branch", @@ -710,7 +713,7 @@ def branch_method(*args): backend.delete_branch, backend.set_branch) def filecmd(legend, hook, args): - ctx = CommandContext(legend, args, require_empty=True) + CommandContext(legend, args, require_empty=True) if len(args) != 2: croak("%s requires exactly two arguments" % legend) (source, target) = args @@ -817,7 +820,7 @@ def fast_export_method(*args): sys.stdout.write("reset refs/heads/%s\nfrom :%d\n\n" % (branch, mark)) for (key, val) in metadata.symbols.items(): val = metadata.rcs_to_revno(val) - if val in revrange: + if val in ctx: sys.stdout.write("reset refs/tags/%s\nfrom :%d\n\n" % (key, markmap[val])) def fast_import_method(*args): @@ -1067,20 +1070,20 @@ class RCS: if __name__ == "__main__": try: - command = list(sys.argv[1:]) + commandline = list(sys.argv[1:]) explicit = False - while command and command[0].startswith("-"): - if command[0] == '-d': + while commandline and commandline[0].startswith("-"): + if commandline[0] == '-d': debug += 1 - elif command[0] == '-q': + elif commandline[0] == '-q': quiet = True - elif command[0] == '-T': + elif commandline[0] == '-T': pseudotime = True - elif command[0] == '-S': - repodir = command[1] + elif commandline[0] == '-S': + repodir = commandline[1] explicit = True - command.pop(0) - command.pop(0) + commandline.pop(0) + commandline.pop(0) # RCS backwards-compatibility hack if not explicit and not os.path.exists(repodir) and os.path.exists("RCS"): @@ -1089,14 +1092,14 @@ if __name__ == "__main__": # Presently there is only one backend backend = RCS() - if not command: + if not commandline: help_method() else: try: - apply(dispatch[command[0]], command[1:]) + apply(dispatch[commandline[0]], commandline[1:]) except KeyError: - sys.stderr.write("src: no such command as '%s'. Try 'src help'\n" \ - % command[0]) + sys.stderr.write("src: no such commandline as '%s'. Try 'src help'\n" \ + % commandline[0]) except KeyboardInterrupt: pass -- 2.43.0