From 9adfa9c1330361c72c630abd88f23bf832ce409e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 8 Nov 2014 21:54:12 -0500 Subject: [PATCH] Faster status check. --- src | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src b/src index f77e47a..5dabdab 100755 --- a/src +++ b/src @@ -526,17 +526,13 @@ def status_method(*args): masterbase = os.path.basename(backend.master(fn)) if masterbase not in registered: pairs.append((fn, "?")) - continue elif not os.path.exists(fn): pairs.append((fn, "!")) - continue # Relies on the fact that we touch the file with utimes(2) # each time it's checked out. elif os.path.getmtime(fn) > os.path.getmtime(backend.master(fn)): pairs.append((fn, "M")) - continue - metadata = History(fn) - if len(metadata) == 0: + elif not backend.has_revisions(fn): pairs.append((fn, "A")) else: pairs.append((fn, "U")) @@ -801,6 +797,20 @@ class RCS: return os.path.join(os.path.dirname(arg), repodir, os.path.basename(arg) + ",v") + def has_revisions(self, arg): + "Does the master for this file have any revisions" + # The magic number 105 is the size of an empty RCS file (no + # metadata, no revisions) at 76 bytes, plus 29 bytes. We + # assume that this ize has stayed constant or increased since + # ancient times. In fact the size of an RCS file with revisions + # goes up more - by the 78 bytes for the final, fixed line of the + # log display. This gives us plenty of slack to cope with + # minor format differences. + # + # The motivation here is to make "src status" faster by avoid + # the need for an entire log parse when checking for "A" + # status. + return os.path.getsize(self.master(arg)) > 105 def workfile(self, arg): return arg[:-2] def add(self, arg): -- 2.43.0