From: Eric S. Raymond Date: Wed, 12 Nov 2014 13:39:09 +0000 (-0500) Subject: A range argument to cat would be an invitation to shoot self in foot. X-Git-Tag: 0.6~28 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=a51083ec501b4af0dbafe3749a9ed08c4243143a;p=src.git A range argument to cat would be an invitation to shoot self in foot. Diallow this. Also, get rid of History __getitem__ - it's a defect attactor. Regression test passes. --- diff --git a/NEWS b/NEWS index dfaf213..e4d0d6e 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ ` src project news +Repository head: + Fixed yet another fast-export bug. + 0.5: 2014-11-11 Removed src add. The first src commit to a file adds it. Branching is mostly working - branch delete isn't implemented, diff --git a/src b/src index d7c2bd9..e288e3f 100755 --- a/src +++ b/src @@ -176,8 +176,6 @@ class History: backend.parse(self) def __len__(self): return len(self.revlist) - def __getitem__(self, i): - return self.revlist[i] def current(self): "Return the revision currently checked out." try: @@ -215,6 +213,8 @@ class History: selection.reverse() return selection def tip(self): + "Return the latest revision in the repo." + # FIXME: should return the current branch tip. return self.revlist[0] def native_to_revno(self, revision): "Map a native ID to a revno" @@ -624,13 +624,15 @@ def status_method(*args): def cat_method(*args): "Dump revision content to standard output." ctx = CommandContext("cat", args) + if ctx.is_range(): + croak("cat refuses to cough up a hairball") for arg in ctx.args: metadata = History(arg) ctx.resolve(metadata) if ctx.is_empty(): ctx.select_tip(metadata) with backend.lifter(arg): - for item in metadata: + for item in metadata.revlist: if item.revno in ctx: backend.cat(arg, item.revision) @@ -969,7 +971,7 @@ class RCS: rev = self.joinrev(n[:-2]) for (i, item) in enumerate(metadata.revlist): if item.revision == rev: - return metadata[i].revno + return metadata.revlist[i].revno return None def succ(self, revno, metadata): "Our successor on the current branch (1-origin)." @@ -979,7 +981,7 @@ class RCS: rev = self.joinrev(n) for (i, item) in enumerate(metadata.revlist): if item.revision == rev: - return metadata[i].revno + return metadata.revlist[i].revno return None def branch_to_base(self, revid): "Go from a branch ID sticky tag to the revision it was based on." diff --git a/src.asc b/src.asc index 69a2fe6..4177ff8 100644 --- a/src.asc +++ b/src.asc @@ -64,8 +64,8 @@ src status ['file'...]:: I = ignored, L = locked (recover with src checkout). The A and L statuses should only occur if you have used RCS directly on a file. -src cat [revision-range] ['file'...]:: - Send the specified revisions of the files to standard output. +src cat ['revision'] ['file'...]:: + Send the specified revision of the files to standard output. src tag [list|-ldelete|del|-d}rename|-r] ['name'] ['revision'] ['file'...]:: Create, rename, or delete a tag. With no or only file arguments, list tags.