summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-09 22:31:25 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-09 22:31:25 +0000
commit612e833c0d7d44fbfd7a5cb6f823d24a54cf52ae (patch)
tree1d47db7d0f7c4882dffb59b8c271fe3ae2b58823 /usr.bin/cvs
parentee3e1ac18a054ca32210be3ce54c697a2042322c (diff)
Properly handle merged files and conflicts which may arrise while merge.
Instead of ignoring all files which contain possible conflict markers, only watch out for files which have actually been merged. With input by and ok joris.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/commit.c47
-rw-r--r--usr.bin/cvs/entries.c12
-rw-r--r--usr.bin/cvs/file.c11
-rw-r--r--usr.bin/cvs/update.c10
4 files changed, 45 insertions, 35 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 9f4a9417c0f..15998dd62f3 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.135 2008/06/08 20:08:43 tobias Exp $ */
+/* $OpenBSD: commit.c,v 1.136 2008/06/09 22:31:24 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -244,7 +244,6 @@ cvs_commit_check_files(struct cvs_file *cf)
{
char *tag;
RCSNUM *branch, *brev;
- char rev[CVS_REV_BUFSZ];
struct cvs_dirlist *d;
branch = brev = NULL;
@@ -262,28 +261,33 @@ cvs_commit_check_files(struct cvs_file *cf)
return;
}
- if (cf->file_status == FILE_CONFLICT ||
+ if (cf->file_status == FILE_UPTODATE)
+ return;
+
+ if (cf->file_status == FILE_MERGE ||
+ cf->file_status == FILE_PATCH ||
+ cf->file_status == FILE_CHECKOUT ||
+ cf->file_status == FILE_LOST ||
cf->file_status == FILE_UNLINK) {
+ cvs_log(LP_ERR, "conflict: %s is not up-to-date",
+ cf->file_path);
conflicts_found++;
return;
}
- if (cf->file_status != FILE_REMOVED &&
- update_has_conflict_markers(cf)) {
+ if (cf->file_status == FILE_CONFLICT &&
+ cf->file_ent->ce_conflict != NULL) {
cvs_log(LP_ERR, "conflict: unresolved conflicts in %s from "
"merging, please fix these first", cf->file_path);
conflicts_found++;
return;
}
- if (cf->file_status == FILE_MERGE ||
- cf->file_status == FILE_PATCH ||
- cf->file_status == FILE_CHECKOUT ||
- cf->file_status == FILE_LOST) {
- cvs_log(LP_ERR, "conflict: %s is not up-to-date",
- cf->file_path);
- conflicts_found++;
- return;
+ if (cf->file_status == FILE_MODIFIED &&
+ cf->file_ent->ce_conflict != NULL &&
+ update_has_conflict_markers(cf)) {
+ cvs_log(LP_ERR, "warning: file %s seems to still contain "
+ "conflict indicators", cf->file_path);
}
if (cf->file_ent != NULL && cf->file_ent->ce_date != -1) {
@@ -313,28 +317,29 @@ cvs_commit_check_files(struct cvs_file *cf)
cf->file_ent->ce_tag);
}
- rcsnum_tostr(brev, rev, sizeof(rev));
if ((branch = rcsnum_revtobr(brev)) == NULL) {
- cvs_log(LP_ERR, "%s is not a branch revision",
- rev);
+ cvs_log(LP_ERR, "sticky tag %s is not "
+ "a branch for file %s", tag,
+ cf->file_path);
conflicts_found++;
rcsnum_free(brev);
return;
}
if (!RCSNUM_ISBRANCHREV(brev)) {
- cvs_log(LP_ERR, "%s is not a branch revision",
- rev);
+ cvs_log(LP_ERR, "sticky tag %s is not "
+ "a branch for file %s", tag,
+ cf->file_path);
conflicts_found++;
rcsnum_free(branch);
rcsnum_free(brev);
return;
}
- rcsnum_tostr(branch, rev, sizeof(rev));
if (!RCSNUM_ISBRANCH(branch)) {
- cvs_log(LP_ERR, "%s (%s) is not a branch",
- cf->file_ent->ce_tag, rev);
+ cvs_log(LP_ERR, "sticky tag %s is not "
+ "a branch for file %s", tag,
+ cf->file_path);
conflicts_found++;
rcsnum_free(branch);
rcsnum_free(brev);
diff --git a/usr.bin/cvs/entries.c b/usr.bin/cvs/entries.c
index 331c0cbe885..6ea873fa539 100644
--- a/usr.bin/cvs/entries.c
+++ b/usr.bin/cvs/entries.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: entries.c,v 1.95 2008/03/01 21:29:36 deraadt Exp $ */
+/* $OpenBSD: entries.c,v 1.96 2008/06/09 22:31:24 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -109,7 +109,7 @@ cvs_ent_parse(const char *entry)
int i;
struct tm t, dt;
struct cvs_ent *ent;
- char *fields[CVS_ENTRIES_NFIELDS], *buf, *sp, *dp;
+ char *fields[CVS_ENTRIES_NFIELDS], *buf, *sp, *dp, *p;
buf = sp = xstrdup(entry);
i = 0;
@@ -156,16 +156,20 @@ cvs_ent_parse(const char *entry)
if (fields[3][0] == '\0' ||
strncmp(fields[3], CVS_DATE_DUMMY, sizeof(CVS_DATE_DUMMY) - 1) == 0 ||
strncmp(fields[3], "Initial ", 8) == 0 ||
- strncmp(fields[3], "Result of merge", 15) == 0) {
+ strcmp(fields[3], "Result of merge") == 0) {
ent->ce_mtime = CVS_DATE_DMSEC;
} else if (cvs_server_active == 1 &&
strncmp(fields[3], CVS_SERVER_UNCHANGED,
strlen(CVS_SERVER_UNCHANGED)) == 0) {
ent->ce_mtime = CVS_SERVER_UPTODATE;
} else {
+ p = fields[3];
+ if (strncmp(fields[3], "Result of merge+", 16) == 0)
+ p += 16;
+
/* Date field can be a '+=' with remote to indicate
* conflict. In this case do nothing. */
- if (strptime(fields[3], "%a %b %d %T %Y", &t) != NULL) {
+ if (strptime(p, "%a %b %d %T %Y", &t) != NULL) {
t.tm_isdst = -1; /* Figure out DST. */
t.tm_gmtoff = 0;
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index eb50da88ad0..a44cea74164 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.241 2008/06/09 17:05:49 tobias Exp $ */
+/* $OpenBSD: file.c,v 1.242 2008/06/09 22:31:24 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -879,7 +879,10 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
"in the repository but is "
"locally modified",
cf->file_path);
- cf->file_status = FILE_CONFLICT;
+ if (cvs_cmdop == CVS_OP_COMMIT)
+ cf->file_status = FILE_UNLINK;
+ else
+ cf->file_status = FILE_CONFLICT;
} else if (cvs_cmdop != CVS_OP_IMPORT) {
cvs_log(LP_NOTICE,
"%s is no longer in the "
@@ -904,13 +907,15 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
cf->file_status = FILE_MODIFIED;
else
cf->file_status = FILE_UPTODATE;
-
if (rcsnum_differ(cf->file_ent->ce_rev,
cf->file_rcsrev)) {
if (cf->file_status == FILE_MODIFIED)
cf->file_status = FILE_MERGE;
else
cf->file_status = FILE_PATCH;
+ } else if (cf->file_ent->ce_conflict != NULL &&
+ cf->file_status != FILE_MODIFIED) {
+ cf->file_status = FILE_CONFLICT;
}
}
}
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index dc9a7a965c4..32a6c7cb7db 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.147 2008/06/08 16:32:34 tobias Exp $ */
+/* $OpenBSD: update.c,v 1.148 2008/06/09 22:31:24 tobias Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -477,15 +477,11 @@ update_clear_conflict(struct cvs_file *cf)
{
time_t now;
CVSENTRIES *entlist;
- char *entry, revbuf[CVS_REV_BUFSZ], timebuf[CVS_TIME_BUFSZ];
+ char *entry, revbuf[CVS_REV_BUFSZ];
char sticky[CVS_ENT_MAXLINELEN], opt[4];
cvs_log(LP_TRACE, "update_clear_conflict(%s)", cf->file_path);
- time(&now);
- ctime_r(&now, timebuf);
- timebuf[strcspn(timebuf, "\n")] = '\0';
-
rcsnum_tostr(cf->file_rcsrev, revbuf, sizeof(revbuf));
sticky[0] = '\0';
@@ -498,7 +494,7 @@ update_clear_conflict(struct cvs_file *cf)
strlcpy(opt, cf->file_ent->ce_opts, sizeof(opt));
entry = xmalloc(CVS_ENT_MAXLINELEN);
- cvs_ent_line_str(cf->file_name, revbuf, timebuf,
+ cvs_ent_line_str(cf->file_name, revbuf, "Result of merge",
opt[0] != '\0' ? opt : "", sticky, 0, 0,
entry, CVS_ENT_MAXLINELEN);