changeset 3265:53d6bcccdbef

merge with upstream
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 05 Oct 2006 10:07:40 +0200
parents 03acd01520ac (diff) c93ce7f10f85 (current diff)
children 03880d4e2550
files
diffstat 6 files changed, 80 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hg.1.txt	Wed Oct 04 19:08:04 2006 -0500
+++ b/doc/hg.1.txt	Thu Oct 05 10:07:40 2006 +0200
@@ -127,6 +127,42 @@
     A range acts as a closed interval.  This means that a range of 3:5
     gives 3, 4 and 5.  Similarly, a range of 4:2 gives 4, 3, and 2.
 
+DATE FORMATS
+------------
+
+    Some commands (backout, commit, tag) allow the user to specify a date.
+    Possible formats for dates are:
+
+YYYY-mm-dd \HH:MM[:SS] [(+|-)NNNN]::
+    This is a subset of ISO 8601, allowing just the recommended notations
+    for date and time. The last part represents the timezone; if omitted,
+    local time is assumed. Examples:
+
+    "2005-08-22 03:27 -0700"
+
+    "2006-04-19 21:39:51"
+
+aaa bbb dd HH:MM:SS YYYY [(+|-)NNNN]::
+    This is the date format used by the C library. Here, aaa stands for
+    abbreviated weekday name and bbb for abbreviated month name. The last
+    part represents the timezone; if omitted, local time is assumed.
+    Examples:
+
+    "Mon Aug 22 03:27:00 2005 -0700"
+
+    "Wed Apr 19 21:39:51 2006"
+
+unixtime offset::
+    This is the internal representation format for dates. unixtime is
+    the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
+    is the offset of the local timezone, in seconds west of UTC (negative
+    if the timezone is east of UTC).
+    Examples:
+
+    "1124706420 25200" (2005-08-22 03:27:00 -0700)
+
+    "1145475591 -7200" (2006-04-19 21:39:51 +0200)
+
 ENVIRONMENT VARIABLES
 ---------------------
 
--- a/hgext/patchbomb.py	Wed Oct 04 19:08:04 2006 -0500
+++ b/hgext/patchbomb.py	Thu Oct 05 10:07:40 2006 +0200
@@ -65,7 +65,7 @@
 
 from mercurial.demandload import *
 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils
