From: Rob Browning Date: Fri, 23 Nov 2012 20:18:52 +0000 (-0600) Subject: Use branch tip, not newest date to choose 'latest' in BranchList._mksubs(). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=24a2f98381009ee54de8cf55773878248bc1f007;p=packages%2Fb%2Fbup.git Use branch tip, not newest date to choose 'latest' in BranchList._mksubs(). 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 --- diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 20627ab..26aeb00 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -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')