[PATCH 1 of 2 v2] Allow commit date before Unix epoch

Adrian Buehlmann adrian at cadifra.com
Sat Apr 2 03:58:27 EDT 2016


On 2016-04-02 02:55, Florent Gallaire wrote:
> # HG changeset patch
> # User Florent Gallaire <fgallaire at gmail.com>
> # Date 1459212616 -7200
> #      Tue Mar 29 02:50:16 2016 +0200
> # Node ID 8152e614ee77606b3e26f8935ded4157b4caa86c
> # Parent  ff0d3b6b287f89594bd8d0308fe2810d2a18ea01
> date: allow negative timestamp
> 
> DVCS are very useful to store various texts (as legislation) written before
> Unix epoch. Fri, 13 Dec 1901 is a nice gain over Thu, 01 Jan 1970.
> 
> diff -r ff0d3b6b287f -r 8152e614ee77 mercurial/util.py
> --- a/mercurial/util.py    Tue Mar 29 12:29:00 2016 -0500
> +++ b/mercurial/util.py    Tue Mar 29 02:50:16 2016 +0200
> @@ -1578,9 +1578,6 @@
>      number of seconds away from UTC. if timezone is false, do not
>      append time zone to string."""
>      t, tz = date or makedate()
> -    if t < 0:
> -        t = 0   # time.gmtime(lt) fails on Windows for lt < -43200
> -        tz = 0
>      if "%1" in format or "%2" in format or "%z" in format:
>          sign = (tz > 0) and "-" or "+"
>          minutes = abs(tz) // 60
> @@ -1714,8 +1711,6 @@
>      # to UTC+14
>      if abs(when) > 0x7fffffff:
>          raise Abort(_('date exceeds 32 bits: %d') % when)
> -    if when < 0:
> -        raise Abort(_('negative date value: %d') % when)
>      if offset < -50400 or offset > 43200:
>          raise Abort(_('impossible time zone offset: %d') % offset)
>      return when, offset
> diff -r ff0d3b6b287f -r 8152e614ee77 tests/test-commit.t
> --- a/tests/test-commit.t    Tue Mar 29 12:29:00 2016 -0500
> +++ b/tests/test-commit.t    Tue Mar 29 02:50:16 2016 +0200
> @@ -27,8 +27,8 @@
>    $ hg commit -d '111111111111 0' -m commit-7
>    abort: date exceeds 32 bits: 111111111111
>    [255]
> -  $ hg commit -d '-7654321 3600' -m commit-7
> -  abort: negative date value: -7654321
> +  $ hg commit -d '-111111111111 3600' -m commit-7
> +  abort: date exceeds 32 bits: -111111111111
>    [255]
> 
>  commit added file that has been deleted

This change would backout change dd24f3e7ca9e and thus reintroduce issue
2513.

In case you indeed manage to find a different solution for old issue
2513, you would have to introduce that solution together with the
removal of the check for negative t values.

Putting the mercurial codebase into an intermediate state which
reintroduces a bug is not acceptable.

Perhaps a different solution for dd24f3e7ca9e is possible, but it likely
is quite a bit more complex than what you sent with your other patches.

For example, you would have to explain the strategy how to introduce
negative time values. The current method of mercurial seems to be to
refuse negative time values on input - because it cannot handle these.

If you introduce a solution which can handle negative time values, then
you have to show how such a soulution can be released. Old and new
versions of Mercurial coexist in the wild. For example, it has been a
long standing requirement that old versions of mercurial can talk to new
versions over the wire (push and pull). Introducing a change which
produces history data that old versions of mercurial can't handle is
usually a rather complex matter.

See also:
https://www.mercurial-scm.org/wiki/CompatibilityRules
https://www.mercurial-scm.org/wiki/RequiresFile
https://www.mercurial-scm.org/wiki/ContributingChanges




More information about the Mercurial-devel mailing list