version 1.42, 2005/07/22 16:27:29 |
version 1.43, 2005/07/23 00:03:00 |
|
|
static char *rev = NULL; |
static char *rev = NULL; |
static char **commit_files = NULL; |
static char **commit_files = NULL; |
static int commit_fcount = 0; |
static int commit_fcount = 0; |
|
static int wantedstatus = 0; |
|
|
static int |
static int |
cvs_commit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg) |
cvs_commit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg) |
|
|
int |
int |
cvs_commit_pre_exec(struct cvsroot *root) |
cvs_commit_pre_exec(struct cvsroot *root) |
{ |
{ |
struct cvs_flist cl; |
|
CVSFILE *cfp; |
CVSFILE *cfp; |
CVSFILE *tmp; |
CVSFILE *tmp; |
int flags = CF_RECURSE | CF_IGNORE | CF_SORT; |
int i, flags = CF_RECURSE | CF_IGNORE | CF_SORT; |
|
struct cvs_flist added, modified, removed, *cl[3]; |
|
int stattype[] = { CVS_FST_ADDED, CVS_FST_MODIFIED, CVS_FST_REMOVED }; |
|
|
SIMPLEQ_INIT(&cl); |
SIMPLEQ_INIT(&added); |
|
SIMPLEQ_INIT(&modified); |
|
SIMPLEQ_INIT(&removed); |
|
|
if (commit_fcount != 0) { |
cl[0] = &added; |
tmp = cvs_file_getspec(commit_files, commit_fcount, |
cl[1] = &modified; |
flags, cvs_commit_prepare, &cl); |
cl[2] = &removed; |
} else { |
|
tmp = cvs_file_get(".", flags, cvs_commit_prepare, &cl); |
|
} |
|
|
|
if (tmp == NULL) |
/* |
return (CVS_EX_DATA); |
* Obtain the file lists for the logmessage. |
|
*/ |
|
tmp = NULL; |
|
for (i = 0; i < 3; i++) { |
|
if (tmp != NULL) |
|
cvs_file_free(tmp); |
|
|
if (SIMPLEQ_EMPTY(&cl)) { |
wantedstatus = stattype[i]; |
|
|
|
if (commit_fcount != 0) { |
|
tmp = cvs_file_getspec(commit_files, commit_fcount, |
|
flags, cvs_commit_prepare, cl[i]); |
|
} else { |
|
tmp = cvs_file_get(".", flags, cvs_commit_prepare, |
|
cl[i]); |
|
} |
|
|
|
if (tmp == NULL) |
|
return (CVS_EX_DATA); |
|
} |
|
|
|
/* |
|
* If we didn't catch any file, don't call the editor. |
|
*/ |
|
if (SIMPLEQ_EMPTY(&added) && SIMPLEQ_EMPTY(&modified) && |
|
SIMPLEQ_EMPTY(&removed)) { |
cvs_file_free(tmp); |
cvs_file_free(tmp); |
return (0); |
return (0); |
} |
} |
|
|
|
/* |
|
* Fetch the log message for real, with all the files. |
|
*/ |
if (cvs_msg == NULL) |
if (cvs_msg == NULL) |
cvs_msg = cvs_logmsg_get(tmp->cf_name, |
cvs_msg = cvs_logmsg_get(tmp->cf_name, &added, &modified, |
NULL, &cl, NULL); |
&removed); |
|
|
cvs_file_free(tmp); |
cvs_file_free(tmp); |
|
|
while (!SIMPLEQ_EMPTY(&cl)) { |
/* free the file lists */ |
cfp = SIMPLEQ_FIRST(&cl); |
for (i = 0; i < 3; i++) { |
SIMPLEQ_REMOVE_HEAD(&cl, cf_list); |
while (!SIMPLEQ_EMPTY(cl[i])) { |
cvs_file_free(cfp); |
cfp = SIMPLEQ_FIRST(cl[i]); |
|
SIMPLEQ_REMOVE_HEAD(cl[i], cf_list); |
|
cvs_file_free(cfp); |
|
} |
} |
} |
|
|
if (cvs_msg == NULL) |
if (cvs_msg == NULL) |
|
|
CVSFILE *copy; |
CVSFILE *copy; |
struct cvs_flist *clp = (struct cvs_flist *)arg; |
struct cvs_flist *clp = (struct cvs_flist *)arg; |
|
|
if ((cf->cf_type == DT_REG) && ((cf->cf_cvstat == CVS_FST_MODIFIED) || |
if ((cf->cf_type == DT_REG) && (cf->cf_cvstat == wantedstatus)) { |
(cf->cf_cvstat == CVS_FST_ADDED) || |
|
(cf->cf_cvstat == CVS_FST_REMOVED))) { |
|
copy = cvs_file_copy(cf); |
copy = cvs_file_copy(cf); |
if (copy == NULL) |
if (copy == NULL) |
return (CVS_EX_DATA); |
return (CVS_EX_DATA); |