Beispiel #1
0
int ESvn::RunCommit(char *ADir, char *ACommand, char *AOnFiles) {
    if (!SameDir(Directory, ADir)) FreeLines();

    free(Command);
    free(Directory);
    free(OnFiles);

    Command = strdup(ACommand);
    Directory = strdup(ADir);
    OnFiles = strdup(AOnFiles);

    RemoveLogFile();
    // Disallow any SVN command while commiting
    Running = 1;

    // Create message buffer
    ESvnLog *svnlog = new ESvnLog(0, &ActiveModel, Directory, OnFiles);
    LogFile = strdup(svnlog->FileName);
    View->SwitchToModel(svnlog);

    AddLine(LogFile, -1, "SVN commit start - enter message text", 1);

    return 0;
}
Beispiel #2
0
int ESvn::RunPipe(char *ADir, char *ACommand, char *AOnFiles) {
    Commiting = 0;
    if (!SameDir(Directory, ADir)) FreeLines();
    return ESvnBase::RunPipe(ADir, ACommand, AOnFiles);
}
int
main(int argc, char *argv[])
{
    const char *name = "PATH";
    char out_delim = PATHDELIM;
    int remove_duplicates = FALSE;
    size_t length = (size_t) argc;
    int operation = 'a';
    const char *where = 0;

    int c, point = 0;
    LIST *list;
    char *s;

    while ((c = getopt(argc, argv, "a:bdefn:prv")) != EOF) {
	switch (c) {
	case 'a':
	    where = optarg;
	    break;
	case 'b':
	    where = BLANK;
	    break;
	case 'd':
	    remove_duplicates = TRUE;
	    break;
	case 'e':
	    where = 0;
	    break;
	case 'f':
	    allow_files = TRUE;
	    break;
	case 'n':
	    name = optarg;
	    break;
	case 'p':
	    out_delim = ' ';
	    break;
	case 'r':
	    if (where == 0)
		where = BLANK;
	    operation = c;
	    break;
	case 'v':
	    out_delim = '\n';
	    break;
	default:
	    usage();
	}
    }

    /* Get the current path, make a corresponding list of strings.  Leave
     * enough room in the list to allow us to insert the arguments also.
     */
    if ((s = getenv(name)) == 0)
	s = StrAlloc(BLANK);
    else
	s = StrAlloc(s);	/* ...just in case someone else uses it */

    for (c = 0; s[c] != EOS; c++)
	if (s[c] == PATHDELIM)
	    length++;
    length += 3;
    list = (LIST *) calloc(length, sizeof(LIST));
    list[0].nn = StrAlloc(BLANK);	/* dummy entry, to simplify -b option */

    /* Split the environment variable into strings indexed in list[] */
    for (c = 1; *s != EOS; c++) {
	if (*s == PATHDELIM) {
	    list[c].nn = StrAlloc(".");
	} else {
	    list[c].nn = s;
	    while (*s != PATHDELIM && *s != EOS)
		s++;
	    if (*s == EOS)
		continue;
	    *s = EOS;
	}
	s++;
    }
    list[c].nn = 0;
    TRACE((stderr, "%s has %d entries\n", name, c));

    /* Find the list-entry after which we insert/remove entries */
    for (c = 0; list[c].nn != 0; c++) {
	if (where != 0 && !Compare(where, list[c].nn)) {
	    point = c;
	    break;
	}
    }
    if (list[c].nn == 0)
	point = c - 1;
    TRACE((stderr, "argc=%d, point=%d (%c)\n", argc, point, operation));

    /* Perform the actual insertion/removal */
    while (optind < argc) {
	s = argv[optind++];
	if (!Compare(s, "-"))
	    break;
	if (operation == 'r') {
	    Remove(point, list, s);
	} else {
	    point = Append(point, list, s);
	}
    }

    if (remove_duplicates) {
	/* Check to see if the directory exists. If not, remove it */
	for (c = 1; list[c].nn != 0; c++)
	    if (!exists(&list[c])) {
		Remove(c, list, list[c].nn);
		c--;
	    };
	/* Compare the inode & device numbers of the remaining items */
	for (c = 1; list[c].nn != 0; c++) {
	    int d;

	    for (d = c + 1; list[d].nn != 0; d++) {
		if (SameDir(&list[c], &list[d])) {
		    Remove(d, list, list[d].nn);
		    d--;
		}
	    }
	}
    }

    /* Finally, print the path */
    if (optind < argc) {
	size_t len = strlen(name) + 2;
	char *changed = 0;

	for (c = 1; list[c].nn != 0; c++)
	    len += 1 + strlen(list[c].nn);
	changed = malloc(len);
	strcpy(changed, name);
	for (c = 1; list[c].nn != 0; c++) {
	    sprintf(changed + strlen(changed), "%c%s",
		    (c > 1) ? PATHDELIM : '=',
		    list[c].nn);
	}
	fflush(stderr);
	fflush(stdout);
	putenv(changed);
#ifdef WIN32
	spawnvp(_P_WAIT, argv[optind], &argv[optind]);
#else
	execvp(argv[optind], &argv[optind]);
#endif
	fflush(stderr);
	fflush(stdout);
    } else {
	fflush(stderr);
	for (c = 1; list[c].nn != 0; c++) {
	    if (c > 1)
		(void) putchar(out_delim);
	    (void) fputs(list[c].nn, stdout);
	}
	(void) putchar('\n');
	fflush(stdout);
    }

    exit(EXIT_SUCCESS);
    /*NOTREACHED */
}