##// END OF EJS Templates
Merge with mpm
Brendan Cully -
r3818:bcdab0b2 merge default
parent child Browse files
Show More
@@ -788,6 +788,12 b' def debugdata(ui, file_, rev):'
788 788 except KeyError:
789 789 raise util.Abort(_('invalid revision identifier %s') % rev)
790 790
791 def debugdate(ui, date):
792 """parse and display a date"""
793 d = util.parsedate(date)
794 ui.write("internal: %s %s\n" % d)
795 ui.write("standard: %s\n" % util.datestr(d))
796
791 797 def debugindex(ui, file_):
792 798 """dump the contents of an index file"""
793 799 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
@@ -2477,6 +2483,7 b' table = {'
2477 2483 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
2478 2484 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
2479 2485 "debugstate": (debugstate, [], _('debugstate')),
2486 "debugdate": (debugdate, [], _('debugdata DATE')),
2480 2487 "debugdata": (debugdata, [], _('debugdata FILE REV')),
2481 2488 "debugindex": (debugindex, [], _('debugindex FILE')),
2482 2489 "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')),
@@ -2727,7 +2734,7 b' table = {'
2727 2734 }
2728 2735
2729 2736 norepo = ("clone init version help debugancestor debugcomplete debugdata"
2730 " debugindex debugindexdot")
2737 " debugindex debugindexdot debugdate")
2731 2738 optionalrepo = ("paths serve showconfig")
2732 2739
2733 2740 def findpossible(ui, cmd):
@@ -9,37 +9,31 b' helptable = {'
9 9 "dates|Date Formats":
10 10 r'''
11 11 Some commands (backout, commit, tag) allow the user to specify a date.
12 Possible formats for dates are:
13
14 YYYY-mm-dd \HH:MM[:SS] [(+|-)NNNN]::
15 This is a subset of ISO 8601, allowing just the recommended notations
16 for date and time. The last part represents the timezone; if omitted,
17 local time is assumed. Examples:
18
19 "2005-08-22 03:27 -0700"
20
21 "2006-04-19 21:39:51"
12 Many date formats are acceptible. Here are some examples:
22 13
23 aaa bbb dd HH:MM:SS YYYY [(+|-)NNNN]::
24 This is the date format used by the C library. Here, aaa stands for
25 abbreviated weekday name and bbb for abbreviated month name. The last
26 part represents the timezone; if omitted, local time is assumed.
27 Examples:
14 "Wed Dec 6 13:18:29 2006" (local timezone assumed)
15 "Dec 6 13:18 -0600" (year assumed, time offset provided)
16 "Dec 6 13:18 UTC" (UTC and GMT are aliases for +0000)
17 "Dec 6" (midnight)
18 "13:18" (today assumed)
19 "3:39" (3:39AM assumed)
20 "3:39pm" (15:39)
21 "2006-12-6 13:18:29" (ISO 8601 format)
22 "2006-12-6 13:18"
23 "2006-12-6"
24 "12-6"
25 "12/6"
26 "12/6/6" (Dec 6 2006)
27 "" (Jan 1 00:00:00 1970 UTC)
28 28
29 "Mon Aug 22 03:27:00 2005 -0700"
29 Lastly, there is Mercurial's internal format:
30 30
31 "Wed Apr 19 21:39:51 2006"
31 "1165432709 0" (Wed Dec 6 13:18:29 2006 UTC)
32 32
33 unixtime offset::
34 33 This is the internal representation format for dates. unixtime is
35 34 the number of seconds since the epoch (1970-01-01 00:00 UTC). offset
36 35 is the offset of the local timezone, in seconds west of UTC (negative
37 36 if the timezone is east of UTC).
38 Examples:
39
40 "1124706420 25200" (2005-08-22 03:27:00 -0700)
41
42 "1145475591 -7200" (2006-04-19 21:39:51 +0200)
43 37 ''',
44 38
45 39 'environment|env|Environment Variables':
@@ -72,8 +72,29 b' def localsub(s, a, b=None):'
72 72 raise Abort("decoding near '%s': %s!\n" % (sub, inst))
73 73
74 74 # used by parsedate
75 defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M',
76 '%a %b %d %H:%M:%S %Y')
75 defaultdateformats = (
76 '%Y-%m-%d %H:%M:%S',
77 '%Y-%m-%d %I:%M:%S%p',
78 '%Y-%m-%d %H:%M',
79 '%Y-%m-%d %I:%M%p',
80 '%Y-%m-%d',
81 '%m-%d',
82 '%m/%d',
83 '%m/%d/%y',
84 '%m/%d/%Y',
85 '%a %b %d %H:%M:%S %Y',
86 '%a %b %d %I:%M:%S%p %Y',
87 '%b %d %H:%M:%S %Y',
88 '%b %d %I:%M:%S%p',
89 '%b %d %H:%M',
90 '%b %d %I:%M%p',
91 '%b %d %Y',
92 '%b %d',
93 '%H:%M:%S',
94 '%I:%M:%SP',
95 '%H:%M',
96 '%I:%M%p',
97 )
77 98
78 99 class SignalInterrupt(Exception):
79 100 """Exception raised on SIGTERM and SIGHUP."""
@@ -1040,18 +1061,32 b" def datestr(date=None, format='%a %b %d "
1040 1061 def strdate(string, format='%a %b %d %H:%M:%S %Y'):
1041 1062 """parse a localized time string and return a (unixtime, offset) tuple.
1042 1063 if the string cannot be parsed, ValueError is raised."""
1043 def hastimezone(string):
1044 return (string[-4:].isdigit() and
1045 (string[-5] == '+' or string[-5] == '-') and
1046 string[-6].isspace())
1064 def timezone(string):
1065 tz = string.split()[-1]
1066 if tz[0] in "+-" and len(tz) == 5 and tz[1:].isdigit():
1067 tz = int(tz)
1068 offset = - 3600 * (tz / 100) - 60 * (tz % 100)
1069 return offset
1070 if tz == "GMT" or tz == "UTC":
1071 return 0
1072 return None
1047 1073
1048 1074 # NOTE: unixtime = localunixtime + offset
1049 if hastimezone(string):
1050 date, tz = string[:-6], string[-5:]
1051 tz = int(tz)
1052 offset = - 3600 * (tz / 100) - 60 * (tz % 100)
1053 else:
1054 date, offset = string, None
1075 offset, date = timezone(string), string
1076 if offset != None:
1077 date = " ".join(string.split()[:-1])
1078
1079 # add missing elements
1080 if '%y' not in format.lower():
1081 date += "@" + datestr(makedate(), "%Y", False)
1082 format += "@%Y"
1083 if '%m' not in format and '%b' not in format:
1084 date += "@" + datestr(makedate(), "%m", False)
1085 format += "@%m"
1086 if '%d' not in format:
1087 date += "@" + datestr(makedate(), "%d", False)
1088 format += "@%d"
1089
1055 1090 timetuple = time.strptime(date, format)
1056 1091 localunixtime = int(calendar.timegm(timetuple))
1057 1092 if offset is None:
@@ -1066,8 +1101,11 b' def parsedate(string, formats=None):'
1066 1101 """parse a localized time string and return a (unixtime, offset) tuple.
1067 1102 The date may be a "unixtime offset" string or in one of the specified
1068 1103 formats."""
1104 if not string:
1105 return 0, 0
1069 1106 if not formats:
1070 1107 formats = defaultdateformats
1108 string = string.strip()
1071 1109 try:
1072 1110 when, offset = map(int, string.split(' '))
1073 1111 except ValueError:
@@ -1079,17 +1117,15 b' def parsedate(string, formats=None):'
1079 1117 else:
1080 1118 break
1081 1119 else:
1082 raise ValueError(_('invalid date: %r '
1083 'see hg(1) manual page for details')
1084 % string)
1120 raise Abort(_('invalid date: %r ') % string)
1085 1121 # validate explicit (probably user-specified) date and
1086 1122 # time zone offset. values must fit in signed 32 bits for
1087 1123 # current 32-bit linux runtimes. timezones go from UTC-12
1088 1124 # to UTC+14
1089 1125 if abs(when) > 0x7fffffff:
1090 raise ValueError(_('date exceeds 32 bits: %d') % when)
1126 raise Abort(_('date exceeds 32 bits: %d') % when)
1091 1127 if offset < -50400 or offset > 43200:
1092 raise ValueError(_('impossible time zone offset: %d') % offset)
1128 raise Abort(_('impossible time zone offset: %d') % offset)
1093 1129 return when, offset
1094 1130
1095 1131 def shortuser(user):
@@ -2,18 +2,13 b''
2 2 abort: impossible time zone offset: 4444444
3 3 transaction abort!
4 4 rollback completed
5 abort: invalid date: '1\t15.1' see hg(1) manual page for details
6 transaction abort!
7 rollback completed
8 abort: invalid date: 'foo bar' see hg(1) manual page for details
5 abort: invalid date: '1\t15.1'
9 6 transaction abort!
10 7 rollback completed
11 abort: invalid date: ' 1 4444' see hg(1) manual page for details
8 abort: invalid date: 'foo bar'
12 9 transaction abort!
13 10 rollback completed
14 abort: date exceeds 32 bits: 111111111111
15 transaction abort!
16 rollback completed
11 nothing changed
17 12 % partial commit test
18 13 trouble committing bar!
19 14 abort: No such file or directory: .../test/bar
@@ -61,6 +61,7 b' debugcheckstate'
61 61 debugcomplete
62 62 debugconfig
63 63 debugdata
64 debugdate
64 65 debugindex
65 66 debugindexdot
66 67 debugrawcommit
@@ -3,7 +3,7 b' changeset 3:107ce1ee2b43 backs out chang'
3 3 merging with changeset 2:e6c3abc120e7
4 4 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
5 5 (branch merge, don't forget to commit)
6 abort: invalid date: 'should fail' see hg(1) manual page for details
6 abort: invalid date: 'should fail'
7 7 transaction abort!
8 8 rollback completed
9 9 abort: date exceeds 32 bits: 100000000000000000
General Comments 0
You need to be logged in to leave comments. Login now