# [PATCH] cvsimport: skip commits that are too recent

5 messages from 2007-01-08 to 2007-01-08. Participants: Martin Langhoff, Junio C Hamano.
Thread: https://gitlist.dev/t/6276

## Martin Langhoff, 2007-01-08 01:11

Subject: [PATCH] cvsimport: skip commits that are too recent
Message-ID: <1168218683853-git-send-email-martin@catalyst.net.nz>
URL: https://gitlist.dev/e/1168218683853-git-send-email-martin%40catalyst.net.nz

```
With this patch, cvsimport will skip commits made
in the last 10 minutes. The recent-ness test is of
5 minutes + cvsps fuzz window (5 minutes default).

When working with a CVS repository that is in use,
importing commits that are too recent can lead to
partially incorrect trees. This is mainly due to

 - Commits that are within the cvsps fuzz window may later
   be found to have affected more files.

 - When performing incremental imports, clock drift between
   the systems may lead to skipped commits.

This commit helps keep incremental imports of in-use
CVS repositories sane.

Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
---
 git-cvsimport.perl |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index c5bf2d1..2686775 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -129,6 +129,11 @@ if ($opt_M) {
 	push (@mergerx, qr/$opt_M/);
 }
 
+# Remember UTC of our starting time
+# we'll want to avoid importing commits
+# that are too recent
+our $starttime = time();
+
 select(STDERR); $|=1; select(STDOUT);
 
 
@@ -824,6 +829,15 @@ while (<CVS>) {
 			$state = 11;
 			next;
 		}
+		if ( $starttime - 300 - (defined $opt_z ? $opt_z : 300) <= $date) {
+			# skip if the commit is too recent
+			# that the cvsps default fuzz is 300s, we give ourselves another
+			# 300s just in case -- this also prevents skipping commits
+			# due to server clock drift
+			print "skip patchset $patchset: $date too recent\n" if $opt_v;
+			$state = 11;
+			next;
+		}
 		if (exists $ignorebranch{$branch}) {
 			print STDERR "Skipping $branch\n";
 			$state = 11;
-- 
1.5.0.rc0.g4017-dirty

```

## Junio C Hamano, 2007-01-08 01:59

Subject: Re: [PATCH] cvsimport: skip commits that are too recent
Message-ID: <7virfiz3at.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7virfiz3at.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1168218683853-git-send-email-martin@catalyst.net.nz>

```
Martin Langhoff <martin@catalyst.net.nz> writes:

> With this patch, cvsimport will skip commits made
> in the last 10 minutes. The recent-ness test is of
> 5 minutes + cvsps fuzz window (5 minutes default).
>
> When working with a CVS repository that is in use,
> importing commits that are too recent can lead to
> partially incorrect trees. This is mainly due to
>
>  - Commits that are within the cvsps fuzz window may later
>    be found to have affected more files.
>
>  - When performing incremental imports, clock drift between
>    the systems may lead to skipped commits.

Hmmmmm.  This is good for tracking other people's work, but, I
am not quite sure how well it works with my workflow.

I have a CVS upstream, but I manage my own development with git.
I start my day by running an incremental cvsimport, rebase my
branch on top of whatever at the tip of the cvsimport branch.  I
use cvsexportcommit (actually a moral equivalent of it I've been
using before cvsexportcommit has become part of git) to make
parts of my branch that are ready for other people's consumption
available by making commits on the CVS side.  Almost immediately
after that, I do another incremental cvsimport so that I can
rebase the remainder of my branch on top of what I made public.

I guess there is no negative impact your patch has on me -- this
10 minute window does not mean that I cannot continue working.
I can keep working on my stuff on my (old) branch without the
second cvsimport and rebase and there is nothing lost.  I can do
the second cvsimport and rebase later.

Which means that you did not give me a new excuse to take a
coffee break and work on git stuff instead of my day job project
to my management but that is Ok.  I'll find other ways ;-).

```

## Martin Langhoff, 2007-01-08 02:13

Subject: Re: [PATCH] cvsimport: skip commits that are too recent
Message-ID: <46a038f90701071813g7b892af1y2cfa620ef2656657@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90701071813g7b892af1y2cfa620ef2656657%40mail.gmail.com
In-Reply-To: <7virfiz3at.fsf@assigned-by-dhcp.cox.net>

```
On 1/8/07, Junio C Hamano <junkio@cox.net> wrote:
>  Almost immediately
> after that, I do another incremental cvsimport so that I can
> rebase the remainder of my branch on top of what I made public.

That probably means I should have added a
--force-fetch-all-and-i-mean-it flag to override the cautious
behaviour. I'll repost ina few hours, with doco too.

 ...

> Which means that you did not give me a new excuse to take a
> coffee break and work on git stuff instead of my day job project
> to my management but that is Ok.  I'll find other ways ;-).

I'll try harder next time ;-)

cheers


martin

```

## Junio C Hamano, 2007-01-08 02:19

Subject: Re: [PATCH] cvsimport: skip commits that are too recent
Message-ID: <7vd55qz2d1.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd55qz2d1.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <46a038f90701071813g7b892af1y2cfa620ef2656657@mail.gmail.com>

```
"Martin Langhoff" <martin.langhoff@gmail.com> writes:

> On 1/8/07, Junio C Hamano <junkio@cox.net> wrote:
>>  Almost immediately
>> after that, I do another incremental cvsimport so that I can
>> rebase the remainder of my branch on top of what I made public.
>
> That probably means I should have added a
> --force-fetch-all-and-i-mean-it flag to override the cautious
> behaviour. I'll repost ina few hours, with doco too.

Well I meant to say that my conclusion is that that flag is not
needed in practice.

>
> ...
>
>> Which means that you did not give me a new excuse to take a
>> coffee break and work on git stuff instead of my day job project
>> to my management but that is Ok.  I'll find other ways ;-).
>
> I'll try harder next time ;-)
>
> cheers
>
>
> martin

```

## Martin Langhoff, 2007-01-08 03:18

Subject: Re: [PATCH] cvsimport: skip commits that are too recent
Message-ID: <46a038f90701071918y4a8078can90ae69dd1d9f9ffd@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90701071918y4a8078can90ae69dd1d9f9ffd%40mail.gmail.com
In-Reply-To: <7vd55qz2d1.fsf@assigned-by-dhcp.cox.net>

```
On 1/8/07, Junio C Hamano <junkio@cox.net> wrote:
> Well I meant to say that my conclusion is that that flag is not
> needed in practice.

you are getting soft in your old age, man :-)

More seriously, as soon as I sent the patch I thought of the use case
you describe. Not everyone is as patient as you are, and someone may
have things scripted. If the cvs repo is local/fast and under your
control, it doesn't make sense to be _so_ conservative.

Also -- by having the flag we get an excuse to mention it in the doco.


m

```
