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