]> arthur.barton.de Git - bup.git/commitdiff
Use branch tip, not newest date to choose 'latest' in BranchList._mksubs().
authorRob Browning <rlb@defaultvalue.org>
Fri, 23 Nov 2012 20:18:52 +0000 (14:18 -0600)
committerRob Browning <rlb@defaultvalue.org>
Fri, 23 Nov 2012 21:33:34 +0000 (15:33 -0600)
Previously 'latest' was chosen in the VFS by taking max(revs), which
would pick the most recent commit by rev_list date, which only has a
resolution of integer seconds.

That approach could fail if two commits (i.e. two "bup save" runs)
executed close enough together that both commits ended up with the
same rev_list date.  In that case, the sort order was determined by
the commit hash, which is effectively random.

Since I couldn't think of a case where you wouldn't want 'latest' to
refer to the most recent commit (save) to the relevant branch,
'latest' is now computed as revs[0], i.e. the first commit returned by
rev_list.

Thanks to Zoran and Gabriel for some helpful sanity checks while
tracking this down.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/vfs.py

index 20627ab852532e5d129ac229a045bd5f2d6dc691..26aeb00f4f25739f1c232820f653b7c5c388a8a7 100644 (file)
@@ -483,6 +483,7 @@ class BranchList(Node):
         tags = git.tags()
 
         revs = list(git.rev_list(self.hash.encode('hex')))
+        latest = revs[0]
         for (date, commit) in revs:
             l = time.localtime(date)
             ls = time.strftime('%Y-%m-%d-%H%M%S', l)
@@ -497,7 +498,6 @@ class BranchList(Node):
                 t1.ctime = t1.mtime = date
                 self._subs[tag] = t1
 
-        latest = max(revs)
         if latest:
             (date, commit) = latest
             commithex = commit.encode('hex')