tests/test-context.py
branchstable
changeset 14379 bd23d5f28bbb
parent 11303 a1aad8333864
child 21689 503bb3af70fe
equal deleted inserted replaced
14360:ab687820c4cc 14379:bd23d5f28bbb
     1 import os
     1 import os
     2 from mercurial import hg, ui
     2 from mercurial import hg, ui, context, encoding
     3 
     3 
     4 u = ui.ui()
     4 u = ui.ui()
     5 
     5 
     6 repo = hg.repository(u, 'test1', create=1)
     6 repo = hg.repository(u, 'test1', create=1)
     7 os.chdir('test1')
     7 os.chdir('test1')
    15 # add+commit 'foo'
    15 # add+commit 'foo'
    16 repo[None].add(['foo'])
    16 repo[None].add(['foo'])
    17 repo.commit(text='commit1', date="0 0")
    17 repo.commit(text='commit1', date="0 0")
    18 
    18 
    19 print "workingfilectx.date =", repo[None]['foo'].date()
    19 print "workingfilectx.date =", repo[None]['foo'].date()
       
    20 
       
    21 # test memctx with non-ASCII commit message
       
    22 
       
    23 def filectxfn(repo, memctx, path):
       
    24     return context.memfilectx("foo", "")
       
    25 
       
    26 ctx = context.memctx(repo, ['tip', None],
       
    27                      encoding.tolocal("Gr\xc3\xbcezi!"),
       
    28                      ["foo"], filectxfn)
       
    29 ctx.commit()
       
    30 for enc in "ASCII", "Latin-1", "UTF-8":
       
    31     encoding.encoding = enc
       
    32     print "%-8s: %s" % (enc, repo["tip"].description())