2007-02-23 19:31:00 +03:00
|
|
|
import os
|
2011-05-19 20:09:25 +04:00
|
|
|
from mercurial import hg, ui, context, encoding
|
2007-02-23 19:31:00 +03:00
|
|
|
|
|
|
|
u = ui.ui()
|
|
|
|
|
|
|
|
repo = hg.repository(u, 'test1', create=1)
|
|
|
|
os.chdir('test1')
|
|
|
|
|
|
|
|
# create 'foo' with fixed time stamp
|
2009-07-05 13:01:30 +04:00
|
|
|
f = open('foo', 'w')
|
2007-02-23 19:31:00 +03:00
|
|
|
f.write('foo\n')
|
|
|
|
f.close()
|
|
|
|
os.utime('foo', (1000, 1000))
|
|
|
|
|
|
|
|
# add+commit 'foo'
|
2010-06-07 22:03:32 +04:00
|
|
|
repo[None].add(['foo'])
|
2007-02-23 19:31:00 +03:00
|
|
|
repo.commit(text='commit1', date="0 0")
|
|
|
|
|
2008-06-26 23:35:46 +04:00
|
|
|
print "workingfilectx.date =", repo[None]['foo'].date()
|
2011-05-19 20:09:25 +04:00
|
|
|
|
|
|
|
# test memctx with non-ASCII commit message
|
|
|
|
|
|
|
|
def filectxfn(repo, memctx, path):
|
|
|
|
return context.memfilectx("foo", "")
|
|
|
|
|
|
|
|
ctx = context.memctx(repo, ['tip', None],
|
|
|
|
encoding.tolocal("Gr\xc3\xbcezi!"),
|
|
|
|
["foo"], filectxfn)
|
|
|
|
ctx.commit()
|
|
|
|
for enc in "ASCII", "Latin-1", "UTF-8":
|
|
|
|
encoding.encoding = enc
|
|
|
|
print "%-8s: %s" % (enc, repo["tip"].description())
|