self.name = name
self.revlist = []
self.symbols = {}
+ self.branch = "trunk"
self.delimiter = None
if not os.path.exists(backend.master(self.name)):
croak("%s is not registered" % self.name)
if debug >= DEBUG_PARSE:
sys.stderr.write("\t-> symbols\n")
state = "symbols"
+ elif line.startswith("branch:"):
+ if not line.strip()[7:]:
+ self.branch = "trunk"
+ else:
+ croak("non-trunk branches are not yet supported.")
elif line.startswith("----------------------------"):
if debug >= DEBUG_PARSE:
sys.stderr.write("\t-> logheader\n")
if not quiet and len(args) > 1:
announce("tag %s = %s in " % (tagname, revno, arg))
-
-def tag_method(*args):
- "Inspect, create, and delete tags."
+def tag_helper(args, list_tags, delete_tags, set_tags):
+ "Dispatch to handlers for tag and branch manipulation."
if not os.path.exists(repodir):
croak("repository subdirectory %s does not exist" % repodir)
args = list(args)
if args[0] == '--':
args.pop(0)
else:
- deleteflag = args[0] in ("-d", "del", "delete")
- if deleteflag:
+ if args[0] in ("-d", "del", "delete"):
delete_tags(args[1:])
return
+ if args[0] in ("-l", "list"):
+ list_tags(*args[1:])
+ return
set_tags(args)
+def tag_method(*args):
+ "Inspect, create, and delete tags."
+ tag_helper(args, list_tags, delete_tags, set_tags)
+
def branch_method(*args):
"Inspect, create, and delete branch."
if not os.path.exists(repodir):
croak("repository subdirectory %s does not exist" % repodir)
- args = list(args)
+ (revspec, args) = preamble("branch", args)
+ if len(args) == 1:
+ metadata = History(args[0])
+ sys.stdout.write("%s\n" % metadata.branch)
+ for branchname in metadata.symbols:
+ if metadata.isbranch(key):
+ if key != metadata.branch:
+ sys.stdout.write("%s\n" % key)
+ return
+ deleteflag = False
+ if args[0] == '--':
+ args.pop(0)
+ elif args[0] in ("delete", "del", "-d"):
+ deleteflag = True
+ args.pop(0)
if not args:
- sys.stdout.write("trunk\n")
- else:
- croak("branches are not yet implemented.")
+ croak("branch requires at least a tagname argument")
+ branchname = args.pop(0)
+ if not deleteflag:
+ if args:
+ revspec = metadata.resolve(args[0])
+ if revspec[0] == revspec[1]:
+ revspec = master.revno_to_rcs(revspec[0])
+ else:
+ croak("branch cannot accept a range")
+ # We have a tag name, and either the delete flag is on or
+ # we have a native revision. Remaining args are files.
+ for arg in args:
+ metadata = History(arg)
+ if deleteflag:
+ if branchname in metadata.symbols:
+ backend.delete_tag(branchname, arg)
+ # FIXME: delete all the branch revisions
+ if len(args) and not quiet:
+ announce("branch %s removed from %s" % (branchname, arg))
+ else:
+ croak("%s is not a branch in %s" % (branchname, arg))
def filecmd(legend, hook, args):
(revspec, args) = preamble(legend, args)