version 1.134, 2008/06/08 02:54:08 |
version 1.135, 2008/06/08 20:08:43 |
|
|
#include "diff.h" |
#include "diff.h" |
#include "remote.h" |
#include "remote.h" |
|
|
void cvs_commit_local(struct cvs_file *); |
struct cvs_dirlist { |
void cvs_commit_check_files(struct cvs_file *); |
char *file_path; |
void cvs_commit_lock_dirs(struct cvs_file *); |
struct cvs_flisthead files_affected; |
|
struct cvs_flisthead files_added; |
|
struct cvs_flisthead files_removed; |
|
struct cvs_flisthead files_modified; |
|
TAILQ_ENTRY(cvs_dirlist) dlist; |
|
}; |
|
|
|
TAILQ_HEAD(cvs_dlisthead, cvs_dirlist); |
|
|
|
void cvs_commit_local(struct cvs_file *); |
|
void cvs_commit_check_files(struct cvs_file *); |
|
void cvs_commit_lock_dirs(struct cvs_file *); |
|
struct cvs_dirlist *cvs_commit_getdir(char *dir); |
|
void cvs_commit_freedirlist(void); |
|
|
static BUF *commit_diff(struct cvs_file *, RCSNUM *, int); |
static BUF *commit_diff(struct cvs_file *, RCSNUM *, int); |
static void commit_desc_set(struct cvs_file *); |
static void commit_desc_set(struct cvs_file *); |
|
|
struct cvs_flisthead files_affected; |
struct cvs_dlisthead directory_list; |
struct cvs_flisthead files_added; |
|
struct cvs_flisthead files_removed; |
|
struct cvs_flisthead files_modified; |
|
|
|
int conflicts_found; |
int conflicts_found; |
char *logmsg = NULL; |
char *logmsg = NULL; |
|
|
int ch, Fflag, mflag; |
int ch, Fflag, mflag; |
struct module_checkout *mc; |
struct module_checkout *mc; |
struct cvs_recursion cr; |
struct cvs_recursion cr; |
|
struct cvs_dirlist *d; |
char *arg = ".", repo[MAXPATHLEN]; |
char *arg = ".", repo[MAXPATHLEN]; |
|
|
flags = CR_RECURSE_DIRS; |
flags = CR_RECURSE_DIRS; |
|
|
if (Fflag && mflag) |
if (Fflag && mflag) |
fatal("cannot specify both a log file and a message"); |
fatal("cannot specify both a log file and a message"); |
|
|
TAILQ_INIT(&files_affected); |
TAILQ_INIT(&directory_list); |
TAILQ_INIT(&files_added); |
|
TAILQ_INIT(&files_removed); |
|
TAILQ_INIT(&files_modified); |
|
conflicts_found = 0; |
conflicts_found = 0; |
|
|
cr.enterdir = NULL; |
cr.enterdir = NULL; |
|
|
fatal("%d conflicts found, please correct these first", |
fatal("%d conflicts found, please correct these first", |
conflicts_found); |
conflicts_found); |
|
|
if (TAILQ_EMPTY(&files_affected)) |
if (TAILQ_EMPTY(&directory_list)) |
return (0); |
return (0); |
|
|
if (logmsg == NULL && cvs_server_active == 0) { |
if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { |
logmsg = cvs_logmsg_create(&files_added, &files_removed, |
d = TAILQ_FIRST(&directory_list); |
&files_modified); |
|
} |
|
|
|
if (logmsg == NULL) |
if (logmsg == NULL) { |
fatal("This shouldnt happen, honestly!"); |
logmsg = cvs_logmsg_create(NULL, &d->files_added, |
|
&d->files_removed, &d->files_modified); |
|
} |
|
|
cvs_file_freelist(&files_modified); |
if (logmsg == NULL) |
cvs_file_freelist(&files_removed); |
fatal("This shouldnt happen, honestly!"); |
cvs_file_freelist(&files_added); |
|
|
|
if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) { |
|
cvs_client_connect_to_server(); |
cvs_client_connect_to_server(); |
cr.fileproc = cvs_client_sendfile; |
cr.fileproc = cvs_client_sendfile; |
|
|
|
|
cvs_client_send_request("ci"); |
cvs_client_send_request("ci"); |
cvs_client_get_responses(); |
cvs_client_get_responses(); |
} else { |
} else { |
cr.fileproc = cvs_commit_lock_dirs; |
TAILQ_FOREACH(d, &directory_list, dlist) { |
cvs_file_walklist(&files_affected, &cr); |
if (!Fflag && !mflag) { |
|
if (logmsg != NULL) |
|
xfree(logmsg); |
|
logmsg = cvs_logmsg_create(d->file_path, |
|
&d->files_added, &d->files_removed, |
|
&d->files_modified); |
|
} |
|
|
cr.fileproc = cvs_commit_local; |
cr.fileproc = cvs_commit_lock_dirs; |
cvs_file_walklist(&files_affected, &cr); |
cvs_file_walklist(&d->files_affected, &cr); |
cvs_file_freelist(&files_affected); |
|
|
|
cvs_get_repository_name(".", repo, MAXPATHLEN); |
cr.fileproc = cvs_commit_local; |
mc = cvs_module_lookup(repo); |
cvs_file_walklist(&d->files_affected, &cr); |
if (mc->mc_prog != NULL && |
|
(mc->mc_flags & MODULE_RUN_ON_COMMIT)) |
cvs_get_repository_name(".", repo, MAXPATHLEN); |
cvs_exec(mc->mc_prog); |
mc = cvs_module_lookup(repo); |
|
if (mc->mc_prog != NULL && |
|
(mc->mc_flags & MODULE_RUN_ON_COMMIT)) |
|
cvs_exec(mc->mc_prog); |
|
} |
} |
} |
|
|
|
cvs_commit_freedirlist(); |
|
|
xfree(logmsg); |
xfree(logmsg); |
return (0); |
return (0); |
} |
} |
|
|
void |
void |
|
cvs_commit_freedirlist(void) |
|
{ |
|
struct cvs_dirlist *d; |
|
|
|
while ((d = TAILQ_FIRST(&directory_list)) != NULL) { |
|
TAILQ_REMOVE(&directory_list, d, dlist); |
|
xfree(d->file_path); |
|
cvs_file_freelist(&(d->files_affected)); |
|
cvs_file_freelist(&(d->files_added)); |
|
cvs_file_freelist(&(d->files_modified)); |
|
cvs_file_freelist(&(d->files_removed)); |
|
xfree(d); |
|
} |
|
} |
|
|
|
struct cvs_dirlist * |
|
cvs_commit_getdir(char *dir) |
|
{ |
|
struct cvs_dirlist *dp; |
|
|
|
TAILQ_FOREACH(dp, &directory_list, dlist) { |
|
if (strcmp(dp->file_path, dir) == 0) |
|
return dp; |
|
} |
|
|
|
dp = xmalloc(sizeof(*dp)); |
|
dp->file_path = xstrdup(dir); |
|
TAILQ_INIT(&(dp->files_affected)); |
|
TAILQ_INIT(&(dp->files_added)); |
|
TAILQ_INIT(&(dp->files_modified)); |
|
TAILQ_INIT(&(dp->files_removed)); |
|
|
|
TAILQ_INSERT_TAIL(&directory_list, dp, dlist); |
|
return dp; |
|
} |
|
|
|
void |
cvs_commit_lock_dirs(struct cvs_file *cf) |
cvs_commit_lock_dirs(struct cvs_file *cf) |
{ |
{ |
char repo[MAXPATHLEN]; |
char repo[MAXPATHLEN]; |
|
|
char *tag; |
char *tag; |
RCSNUM *branch, *brev; |
RCSNUM *branch, *brev; |
char rev[CVS_REV_BUFSZ]; |
char rev[CVS_REV_BUFSZ]; |
|
struct cvs_dirlist *d; |
|
|
branch = brev = NULL; |
branch = brev = NULL; |
|
|
|
|
if (brev != NULL) |
if (brev != NULL) |
rcsnum_free(brev); |
rcsnum_free(brev); |
|
|
if (cf->file_status == FILE_ADDED || |
if (cf->file_status != FILE_ADDED && |
cf->file_status == FILE_REMOVED || |
cf->file_status != FILE_REMOVED && |
cf->file_status == FILE_MODIFIED) |
cf->file_status != FILE_MODIFIED) |
cvs_file_get(cf->file_path, 0, &files_affected); |
return; |
|
|
|
if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { |
|
d = cvs_commit_getdir(cf->file_wd); |
|
} else { |
|
d = cvs_commit_getdir("remote"); |
|
} |
|
|
|
cvs_file_get(cf->file_path, 0, &d->files_affected); |
|
|
switch (cf->file_status) { |
switch (cf->file_status) { |
case FILE_ADDED: |
case FILE_ADDED: |
cvs_file_get(cf->file_path, 0, &files_added); |
cvs_file_get(cf->file_path, 0, &d->files_added); |
break; |
break; |
case FILE_REMOVED: |
case FILE_REMOVED: |
cvs_file_get(cf->file_path, 0, &files_removed); |
cvs_file_get(cf->file_path, 0, &d->files_removed); |
break; |
break; |
case FILE_MODIFIED: |
case FILE_MODIFIED: |
cvs_file_get(cf->file_path, 0, &files_modified); |
cvs_file_get(cf->file_path, 0, &d->files_modified); |
break; |
break; |
} |
} |
} |
} |