mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Commit date validation: more stringent checks, more useful error messages.
This commit is contained in:
parent
fff715d0f9
commit
75cd295fec
@ -35,7 +35,10 @@ class changelog(revlog):
|
||||
# validate explicit (probably user-specified) date and
|
||||
# time zone offset. values must fit in signed 32 bits for
|
||||
# current 32-bit linux runtimes.
|
||||
when, offset = map(int, date.split(' '))
|
||||
try:
|
||||
when, offset = map(int, date.split(' '))
|
||||
except ValueError:
|
||||
raise ValueError('invalid date: %r' % date)
|
||||
if abs(when) > 0x7fffffff:
|
||||
raise ValueError('date exceeds 32 bits: %d' % when)
|
||||
if abs(offset) >= 43200:
|
||||
|
@ -660,7 +660,10 @@ def commit(ui, repo, *pats, **opts):
|
||||
files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r']
|
||||
else:
|
||||
files = []
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
try:
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
except ValueError, inst:
|
||||
raise util.Abort(str(inst))
|
||||
|
||||
def copy(ui, repo, source, dest):
|
||||
"""mark a file as copied or renamed for the next commit"""
|
||||
@ -1264,7 +1267,10 @@ def rawcommit(ui, repo, *flist, **rc):
|
||||
|
||||
rc['parent'] = map(repo.lookup, rc['parent'])
|
||||
|
||||
repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent'])
|
||||
try:
|
||||
repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent'])
|
||||
except ValueError, inst:
|
||||
raise util.Abort(str(inst))
|
||||
|
||||
def recover(ui, repo):
|
||||
"""roll back an interrupted transaction"""
|
||||
@ -1502,7 +1508,10 @@ def tag(ui, repo, name, rev=None, **opts):
|
||||
|
||||
message = (opts['message'] or opts['text'] or
|
||||
"Added tag %s for changeset %s" % (name, r))
|
||||
repo.commit([".hgtags"], message, opts['user'], opts['date'])
|
||||
try:
|
||||
repo.commit([".hgtags"], message, opts['user'], opts['date'])
|
||||
except ValueError, inst:
|
||||
raise util.Abort(str(inst))
|
||||
|
||||
def tags(ui, repo):
|
||||
"""list repository tags"""
|
||||
|
@ -1,90 +1,15 @@
|
||||
Traceback (most recent call last):
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/bin/hg", line 13, in ?
|
||||
commands.run()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1809, in run
|
||||
sys.exit(dispatch(sys.argv[1:]))
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1945, in dispatch
|
||||
return d()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1930, in <lambda>
|
||||
d = lambda: func(u, repo, *args, **cmdoptions)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 663, in commit
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/localrepo.py", line 398, in commit
|
||||
n = self.changelog.add(mn, changed, text, tr, p1, p2, user, date)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/changelog.py", line 42, in add
|
||||
raise ValueError('impossible time zone offset: %d' % offset)
|
||||
ValueError: impossible time zone offset: 4444444
|
||||
transaction abort!
|
||||
rollback completed
|
||||
Traceback (most recent call last):
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/bin/hg", line 13, in ?
|
||||
commands.run()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1809, in run
|
||||
sys.exit(dispatch(sys.argv[1:]))
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1945, in dispatch
|
||||
return d()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1930, in <lambda>
|
||||
d = lambda: func(u, repo, *args, **cmdoptions)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 663, in commit
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/localrepo.py", line 398, in commit
|
||||
n = self.changelog.add(mn, changed, text, tr, p1, p2, user, date)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/changelog.py", line 38, in add
|
||||
when, offset = map(int, date.split(' '))
|
||||
ValueError: invalid literal for int(): 1 15.1
|
||||
abort: impossible time zone offset: 4444444
|
||||
transaction abort!
|
||||
rollback completed
|
||||
Traceback (most recent call last):
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/bin/hg", line 13, in ?
|
||||
commands.run()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1809, in run
|
||||
sys.exit(dispatch(sys.argv[1:]))
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1945, in dispatch
|
||||
return d()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1930, in <lambda>
|
||||
d = lambda: func(u, repo, *args, **cmdoptions)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 663, in commit
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/localrepo.py", line 398, in commit
|
||||
n = self.changelog.add(mn, changed, text, tr, p1, p2, user, date)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/changelog.py", line 38, in add
|
||||
when, offset = map(int, date.split(' '))
|
||||
ValueError: invalid literal for int(): foo
|
||||
abort: invalid date: '1\t15.1'
|
||||
transaction abort!
|
||||
rollback completed
|
||||
Traceback (most recent call last):
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/bin/hg", line 13, in ?
|
||||
commands.run()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1809, in run
|
||||
sys.exit(dispatch(sys.argv[1:]))
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1945, in dispatch
|
||||
return d()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1930, in <lambda>
|
||||
d = lambda: func(u, repo, *args, **cmdoptions)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 663, in commit
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/localrepo.py", line 398, in commit
|
||||
n = self.changelog.add(mn, changed, text, tr, p1, p2, user, date)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/changelog.py", line 38, in add
|
||||
when, offset = map(int, date.split(' '))
|
||||
ValueError: invalid literal for int():
|
||||
abort: invalid date: 'foo bar'
|
||||
transaction abort!
|
||||
rollback completed
|
||||
Traceback (most recent call last):
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/bin/hg", line 13, in ?
|
||||
commands.run()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1809, in run
|
||||
sys.exit(dispatch(sys.argv[1:]))
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1945, in dispatch
|
||||
return d()
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 1930, in <lambda>
|
||||
d = lambda: func(u, repo, *args, **cmdoptions)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/commands.py", line 663, in commit
|
||||
repo.commit(files, message, opts['user'], opts['date'], match)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/localrepo.py", line 398, in commit
|
||||
n = self.changelog.add(mn, changed, text, tr, p1, p2, user, date)
|
||||
File "/tmp/hgtests.22041.15131.11536.3935/install/lib/python/mercurial/changelog.py", line 40, in add
|
||||
raise ValueError('date exceeds 32 bits: %d' % when)
|
||||
ValueError: date exceeds 32 bits: 111111111111
|
||||
abort: invalid date: ' 1 4444'
|
||||
transaction abort!
|
||||
rollback completed
|
||||
abort: date exceeds 32 bits: 111111111111
|
||||
|
Loading…
Reference in New Issue
Block a user