tags:

views:

50

answers:

1

I'm working on a Mercurial GUI client that interacts with hg.exe through the command line (the preferred high-level API, as I understand it).

However, I am having trouble determining the possible outputs of each command. I can see several outputs by simulating situations, but I was wondering if there is a complete reference of the possible outputs for each command.

For instance, for the command hg fetch, some possible outputs are:

pulling from https://[email protected]/Repo
searching for changes
no changes found

if there are no changes, or:

abort: outstanding uncommitted changes

or one of several other messages, depending on the situation.

I would like to structure my program to handle as many of these cases as possible, but it's hard for me to know in advance what they all are.

Is there a documented reference for the command-line? I have not been able to find one with The Google.

+1  A: 

Look through the translation strings file. Then you'll know you have every message handled and be able to see what parts of it vary.

Also, fetch is just a convenience wrapper around pull/update/merge. If you're invoking mercurial programmatically you probably want to keep those three very different concepts separate in your running it so you know which part failed. In your example above it's the 'update' failing, so the 'pull' would have succeeded and the 'update's failing would allow you to provide the user with a better message.

(fetch is an abomination, which is part of why it's disabled by default)

Ry4an
Checking the strings file is a good idea, although that doesn't really provide an easy way to determine the possible responses for each command. There are about 200 strings in that file; I don't feel confidant that I could correctly identify the context (or contexts) for each one. And about your `fetch` tirade: I realize that it may not be the best example of pure DVCS, but I find in practice that I often want to do all 3 of those actions together, which makes it convenient. But hey, that's what config files are for, right?
Henry Jackson
Yeah, 'fetch' is more okay when run by humans, but if you're automating anything it's a very suspect choice. :) Unfortunately the exit codes from mercurial (which are documented in the wiki) aren't terribly helpful either. In general, if something goes to stderr something didn't work, and if everything was to stdout you have a success.
Ry4an