threads / patch / 715

patchMake cvs2git support remote CVS repos

Subject: [PATCH] Make cvs2git support remote CVS repos

## tl;dr

2 messages between May 25, 2005 and May 26, 2005. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Mark Allen· May 25, 2005, 18:11 UTC · lore

Added a "--module=cvsmodule" command line option and (since we're going to process argv anyway) made "-v" for verbose mode a command line option too, instead of a compile time option.

I've tested it on some (small) private CVS repos and it *seems* to work, although some of the initial commit ordering is wrong, but I think this is due to the commit time being wrong within my CVS repo itself.

I didn't make author and email prettyprint, but I really want to make it a command line option, the discussion from yesterday about whether prettyprinting should be at the plumbing or porcelain layer notwithstanding.

Regards,
--Mark
Show changes to diff +32 −5
Index: cvs2git.c
===================================================================
--- a0e0d3940c350f14545a481b179217f626c93440/cvs2git.c  (mode:100644)
+++ uncommitted/cvs2git.c  (mode:100644)
@@ -32,6 +32,8 @@
 };
 
 static char *rcsdir;
+static char *cvsroot;
+static char *cvsmodule;
 
 static char date[100];
 static char author[100];
@@ -194,9 +196,13 @@
 	if (dir)
 		printf("mkdir -p %.*s\n", (int)(dir - name), name);
 
-	get_rcs_name(rcspathname, name, dir);
-		
-	printf("co -q -p -r%s '%s' > '%s'\n", version, rcspathname, name);
+	if ( !cvsmodule ) {
+		get_rcs_name(rcspathname, name, dir);
+		printf("co -q -p -r%s '%s' > '%s'\n", version, rcspathname, name);
+	} else {
+		printf("cvs -d %s checkout -r%s -p '%s/%s' > '%s'\n", cvsroot, version, cvsmodule, name, name);
+	}
+
 	printf("git-update-cache --add -- '%s'\n", name);
 }
 
@@ -217,13 +223,34 @@
 {
 	static char line[1000];
 	enum state state = Header;
+	int i;
+
+	for (i = 1; i < argc; i++) {
+		const char *arg = argv[i];
+		if (!memcmp(arg, "--module=", 9)) {
+			cvsroot = getenv("CVSROOT");
+			cvsmodule = (char *)arg+9;
+			continue;
+		} 
+		if (!strcmp(arg, "-v")) {
+			verbose = 1;
+			continue;
+		}
+	}
+
+	if (!cvsmodule)
+		rcsdir = getenv("RCSDIR");
 
-	rcsdir = getenv("RCSDIR");
-	if (!rcsdir) {
+	if (!cvsmodule && !rcsdir) {
 		fprintf(stderr, "I need an $RCSDIR\n");
 		exit(1);
 	}
 
+	if (cvsmodule && !cvsroot) {
+		fprintf(stderr, "I need a $CVSROOT\n");
+		exit(1);
+	}
+
 	printf("[ -d .git ] && exit 1\n");
 	printf("git-init-db\n");
 	printf("mkdir -p .git/refs/heads\n");
Linus Torvalds· May 26, 2005, 02:42 UTC · re: Mark Allen · lore

Re: [PATCH] Make cvs2git support remote CVS repos

On Wed, 25 May 2005, Mark Allen wrote:
>
> Added a "--module=cvsmodule" command line option and (since we're going to process argv
> anyway) made "-v" for verbose mode a command line option too, instead of a compile time
> option.
Ahh.. You found out how to get CVS to check out individual files. 

The reason I use RCS "co" directly is because I couldn't figure out how CVS can be made to do it. Of course, the raw RCS possibly also performs better, but somebody should check that. If the overhead of using CVS to do this is low enough, we should drop the raw RCS access, which should simplify your patch and get rid of the need for "RCSDIR".

Anybody up for some performance testing?
			Linus

← back to recent threads