From: Heiko Voigt <git-list@hvoigt.net>
To: Michael Haggerty <mhagger@alum.mit.edu>,
Junio C Hamano <gitster@pobox.com>,
ydirson@altern.org
Cc: git@vger.kernel.org
Subject: [CVSPS PATCH] fix: correct rev order in case commiters clocks were not syncronised
Date: Mon, 09 Mar 2009 12:26:18 +0100 [thread overview]
Message-ID: <49B4FCDA.4030106@hvoigt.net> (raw)
In-Reply-To: <49AC1E88.1010709@hvoigt.net>
This fixes the following kind of cvsps issues:
Structure of the test cvs repository
Message File:Content Commit Time
Rev 1 a: 1.1 2009-02-21 19:11:43 +0100
Rev 2 a: 1.2 b: 1.1 2009-02-21 19:11:14 +0100
Rev 3 b: 1.2 2009-02-21 19:11:43 +0100
As you can see the commit of Rev 3 has the same time as
Rev 1 this was leading to a broken estimation of patchset
order.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
After precisely formulating my problem with cvsps I was curious if this
issue actually could be fixed. Additionally I don't want my test to be
disabled ;). This patch seems to fix it. Is Yann still maintaining the
patches for cvsps or should I forward this patch to someone else ?
Calculating with time_t like I did is probably not valid on all systems
if you know of a nicer, more portable solution please let me know.
cvsps.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/cvsps.c b/cvsps.c
index 81c6e21..d5c30d4 100644
--- a/cvsps.c
+++ b/cvsps.c
@@ -259,6 +259,32 @@ int main(int argc, char *argv[])
exit(0);
}
+void detect_and_repair_time_skew(const char *last_date, char *date, int n,
+ const char *filename)
+{
+
+ time_t smaller;
+ time_t bigger;
+ struct tm *ts;
+
+ /* if last_date does not exist do nothing */
+ if (last_date[0] == '\0')
+ return;
+
+ /* important: because rlog is showing revisions backwards last_date should
+ * always be bigger than date */
+ convert_date(&bigger, last_date);
+ convert_date(&smaller, date);
+
+ if (difftime(bigger, smaller) <= 0) {
+ debug(DEBUG_APPMSG1, "broken revision date: %s -> %s file: %s, repairing.\n",
+ date, last_date, filename);
+ smaller = bigger - 1;
+ ts = gmtime(&smaller);
+ strftime(date, n, "%Y-%m-%d %H:%M:%S", ts);
+ }
+}
+
static void load_from_cvs()
{
FILE * cvsfp;
@@ -267,6 +293,7 @@ static void load_from_cvs()
CvsFile * file = NULL;
PatchSetMember * psm = NULL;
char datebuff[20];
+ char last_datebuff[20];
char authbuff[AUTH_STR_MAX];
int logbufflen = LOG_STR_MAX + 1;
char * logbuff = malloc(logbufflen);
@@ -334,6 +361,8 @@ static void load_from_cvs()
exit(1);
}
+ /* initialize the last_datebuff with value indicating invalid date */
+ last_datebuff[0]='\0';
for (;;)
{
char * tst;
@@ -474,8 +503,14 @@ static void load_from_cvs()
{
if (psm)
{
+ detect_and_repair_time_skew(last_datebuff, datebuff, 20, psm->file->filename);
PatchSet * ps = get_patch_set(datebuff, logbuff, authbuff, psm->post_rev->branch, psm);
patch_set_add_member(ps, psm);
+
+ /* remember last revision */
+ strncpy(last_datebuff, datebuff, 20);
+ /* just to be sure */
+ last_datebuff[19] = '\0';
}
logbuff[0] = 0;
@@ -487,8 +522,13 @@ static void load_from_cvs()
{
if (psm)
{
+ detect_and_repair_time_skew(last_datebuff, datebuff, 20, psm->file->filename);
PatchSet * ps = get_patch_set(datebuff, logbuff, authbuff, psm->post_rev->branch, psm);
patch_set_add_member(ps, psm);
+
+ /* just finished the last revision of this file, set last_datebuff to invalid */
+ last_datebuff[0]='\0';
+
assign_pre_revision(psm, NULL);
}
next prev parent reply other threads:[~2009-03-09 11:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-23 18:49 [PATCH] cvsimport: add test illustrating a bug in cvsps Heiko Voigt
2009-02-23 20:35 ` Heiko Voigt
2009-02-24 5:00 ` Michael Haggerty
2009-03-02 17:59 ` [PATCH v2 0/1] " Heiko Voigt
2009-03-02 17:59 ` [PATCH v2 1/1] " Heiko Voigt
2009-03-09 11:26 ` Heiko Voigt [this message]
2009-03-09 15:02 ` [CVSPS PATCH] fix: correct rev order in case commiters clocks were not syncronised Michael Haggerty
2009-03-18 17:33 ` [PATCH v3 0/2] cvsimport: add test illustrating a bug in cvsps Heiko Voigt
2009-03-18 18:22 ` Junio C Hamano
2009-03-19 10:41 ` Michael J Gruber
2009-03-19 11:00 ` Johannes Schindelin
2009-03-19 11:22 ` Michael J Gruber
2009-03-21 5:41 ` Michael Haggerty
2009-03-23 18:11 ` started a cvsps testsuite Was: " Heiko Voigt
2009-03-23 19:06 ` Martin Langhoff
2009-03-24 4:50 ` Michael Haggerty
2009-04-06 19:01 ` Heiko Voigt
2009-03-23 17:47 ` Heiko Voigt
2009-03-18 17:33 ` [PATCH v3 1/2] " Heiko Voigt
2009-03-18 17:33 ` [PATCH v3 2/2] cvsimport: extend testcase about patchset order to contain branches Heiko Voigt
2009-03-18 17:34 ` [CVSPS PATCH v2] fix: correct rev order in case commiters clocks were not syncronised Heiko Voigt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B4FCDA.4030106@hvoigt.net \
--to=git-list@hvoigt.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
--cc=ydirson@altern.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.