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?
When you get the ui, it doesn't get the local config from the repo's .hg because it doesn't have a repository yet:
You need to get the ui from the repo, which does include its local config: