Detect If Push Destination Requires Authorization
Matt Mackall
mpm at selenic.com
Mon Jul 14 19:39:08 UTC 2014
On Mon, 2014-07-14 at 18:34 +0000, Jensen, Aaron wrote:
> I've got an PowerShell module that wraps Mercurial. It captures stdout, parses it, converts it into objects, then returns those objects to whatever script is using it. When a user uses one of our scripts to push changes to a repository that requires authentication, the 'user:' prompt never shows, because it gets written to stdout, and so users think the script is hanging. Sad trombone. One solution is to make sure the username is specified in the [auth] section of the repository or user's mercurial.ini file.
>
> I spent several hours Friday with .NET's process redirection APIs and could not find a way to detect the `user:` prompt and still show it to the user. Seems that even though .NET supports reading stdout character by character, you can only do so once a full line has been written. Grrr.
>
> So, I'd like my module to be able to detect the situation when a username is needed and show its own prompt for the username, and pass that to the push command as a command line option.
>
> Is there a way to detect if the server I'm pushing to is going to require authorization?*
Without trying a push? No.
But it's certainly the case that authorization is going to be required
more often than not. If you're in the position to prompt for and store a
user name, you should probably just do it.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial
mailing list