if item.revno == revno:
return item.revision
croak("{0} has no revno {1}".format(self.name, revno))
+ def resolve(self, revspec):
+ "Resolve a revision spec that may contain tags into revnos."
+ if revspec is None:
+ return None
+ (start, end) = revspec
+ if type(start) == type(""):
+ if start in self.symbols:
+ start = self.symbols[start]
+ else:
+ croak("can't resolve symbol {0} in {1}".format(start,self.name))
+ if type(end) == type(""):
+ if end in self.symbols:
+ end = self.symbols[end]
+ else:
+ croak("can't resolve symbol {0} in {1}".format(end, self.name))
+ return range(start, end+1)
def help_method(*args):
"Summarize src commands, or (with argument) show help for a single command."
try:
if "-" in revspec:
(start, end) = revspec.split("-")
- start = int(start)
- end = int(end)
+ try:
+ start = int(start)
+ except ValueError:
+ pass
+ try:
+ end = int(end)
+ except ValueError:
+ pass
else:
- start = int(revspec)
+ try:
+ start = int(revspec)
+ except ValueError:
+ pass
end = start
except ValueError:
croak("malformed revision spec: %s" % revspec)
- revspec = range(start, end+1)
+ revspec = (start, end)
if not args:
masters = os.listdir(".src")
if len(masters) == 1:
width = screenwidth()
for arg in args:
sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
- for item in RCSLog(arg):
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
+ for item in master:
if not revspec or item.revno in revspec:
# Must allow enough room for revno and date
summary = item.log.strip()[:width - 34]
width = screenwidth()
for arg in args:
sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
- for item in RCSLog(arg):
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
+ for item in master:
if not revspec or item.revno in revspec:
sys.stdout.write("%-4d | %s\n%s" % (item.revno, item.date, item.log))
sys.stdout.write(("-" * (width - 1)) + "\n")
if revspec and len(revspec) > 1:
croak("checkout needs an empty or singleton revision spec")
for arg in args:
- revlist = RCSLog(arg)
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
if revspec is None:
- revspec = [len(revlist)]
+ revspec = [len(master)]
revision = ""
elif len(revspec) != 1:
croak("checkout cannot take a range")
- elif revspec[0] > len(revlist):
- croak("%s has only %d revisions" % (arg, len(revlist)))
+ elif revspec[0] > len(master):
+ croak("%s has only %d revisions" % (arg, len(master)))
else:
- revision = revlist[len(revlist) - revspec[0]].revision
+ revision = master[len(master) - revspec[0]].revision
with lifted(arg):
do_or_die("rm -f {0} && rcs -q -u {0},v && co -q -l{1} {0}".format(arg, revision))
announce("%s <- %d" % (arg, revspec[0]))
"Dump revision content to standard output."
(revspec, args) = preamble("cat", args)
for arg in args:
- revlist = RCSLog(arg)
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
if revspec is None:
- revspec = range(1, len(revlist)+1)
+ revspec = range(1, len(master)+1)
with lifted(arg):
- for item in revlist:
+ for item in master:
if item.revno in revspec:
do_or_die("co -q -p -r{1} {0}".format(arg, item.revision), loud=True)
for arg in args:
diffspec = ""
if revspec is not None:
- state = RCSLog(arg)
- diffspec += "-r" + state.revno_to_rcs(revspec[0])
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
+ diffspec += "-r" + master.revno_to_rcs(revspec[0])
if len(revspec) > 1:
- diffspec += " -r" + state.revno_to_rcs(revspec[1])
+ diffspec += " -r" + master.revno_to_rcs(revspec[1])
with lifted(arg):
# The || : suppresses the error return from diff(1)
do_or_die("rcsdiff -q {0} {1} {2} || :".format(diffspec, diffopts, arg),loud=True)
croak("can't accept a revision-spec when deleting tags.")
width = screenwidth()
for arg in args:
- state = RCSLog(arg)
+ master = RCSLog(arg)
sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
- for (key, value) in state.symbols.items():
- sys.stdout.write("%4d %s\n" % (state.rcs_to_revno(value),key))
+ for (key, value) in master.symbols.items():
+ sys.stdout.write("%4d %s\n" % (master.rcs_to_revno(value),key))
def delete_tags(args):
if not args:
if not args:
croak("setting tags requires a tagname argument")
tagname = args.pop(0)
+ if not args:
+ croak("setting tags requires a revision-spec after the tag name")
(revspec, args) = preamble("tag", args)
- print "Foo!", revspec
for arg in args:
- state = RCSLog(arg)
+ master = RCSLog(arg)
+ revspec = master.resolve(revspec)
if revspec is None:
- revision = state.tip().revision
+ revision = master.tip().revision
elif len(revspec) == 1:
- revision = state.revno_to_rcs(revspec[0])
+ revision = master.revno_to_rcs(revspec[0])
else:
croak("can't accept a range when setting tags.")
with lifted(arg):