Show More
@@ -34,6 +34,7 b' enum {' | |||||
34 | CAP_GETPAGER = 0x0400, |
|
34 | CAP_GETPAGER = 0x0400, | |
35 | CAP_SETENV = 0x0800, |
|
35 | CAP_SETENV = 0x0800, | |
36 | CAP_SETUMASK = 0x1000, |
|
36 | CAP_SETUMASK = 0x1000, | |
|
37 | CAP_VALIDATE = 0x2000, | |||
37 | }; |
|
38 | }; | |
38 |
|
39 | |||
39 | typedef struct { |
|
40 | typedef struct { | |
@@ -49,6 +50,7 b' static const cappair_t captable[] = {' | |||||
49 | {"getpager", CAP_GETPAGER}, |
|
50 | {"getpager", CAP_GETPAGER}, | |
50 | {"setenv", CAP_SETENV}, |
|
51 | {"setenv", CAP_SETENV}, | |
51 | {"setumask", CAP_SETUMASK}, |
|
52 | {"setumask", CAP_SETUMASK}, | |
|
53 | {"validate", CAP_VALIDATE}, | |||
52 | {NULL, 0}, /* terminator */ |
|
54 | {NULL, 0}, /* terminator */ | |
53 | }; |
|
55 | }; | |
54 |
|
56 | |||
@@ -463,6 +465,40 b' pid_t hgc_peerpid(const hgclient_t *hgc)' | |||||
463 | } |
|
465 | } | |
464 |
|
466 | |||
465 | /*! |
|
467 | /*! | |
|
468 | * Send command line arguments to let the server load the repo config and check | |||
|
469 | * whether it can process our request directly or not. | |||
|
470 | * Make sure hgc_setenv is called before calling this. | |||
|
471 | * | |||
|
472 | * @return - NULL, the server believes it can handle our request, or does not | |||
|
473 | * support "validate" command. | |||
|
474 | * - a list of strings, the server cannot handle our request and it | |||
|
475 | * sent instructions telling us how to fix the issue. See | |||
|
476 | * chgserver.py for possible instruction formats. | |||
|
477 | * the list should be freed by the caller. | |||
|
478 | * the last string is guaranteed to be NULL. | |||
|
479 | */ | |||
|
480 | const char **hgc_validate(hgclient_t *hgc, const char *const args[], | |||
|
481 | size_t argsize) | |||
|
482 | { | |||
|
483 | assert(hgc); | |||
|
484 | if (!(hgc->capflags & CAP_VALIDATE)) | |||
|
485 | return NULL; | |||
|
486 | ||||
|
487 | packcmdargs(&hgc->ctx, args, argsize); | |||
|
488 | writeblockrequest(hgc, "validate"); | |||
|
489 | handleresponse(hgc); | |||
|
490 | ||||
|
491 | /* the server returns '\0' if it can handle our request */ | |||
|
492 | if (hgc->ctx.datasize <= 1) | |||
|
493 | return NULL; | |||
|
494 | ||||
|
495 | /* make sure the buffer is '\0' terminated */ | |||
|
496 | enlargecontext(&hgc->ctx, hgc->ctx.datasize + 1); | |||
|
497 | hgc->ctx.data[hgc->ctx.datasize] = '\0'; | |||
|
498 | return unpackcmdargsnul(&hgc->ctx); | |||
|
499 | } | |||
|
500 | ||||
|
501 | /*! | |||
466 | * Execute the specified Mercurial command |
|
502 | * Execute the specified Mercurial command | |
467 | * |
|
503 | * | |
468 | * @return result code |
|
504 | * @return result code |
@@ -20,6 +20,8 b' void hgc_close(hgclient_t *hgc);' | |||||
20 |
|
20 | |||
21 | pid_t hgc_peerpid(const hgclient_t *hgc); |
|
21 | pid_t hgc_peerpid(const hgclient_t *hgc); | |
22 |
|
22 | |||
|
23 | const char **hgc_validate(hgclient_t *hgc, const char *const args[], | |||
|
24 | size_t argsize); | |||
23 | int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize); |
|
25 | int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize); | |
24 | void hgc_attachio(hgclient_t *hgc); |
|
26 | void hgc_attachio(hgclient_t *hgc); | |
25 | const char *hgc_getpager(hgclient_t *hgc, const char *const args[], |
|
27 | const char *hgc_getpager(hgclient_t *hgc, const char *const args[], |
General Comments 0
You need to be logged in to leave comments.
Login now