14 #define INIT_REPO "init_test_repo"
23 system(
"hg init tmp");
51 system(
"touch foo ; hg add foo ; hg commit -m foo");
52 system(
"echo baloo > foo ; hg commit -m 'baloo text'");
61 system(
"touch foo ; hg add foo ; hg commit -m foo");
62 system(
"echo baloo > foo ; hg commit -m 'baloo text'");
63 system(
"touch voodoo ; hg add voodoo ; hg commit -m voodoo");
64 system(
"echo voodoo > voodoo ; hg commit -m 'voodoo text'");
72 system(
"touch foo ; hg add foo ; hg commit -m foo");
73 system(
"echo baloo > foo ; hg commit -m 'baloo text'");
75 system(
"touch boo ; hg add boo ; hg commit -m boo");
76 system(
"echo voodoo > boo ; hg commit -m 'voodoo text'");
84 system(
"touch foo ; hg add foo ; hg commit -m foo");
85 system(
"echo baloo > foo ; hg commit -m 'baloo text'");
87 system(
"echo voodoo > foo ; hg commit -m 'voodoo text'");
95 system(
"hg init export");
97 system(
"touch foo ; echo baloo > foo; hg add foo ; hg commit -m foo");
99 system(
"hg init import");
107 system(
"rm -rf export import");
115 system(
"touch 'foo bar'");
116 printf(
"---- ls command ----\n");
141 sprintf(command,
"hg init %s",
INIT_REPO);
143 if((cpid = fork()) < 0) {
144 printf(
"Fork failed\n");
147 }
else if(cpid == 0) {
148 execl(
"/bin/sh",
"sh",
"-c", command, NULL);
149 printf(
"dadads\n\n");
151 waitpid( cpid, &status, 0);
170 char *comm[] = {
"log",
"-v"};
177 while(ns =
hg_rawread(handle, buff, 4096), ns > 0){
183 printf(
"exitcode = %d\n", exitcode);
200 char *comm[] = {
"import",
"-"};
206 fd = open(import_patch, O_RDONLY);
211 while(ns =
hg_rawread(handle, buff, 4096), ns > 0){
216 int length = read(fd, buff, header.
length);
232 scanf(
"\n%c", &option);
250 char *comm[] = {
"merge",
"--tool=internal:prompt"};
259 while(ns =
hg_rawread(handle, buff, 4096), ns > 0){
270 char option = (*prompt)(NULL);
271 printf(
"\noption = %c\n", option);
281 printf(
"exitcode = %d\n", exitcode);
296 char *comm[] = {
"verify"};
304 while(ns =
hg_rawread(handle, buff, 4096), ns > 0){
306 printf(
"out = %s", buff);
309 printf(
"err = %s", buff);
315 printf(
"exitcode = %d\n", exitcode);
330 char *export_comm[] = {
"export",
"-r",
"0"};
331 char *import_comm[] = {
"import",
"-"};
332 char ebuff[4096], ibuff[4096];
339 while(es =
hg_rawread(ehandle, ebuff, 4096), es > 0){
340 while(is =
hg_rawread(ihandle, ibuff, 4096), is > 0){
353 while(is =
hg_rawread(ihandle, ibuff, 4096), is > 0){
358 printf(
"exitcode for export process is %d \n",
hg_exitcode(ehandle));
359 printf(
"exitcode for import process is %d \n",
hg_exitcode(ihandle));
371 char *comm[] = {
"add",
"foo bar"};
378 while(ns =
hg_rawread(handle, buff, 4096), ns > 0){
384 printf(
"exitcode = %d\n", exitcode);
395 printf(
"Select test case to run:\n");
396 printf(
"0) init - 'make some commits' & log \n");
398 printf(
"2) import - from stdin (simulate from a file) \n");
399 printf(
"3) merge - (solve conflicts from stdin) \n");
400 printf(
"4) merge - (without conflicts)\n");
401 printf(
"5) verify \n");
402 printf(
"6) verify a corrupt repo.\n");
403 printf(
"7) export-import example.\n");
404 printf(
"8) add 'filename with space'\n");
406 printf(
"Your choice: ");
414 int main(
int argc,
char **argv)
421 scanf(
"%d", &select_case);
422 if(select_case < 0 || select_case > 8){
423 printf(
"Your choice is not an option...\n");
448 ihandle =
hg_open(
"import",
"");
451 system(
"hg export -r 0 > r0.diff");
470 system(
"hg ci -m 'merge'");
483 system(
"rm .hg/store/data/foo.i");
491 ehandle =
hg_open(
"export",
"");
492 ihandle =
hg_open(
"import",
"");
504 printf(
"\n---- hs status command ----\n");