Comments
Patch
@@ -41,34 +41,39 @@
* */
int hg_merge_by_hand(hg_handle *handle, char *(*prompt)(char *buff, int size))
{
- char *comm[] = {"merge", "--tool=internal:prompt", NULL};
+ char *cmd[] = {"merge", "--tool=internal:prompt", NULL};
char buff[BUFF_SIZE];
char *prompt_msg;
int exitcode = 0;
- int ns;
+ int exit = 0;
+ int n;
+ hg_header *header;
- hg_rawcommand(handle, comm);
+ hg_rawcommand(handle, cmd);
- hg_header *head;
- while (head = hg_read_header(handle), head != NULL &&
- head->channel != r) {
- if (head->channel == o) {
- if (ns = hg_rawread(handle, buff, BUFF_SIZE), ns > 0) {
+ while (!exit) {
+ header = hg_read_header(handle);
+ switch (header->channel) {
+ case o:
+ case e:
+ while (n = hg_rawread(handle, buff, BUFF_SIZE), n > 0)
printf("%s", buff);
- }
- } else if (head->channel == e) {
- if (ns = hg_rawread(handle, buff, BUFF_SIZE), ns > 0) {
- printf("error data: %s", buff);
- }
- } else if (head->channel == L || head->channel == I) {
+ break;
+ case I:
+ case L:
prompt_msg = prompt(buff, strlen(buff));
hg_rawwrite(handle, prompt_msg, strlen(prompt_msg));
+ break;
+ case r:
+ exitcode = hg_exitcode(handle);
+ printf("exitcode = %d \n", exitcode);
+ exit = 1;
+ break;
+ case unknown_channel:
+ break;
}
}
- exitcode = hg_exitcode(handle);
- printf("exitcode = %d\n", exitcode);
-
return exitcode;
}