From 12a69d7c5018c0dc0188e8f79933f2f7cb257c57 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 25 May 2020 15:48:06 -0400 Subject: Backfill series before diffing them Make sure we a) attempt to backfill the series if they are incomplete, b) error out if the series is incomplete anyway Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 3 +++ b4/diff.py | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 3cdad1c..ab8f034 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -680,6 +680,9 @@ class LoreSeries: # Logic largely borrowed from gj_tools seenfiles = set() for lmsg in self.patches[1:]: + if lmsg is None: + logger.critical('ERROR: v%s series incomplete; unable to create a fake-am range', self.revision) + return None, None logger.debug('Looking at %s', lmsg.full_subject) lmsg.load_hashes() if not len(lmsg.blob_indexes): diff --git a/b4/diff.py b/b4/diff.py index ab23b0c..33a8b0c 100644 --- a/b4/diff.py +++ b/b4/diff.py @@ -30,11 +30,12 @@ def diff_same_thread_series(cmdargs): savefile = mkstemp('b4-diff-to')[1] # Do we have a cache of this lookup? cachedir = b4.get_cache_dir() + cachebase = urllib.parse.quote_plus(msgid) if wantvers: - cachefile = os.path.join(cachedir, '%s-%s.diff.mbx' % (urllib.parse.quote_plus(msgid), - '-'.join([str(x) for x in wantvers]))) - else: - cachefile = os.path.join(cachedir, '%s-latest.diff.mbx' % urllib.parse.quote_plus(msgid)) + cachebase += '-' + '-'.join([str(x) for x in wantvers]) + if cmdargs.useproject: + cachebase += '-' + cmdargs.useproject + cachefile = os.path.join(cachedir, '%s.diff.mbx' % cachebase) if os.path.exists(cachefile) and not cmdargs.nocache: logger.info('Using cached copy of the lookup') shutil.copyfile(cachefile, savefile) @@ -79,6 +80,12 @@ def diff_same_thread_series(cmdargs): if lower not in lmbx.series: return None, None + if not lmbx.series[lower].complete: + lmbx.backfill(lower) + + if not lmbx.series[upper].complete: + lmbx.backfill(upper) + return lmbx.series[lower], lmbx.series[upper] -- cgit v1.2.3