# HG changeset patch # User RhodeCode Admin # Date 2024-07-15 18:04:16 # Node ID 3fe73e54bd200adde6b26cf10e3e1da831f57489 # Parent 8c6daedaf90931f7321ca4043f9216fd1fda8d76 fix: clone-url test for mercurial uses a consistent and strict non-interactive mode so we never will see password prompts diff --git a/vcsserver/remote/hg_remote.py b/vcsserver/remote/hg_remote.py --- a/vcsserver/remote/hg_remote.py +++ b/vcsserver/remote/hg_remote.py @@ -86,7 +86,7 @@ from vcsserver.lib.exc_tracking import f log = logging.getLogger(__name__) -def make_ui_from_config(repo_config): +def make_ui_from_config(repo_config, interactive=True): class LoggingUI(ui.ui): @@ -144,6 +144,7 @@ def make_ui_from_config(repo_config): log.debug('Explicitly disable largefiles extension for repo.') baseui.setconfig(b'extensions', b'largefiles', b'!') + baseui.setconfig(b'ui', b'interactive', b'true' if interactive else b'false') return baseui @@ -523,7 +524,7 @@ class HgRemote(RemoteBase): log.debug( "Verifying if URL is a Mercurial repository: %s", obfuscated_uri) # Create repo path with custom mercurial path object - ui = make_ui_from_config(config) + ui = make_ui_from_config(config, interactive=False) repo_path = hg_path(ui=ui, rawloc=safe_bytes(url)) peer_checker = make_peer(ui, repo_path, False) peer_checker.lookup(b'tip') @@ -803,12 +804,12 @@ class HgRemote(RemoteBase): repo = self._factory.repo(wire) # Disable any prompts for this repo - repo.ui.setconfig(b'ui', b'interactive', b'off', b'-y') + repo.ui.setconfig(b'ui', b'interactive', b'false', b'-y') bookmarks = list(dict(repo._bookmarks).keys()) remote = peer(repo, {}, safe_bytes(url)) # Disable any prompts for this remote - remote.ui.setconfig(b'ui', b'interactive', b'off', b'-y') + remote.ui.setconfig(b'ui', b'interactive', b'false', b'-y') return exchange.push( repo, remote, newbranch=True, bookmarks=bookmarks).cgresult @@ -1020,11 +1021,11 @@ class HgRemote(RemoteBase): def pull(self, wire, url, commit_ids=None): repo = self._factory.repo(wire) # Disable any prompts for this repo - repo.ui.setconfig(b'ui', b'interactive', b'off', b'-y') + repo.ui.setconfig(b'ui', b'interactive', b'false', b'-y') remote = peer(repo, {}, safe_bytes(url)) # Disable any prompts for this remote - remote.ui.setconfig(b'ui', b'interactive', b'off', b'-y') + remote.ui.setconfig(b'ui', b'interactive', b'false', b'-y') if commit_ids: commit_ids = [bin(commit_id) for commit_id in commit_ids] @@ -1103,7 +1104,7 @@ class HgRemote(RemoteBase): # case of merge conflicts or different sub repository sources. By # setting the interactive flag to `False` mercurial doesn't prompt the # used but instead uses a default value. - repo.ui.setconfig(b'ui', b'interactive', False) + repo.ui.setconfig(b'ui', b'interactive', b'false') commands.merge(baseui, repo, rev=safe_bytes(revision)) @reraise_safe_exceptions @@ -1115,7 +1116,7 @@ class HgRemote(RemoteBase): # case of merge conflicts or different sub repository sources. By # setting the interactive flag to `False` mercurial doesn't prompt the # used but instead uses a default value. - repo.ui.setconfig(b'ui', b'interactive', False) + repo.ui.setconfig(b'ui', b'interactive', b'false') ms = hg_merge.mergestate(repo) return [x for x in ms.unresolved()] @@ -1136,7 +1137,7 @@ class HgRemote(RemoteBase): # case of merge conflicts or different sub repository sources. By # setting the interactive flag to `False` mercurial doesn't prompt the # used but instead uses a default value. - repo.ui.setconfig(b'ui', b'interactive', False) + repo.ui.setconfig(b'ui', b'interactive', b'false') rebase_kws = dict( keep=not abort,