Patchwork [follow-up] obsfate: fix obsfate_printer with empty date list

login
register
mail settings
Submitter Boris Feld
Date Oct. 18, 2017, 2:35 p.m.
Message ID <328ec528162a716ef618.1508337302@FB>
Download mbox | patch
Permalink /patch/25167/
State Accepted
Headers show

Comments

Boris Feld - Oct. 18, 2017, 2:35 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1508333931 -7200
#      Wed Oct 18 15:38:51 2017 +0200
# Node ID 328ec528162a716ef61877de1982860b67973afa
# Parent  962f7df21a73f044d171fee9c237d0c5062ae317
# EXP-Topic elite-mink
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 328ec528162a
obsfate: fix obsfate_printer with empty date list

When the list of dates is empty, `min` and `max` would raises a ValueError.
Protect against this case by checking that the date list is not empty.

I didn't add a test because I couldn't find a reproducing test case.
Yuya Nishihara - Oct. 19, 2017, 2:19 p.m.
On Wed, 18 Oct 2017 16:35:02 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1508333931 -7200
> #      Wed Oct 18 15:38:51 2017 +0200
> # Node ID 328ec528162a716ef61877de1982860b67973afa
> # Parent  962f7df21a73f044d171fee9c237d0c5062ae317
> # EXP-Topic elite-mink
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 328ec528162a
> obsfate: fix obsfate_printer with empty date list
> 
> When the list of dates is empty, `min` and `max` would raises a ValueError.
> Protect against this case by checking that the date list is not empty.
> 
> I didn't add a test because I couldn't find a reproducing test case.

This happens if markers list is empty. Perhaps a weird case of prune?

Patch

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -822,7 +822,7 @@ 
     # Date
     dates = markersdates(markers)
 
-    if verbose:
+    if dates and verbose:
         min_date = min(dates)
         max_date = max(dates)