def complain(msg):
sys.stderr.write("src: " + msg + "\n")
+def croak(msg):
+ sys.stderr.write("src: " + msg + "\n")
+ sys.exit(1)
+
debug = 1
DEBUG_COMMANDS = 1 # Show commands as they are executed
else:
complain(".src/ exists but is not a directory.")
+def preamble(cmd, args):
+ "Common setup code."
+ if args:
+ return list(args)
+ else:
+ masters = os.listdir(".src")
+ if len(masters) == 1:
+ return [masters[0][:-2]]
+ else:
+ croak("%s requires at least one file argument" % cmd)
+
def add_method(*args):
"Register a file into src control."
- preamble("add", args)
+ args = preamble("add", args)
for arg in args:
if not os.path.exists(arg):
complain("I see no '%s' here." % arg)
- elif os.path.exists(".src/%s,v"):
- complain("%s is already registered.")
+ elif os.path.exists(".src/%s,v" % arg):
+ complain("%s is already registered." % arg)
else:
do_or_die("rcs -q -i %s </dev/null" % arg)
do_or_die("ci -l %s && mv %s,v .src" % (arg, arg))
announce("%s: 1" % arg)
-def preamble(cmd, args):
- "Common setup code."
- if not args:
- masters = os.listdir(".src")
- if len(masters) == 1:
- args.append(masters[0])
-
def commit_method(*args):
"Commit changes to files."
- preamble("commit", args)
+ args = preamble("commit", args)
for arg in args:
if not os.path.exists(arg):
complain("I see no '%s' here." % arg)