diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-06-21 15:53:39 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-06-21 15:53:39 -0400 |
commit | 9622ab417325c6d60f5e9e95f4e3786bf6f0e2d5 (patch) | |
tree | ba96af39d47aad8e3e64e243a45dfb71c17e5b8e /b4/mbox.py | |
parent | c5cfd019feb50632f6f125e8ce36ceec807e7a27 (diff) | |
download | b4-9622ab417325c6d60f5e9e95f4e3786bf6f0e2d5.tar.gz |
Reimplement --guess-base
Based on some feedback, attempt to reimplement --guess-base by looking
at the file index hashes and using --find-object to locate when they
were last changed. We limit this using --since and --until, so that we
aren't trying to look through the entire history of the repo. For the
--until date, we take the date of the patch. For the --since date, we
take the timedelta using the number of days specified by
--guess-lookback (default is 14 days).
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/mbox.py')
-rw-r--r-- | b4/mbox.py | 63 |
1 files changed, 25 insertions, 38 deletions
@@ -228,46 +228,33 @@ def make_am(msgs, cmdargs, msgid): if base_commit: logger.critical(' Base: %s', base_commit) - logger.critical(' git checkout -b %s %s', gitbranch, base_commit) - if cmdargs.outdir != '-': - logger.critical(' git am %s', am_filename) else: - cleanmsg = '' if topdir is not None: - checked, mismatches = lser.check_applies_clean(topdir) - if mismatches == 0 and checked != mismatches: - cleanmsg = ' (applies clean to current tree)' - elif cmdargs.guessbase: - # Look at the last 10 tags and see if it applies cleanly to - # any of them. I'm not sure how useful this is, but I'm going - # to put it in for now and maybe remove later if it causes - # problems or slowness - if checked != mismatches: - best_matches = mismatches - cleanmsg = ' (best guess: current tree)' - else: - best_matches = None - # sort the tags by authordate - gitargs = ['tag', '-l', '--sort=-taggerdate'] - lines = b4.git_get_command_lines(None, gitargs) - if lines: - # Check last 10 tags - for tag in lines[:10]: - logger.debug('Checking base-commit possibility for %s', tag) - checked, mismatches = lser.check_applies_clean(topdir, tag) - if mismatches == 0 and checked != mismatches: - cleanmsg = ' (applies clean to: %s)' % tag - break - # did they all mismatch? - if checked == mismatches: - continue - if best_matches is None or mismatches < best_matches: - best_matches = mismatches - cleanmsg = ' (best guess: %s)' % tag - - logger.critical(' Base: not found%s', cleanmsg) - if cmdargs.outdir != '-': - logger.critical(' git am %s', am_filename) + checked, mismatches = lser.check_applies_clean(topdir, at=cmdargs.guessbranch) + if len(mismatches) == 0 and checked != mismatches: + logger.critical(' Base: current tree') + elif len(mismatches) and cmdargs.guessbase: + logger.critical(' attempting to guess base-commit...') + try: + base_commit, mismatches = lser.find_base(topdir, branches=cmdargs.guessbranch, + maxdays=cmdargs.guessdays) + if mismatches == 0: + logger.critical(' Base: %s (exact match)', base_commit) + else: + logger.critical(' Base: %s (best guess, %s blobs not matched)', base_commit, + mismatches) + except IndexError: + logger.critical(' Base: not specified') + pass + else: + logger.critical(' Base: not specified') + else: + logger.critical(' Base: not specified') + + if base_commit is not None: + logger.critical(' git checkout -b %s %s', gitbranch, base_commit) + if cmdargs.outdir != '-': + logger.critical(' git am %s', am_filename) thanks_record_am(lser, cherrypick=cherrypick) |