summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-12-03 15:07:22 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-12-03 15:07:22 +0000
commitc754d6bad3dea47b57c8497f2e1f3aa15cb9c3c8 (patch)
tree811ab201499114384c0627ebf0c133aac695c427
parent3d78890027fb19ead4c3ba84f930b0a1bd219f96 (diff)
fix date handling in opencvs, this was broken since the very start.
now, when you checkout a tree with gnu cvs, opencvs no longer sees all the files as modified, and visa versa. this actually makes gnu cvs and opencvs dance together in working copies.
-rw-r--r--usr.bin/cvs/cvs.c4
-rw-r--r--usr.bin/cvs/cvs.h3
-rw-r--r--usr.bin/cvs/file.c11
-rw-r--r--usr.bin/cvs/rcs.c11
-rw-r--r--usr.bin/cvs/util.c31
5 files changed, 55 insertions, 5 deletions
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 7bf9cf7887b..3fcdfc254fc 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.86 2005/11/12 21:34:48 niallo Exp $ */
+/* $OpenBSD: cvs.c,v 1.87 2005/12/03 15:07:20 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -102,6 +102,8 @@ main(int argc, char **argv)
struct passwd *pw;
struct stat st;
+ tzset();
+
TAILQ_INIT(&cvs_variables);
if (cvs_log_init(LD_STD, 0) < 0)
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 5860bb596fe..24914141c1d 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.89 2005/12/03 15:02:54 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.90 2005/12/03 15:07:21 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -447,6 +447,7 @@ void cvs_freeargv(char **, int);
void cvs_write_tagfile(char *, char *, int);
void cvs_parse_tagfile(char **, char **, int *);
size_t cvs_path_cat(const char *, const char *, char *, size_t);
+time_t cvs_hack_time(time_t, int);
BUF *cvs_patchfile(const char *, const char *,
int (*p)(struct cvs_lines *, struct cvs_lines *));
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 1ecb29e7b10..593e4c31e05 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.129 2005/12/03 02:19:17 joris Exp $ */
+/* $OpenBSD: file.c,v 1.130 2005/12/03 15:07:21 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1252,6 +1252,15 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent, CVSENTRIES *pent,
else if (rcsnum_cmp(ent->ce_rev, cvs_addedrev, 2) == 0)
cfp->cf_cvstat = CVS_FST_ADDED;
else {
+ /*
+ * correct st.st_mtime first
+ */
+ if ((st.st_mtime =
+ cvs_hack_time(st.st_mtime, 1)) == 0) {
+ cvs_file_free(cfp);
+ return (NULL);
+ }
+
/* check last modified time */
if (ent->ce_mtime == (time_t)st.st_mtime) {
cfp->cf_cvstat = CVS_FST_UPTODATE;
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 7ae69a94a06..a954d9964e0 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.106 2005/12/03 02:10:58 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.107 2005/12/03 15:07:21 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -3141,6 +3141,12 @@ cvs_checkout_rev(RCSFILE *rf, RCSNUM *rev, CVSFILE *cf, char *fpath,
goto out;
}
+ /*
+ * correct the time first
+ */
+ if ((rcstime = cvs_hack_time(rcstime, 0)) == 0)
+ goto out;
+
tv[0].tv_sec = rcstime;
tv[0].tv_usec = 0;
tv[1] = tv[0];
@@ -3159,6 +3165,9 @@ cvs_checkout_rev(RCSFILE *rf, RCSNUM *rev, CVSFILE *cf, char *fpath,
* if we are removing a file, we don't need this stuff.
*/
if (type != CHECKOUT_REV_REMOVED) {
+ if ((rcstime = cvs_hack_time(rcstime, 0)) == 0)
+ goto out;
+
tp = gmtime(&rcstime);
l = snprintf(timebuf, sizeof(timebuf),
"%02d %s %d %02d:%02d:%02d -0000",
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index fcac258e450..30189cc4998 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.57 2005/12/03 03:59:47 joris Exp $ */
+/* $OpenBSD: util.c,v 1.58 2005/12/03 15:07:21 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1035,3 +1035,32 @@ cvs_patchfile(const char *data, const char *patch,
cvs_freelines(plines);
return (res);
}
+
+/*
+ * a hack to mimic and thus match gnu cvs behaviour.
+ */
+time_t
+cvs_hack_time(time_t oldtime, int togmt)
+{
+ int l;
+ struct tm *t;
+ char tbuf[32];
+
+ if (togmt == 1) {
+ t = gmtime(&oldtime);
+ if (t == NULL)
+ return (0);
+
+ return (mktime(t));
+ }
+
+ t = localtime(&oldtime);
+
+ l = snprintf(tbuf, sizeof(tbuf), "%d/%d/%d GMT %d:%d:%d",
+ t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
+ t->tm_min, t->tm_sec);
+ if (l == -1 || l >= (int)sizeof(tbuf))
+ return (0);
+
+ return (cvs_date_parse(tbuf));
+}