Created
April 23, 2011 03:09
-
-
Save laclefyoshi/938214 to your computer and use it in GitHub Desktop.
try Mercurial API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from mercurial import ui, hg | |
>>> repo = hg.repository(ui=ui.ui(), path='.', create=True) | |
# create a repository | |
>>> repo | |
<mercurial.localrepo.localrepository object at 0x1019581d0> | |
>>> f = open("foo", "w") | |
>>> f.write("foofoo") | |
>>> f.close() | |
>>> repo.status(unknown=True) | |
([], [], [], [], ['foo'], [], []) | |
# exists an unknown file | |
>>> repo.dirstate | |
<mercurial.dirstate.dirstate object at 0x1019658d0> | |
>>> repo.dirstate.add("foo") | |
# add an unknown file | |
>>> repo.status() | |
([], ['foo'], [], [], [], [], []) | |
# exists an added file | |
>>> repo.dirstate.write() | |
>>> repo.commit(text="hello, foo") | |
# commit to repository with a message | |
>>> repo.status() | |
([], [], [], [], [], [], []) | |
>>> repo[0] | |
<changectx 389f25c9c254> | |
# a change context | |
>>> repo[0].files() | |
['foo'] | |
>>> repo[0].changeset() | |
('\xe8\x05\x99\xac\xae\x8b\xa4\xfa\x87\x9c\x1e\xc4\x84\xab6?=\x90\xcc\x05', 'yoshiyasu', (1303479637.0, -32400), ['foo'], 'hello, foo', {'branch': 'default'}) | |
>>> repo[0].filectx("foo") | |
<filectx foo@389f25c9c254> | |
# a file context | |
>>> repo[0].filectx("foo").data() | |
'foofoo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment