I'm using MercurialApi for pushing to a remote repo.
u = ui.ui()
repo = hg.repository(u, path)
commands.commit(u, repo, message=message)
commands.push(u, repo)
This block gives me an error:
repository default-push not found
But I have the default set in the repo's .hg/hgrc. And yet I need to pass it to the ui manually:
import configparser, codecs
config = configparser.ConfigParser()
hgrc = os.path.join(path, '.hg/hgrc')
with codecs.open(hgrc, 'r', 'utf-8') as f:
try:
config.read_file(f)
except Exception as e:
raise CommitToRepositoryException(str(e))
default_path = config.get('paths', 'default')
u = ui.ui()
u.setconfig('paths', 'default', default_path)
repo = hg.repository(u, path)
commands.commit(u, repo, message=message)
commands.push(u, repo)
So much code for something that should just work. Any idea why the ui object doesn't get set properly?
The ui may be getting another hgrc file template where all paths including 'default-push' are set to null. When you set 'default' path , it can at least find that one and is able to push.