playing with mercurial API
to make this code be useful a script like this should be run to test
[ -d fresita ] && rm -rf fresita
mkdir fresita
cd fresita
echo "test" > README.txt
my first test script:
import os
from mercurial import ui
from mercurial import commands
from mercurial import localrepo
ui_ = ui.ui()
create = 1
path = os.path.abspath('./fresita')
def repo_initialized(path):
'''return True if the repo is already initialized'''
return os.path.isdir(os.path.join(path, '.hg'))
if repo_initialized(path):
create = 0
repo = localrepo.localrepository(ui_, path, create)
repo.add(['README.txt'])
modified, added, removed, deleted, unknown, ignored, clean = repo.status()
print 'modified', modified
print 'added', added
print 'removed', removed
print 'deleted', deleted
print 'unknown', unknown
print 'ignored', ignored
print 'clean', clean
repo.commit(text="my first commit")
pretty easy :)