-                         mercurial:commands,hg,mail,ui,patch
+                         mercurial:cmdutil,commands,hg,mail,ui,patch
                          os errno popen2 socket sys tempfile time''')
 from mercurial.i18n import gettext as _
 from mercurial.node import *
@@ -146,10 +146,10 @@
             if patchname:
                 patchname = patchname[0]
             elif total > 1:
-                patchname = commands.make_filename(repo, '%b-%n.patch',
+                patchname = cmdutil.make_filename(repo, '%b-%n.patch',
                                                    binnode, idx, total)
             else:
-                patchname = commands.make_filename(repo, '%b.patch', binnode)
+                patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
             p['Content-Disposition'] = 'inline; filename=' + patchname
             msg.attach(p)
         else:
--- a/mercurial/util.py	Wed Oct 04 19:08:04 2006 -0500
+++ b/mercurial/util.py	Thu Oct 05 10:07:40 2006 +0200
@@ -15,7 +15,7 @@
 from i18n import gettext as _
 from demandload import *
 demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile")
-demandload(globals(), "os threading time")
+demandload(globals(), "os threading time calendar")
 
 # used by parsedate
 defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M',
@@ -903,14 +903,22 @@
                (string[-5] == '+' or string[-5] == '-') and
                string[-6].isspace())
 
+    # NOTE: unixtime = localunixtime + offset
     if hastimezone(string):
         date, tz = string[:-6], string[-5:]
         tz = int(tz)
         offset = - 3600 * (tz / 100) - 60 * (tz % 100)
     else:
-        date, offset = string, 0
-    when = int(time.mktime(time.strptime(date, format))) + offset
-    return when, offset
+        date, offset = string, None
+    timetuple = time.strptime(date, format)
+    localunixtime = int(calendar.timegm(timetuple))
+    if offset is None:
+        # local timezone
+        unixtime = int(time.mktime(timetuple))
+        offset = unixtime - localunixtime
+    else:
+        unixtime = localunixtime + offset
+    return unixtime, offset
 
 def parsedate(string, formats=None):
     """parse a localized time string and return a (unixtime, offset) tuple.
@@ -929,7 +937,9 @@
             else:
                 break
         else:
-            raise ValueError(_('invalid date: %r') % string)
+            raise ValueError(_('invalid date: %r '
+                               'see hg(1) manual page for details')
+                             % string)
     # validate explicit (probably user-specified) date and
     # time zone offset. values must fit in signed 32 bits for
     # current 32-bit linux runtimes. timezones go from UTC-12
--- a/tests/test-commit.out	Wed Oct 04 19:08:04 2006 -0500
+++ b/tests/test-commit.out	Thu Oct 05 10:07:40 2006 +0200
@@ -1,13 +1,13 @@
 abort: impossible time zone offset: 4444444
 transaction abort!
 rollback completed
-abort: invalid date: '1\t15.1'
+abort: invalid date: '1\t15.1' see hg(1) manual page for details
 transaction abort!
 rollback completed
-abort: invalid date: 'foo bar'
+abort: invalid date: 'foo bar' see hg(1) manual page for details
 transaction abort!
 rollback completed
-abort: invalid date: ' 1 4444'
+abort: invalid date: ' 1 4444' see hg(1) manual page for details
 transaction abort!
 rollback completed
 abort: date exceeds 32 bits: 111111111111
--- a/tests/test-parse-date	Wed Oct 04 19:08:04 2006 -0500
+++ b/tests/test-parse-date	Thu Oct 05 10:07:40 2006 +0200
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+# This runs with TZ="GMT"
 hg init
 echo "test-parse-date" > a
 hg add a
@@ -13,4 +14,21 @@
 hg ci -d "should fail" -m "fail"
 hg ci -d "100000000000000000 1400" -m "fail"
 hg ci -d "100000 1400000" -m "fail"
+
+# Check with local timezone other than GMT and with DST
+TZ="PST+8PDT"
+export TZ
+# PST=UTC-8 / PDT=UTC-7
+hg debugrebuildstate
+echo "a" > a
+hg ci -d "2006-07-15 13:30" -m "summer@UTC-7"
+hg debugrebuildstate
+echo "b" > a
+hg ci -d "2006-07-15 13:30 +0500" -m "summer@UTC+5"
+hg debugrebuildstate
+echo "c" > a
+hg ci -d "2006-01-15 13:30" -m "winter@UTC-8"
+hg debugrebuildstate
+echo "d" > a
+hg ci -d "2006-01-15 13:30 +0500" -m "winter@UTC+5"
 hg log --template '{date|date}\n'
--- a/tests/test-parse-date.out	Wed Oct 04 19:08:04 2006 -0500
+++ b/tests/test-parse-date.out	Thu Oct 05 10:07:40 2006 +0200
@@ -3,7 +3,7 @@
 merging with changeset 2:e6c3abc120e7
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
-abort: invalid date: 'should fail'
+abort: invalid date: 'should fail' see hg(1) manual page for details
 transaction abort!
 rollback completed
 abort: date exceeds 32 bits: 100000000000000000
@@ -12,6 +12,10 @@
 abort: impossible time zone offset: 1400000
 transaction abort!
 rollback completed
+Sun Jan 15 13:30:00 2006 +0500
+Sun Jan 15 13:30:00 2006 -0800
+Sat Jul 15 13:30:00 2006 +0500
+Sat Jul 15 13:30:00 2006 -0700
 Sun Jun 11 00:26:40 2006 -0400
 Sat Apr 15 13:30:00 2006 +0200
 Sat Apr 15 13:30:00 2006 +0000