[issue3398] "hg convert" is aborted by date parsing fail

FUJIWARA Katsunori bugs at mercurial.selenic.com
Wed Apr 25 10:31:39 CDT 2012


New submission from FUJIWARA Katsunori <foozy at lares.dti.ne.jp>:

on "ja_JP.utf-8" locale environment, "hg convert" was aborted, because
"util.parsedate()" fails.

====================
Traceback (most recent call last):
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 87, in _runcatch
    return _dispatch(req)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 685, in _dispatch
    cmdpats, cmdoptions)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 467, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/extensions.py",
line 184, in wrap
    return wrapper(origfn, *args, **kwargs)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/pager.py",
line 107, in pagecmd
    return orig(ui, options, cmd, cmdfunc)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 739, in _runcommand
    return checkargs()
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 693, in checkargs
    return cmdfunc()
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/dispatch.py",
line 682, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/util.py",
line 456, in check
    return func(*args, **kwargs)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/convert/__init__.py",
line 269, in convert
    return convcmd.convert(ui, src, dest, revmapfile, **opts)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/convert/convcmd.py",
line 469, in convert
    c.convert(sortmode)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/convert/convcmd.py",
line 385, in convert
    self.copy(c)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/convert/convcmd.py",
line 353, in copy
    source, self.map)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/hgext/convert/hg.py",
line 170, in putcommit
    getfilectx, commit.author, commit.date, extra)
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/context.py",
line 1090, in __init__
    self._date = date and util.parsedate(date) or util.makedate()
  File
"/home/blah/mercurial/convert-debug/lib/python2.7/site-packages/mercurial/util.py",
line 1023, in parsedate
    raise Abort(_('invalid date: %r') % date)
====================

according to our researching, datetime formatted by "util.datestr()"
with default format can't be parsed by "util.parsedate()".

for example, in "ja_JP.utf-8" locale:

- datetime tuple: (1295867761, 0)
- datestr()-ed string: "月  1月 24 11:16:01 2011 +0000"

this issue was reported by the user working on:

- Mercurial 2.1
- Python 2.7.2+
- python-subversion 1.6.12dfsg-4ubuntu5
- GNU libc 2.13-20ubuntu5.1
- ubuntu 11.10

on that environment, below script can be executed successfully
(and unexpectedly), even in the "ja_JP.utf-8" locale.

so, preprocessing for strptime() in parsedate() or strdate() may
cause this problem.

# but I'm not sure

====================
import time
date = time.gmtime(float(1295867761))
format = '%a %b %d %H:%M:%S %Y'
datestr = time.strftime(format, date)
print datestr
struct_time = time.strptime(datestr, format)
print struct_time
====================

----------
messages: 19747
nosy: foozy
priority: bug
status: unread
title: "hg convert" is aborted by date parsing fail
topic: convert

____________________________________________________
Mercurial issue tracker <bugs at mercurial.selenic.com>
<http://mercurial.selenic.com/bts/issue3398>
____________________________________________________


More information about the Mercurial-devel mailing list