diff --git a/hgext/imerge.py b/hgext/imerge.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_aGdleHQvaW1lcmdlLnB5..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_aGdleHQvaW1lcmdlLnB5 100644 --- a/hgext/imerge.py +++ b/hgext/imerge.py @@ -79,7 +79,8 @@ try: parents = [self.repo.changectx(n) for n in status[:2]] except revlog.LookupError, e: - raise util.Abort('merge parent %s not in repository' % e.name) + raise util.Abort(_('merge parent %s not in repository') % + short(e.name)) status = status[2:] conflicts = int(status.pop(0)) * 3 diff --git a/hgext/notify.py b/hgext/notify.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_aGdleHQvbm90aWZ5LnB5..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_aGdleHQvbm90aWZ5LnB5 100644 --- a/hgext/notify.py +++ b/hgext/notify.py @@ -210,9 +210,7 @@ del msg['From'] msg['From'] = sender - msg['Date'] = util.datestr(date=util.makedate(), - format="%a, %d %b %Y %H:%M:%S", - timezone=True) + msg['Date'] = util.datestr(format="%a, %d %b %Y %H:%M:%S %1%2") fix_subject() fix_sender() diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_aGdleHQvcGF0Y2hib21iLnB5..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_aGdleHQvcGF0Y2hib21iLnB5 100644 --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -391,8 +391,7 @@ m['In-Reply-To'] = parent else: parent = m['Message-Id'] - m['Date'] = util.datestr(date=start_time, - format="%a, %d %b %Y %H:%M:%S", timezone=True) + m['Date'] = util.datestr(start_time, "%a, %d %b %Y %H:%M:%S %1%2") start_time = (start_time[0] + 1, start_time[1]) m['From'] = sender @@ -419,8 +418,7 @@ elif opts.get('mbox'): ui.status('Writing ', m['Subject'], ' ...\n') fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') - date = util.datestr(date=start_time, - format='%a %b %d %H:%M:%S %Y', timezone=False) + date = util.datestr(start_time, '%a %b %d %H:%M:%S %Y') fp.write('From %s %s\n' % (sender_addr, date)) fp.write(m.as_string(0)) fp.write('\n\n') diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_bWVyY3VyaWFsL2J1bmRsZXJlcG8ucHk=..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_bWVyY3VyaWFsL2J1bmRsZXJlcG8ucHk= 100644 --- a/mercurial/bundlerepo.py +++ b/mercurial/bundlerepo.py @@ -48,7 +48,8 @@ continue for p in (p1, p2): if not p in self.nodemap: - raise revlog.LookupError(hex(p1), _("unknown parent %s") % short(p1)) + raise revlog.LookupError(p1, self.indexfile, + _("unknown parent")) if linkmapper is None: link = n else: diff --git a/mercurial/context.py b/mercurial/context.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_bWVyY3VyaWFsL2NvbnRleHQucHk=..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644 --- a/mercurial/context.py +++ b/mercurial/context.py @@ -100,9 +100,10 @@ try: return self._manifest[path], self._manifest.flags(path) except KeyError: - raise revlog.LookupError(path, _("'%s' not found in manifest") % path) + raise revlog.LookupError(self._node, path, + _('not found in manifest')) if '_manifestdelta' in self.__dict__ or path in self.files(): if path in self._manifestdelta: return self._manifestdelta[path], self._manifestdelta.flags(path) node, flag = self._repo.manifest.find(self._changeset[0], path) if not node: @@ -104,9 +105,10 @@ if '_manifestdelta' in self.__dict__ or path in self.files(): if path in self._manifestdelta: return self._manifestdelta[path], self._manifestdelta.flags(path) node, flag = self._repo.manifest.find(self._changeset[0], path) if not node: - raise revlog.LookupError(path, _("'%s' not found in manifest") % path) + raise revlog.LookupError(self._node, path, + _('not found in manifest')) return node, flag diff --git a/mercurial/revlog.py b/mercurial/revlog.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_bWVyY3VyaWFsL3JldmxvZy5weQ==..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_bWVyY3VyaWFsL3JldmxvZy5weQ== 100644 --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -33,8 +33,5 @@ pass class LookupError(RevlogError): - def __init__(self, name, message=None): - if message is None: - message = _('not found: %s') % name - RevlogError.__init__(self, message) + def __init__(self, name, index, message): self.name = name @@ -40,4 +37,7 @@ self.name = name + if isinstance(name, str) and len(name) == 20: + name = short(name) + RevlogError.__init__(self, _('%s@%s: %s') % (index, name, message)) def getoffset(q): return int(q >> 16) @@ -519,7 +519,7 @@ try: return self.nodemap[node] except KeyError: - raise LookupError(hex(node), _('%s: no node %s') % (self.indexfile, hex(node))) + raise LookupError(node, self.indexfile, _('no node')) def node(self, rev): return self.index[rev][7] def linkrev(self, node): @@ -839,8 +839,8 @@ for n in self.nodemap: if n.startswith(bin_id) and hex(n).startswith(id): if node is not None: - raise LookupError(hex(node), - _("Ambiguous identifier")) + raise LookupError(id, self.indexfile, + _('ambiguous identifier')) node = n if node is not None: return node @@ -859,7 +859,7 @@ if n: return n - raise LookupError(id, _("No match found")) + raise LookupError(id, self.indexfile, _('no match found')) def cmp(self, node, text): """compare text with a given file revision""" @@ -1170,9 +1170,9 @@ for p in (p1, p2): if not p in self.nodemap: - raise LookupError(hex(p), _("unknown parent %s") % short(p)) + raise LookupError(p, self.indexfile, _('unknown parent')) if not chain: # retrieve the parent revision of the delta chain chain = p1 if not chain in self.nodemap: @@ -1174,9 +1174,9 @@ if not chain: # retrieve the parent revision of the delta chain chain = p1 if not chain in self.nodemap: - raise LookupError(hex(chain), _("unknown base %s") % short(chain[:4])) + raise LookupError(chain, self.indexfile, _('unknown base')) # full versions are inserted when the needed deltas become # comparable to the uncompressed text or when the previous diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_bWVyY3VyaWFsL3RlbXBsYXRlZmlsdGVycy5weQ==..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_bWVyY3VyaWFsL3RlbXBsYXRlZmlsdGVycy5weQ== 100644 --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -69,14 +69,6 @@ except IndexError: return '' -def isodate(date): - '''turn a (timestamp, tzoff) tuple into an iso 8631 date and time.''' - return util.datestr(date, format='%Y-%m-%d %H:%M') - -def hgdate(date): - '''turn a (timestamp, tzoff) tuple into an hg cset timestamp.''' - return "%d %d" % date - def nl2br(text): '''replace raw newlines with xhtml line breaks.''' return text.replace('\n', '<br/>\n') @@ -142,8 +134,8 @@ "fill76": lambda x: fill(x, width=76), "firstline": firstline, "tabindent": lambda x: indent(x, '\t'), - "hgdate": hgdate, - "isodate": isodate, + "hgdate": lambda x: "%d %d" % x, + "isodate": lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2'), "obfuscate": obfuscate, "permissions": permissions, "person": person, @@ -147,8 +139,8 @@ "obfuscate": obfuscate, "permissions": permissions, "person": person, - "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), - "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S", True, "%+03d:%02d"), + "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2"), + "rfc3339date": lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2"), "short": lambda x: x[:12], "shortdate": util.shortdate, "stringify": templater.stringify, diff --git a/mercurial/util.py b/mercurial/util.py index 59200a2de7bf61d948e4efeb40b6cd743eefd310_bWVyY3VyaWFsL3V0aWwucHk=..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_bWVyY3VyaWFsL3V0aWwucHk= 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1524,9 +1524,9 @@ tz = time.timezone return time.mktime(lt), tz -def datestr(date=None, format='%a %b %d %H:%M:%S %Y', timezone=True, timezone_format=" %+03d%02d"): +def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): """represent a (unixtime, offset) tuple as a localized time. unixtime is seconds since the epoch, and offset is the time zone's number of seconds away from UTC. if timezone is false, do not append time zone to string.""" t, tz = date or makedate() @@ -1528,6 +1528,11 @@ """represent a (unixtime, offset) tuple as a localized time. unixtime is seconds since the epoch, and offset is the time zone's number of seconds away from UTC. if timezone is false, do not append time zone to string.""" t, tz = date or makedate() + if "%1" in format or "%2" in format: + sign = (tz > 0) and "-" or "+" + minutes = abs(tz) / 60 + format = format.replace("%1", "%c%02d" % (sign, minutes / 60)) + format = format.replace("%2", "%02d" % (minutes % 60)) s = time.strftime(format, time.gmtime(float(t) - tz)) @@ -1533,7 +1538,5 @@ s = time.strftime(format, time.gmtime(float(t) - tz)) - if timezone: - s += timezone_format % (int(-tz / 3600.0), ((-tz % 3600) / 60)) return s def shortdate(date=None): """turn (timestamp, tzoff) tuple into iso 8631 date.""" @@ -1536,8 +1539,8 @@ return s def shortdate(date=None): """turn (timestamp, tzoff) tuple into iso 8631 date.""" - return datestr(date, format='%Y-%m-%d', timezone=False) + return datestr(date, format='%Y-%m-%d') def strdate(string, format, defaults=[]): """parse a localized time string and return a (unixtime, offset) tuple. @@ -1545,9 +1548,10 @@ def timezone(string): tz = string.split()[-1] if tz[0] in "+-" and len(tz) == 5 and tz[1:].isdigit(): - tz = int(tz) - offset = - 3600 * (tz / 100) - 60 * (tz % 100) - return offset + sign = (tz[0] == "+") and 1 or -1 + hours = int(tz[1:3]) + minutes = int(tz[3:5]) + return -sign * (hours * 60 + minutes) * 60 if tz == "GMT" or tz == "UTC": return 0 return None @@ -1582,7 +1586,7 @@ """ if not date: return 0, 0 - if type(date) is type((0, 0)) and len(date) == 2: + if isinstance(date, tuple) and len(date) == 2: return date if not formats: formats = defaultdateformats @@ -1598,6 +1602,4 @@ if part not in defaults: if part[0] in "HMS": defaults[part] = "00" - elif part[0] in "dm": - defaults[part] = "1" else: @@ -1603,5 +1605,5 @@ else: - defaults[part] = datestr(now, "%" + part[0], False) + defaults[part] = datestr(now, "%" + part[0]) for format in formats: try: @@ -1636,7 +1638,8 @@ """ def lower(date): - return parsedate(date, extendeddateformats)[0] + d = dict(mb="1", d="1") + return parsedate(date, extendeddateformats, d)[0] def upper(date): d = dict(mb="12", HI="23", M="59", S="59") diff --git a/tests/test-bundle-r.out b/tests/test-bundle-r.out index 59200a2de7bf61d948e4efeb40b6cd743eefd310_dGVzdHMvdGVzdC1idW5kbGUtci5vdXQ=..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_dGVzdHMvdGVzdC1idW5kbGUtci5vdXQ= 100644 --- a/tests/test-bundle-r.out +++ b/tests/test-bundle-r.out @@ -168,7 +168,7 @@ adding changesets transaction abort! rollback completed -abort: unknown parent ac69c658229d! +abort: 00changelog.i@ac69c658229d: unknown parent! % 2 2:d62976ca1e50 adding changesets diff --git a/tests/test-diffdir.out b/tests/test-diffdir.out index 59200a2de7bf61d948e4efeb40b6cd743eefd310_dGVzdHMvdGVzdC1kaWZmZGlyLm91dA==..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_dGVzdHMvdGVzdC1kaWZmZGlyLm91dA== 100644 --- a/tests/test-diffdir.out +++ b/tests/test-diffdir.out @@ -18,5 +18,5 @@ +++ b/b @@ -0,0 +1,1 @@ +123 -abort: Ambiguous identifier! -abort: Ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier! diff --git a/tests/test-imerge.out b/tests/test-imerge.out index 59200a2de7bf61d948e4efeb40b6cd743eefd310_dGVzdHMvdGVzdC1pbWVyZ2Uub3V0..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_dGVzdHMvdGVzdC1pbWVyZ2Uub3V0 100644 --- a/tests/test-imerge.out +++ b/tests/test-imerge.out @@ -47,4 +47,4 @@ % nothing to merge abort: there is nothing to merge - use "hg update" instead % load unknown parent -abort: merge parent e6da4671640124fe5d3d70d2f54441d6cd76ae35 not in repository +abort: merge parent e6da46716401 not in repository diff --git a/tests/test-log.out b/tests/test-log.out index 59200a2de7bf61d948e4efeb40b6cd743eefd310_dGVzdHMvdGVzdC1sb2cub3V0..14a4fdf9037fd86b8205b18bd78b9fb658c1a13e_dGVzdHMvdGVzdC1sb2cub3V0 100644 --- a/tests/test-log.out +++ b/tests/test-log.out @@ -220,4 +220,4 @@ summary: b1 % log -r "" -abort: Ambiguous identifier! +abort: 00changelog.i@: ambiguous identifier!