diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-09-29 18:14:53 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-09-29 18:14:53 +0000 |
commit | c6ea4e82f510028441250ec52726bbd8ac8d27be (patch) | |
tree | 3036e758f9cf92a085ec9fd0a682a8b9316496e9 /usr.bin | |
parent | 515b6e60d73f229d5beca6266d98e68f167b937a (diff) |
Support for update -C, from zinovik.
ok tobias xsa
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/client.c | 17 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.h | 4 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 45 |
3 files changed, 57 insertions, 9 deletions
diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index b41f101f6cc..ba9184b5816 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.122 2010/07/23 21:46:05 ray Exp $ */ +/* $OpenBSD: client.c,v 1.123 2010/09/29 18:14:52 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -524,7 +524,22 @@ cvs_client_sendfile(struct cvs_file *cf) cf->file_name); break; case FILE_ADDED: + if (backup_local_changes) /* for update -C */ + cvs_backup_file(cf); + + cvs_client_send_request("Modified %s", cf->file_name); + cvs_remote_send_file(cf->file_path, cf->fd); + break; case FILE_MODIFIED: + if (backup_local_changes) { /* for update -C */ + cvs_backup_file(cf); + cvs_client_send_request("Entry /%s/%s%s/%s/%s/%s", + cf->file_name, "", rev, timebuf, + cf->file_ent->ce_opts ? cf->file_ent->ce_opts : "", + sticky); + break; + } + cvs_client_send_request("Modified %s", cf->file_name); cvs_remote_send_file(cf->file_path, cf->fd); break; diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index bbb9aa0bf47..ba74fdf691e 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.178 2010/07/23 21:46:05 ray Exp $ */ +/* $OpenBSD: cvs.h,v 1.179 2010/09/29 18:14:52 nicm Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -274,6 +274,7 @@ typedef struct cvs_entries { extern char *checkout_target_dir; extern char *cvs_join_rev1; extern char *cvs_join_rev2; +extern int backup_local_changes; extern struct module_checkout *current_module; extern char *module_repo_root; @@ -388,6 +389,7 @@ void cvs_checkout_file(struct cvs_file *, RCSNUM *, char *, int); void cvs_remove_local(struct cvs_file *); void cvs_add_local(struct cvs_file *); int update_has_conflict_markers(struct cvs_file *); +void cvs_backup_file(struct cvs_file *); #define CO_MERGE 0x01 #define CO_SETSTICKY 0x02 diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 4ff5fb8eacc..2623495577b 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.163 2010/07/30 21:47:18 ray Exp $ */ +/* $OpenBSD: update.c,v 1.164 2010/09/29 18:14:52 nicm Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -31,6 +31,7 @@ int print_stdout = 0; int build_dirs = 0; int reset_option = 0; int reset_tag = 0; +int backup_local_changes = 0; char *cvs_specified_tag = NULL; char *cvs_join_rev1 = NULL; char *cvs_join_rev2 = NULL; @@ -75,6 +76,7 @@ cvs_update(int argc, char **argv) reset_tag = 1; break; case 'C': + backup_local_changes = 1; break; case 'D': dateflag = optarg; @@ -404,13 +406,20 @@ cvs_update_local(struct cvs_file *cf) cvs_printf("? %s\n", cf->file_path); break; case FILE_MODIFIED: - ret = update_has_conflict_markers(cf); - if (cf->file_ent->ce_conflict != NULL && ret == 1) { - cvs_printf("C %s\n", cf->file_path); + if (backup_local_changes) { + cvs_backup_file(cf); + + cvs_checkout_file(cf, cf->file_rcsrev, NULL, flags); + cvs_printf("U %s\n", cf->file_path); } else { - if (cf->file_ent->ce_conflict != NULL && ret == 0) - update_clear_conflict(cf); - cvs_printf("M %s\n", cf->file_path); + ret = update_has_conflict_markers(cf); + if (cf->file_ent->ce_conflict != NULL && ret == 1) + cvs_printf("C %s\n", cf->file_path); + else { + if (cf->file_ent->ce_conflict != NULL && ret == 0) + update_clear_conflict(cf); + cvs_printf("M %s\n", cf->file_path); + } } break; case FILE_ADDED: @@ -714,3 +723,25 @@ out: if (jrev2 != NULL) xfree(jrev2); } + +void +cvs_backup_file(struct cvs_file *cf) +{ + char backup_name[MAXPATHLEN]; + char revstr[RCSNUM_MAXLEN]; + + if (cf->file_status == FILE_ADDED) + (void)xsnprintf(revstr, RCSNUM_MAXLEN, "0"); + else + rcsnum_tostr(cf->file_ent->ce_rev, revstr, RCSNUM_MAXLEN); + + (void)xsnprintf(backup_name, MAXPATHLEN, "%s/.#%s.%s", + cf->file_wd, cf->file_name, revstr); + + cvs_file_copy(cf->file_path, backup_name); + + (void)xsnprintf(backup_name, MAXPATHLEN, ".#%s.%s", + cf->file_name, revstr); + cvs_printf("(Locally modified %s moved to %s)\n", + cf->file_name, backup_name); +} |