From 810a5305b8107a4bce7ee804b9753a56518e4db5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 12 Nov 2014 17:05:08 -0500 Subject: [PATCH] Tag renaming works and has a test. All tests pass. --- NEWS | 2 +- src | 40 ++++++++++++++++++++++++---------------- srctest | 12 ++++++++++++ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index aab389f..4605b3b 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ ` src project news Repository head: - Tag names for revisions work. + Tag names for revisions work; so does tag renaming. Branch-sensitive traversal with .. is working. Fixed yet another fast-export bug. diff --git a/src b/src index 759fe0d..97ad9f6 100755 --- a/src +++ b/src @@ -752,9 +752,7 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method): return if args[0] in ("-l", "list"): args.pop(0) - ctx = CommandContext(legend, args) - if not ctx.is_empty(): - croak("can't accept a revision-spec when %s listing." % legend) + ctx = CommandContext(legend + " listing", args, require_empty=True) width = screenwidth() for arg in ctx.args: metadata = History(arg) @@ -773,20 +771,31 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method): return if args[0] in ("-r", "rename"): args.pop(0) - if name not in metadata.symbols: - croak("cannot rename nonexistent %s" % legend) if not args: - croak("rename requires a second name argement") + croak("rename requires a source name argement") + name = args.pop(0) + if not args: + croak("rename requires a target name argement") newname = args.pop(0) - if newname in metadata.symbols: - croak("cannot rename to existing %s" % legend) - ctx = CommandContext(legend, args) - 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. + ctx = CommandContext(legend + " renaming", args, require_empty=True) for arg in ctx.args: - backend.set_tag(newname, metadata.symbols[name], metadata, arg) - backend.delete_tag(name, arg) + metadata = History(arg) + if name not in metadata.symbols: + croak("cannot rename nonexistent %s %s" % (legend, name)) + if newname in metadata.symbols: + croak("cannot rename to existing %s %s" % (legend, name)) + ctx = CommandContext(legend, args) + if not ctx.is_empty(): + croak("can't accept a revision-spec when renaming a %s." \ + % legend) + # In the case of a branch, we want to change only the + # tag reference. + with backend.lifter(arg): + backend.set_tag(newname, metadata.symbols[name], metadata, arg) + backend.delete_tag(name, arg) + if not quiet and len(args) > 1: + announce("%s -> %s in %s" % (name, newname, arg)) + return if not args: croak("%s setting requires a name argument" % legend) name = args.pop(0) @@ -799,8 +808,7 @@ def tag_helper(args, legend, validation_hook, delete_method, set_method): with backend.lifter(arg): set_method(name, revision, metadata, arg) if not quiet and len(args) > 1: - announce("%s %s = %s in " % (legend, name, revno, arg)) - pass + announce("%s %s = %s in %s" % (legend, name, revno, arg)) def tag_method(*args): "Inspect, create, and delete tags." diff --git a/srctest b/srctest index 975ed02..6025226 100755 --- a/srctest +++ b/srctest @@ -440,6 +440,18 @@ src $TESTOPTS list @BLARGH sample >tryit diff -u tryit sample.taglog check "named-tag lookup with @" +src $TESTOPTS tag -r BLARGH GROTTY sample +check "tag renaming" + +cat >changes <tryit +diff -u tryit changes +check "tag list after rename" rm -fr $SANDBOX -- 2.43.0