From b27eeb4c290d74dbac44eb9e68959a29afae5724 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 12 Nov 2014 16:16:38 -0500 Subject: [PATCH] Tag lookup and @ are wirking. --- NEWS | 1 + TODO | 4 +--- src | 27 ++++++++++++++++++++++----- src.asc | 2 ++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index ec2c5a1..aab389f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ` src project news Repository head: + Tag names for revisions work. Branch-sensitive traversal with .. is working. Fixed yet another fast-export bug. diff --git a/TODO b/TODO index f5abb7f..d6b066c 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ SRC TODO list -* tag and branch names as revision-spec parts - -* revert? reset? +* branch names as revision-spec parts * src branch delete. Should branch_delete really obsolesce branched or just mark them dead? diff --git a/src b/src index 6a18d47..759fe0d 100755 --- a/src +++ b/src @@ -261,6 +261,8 @@ A 'revision' is a 1-origin integer, or a tag name designating an integer revision. A revision range is a single revision, or a pair of revisions M-N (all revisions numerically from M to N) or M..N (all revisions that are branch ancestots of N and branch successors of M). +If src complains that your revision spec looks like a nonexistent +filename, you can prefix it with @ (this is always allowed). Unless otherwise noted under individual commands, the default revision is the tip revision on the current branch and the default range is all @@ -354,6 +356,18 @@ src version The omission of 'src remove' is a deliberate speed bump. """) + +def parse_as_revspec(token): + "Does this look like something that should be parsed aas a revision spec?" + if "-" in token or ".." in token: + return True + elif token.isdigit(): + return True + elif token.startswith("@"): # Escape clause for tags that look like files + return True + else: + return False + class CommandContext: "Consume a revision specification or range from an argument list" def __init__(self, cmd, args, @@ -372,8 +386,10 @@ class CommandContext: if self.args: if self.args[0] == "--": self.args.pop(0) - elif self.args[0][0].isdigit(): + elif parse_as_revspec(args[0]): revspec = self.args.pop(0) + if revspec.startswith("@"): + revspec = revspec[1:] try: if "-" in revspec or ".." in revspec: self.branchwise = ".." in revspec @@ -394,10 +410,9 @@ class CommandContext: pass else: try: - self.start = int(revspec) + self.end = self.start = int(revspec) except ValueError: - pass - self.end = self.start + self.end = self.start = revspec except ValueError: croak("malformed revision spec: %s" % revspec) if require_empty and not self.is_empty(): @@ -437,6 +452,8 @@ class CommandContext: return i in self.seq def resolve(self, metadata, reversed=True): "Resolve a revision spec that may contain tags into revnos." + if debug >= DEBUG_SEQUENCE: + sys.stderr.write("Entering do_resolve with start=%s, end=%s\n" % (self.start, self.end)) if self.is_empty(): if self.default_to == "branch": self.seq = metadata.current_branch(reversed=False) @@ -1231,7 +1248,7 @@ if __name__ == "__main__": try: dispatch[commandline[0]](*commandline[1:]) except KeyError: - sys.stderr.write("src: no such commandline as '%s'. Try 'src help'\n" \ + sys.stderr.write("src: no such command as '%s'. Try 'src help'\n" \ % commandline[0]) except KeyboardInterrupt: pass diff --git a/src.asc b/src.asc index 41dbec9..7bcae0c 100644 --- a/src.asc +++ b/src.asc @@ -34,6 +34,8 @@ A 'revision' is a 1-origin integer, or a tag name designating an integer revision. A revision range is a single revision, or a pair of revisions M-N (all revisions numerically from M to N) or M..N (all revisions that are branch ancestors of N and branch successors of M). +If src complains that your revision spec looks like a nonexistent +filename, you can prefix it with @ (this is always allowed). Unless otherwise noted under individual commands, the default revision is the tip revision on the current branch and the default range is all -- 2.43.0