Show More
@@ -788,11 +788,17 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): | |
|
791 | def debugdate(ui, date, range=None, **opts): | |
|
792 | 792 | """parse and display a date""" |
|
793 | d = util.parsedate(date) | |
|
793 | if opts["extended"]: | |
|
794 | d = util.parsedate(date, util.extendeddateformats) | |
|
795 | else: | |
|
796 | d = util.parsedate(date) | |
|
794 | 797 | ui.write("internal: %s %s\n" % d) |
|
795 | 798 | ui.write("standard: %s\n" % util.datestr(d)) |
|
799 | if range: | |
|
800 | m = util.matchdate(range) | |
|
801 | ui.write("match: %s\n" % m(d[0])) | |
|
796 | 802 | |
|
797 | 803 | def debugindex(ui, file_): |
|
798 | 804 | """dump the contents of an index file""" |
@@ -1521,6 +1527,11 b' def log(ui, repo, *pats, **opts):' | |||
|
1521 | 1527 | return ncache[fn].get(dcache[1][fn]) |
|
1522 | 1528 | return None |
|
1523 | 1529 | |
|
1530 | df = False | |
|
1531 | if opts["date"]: | |
|
1532 | df = util.matchdate(opts["date"]) | |
|
1533 | ||
|
1534 | ||
|
1524 | 1535 | displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True) |
|
1525 | 1536 | for st, rev, fns in changeiter: |
|
1526 | 1537 | if st == 'add': |
@@ -1532,6 +1543,11 b' def log(ui, repo, *pats, **opts):' | |||
|
1532 | 1543 | if opts['only_merges'] and len(parents) != 2: |
|
1533 | 1544 | continue |
|
1534 | 1545 | |
|
1546 | if df: | |
|
1547 | changes = get(rev) | |
|
1548 | if not df(changes[2][0]): | |
|
1549 | continue | |
|
1550 | ||
|
1535 | 1551 | if opts['keyword']: |
|
1536 | 1552 | changes = get(rev) |
|
1537 | 1553 | miss = 0 |
@@ -2483,7 +2499,9 b' table = {' | |||
|
2483 | 2499 | "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')), |
|
2484 | 2500 | "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')), |
|
2485 | 2501 | "debugstate": (debugstate, [], _('debugstate')), |
|
2486 |
"debugdate": (debugdate, |
|
|
2502 | "debugdate": (debugdate, | |
|
2503 | [('e','extended', None, _('try extended date formats'))], | |
|
2504 | _('debugdata [-e] DATE [RANGE]')), | |
|
2487 | 2505 | "debugdata": (debugdata, [], _('debugdata FILE REV')), |
|
2488 | 2506 | "debugindex": (debugindex, [], _('debugindex FILE')), |
|
2489 | 2507 | "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')), |
@@ -2578,6 +2596,7 b' table = {' | |||
|
2578 | 2596 | _('follow changeset history, or file history across copies and renames')), |
|
2579 | 2597 | ('', 'follow-first', None, |
|
2580 | 2598 | _('only follow the first parent of merge changesets')), |
|
2599 | ('d', 'date', '', _('show revs matching date spec')), | |
|
2581 | 2600 | ('C', 'copies', None, _('show copied files')), |
|
2582 | 2601 | ('k', 'keyword', [], _('search for a keyword')), |
|
2583 | 2602 | ('l', 'limit', '', _('limit number of changes displayed')), |
@@ -85,6 +85,8 b' defaultdateformats = (' | |||
|
85 | 85 | '%a %b %d %H:%M:%S %Y', |
|
86 | 86 | '%a %b %d %I:%M:%S%p %Y', |
|
87 | 87 | '%b %d %H:%M:%S %Y', |
|
88 | '%b %d %I:%M:%S%p %Y', | |
|
89 | '%b %d %H:%M:%S', | |
|
88 | 90 | '%b %d %I:%M:%S%p', |
|
89 | 91 | '%b %d %H:%M', |
|
90 | 92 | '%b %d %I:%M%p', |
@@ -96,6 +98,13 b' defaultdateformats = (' | |||
|
96 | 98 | '%I:%M%p', |
|
97 | 99 | ) |
|
98 | 100 | |
|
101 | extendeddateformats = defaultdateformats + ( | |
|
102 | "%Y", | |
|
103 | "%Y-%m", | |
|
104 | "%b", | |
|
105 | "%b %Y", | |
|
106 | ) | |
|
107 | ||
|
99 | 108 | class SignalInterrupt(Exception): |
|
100 | 109 | """Exception raised on SIGTERM and SIGHUP.""" |
|
101 | 110 | |
@@ -1058,7 +1067,7 b" def datestr(date=None, format='%a %b %d " | |||
|
1058 | 1067 | s += " %+03d%02d" % (-tz / 3600, ((-tz % 3600) / 60)) |
|
1059 | 1068 | return s |
|
1060 | 1069 | |
|
1061 |
def strdate(string, format |
|
|
1070 | def strdate(string, format, defaults): | |
|
1062 | 1071 | """parse a localized time string and return a (unixtime, offset) tuple. |
|
1063 | 1072 | if the string cannot be parsed, ValueError is raised.""" |
|
1064 | 1073 | def timezone(string): |
@@ -1076,16 +1085,12 b" def strdate(string, format='%a %b %d %H:" | |||
|
1076 | 1085 | if offset != None: |
|
1077 | 1086 | date = " ".join(string.split()[:-1]) |
|
1078 | 1087 | |
|
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" | |
|
1088 | # add missing elements from defaults | |
|
1089 | for part in defaults: | |
|
1090 | found = [True for p in part if ("%"+p) in format] | |
|
1091 | if not found: | |
|
1092 | date += "@" + defaults[part] | |
|
1093 | format += "@%" + part[0] | |
|
1089 | 1094 | |
|
1090 | 1095 | timetuple = time.strptime(date, format) |
|
1091 | 1096 | localunixtime = int(calendar.timegm(timetuple)) |
@@ -1097,7 +1102,7 b" def strdate(string, format='%a %b %d %H:" | |||
|
1097 | 1102 | unixtime = localunixtime + offset |
|
1098 | 1103 | return unixtime, offset |
|
1099 | 1104 | |
|
1100 | def parsedate(string, formats=None): | |
|
1105 | def parsedate(string, formats=None, defaults=None): | |
|
1101 | 1106 | """parse a localized time string and return a (unixtime, offset) tuple. |
|
1102 | 1107 | The date may be a "unixtime offset" string or in one of the specified |
|
1103 | 1108 | formats.""" |
@@ -1109,9 +1114,22 b' def parsedate(string, formats=None):' | |||
|
1109 | 1114 | try: |
|
1110 | 1115 | when, offset = map(int, string.split(' ')) |
|
1111 | 1116 | except ValueError: |
|
1117 | # fill out defaults | |
|
1118 | if not defaults: | |
|
1119 | defaults = {} | |
|
1120 | now = makedate() | |
|
1121 | for part in "d mb yY HI M S".split(): | |
|
1122 | if part not in defaults: | |
|
1123 | if part[0] in "HMS": | |
|
1124 | defaults[part] = "00" | |
|
1125 | elif part[0] in "dm": | |
|
1126 | defaults[part] = "1" | |
|
1127 | else: | |
|
1128 | defaults[part] = datestr(now, "%" + part[0], False) | |
|
1129 | ||
|
1112 | 1130 | for format in formats: |
|
1113 | 1131 | try: |
|
1114 | when, offset = strdate(string, format) | |
|
1132 | when, offset = strdate(string, format, defaults) | |
|
1115 | 1133 | except ValueError: |
|
1116 | 1134 | pass |
|
1117 | 1135 | else: |
@@ -1128,6 +1146,54 b' def parsedate(string, formats=None):' | |||
|
1128 | 1146 | raise Abort(_('impossible time zone offset: %d') % offset) |
|
1129 | 1147 | return when, offset |
|
1130 | 1148 | |
|
1149 | def matchdate(date): | |
|
1150 | """Return a function that matches a given date match specifier | |
|
1151 | ||
|
1152 | Formats include: | |
|
1153 | ||
|
1154 | '{date}' match a given date to the accuracy provided | |
|
1155 | ||
|
1156 | '<{date}' on or before a given date | |
|
1157 | ||
|
1158 | '>{date}' on or after a given date | |
|
1159 | ||
|
1160 | """ | |
|
1161 | ||
|
1162 | def lower(date): | |
|
1163 | return parsedate(date, extendeddateformats)[0] | |
|
1164 | ||
|
1165 | def upper(date): | |
|
1166 | d = dict(mb="12", HI="23", M="59", S="59") | |
|
1167 | for days in "31 30 29".split(): | |
|
1168 | try: | |
|
1169 | d["d"] = days | |
|
1170 | return parsedate(date, extendeddateformats, d)[0] | |
|
1171 | except: | |
|
1172 | pass | |
|
1173 | d["d"] = "28" | |
|
1174 | return parsedate(date, extendeddateformats, d)[0] | |
|
1175 | ||
|
1176 | if date[0] == "<": | |
|
1177 | when = upper(date[1:]) | |
|
1178 | return lambda x: x <= when | |
|
1179 | elif date[0] == ">": | |
|
1180 | when = lower(date[1:]) | |
|
1181 | return lambda x: x >= when | |
|
1182 | elif date[0] == "-": | |
|
1183 | try: | |
|
1184 | days = int(date[1:]) | |
|
1185 | except ValueError: | |
|
1186 | raise Abort(_("invalid day spec: %s") % date[1:]) | |
|
1187 | when = makedate()[0] - days * 3600 * 24 | |
|
1188 | return lambda x: x >= when | |
|
1189 | elif " to " in date: | |
|
1190 | a, b = date.split(" to ") | |
|
1191 | start, stop = lower(a), upper(b) | |
|
1192 | return lambda x: x >= start and x <= stop | |
|
1193 | else: | |
|
1194 | start, stop = lower(date), upper(date) | |
|
1195 | return lambda x: x >= start and x <= stop | |
|
1196 | ||
|
1131 | 1197 | def shortuser(user): |
|
1132 | 1198 | """Return a short representation of a user name or email address.""" |
|
1133 | 1199 | f = user.find('@') |
General Comments 0
You need to be logged in to leave comments.
Login now