Skip to contentSkip to conversation

Reroll of the remote-vcs-helper series

PATCH Superseded Sverre Rabbelier 4 participants 43 messages Jun 15, 2016

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Reroll of the remote-vcs-helper series

Reroll of the entire series that is currently in pu, rebased on current master.

I did not squash the cvs makefile fixes since my Makefile foo is not that great.

Daniel, please have a close look at the UNSTABLE patch, as I am not sure at all that I rebased it properly.

I did not have time to work on my git-remote-hg patches yet, but I might send those two out later today before I get on my flight back home. If not it'll be tomorrow somewhere :).

Daniel Barkalow (7):
Use a function to determine whether a remote is valid Allow fetch to modify refs
Allow programs to not depend on remotes having urls
Add a config option for remotes to specify a foreign vcs Add support for "import" helper command
Allow helpers to report in "list" command that the ref is unchanged Fix memory leak in helper method for disconnect

Johan Herland (8):
Allow helpers to request marks for fast-import
Basic build infrastructure for Python scripts
1/2: Add Python support library for CVS remote helper
2/2: Add Python support library for CVS remote helper
git-remote-cvs: Remote helper program for CVS repositories
Add simple selftests of git-remote-cvs functionality
Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvs More fixes to the git-remote-cvs installation procedure

Johannes Schindelin (1):
Finally make remote helper support useful

Sverre Rabbelier (3):
Factor ref updating out of fetch_with_import Refactor git_remote_cvs to a more generic git_remote_helpers .gitignore: add git-remote-cvs

 .gitignore                              |    1 +
 Documentation/config.txt                |    4 +
 Documentation/git-remote-cvs.txt        |   85 +++
 Documentation/git-remote-helpers.txt    |   22 +-
 Makefile                                |   53 ++
 builtin-clone.c                         |   12 +-
 builtin-fetch.c                         |   10 +-
 builtin-ls-remote.c                     |    4 +-
 builtin-push.c                          |   68 ++-
 configure.ac                            |    3 +
 git-remote-cvs.py                       |  683 +++++++++++++++++++++
 git_remote_helpers/.gitignore           |    2 +
 git_remote_helpers/Makefile             |   35 ++
 git_remote_helpers/__init__.py          |   27 +
 git_remote_helpers/cvs/changeset.py     |  126 ++++
 git_remote_helpers/cvs/commit_states.py |   62 ++
 git_remote_helpers/cvs/cvs.py           |  998 +++++++++++++++++++++++++++++++
 git_remote_helpers/cvs/revision_map.py  |  418 +++++++++++++
 git_remote_helpers/cvs/symbol_cache.py  |  313 ++++++++++
 git_remote_helpers/git/git.py           |  680 +++++++++++++++++++++
 git_remote_helpers/setup.py             |   17 +
 git_remote_helpers/util.py              |  194 ++++++
 remote.c                                |   15 +-
 remote.h                                |    2 +
 t/t9800-remote-cvs-basic.sh             |  524 ++++++++++++++++
 t/t9801-remote-cvs-fetch.sh             |  291 +++++++++
 t/test-lib.sh                           |   10 +
 transport-helper.c                      |  117 ++++-
 transport.c                             |   37 +-
 transport.h                             |   45 ++-
 30 files changed, 4810 insertions(+), 48 deletions(-)
#1 lore raw

PATCH 1/19 Use a function to determine whether a remote is valid

From: Daniel Barkalow <[email protected]>

Currently, it only checks url, but it will allow other things in the future.

---

Signed off by me because I fixed the conflict with alias_url.

 remote.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
remote.c +9 -4
index 73d33f2..15c9cec 100644
@@ -52,6 +52,11 @@ static struct rewrites rewrites_push;
 #define BUF_SIZE (2048)
 static char buffer[BUF_SIZE];
 
+static int valid_remote(const struct remote *remote)
+{
+	return !!remote->url;
+}
+
 static const char *alias_url(const char *url, struct rewrites *r)
 {
 	int i, j;
@@ -688,14 +693,14 @@ struct remote *remote_get(const char *name)
 
 	ret = make_remote(name, 0);
 	if (valid_remote_nick(name)) {
-		if (!ret->url)
+		if (!valid_remote(ret))
 			read_remotes_file(ret);
-		if (!ret->url)
+		if (!valid_remote(ret))
 			read_branches_file(ret);
 	}
-	if (name_given && !ret->url)
+	if (name_given && !valid_remote(ret))
 		add_url_alias(ret, name);
-	if (!ret->url)
+	if (!valid_remote(ret))
 		return NULL;
 	ret->fetch = parse_fetch_refspec(ret->fetch_refspec_nr, ret->fetch_refspec);
 	ret->push = parse_push_refspec(ret->push_refspec_nr, ret->push_refspec);
Signature · 1 line
1.6.5.2.291.gf76a3
#2 lore raw

PATCH 2/19 Allow fetch to modify refs

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

This allows the transport to use the null sha1 for a ref reported to be present in the remote repository to indicate that a ref exists but its actual value is presently unknown and will be set if the objects are fetched.

Also adds documentation to the API to specify exactly what the methods should do and how they should interpret arguments.

---

Signed off by me because I rebased it on master and fixed the conflicts with nico's patch.

 builtin-clone.c    |    5 +++--
 transport-helper.c |    4 ++--
 transport.c        |   13 +++++++------
 transport.h        |   41 +++++++++++++++++++++++++++++++++++++++--
 4 files changed, 51 insertions(+), 12 deletions(-)
builtin-clone.c +3 -2
index 5762a6f..0042bee 100644
@@ -526,8 +526,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		refs = transport_get_remote_refs(transport);
 		if (refs) {
-			mapped_refs = wanted_peer_refs(refs, refspec);
-			transport_fetch_refs(transport, mapped_refs);
+			struct ref *ref_cpy = wanted_peer_refs(refs, refspec);
+			mapped_refs = ref_cpy;
+			transport_fetch_refs(transport, ref_cpy);
 		}
 	}
 
transport-helper.c +2 -2
index f57e84c..a0e4219 100644
@@ -68,7 +68,7 @@ static int disconnect_helper(struct transport *transport)
 }
 
 static int fetch_with_fetch(struct transport *transport,
-			    int nr_heads, const struct ref **to_fetch)
+			    int nr_heads, struct ref **to_fetch)
 {
 	struct child_process *helper = get_helper(transport);
 	FILE *file = xfdopen(helper->out, "r");
@@ -92,7 +92,7 @@ static int fetch_with_fetch(struct transport *transport,
 }
 
 static int fetch(struct transport *transport,
-		 int nr_heads, const struct ref **to_fetch)
+		 int nr_heads, struct ref **to_fetch)
 {
 	struct helper_data *data = transport->data;
 	int i, count;
transport.c +7 -6
index 644a30a..3822fc7 100644
@@ -204,7 +204,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
 }
 
 static int fetch_objs_via_rsync(struct transport *transport,
-				int nr_objs, const struct ref **to_fetch)
+				int nr_objs, struct ref **to_fetch)
 {
 	struct strbuf buf = STRBUF_INIT;
 	struct child_process rsync;
@@ -408,7 +408,7 @@ static struct ref *get_refs_from_bundle(struct transport *transport, int for_pus
 }
 
 static int fetch_refs_from_bundle(struct transport *transport,
-			       int nr_heads, const struct ref **to_fetch)
+			       int nr_heads, struct ref **to_fetch)
 {
 	struct bundle_transport_data *data = transport->data;
 	return unbundle(&data->header, data->fd);
@@ -486,7 +486,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
 }
 
 static int fetch_refs_via_pack(struct transport *transport,
-			       int nr_heads, const struct ref **to_fetch)
+			       int nr_heads, struct ref **to_fetch)
 {
 	struct git_transport_data *data = transport->data;
 	char **heads = xmalloc(nr_heads * sizeof(*heads));
@@ -923,16 +923,17 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
 	return transport->remote_refs;
 }
 
-int transport_fetch_refs(struct transport *transport, const struct ref *refs)
+int transport_fetch_refs(struct transport *transport, struct ref *refs)
 {
 	int rc;
 	int nr_heads = 0, nr_alloc = 0, nr_refs = 0;
-	const struct ref **heads = NULL;
-	const struct ref *rm;
+	struct ref **heads = NULL;
+	struct ref *rm;
 
 	for (rm = refs; rm; rm = rm->next) {
 		nr_refs++;
 		if (rm->peer_ref &&
+		    !is_null_sha1(rm->old_sha1) &&
 		    !hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
 			continue;
 		ALLOC_GROW(heads, nr_heads + 1, nr_alloc);
transport.h +39 -2

57 lines not on this page · raw message

Signature · 1 line
1.6.5.2.291.gf76a3
#3 lore raw

Re: [PATCH 02/19] Allow fetch to modify refs

Quoted 28 lines · Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

This allows the transport to use the null sha1 for a ref reported to be present in the remote repository to indicate that a ref exists but its actual value is presently unknown and will be set if the objects are fetched.

Also adds documentation to the API to specify exactly what the methods should do and how they should interpret arguments.

---

Signed off by me because I rebased it on master and fixed the conflicts with nico's patch.

 builtin-clone.c    |    5 +++--
 transport-helper.c |    4 ++--
 transport.c        |   13 +++++++------
 transport.h        |   41 +++++++++++++++++++++++++++++++++++++++--
 4 files changed, 51 insertions(+), 12 deletions(-)
builtin-clone.c +0 -0
index 5762a6f..0042bee 100644

builtin-clone.c int cmd_clone(int argc, const char **argv, const char *prefix) · line 531

Quoted 8 lines
builtin-clone.c +3 -2
@@ -526,8 +526,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 		refs = transport_get_remote_refs(transport);
 		if (refs) {
-			mapped_refs = wanted_peer_refs(refs, refspec);
-			transport_fetch_refs(transport, mapped_refs);
+			struct ref *ref_cpy = wanted_peer_refs(refs, refspec);
+			mapped_refs = ref_cpy;
+			transport_fetch_refs(transport, ref_cpy);

Just drop this hunk; the change doesn't actually do anything. Otherwise, the patch matches what I have.

-Daniel
*This .sig left intentionally blank*

#4 lore raw

Re: [PATCH 02/19] Allow fetch to modify refs

Heya,

Quoted 13 lines · Daniel Barkalow

builtin-clone.c int cmd_clone(int argc, const char **argv, const char *prefix) · line 531

Quoted 10 lines

+++ b/builtin-clone.c

builtin-clone.c +3 -2
@@ -526,8 +526,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
               refs = transport_get_remote_refs(transport);
               if (refs) {
-                     mapped_refs = wanted_peer_refs(refs, refspec);
-                     transport_fetch_refs(transport, mapped_refs);
+                     struct ref *ref_cpy = wanted_peer_refs(refs, refspec);
+                     mapped_refs = ref_cpy;
+                     transport_fetch_refs(transport, ref_cpy);

Just drop this hunk; the change doesn't actually do anything. Otherwise, the patch matches what I have.

Am I missing something? I thought we need this hunk since mapped_refs is const, and transport_fetch_refs takes a non-const argument?

builtin-clone.c: In function ‘cmd_clone’:
builtin-clone.c:531: warning: passing argument 2 of ‘transport_fetch_refs’ discards qualifiers from pointer target type

Signature · 3 lines
Cheers,

Sverre Rabbelier
#5 lore raw

Re: [PATCH 02/19] Allow fetch to modify refs

Quoted 17 lines · Sverre Rabbelier

Heya,

Quoted 13 lines · Daniel Barkalow

builtin-clone.c int cmd_clone(int argc, const char **argv, const char *prefix) · line 531

Quoted 10 lines

+++ b/builtin-clone.c

builtin-clone.c +3 -2
@@ -526,8 +526,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
               refs = transport_get_remote_refs(transport);
               if (refs) {
-                     mapped_refs = wanted_peer_refs(refs, refspec);
-                     transport_fetch_refs(transport, mapped_refs);
+                     struct ref *ref_cpy = wanted_peer_refs(refs, refspec);
+                     mapped_refs = ref_cpy;
+                     transport_fetch_refs(transport, ref_cpy);

Just drop this hunk; the change doesn't actually do anything. Otherwise, the patch matches what I have.

Quoted 6 lines

Am I missing something? I thought we need this hunk since mapped_refs is const, and transport_fetch_refs takes a non-const argument?

builtin-clone.c: In function ‘cmd_clone’:
builtin-clone.c:531: warning: passing argument 2 of ‘transport_fetch_refs’ discards qualifiers from pointer target type

Ah, actually, mapped_refs should just be made non-const; unlike "refs", it's set from wanted_peer_refs(), which returns a non-const value.

-Daniel
*This .sig left intentionally blank*

#6 lore raw

Re: [PATCH 02/19] Allow fetch to modify refs

Heya,

Quoted 2 lines · Daniel Barkalow

Ah, actually, mapped_refs should just be made non-const; unlike "refs", it's set from wanted_peer_refs(), which returns a non-const value.

That works too, even better I guess :).

Signature · 3 lines
Cheers,

Sverre Rabbelier
#7 lore raw

PATCH 3/19 Allow programs to not depend on remotes having urls

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

For fetch and ls-remote, which use the first url of a remote, have transport_get() determine this by passing a remote and passing NULL for the url. For push, which uses every url of a remote, use each url in turn if there are any, and use NULL if there are none.

This will allow the transport code to do something different if the location is not specified with a url.

Also, have the message for a fetch say "foreign" if there is no url.

---

I rebased this on master and had major conflicts with the recent 'advice' series, Daniel, please have a look at this to see whether it is sane at all.

 builtin-fetch.c     |    7 +++-
 builtin-ls-remote.c |    4 +-
 builtin-push.c      |   68 +++++++++++++++++++++++++++++++-------------------
 transport.c         |    3 ++
 4 files changed, 52 insertions(+), 30 deletions(-)
builtin-fetch.c +5 -2
index a35a6f8..013a6ba 100644
@@ -309,7 +309,10 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 	if (!fp)
 		return error("cannot open %s: %s\n", filename, strerror(errno));
 
-	url = transport_anonymize_url(raw_url);
+	if (raw_url)
+		url = transport_anonymize_url(raw_url);
+	else
+		url = xstrdup("foreign");
 	for (rm = ref_map; rm; rm = rm->next) {
 		struct ref *ref = NULL;
 
@@ -704,7 +707,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 	if (!remote)
 		die("Where do you want to fetch from today?");
 
-	transport = transport_get(remote, remote->url[0]);
+	transport = transport_get(remote, NULL);
 	if (verbosity >= 2)
 		transport->verbose = 1;
 	if (verbosity < 0)
builtin-ls-remote.c +2 -2
index 78a88f7..4c6fc58 100644
@@ -87,9 +87,9 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 		}
 	}
 	remote = nongit ? NULL : remote_get(dest);
-	if (remote && !remote->url_nr)
+	if (!nongit && !remote)
 		die("remote %s has no configured URL", dest);
-	transport = transport_get(remote, remote ? remote->url[0] : dest);
+	transport = transport_get(remote, remote ? NULL : dest);
 	if (uploadpack != NULL)
 		transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
 
builtin-push.c +42 -26

81 lines not on this page · raw message

transport.c +3 -0
index 3822fc7..5ae8db6 100644
@@ -813,6 +813,9 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	struct transport *ret = xcalloc(1, sizeof(*ret));
 
 	ret->remote = remote;
+
+	if (!url && remote && remote->url)
+		url = remote->url[0];
 	ret->url = url;
 
 	if (!prefixcmp(url, "rsync:")) {
Signature · 1 line
1.6.5.2.291.gf76a3
#8 lore raw

Re: [UNSTABLE PATCH 03/19] Allow programs to not depend on remotes having urls

Quoted 12 lines · Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

For fetch and ls-remote, which use the first url of a remote, have transport_get() determine this by passing a remote and passing NULL for the url. For push, which uses every url of a remote, use each url in turn if there are any, and use NULL if there are none.

This will allow the transport code to do something different if the location is not specified with a url.

Also, have the message for a fetch say "foreign" if there is no url.

Quoted 7 lines

---

I rebased this on master and had major conflicts with the recent 'advice' series, Daniel, please have a look at this to see whether it is sane at all.

Yup, this is right. Perhaps I should try to get the refactor in builtin-push to use push_with_options() without any behavior change into master ahead of the rest of this series, to avoid having to deal with this sort of conflict every time someone touches this section of code, which has happened several times recently now. Anyway, you correctly understood the intended change here.

-Daniel
*This .sig left intentionally blank*

#9 lore raw

Re: [UNSTABLE PATCH 03/19] Allow programs to not depend on remotes having urls

Heya,

Quoted 3 lines · Daniel Barkalow

Perhaps I should try to get the refactor in
builtin-push to use push_with_options() without any behavior change into master ahead of the rest of this series.

I think that's a good idea in general :).

Quoted 1 line

Anyway, you correctly understood the intended change here.

Ok, nice.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#10 lore raw

PATCH 4/19 Add a config option for remotes to specify a foreign vcs

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

If this is set, the url is not required, and the transport always uses a helper named "git-remote-<value>".

It is a separate configuration option in order to allow a sensible configuration for foreign systems which either have no meaningful urls for repositories or which require urls that do not specify the system used by the repository at that location. However, this only affects how the name of the helper is determined, not anything about the interaction with the helper, and the contruction is such that, if the foreign scm does happen to use a co-named url method, a url with that method may be used directly.

---

This has my patch to fix valid_remote to allow for both url vcs squashed in.

 Documentation/config.txt |    4 ++++
 remote.c                 |    4 +++-
 remote.h                 |    2 ++
 transport.c              |    5 +++++
 4 files changed, 14 insertions(+), 1 deletions(-)
Documentation/config.txt +4 -0
index d1e2120..0d9d369 100644
@@ -1408,6 +1408,10 @@ remote.<name>.tagopt::
 	Setting this value to \--no-tags disables automatic tag following when
 	fetching from remote <name>
 
+remote.<name>.vcs::
+	Setting this to a value <vcs> will cause git to interact with
+	the remote with the git-remote-<vcs> helper.
+
 remotes.<group>::
 	The list of remotes which are fetched by "git remote update
 	<group>".  See linkgit:git-remote[1].
remote.c +3 -1
index 15c9cec..09bb79c 100644
@@ -54,7 +54,7 @@ static char buffer[BUF_SIZE];
 
 static int valid_remote(const struct remote *remote)
 {
-	return !!remote->url;
+	return (!!remote->url) || (!!remote->foreign_vcs);
 }
 
 static const char *alias_url(const char *url, struct rewrites *r)
@@ -444,6 +444,8 @@ static int handle_config(const char *key, const char *value, void *cb)
 	} else if (!strcmp(subkey, ".proxy")) {
 		return git_config_string((const char **)&remote->http_proxy,
 					 key, value);
+	} else if (!strcmp(subkey, ".vcs")) {
+		return git_config_string(&remote->foreign_vcs, key, value);
 	}
 	return 0;
 }
remote.h +2 -0
index 5db8420..ac0ce2f 100644
@@ -11,6 +11,8 @@ struct remote {
 	const char *name;
 	int origin;
 
+	const char *foreign_vcs;
+
 	const char **url;
 	int url_nr;
 	int url_alloc;
transport.c +5 -0
index 5ae8db6..13bab4e 100644
@@ -818,6 +818,11 @@ struct transport *transport_get(struct remote *remote, const char *url)
 		url = remote->url[0];
 	ret->url = url;
 
+	if (remote && remote->foreign_vcs) {
+		transport_helper_init(ret, remote->foreign_vcs);
+		return ret;
+	}
+
 	if (!prefixcmp(url, "rsync:")) {
 		ret->get_refs_list = get_refs_via_rsync;
 		ret->fetch = fetch_objs_via_rsync;
Signature · 1 line
1.6.5.2.291.gf76a3
#11 lore raw

PATCH 5/19 Add support for "import" helper command

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

This command, supported if the "import" capability is advertized, allows a helper to support fetching by outputting a git-fast-import stream.

If both "fetch" and "import" are advertized, git itself will use "fetch" (although other users may use "import" in this case).

---

This has my symref patch squashed in.

 Documentation/git-remote-helpers.txt |   10 ++++++
 transport-helper.c                   |   52 ++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 0 deletions(-)
Documentation/git-remote-helpers.txt +10 -0
index 173ee23..e9aa67e 100644
@@ -43,6 +43,13 @@ Commands are given by the caller on the helper's standard input, one per line.
 +
 Supported if the helper has the "fetch" capability.
 
+'import' <name>::
+	Produces a fast-import stream which imports the current value
+	of the named ref. It may additionally import other refs as
+	needed to construct the history efficiently.
++
+Supported if the helper has the "import" capability.
+
 If a fatal error occurs, the program writes the error message to
 stderr and exits. The caller should expect that a suitable error
 message has been printed if the child closes the connection without
@@ -57,6 +64,9 @@ CAPABILITIES
 'fetch'::
 	This helper supports the 'fetch' command.
 
+'import'::
+	This helper supports the 'import' command.
+
 REF LIST ATTRIBUTES
 -------------------
 
transport-helper.c +52 -0

76 lines not on this page · raw message

Signature · 1 line
1.6.5.2.291.gf76a3
#12 lore raw

RFC PATCH 6/19 Factor ref updating out of fetch_with_import

In reply to Sverre Rabbelier

Also allow the new update_refs to actually update the refs set, this way the remote helper can set the value of previously unknown refs.

---

Daniel, if we can get wanted_peer_refs to keep HEAD as a wanted ref somehow this patch could be a lot simpler.

 builtin-clone.c    |    7 +++++++
 builtin-fetch.c    |    3 +++
 transport-helper.c |   15 +++++++++++++++
 transport.c        |    6 ++++++
 transport.h        |    8 ++++++--
 5 files changed, 37 insertions(+), 2 deletions(-)
builtin-clone.c +7 -0
index 0042bee..7c90ce2 100644
@@ -529,6 +529,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 			struct ref *ref_cpy = wanted_peer_refs(refs, refspec);
 			mapped_refs = ref_cpy;
 			transport_fetch_refs(transport, ref_cpy);
+			if (transport->update_refs)
+			{
+				ref_cpy = copy_ref_list(refs);
+				transport_update_refs(transport, ref_cpy);
+				refs = ref_cpy;
+				mapped_refs = wanted_peer_refs(refs, refspec);
+			}
 		}
 	}
 
builtin-fetch.c +3 -0
index 013a6ba..c35188b 100644
@@ -479,7 +479,10 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
 {
 	int ret = quickfetch(ref_map);
 	if (ret)
+	{
 		ret = transport_fetch_refs(transport, ref_map);
+		transport_update_refs(transport, ref_map);
+	}
 	if (!ret)
 		ret |= store_updated_refs(transport->url,
 				transport->remote->name,
transport-helper.c +15 -0
index f840842..ab40a9a 100644
@@ -207,6 +207,20 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
 	return ret;
 }
 
+static int update_refs(struct transport *transport, struct ref *refs)
+{
+	struct ref *ref = refs;
+
+	while (ref) {
+		if (ref->status & REF_STATUS_UPTODATE)
+			continue;
+		read_ref(ref->symref ? ref->symref : ref->name, ref->old_sha1);
+		ref = ref->next;
+	}
+
+	return 0;
+}
+
 int transport_helper_init(struct transport *transport, const char *name)
 {
 	struct helper_data *data = xcalloc(sizeof(*data), 1);
@@ -215,6 +229,7 @@ int transport_helper_init(struct transport *transport, const char *name)
 	transport->data = data;
 	transport->get_refs_list = get_refs_list;
 	transport->fetch = fetch;
+	transport->update_refs = update_refs;
 	transport->disconnect = disconnect_helper;
 	return 0;
 }
transport.c +6 -0
index 13bab4e..741a3a7 100644
@@ -966,6 +966,12 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs)
 	return rc;
 }
 
+void transport_update_refs(struct transport *transport, struct ref *refs)
+{
+	if (transport->update_refs)
+		transport->update_refs(transport, refs);
+}
+
 void transport_unlock_pack(struct transport *transport)
 {
 	if (transport->pack_lockfile) {
transport.h +6 -2
index 503db11..1aba16c 100644
@@ -32,12 +32,15 @@ struct transport {
 	/**
 	 * Fetch the objects for the given refs. Note that this gets
 	 * an array, and should ignore the list structure.
-	 *
+	 **/
+	int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
+
+	/**
 	 * If the transport did not get hashes for refs in
 	 * get_refs_list(), it should set the old_sha1 fields in the
 	 * provided refs now.
 	 **/
-	int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
+	int (*update_refs)(struct transport *transport, struct ref *refs);
 
 	/**
 	 * Push the objects and refs. Send the necessary objects, and
@@ -112,6 +115,7 @@ int transport_push(struct transport *connection,
 const struct ref *transport_get_remote_refs(struct transport *transport);
 
 int transport_fetch_refs(struct transport *transport, struct ref *refs);
+void transport_update_refs(struct transport *transport, struct ref *refs);
 void transport_unlock_pack(struct transport *transport);
 int transport_disconnect(struct transport *transport);
 char *transport_anonymize_url(const char *url);
Signature · 1 line
1.6.5.2.291.gf76a3
#13 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Quoted 8 lines · Sverre Rabbelier

Also allow the new update_refs to actually update the refs set, this way the remote helper can set the value of previously unknown refs.

---

Daniel, if we can get wanted_peer_refs to keep HEAD as a wanted ref somehow this patch could be a lot simpler.

Actually, I think the problem is that builtin-clone will always default to setting up a refspec of "refs/heads/*:refs/remotes/origin/*", but that doesn't actually make any sense if the source repository isn't presented as having refs names like "refs/heads/*". The immediate problem that you don't get HEAD because it's a symref to something outside the pattern is somewhat secondary to the general problem that you don't get anything at all, because everything's outside the pattern.

I don't really think that presenting the real refs in refs/<vcs>/*, and having the list give symrefs to them from refs/heads/* and refs/tags/* really makes sense; I think it would be better to rework fetch_with_import and the list provided by a foreign vcs helper such that it can present refs with normal names (refs/heads/*, refs/tags/*, etc) if the foreign vcs has standards that correspond to branches and tags. Then "clone" would work normally.

Or, perhaps, there should be some other way of allowing git users to take advantage of foreign vcs standards; I don't have a good perspective on this, since I only presently use git and a foreign vcs without any useful standards. But I think it should be such that the transport user sees as close as possible to a native git layout, and clone continues to rely on the layout being normal, instead of presenting a weird layout mapped into a normal layout or something like that and working around transport users not expecting this.

-Daniel
*This .sig left intentionally blank*

#14 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Quoted 7 lines · Daniel Barkalow

Actually, I think the problem is that builtin-clone will always default to setting up a refspec of "refs/heads/*:refs/remotes/origin/*", but that doesn't actually make any sense if the source repository isn't presented as having refs names like "refs/heads/*". The immediate problem that you don't get HEAD because it's a symref to something outside the pattern is somewhat secondary to the general problem that you don't get anything at all, because everything's outside the pattern.

Ah, I didn't realize that as long as HEAD is a symref to something in refs/heads/* it would be fetched.

Quoted 7 lines

I don't really think that presenting the real refs in refs/<vcs>/*, and having the list give symrefs to them from refs/heads/* and refs/tags/* really makes sense; I think it would be better to rework fetch_with_import and the list provided by a foreign vcs helper such that it can present refs with normal names (refs/heads/*, refs/tags/*, etc) if the foreign vcs has standards that correspond to branches and tags. Then "clone" would work normally.

Perhaps we could introduce an additional phase before import to set the default refspec? If we could tell git that we want "refs/heads/*:refs/hg/origin/*" before line 468 "if (option_bare) {", that would save us a lot of trouble. Does that sound like a good idea? It would mean we have to move the transport_get part up a bit, but I don't think that will be a problem. A svn helper for example might respond the following to the "refspec" command:
"refs/heads/trunkr:refs/svn/origin/trunk" "refs/tags/*:refs/svn/origin/tags/*" "refs/heads/*:refs/svn/origin/branches/*"

How does that sound?

Signature · 3 lines
Cheers,

Sverre Rabbelier
#15 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Quoted 11 lines · Sverre Rabbelier
Quoted 7 lines · Daniel Barkalow

Actually, I think the problem is that builtin-clone will always default to setting up a refspec of "refs/heads/*:refs/remotes/origin/*", but that doesn't actually make any sense if the source repository isn't presented as having refs names like "refs/heads/*". The immediate problem that you don't get HEAD because it's a symref to something outside the pattern is somewhat secondary to the general problem that you don't get anything at all, because everything's outside the pattern.

Ah, I didn't realize that as long as HEAD is a symref to something in refs/heads/* it would be fetched.

Clone only cares about the remote HEAD for the purpose of making refs/remotes/origin/HEAD a symref to something. It doesn't really want a SHA1 for it (except in order to guess that it's a symref to something that the remote has dereferenced in its list); and, since it's a symref, no objects have to be fetched for it -- except for the possibility that it's known to be a symref to something that wasn't fetched, in which case, we know that HEAD -> something, and something's SHA1 is sha1, but we didn't fetch something so we don't have sha1. Of course, I think clone then writes a dangling symref anyway and forgets about sha1.

Quoted 19 lines
Quoted 7 lines

I don't really think that presenting the real refs in refs/<vcs>/*, and having the list give symrefs to them from refs/heads/* and refs/tags/* really makes sense; I think it would be better to rework fetch_with_import and the list provided by a foreign vcs helper such that it can present refs with normal names (refs/heads/*, refs/tags/*, etc) if the foreign vcs has standards that correspond to branches and tags. Then "clone" would work normally.

Perhaps we could introduce an additional phase before import to set the default refspec? If we could tell git that we want "refs/heads/*:refs/hg/origin/*" before line 468 "if (option_bare) {", that would save us a lot of trouble. Does that sound like a good idea? It would mean we have to move the transport_get part up a bit, but I don't think that will be a problem. A svn helper for example might respond the following to the "refspec" command:
"refs/heads/trunkr:refs/svn/origin/trunk" "refs/tags/*:refs/svn/origin/tags/*" "refs/heads/*:refs/svn/origin/branches/*"

Quoted 1 line

How does that sound?

The values you've got for refspecs don't make sense as fetch refspecs; these would cause refs with names the helper won't supply to be stored in the helper's private namespace, which is certainly wrong. (And I think you have the sides backwards)

On the other hand, I think it would make sense to use the same style of refspec between the helper and transport-helper.c such that the helper reports something like:

refs/svn/origin/trunk:refs/heads/trunkr
refs/svn/origin/branches/*:refs/heads/*
refs/svn/origin/tags/*:refs/tags/*

"list" gives:

000000...000 refs/heads/trunkr

"import refs/heads/trunkr" imports the objects, but the refspecs have to be consulted by transport-helper.c in order to determine what ref to read to get the value of refs/heads/trunkr. Instead of getting the value with read_ref("refs/heads/trunkr", ...) like it does now, it would do read_ref("refs/svn/origin/trunk", ...). And systems like p4 that don't have a useful standard just wouldn't support the "refspec" command and people would have to do site-specific configuration to get anything useful.

-Daniel
*This .sig left intentionally blank*

#20 lore raw

PATCH 7/19 Allow helpers to report in "list" command that the ref is unchanged

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

Helpers may use a line like "? name unchanged" to specify that there is nothing new at that name, without any git-specific code to determine the correct response.

---

Unchanged.

 Documentation/git-remote-helpers.txt |    4 +++-
 transport-helper.c                   |   22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)
Documentation/git-remote-helpers.txt +3 -1
index e9aa67e..2c5130f 100644
@@ -70,7 +70,9 @@ CAPABILITIES
 REF LIST ATTRIBUTES
 -------------------
 
-None are defined yet, but the caller must accept any which are supplied.
+'unchanged'::
+	This ref is unchanged since the last import or fetch, although
+	the helper cannot necessarily determine what value that produced.
 
 Documentation
 -------------
transport-helper.c +22 -0
index ab40a9a..e093d05 100644
@@ -163,6 +163,22 @@ static int fetch(struct transport *transport,
 	return -1;
 }
 
+static int has_attribute(const char *attrs, const char *attr) {
+	int len;
+	if (!attrs)
+		return 0;
+
+	len = strlen(attr);
+	for (;;) {
+		const char *space = strchrnul(attrs, ' ');
+		if (len == space - attrs && !strncmp(attrs, attr, len))
+			return 1;
+		if (!*space)
+			return 0;
+		attrs = space + 1;
+	}
+}
+
 static struct ref *get_refs_list(struct transport *transport, int for_push)
 {
 	struct child_process *helper;
@@ -197,6 +213,12 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
 			(*tail)->symref = xstrdup(buf.buf + 1);
 		else if (buf.buf[0] != '?')
 			get_sha1_hex(buf.buf, (*tail)->old_sha1);
+		if (eon) {
+			if (has_attribute(eon + 1, "unchanged")) {
+				(*tail)->status |= REF_STATUS_UPTODATE;
+				read_ref((*tail)->name, (*tail)->old_sha1);
+			}
+		}
 		tail = &((*tail)->next);
 	}
 	strbuf_release(&buf);
Signature · 1 line
1.6.5.2.291.gf76a3
#21 lore raw

PATCH 8/19 Fix memory leak in helper method for disconnect

In reply to Sverre Rabbelier

From: Daniel Barkalow <[email protected]>

Since some cases may need to disconnect from the helper and reconnect, wrap the function that just disconnects in a function that also frees transport->data.

---

Unchanged.

 transport-helper.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
transport-helper.c +8 -1
index e093d05..36a265d 100644
@@ -70,6 +70,13 @@ static int disconnect_helper(struct transport *transport)
 	return 0;
 }
 
+static int release_helper(struct transport *transport)
+{
+	disconnect_helper(transport);
+	free(transport->data);
+	return 0;
+}
+
 static int fetch_with_fetch(struct transport *transport,
 			    int nr_heads, struct ref **to_fetch)
 {
@@ -252,6 +259,6 @@ int transport_helper_init(struct transport *transport, const char *name)
 	transport->get_refs_list = get_refs_list;
 	transport->fetch = fetch;
 	transport->update_refs = update_refs;
-	transport->disconnect = disconnect_helper;
+	transport->disconnect = release_helper;
 	return 0;
 }
Signature · 1 line
1.6.5.2.291.gf76a3
#22 lore raw

PATCH 9/19 Finally make remote helper support useful

In reply to Sverre Rabbelier

From: Johannes Schindelin <[email protected]>

The common case for remote helpers will be to import some repository which can be specified by a single URL. Rather than supporting those who say that Git is really complicated, let's be nice to users so that they will be able to say:

git clone hg::https://soc.googlecode.com/hg/ soc

---

I decided to not allow 'hg+https' format, since clone does not deal well with that syntax (it checks to see whether there is a ':' in the url or not).

 transport.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
transport.c +10 -0
index 741a3a7..e6a00b2 100644
@@ -818,6 +818,16 @@ struct transport *transport_get(struct remote *remote, const char *url)
 		url = remote->url[0];
 	ret->url = url;
 
+	/* maybe it is a foreign URL? */
+	if (url) {
+		const char *p = url;
+
+		while (isalnum(*p))
+			p++;
+		if (!prefixcmp(p, "::"))
+			remote->foreign_vcs = xstrndup(url, p - url);
+	}
+
 	if (remote && remote->foreign_vcs) {
 		transport_helper_init(ret, remote->foreign_vcs);
 		return ret;
Signature · 1 line
1.6.5.2.291.gf76a3
#23 lore raw

PATCH 10/19 Allow helpers to request marks for fast-import

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

The 'marks' capability is reported by the remote helper if it requires the fast-import marks database to loaded/saved by any git-fast-import process that is provided by the transport machinery. The feature is advertised along with exactly one argument: the location of the file containing the marks database.

---

Unchanged.

 Documentation/git-remote-helpers.txt |    8 ++++++++
 transport-helper.c                   |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
Documentation/git-remote-helpers.txt +8 -0
index 2c5130f..9a3c5bc 100644
@@ -67,6 +67,14 @@ CAPABILITIES
 'import'::
 	This helper supports the 'import' command.
 
+'marks' filename::
+	Helper requires the marks from a git-fast-import run to be
+	loaded from, and saved to, the given filename. When this
+	"feature" is advertised, each git-fast-import run must load
+	and save the internal marks database (see the --import-marks
+	and --export-marks option to git-fast-import for more details)
+	located at the given filename.
+
 REF LIST ATTRIBUTES
 -------------------
 
transport-helper.c +15 -0
index 36a265d..cd3f0df 100644
@@ -10,6 +10,7 @@ struct helper_data
 {
 	const char *name;
 	struct child_process *helper;
+	char *marks_filename;
 	unsigned fetch : 1;
 	unsigned import : 1;
 };
@@ -51,6 +52,8 @@ static struct child_process *get_helper(struct transport *transport)
 			data->fetch = 1;
 		if (!strcmp(buf.buf, "import"))
 			data->import = 1;
+		if (!prefixcmp(buf.buf, "marks "))
+			data->marks_filename = xstrdup(buf.buf + 6);
 	}
 	return data->helper;
 }
@@ -104,11 +107,21 @@ static int fetch_with_fetch(struct transport *transport,
 static int get_importer(struct transport *transport, struct child_process *fastimport)
 {
 	struct child_process *helper = get_helper(transport);
+	struct helper_data *data = transport->data;
 	memset(fastimport, 0, sizeof(*fastimport));
 	fastimport->in = helper->out;
 	fastimport->argv = xcalloc(5, sizeof(*fastimport->argv));
 	fastimport->argv[0] = "fast-import";
 	fastimport->argv[1] = "--quiet";
+	if (data->marks_filename) {
+		struct strbuf buf = STRBUF_INIT;
+		strbuf_addf(&buf, "--export-marks=%s", data->marks_filename);
+		fastimport->argv[2] = strbuf_detach(&buf, 0);
+		if (!access(data->marks_filename, R_OK)) {
+			strbuf_addf(&buf, "--import-marks=%s", data->marks_filename);
+			fastimport->argv[3] = strbuf_detach(&buf, 0);
+		}
+	}
 
 	fastimport->git_cmd = 1;
 	return start_command(fastimport);
@@ -137,6 +150,8 @@ static int fetch_with_import(struct transport *transport,
 	}
 	disconnect_helper(transport);
 	finish_command(&fastimport);
+	free((char *) fastimport.argv[2]);
+	free((char *) fastimport.argv[3]);
 
 	for (i = 0; i < nr_heads; i++) {
 		posn = to_fetch[i];
Signature · 1 line
1.6.5.2.291.gf76a3
#24 lore raw

Re: [PATCH 10/19] Allow helpers to request marks for fast-import

Quoted 8 lines · Sverre Rabbelier

From: Johan Herland <[email protected]>

The 'marks' capability is reported by the remote helper if it requires the fast-import marks database to loaded/saved by any git-fast-import process that is provided by the transport machinery. The feature is advertised along with exactly one argument: the location of the file containing the marks database.

Quoted 5 lines

---

Unchanged.

Please drop this patch from the series. The functionality is not needed, since we'll use the fast-import "option" command from the sr/gfi-options series instead.

...Johan

Signature · 2 lines
Johan Herland, <[email protected]>
www.herland.net
#25 lore raw

Re: [PATCH 10/19] Allow helpers to request marks for fast-import

Heya,

Quoted 3 lines · Johan Herland

Please drop this patch from the series. The functionality is not needed, since we'll use the fast-import "option" command from the sr/gfi-options series instead.

In that case I will rebase the series on top of sr/gfi-options then as soon as I reroll that one. Also, do you need to change anything else in git-remote-cvs to do that?

Signature · 3 lines
Cheers,

Sverre Rabbelier
#28 lore raw

PATCH 11/19 Basic build infrastructure for Python scripts

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

This patch adds basic boilerplate support (based on corresponding Perl sections) for enabling the building and installation Python scripts.

There are currently no Python scripts being built, and when Python scripts are added in future patches, their building and installation can be disabled by defining NO_PYTHON.

---

Unchanged.

 Makefile      |   13 +++++++++++++
 configure.ac  |    3 +++
 t/test-lib.sh |    1 +
 3 files changed, 17 insertions(+), 0 deletions(-)
Makefile +13 -0
index 268aede..b27a7d6 100644
@@ -164,6 +164,8 @@ all::
 #
 # Define NO_PERL if you do not want Perl scripts or libraries at all.
 #
+# Define NO_PYTHON if you do not want Python scripts or libraries at all.
+#
 # Define NO_TCLTK if you do not want Tcl/Tk GUI.
 #
 # The TCL_PATH variable governs the location of the Tcl interpreter
@@ -308,6 +310,7 @@ LIB_H =
 LIB_OBJS =
 PROGRAMS =
 SCRIPT_PERL =
+SCRIPT_PYTHON =
 SCRIPT_SH =
 TEST_PROGRAMS =
 
@@ -345,6 +348,7 @@ SCRIPT_PERL += git-svn.perl
 
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
+	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-instaweb
 
 # Empty...
@@ -398,8 +402,12 @@ endif
 ifndef PERL_PATH
 	PERL_PATH = /usr/bin/perl
 endif
+ifndef PYTHON_PATH
+	PYTHON_PATH = /usr/bin/python
+endif
 
 export PERL_PATH
+export PYTHON_PATH
 
 LIB_FILE=libgit.a
 XDIFF_LIB=xdiff/lib.a
@@ -1308,6 +1316,10 @@ ifeq ($(PERL_PATH),)
 NO_PERL=NoThanks
 endif
 
+ifeq ($(PYTHON_PATH),)
+NO_PYTHON=NoThanks
+endif
+
 QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 QUIET_SUBDIR1  =
 
@@ -1355,6 +1367,7 @@ prefix_SQ = $(subst ','\'',$(prefix))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 
 LIBS = $(GITLIBS) $(EXTLIBS)
configure.ac +3 -0
index b09b8e4..84b6cf4 100644
@@ -233,6 +233,9 @@ GIT_ARG_SET_PATH(shell)
 # Define PERL_PATH to provide path to Perl.
 GIT_ARG_SET_PATH(perl)
 #
+# Define PYTHON_PATH to provide path to Python.
+GIT_ARG_SET_PATH(python)
+#
 # Define ZLIB_PATH to provide path to zlib.
 GIT_ARG_SET_PATH(zlib)
 #
t/test-lib.sh +1 -0
index f2ca536..0b991db 100644
@@ -729,6 +729,7 @@ case $(uname -s) in
 esac
 
 test -z "$NO_PERL" && test_set_prereq PERL
+test -z "$NO_PYTHON" && test_set_prereq PYTHON
 
 # test whether the filesystem supports symbolic links
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
Signature · 1 line
1.6.5.2.291.gf76a3
#29 lore raw

PATCH 12/19 1/2: Add Python support library for CVS remote helper

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

This patch introduces parts of a Python package called "git_remote_cvs" containing the building blocks of the CVS remote helper.
The CVS remote helper itself is NOT part of this patch.

This patch has been improved by the following contributions:
- David Aguilar: Lots of Python coding style fixes

---

This has my patch to util.py squashed in.

 git_remote_cvs/changeset.py        |  126 +++++
 git_remote_cvs/cvs.py              |  998 ++++++++++++++++++++++++++++++++++++
 git_remote_cvs/cvs_symbol_cache.py |  313 +++++++++++
 git_remote_cvs/util.py             |  194 +++++++
 4 files changed, 1631 insertions(+), 0 deletions(-)
 create mode 100644 git_remote_cvs/changeset.py
 create mode 100644 git_remote_cvs/cvs.py
 create mode 100644 git_remote_cvs/cvs_symbol_cache.py
 create mode 100644 git_remote_cvs/util.py
git_remote_cvs/changeset.py new file +126 -0
new file mode 100644
index 0000000..9eea9d2
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+
+"""Code for collecting individual CVS revisions into "changesets"
+
+A changeset is a collection of CVSRev objects that belong together in
+the same "commit".  This is a somewhat artificial construct on top of
+CVS, which only stores changes at the per-file level.  Normally, CVS
+users create several CVS revisions simultaneously by applying the
+"cvs commit" command to several files with related changes.  This
+module tries to reconstruct this notion of related revisions.
+
+"""
+
+from git_remote_cvs.util import debug, error, die
+
+
+class Changeset(object):
+
+    """Encapsulate a single changeset/commit."""
+
+    __slots__ = ('revs', 'date', 'author', 'message')
+
+    # The maximum time between the changeset's date, and the date of a
+    # rev to included in that changeset.
+    MaxSecondsBetweenRevs = 8 * 60 * 60  # 8 hours
+
+    @classmethod
+    def from_rev (cls, rev):
+        """Return a Changeset based on the given CVSRev object."""
+        c = cls(rev.date, rev.author, rev.message)
+        result = c.add(rev)
+        assert result
+        return c
+
+    def __init__ (self, date, author, message):
+        """Create a new Changeset with the given metadata."""
+        self.revs = {}  # dict: path -> CVSRev object
+        self.date = date  # CVSDate object
+        self.author = author
+        self.message = message  # Lines of commit message
+
+    def __str__ (self):
+        """Stringify this Changeset object."""
+        msg = self.message[0]  # First line only
+        # Limit message to 25 chars
+        if len(msg) > 25:
+            msg = msg[:22] + "..."
+        return ("<Changeset @(%s) by %s (%s) updating %i files>" %
+                (self.date, self.author, msg, len(self.revs)))
+
+    def __iter__ (self):
+        """Return iterator traversing the CVSRevs in this Changeset."""
+        return self.revs.itervalues()
+
+    def __getitem__ (self, path):
+        """Look up a specific CVSRev in this Changeset."""
+        return self.revs[path]
+
+    def within_time_window (self, rev):
+        """Return True iff the rev is within the time window of self."""
+        return abs(rev.date.diff(self.date)) <= self.MaxSecondsBetweenRevs
+
+    def add (self, rev):
+        """Add the given CVSRev to this Changeset.
+
+        The addition will only succeed if the following holds:
+          - rev.author == self.author
+          - rev.message == self.message
+          - rev.path is not in self.revs
+          - rev.date is within MaxSecondsBetweenRevs of self.date
+        If the addition succeeds, True is returned; otherwise False.
+
+        """
+        if rev.author != self.author or \
+           rev.message != self.message or \
+           rev.path in self.revs or \
+           not self.within_time_window(rev):
+            return False
+
+        self.revs[rev.path] = rev
+        return True
+
+
+def build_changesets_from_revs (cvs_revs):
+    """Organize CVSRev objects into a chronological list of Changesets."""
+    # Construct chronological list of CVSRev objects
+    chron_revs = []
+    for path, d in cvs_revs.iteritems():
+        i = 0  # Current index into chronRevs
+        for revnum, cvsrev in sorted(d.iteritems()):
+            assert path == cvsrev.path
+            assert revnum == cvsrev.num
+            while i < len(chron_revs) and cvsrev.date > chron_revs[i].date:
+                i += 1
+            # Insert cvsRev at position i in chronRevs
+            chron_revs.insert(i, cvsrev)
+            i += 1
+
+    changesets = []  # Chronological list of Changeset objects
+    while len(chron_revs):
+        # There are still more revs to be added to Changesets
+        # Create Changeset based on the first rev in chronRevs
+        changeset = Changeset.from_rev(chron_revs.pop(0))
+        # Keep adding revs chronologically until MaxSecondsBetweenRevs
+        rejects = []  # Revs that cannot be added to this changeset
+        while len(chron_revs):
+            rev = chron_revs.pop(0)
+            reject = False
+            # First, if we have one of rev's parents in rejects, we
+            # must also reject rev
+            for r in rejects:
+                if r.path == rev.path:
+                    reject = True
+                    break
+            # Next, add rev to changeset, reject if add fails
+            if not reject:
+                reject = not changeset.add(rev)
+            if reject:
+                rejects.append(rev)
+                # stop trying when rev is too far in the future
+                if not changeset.within_time_window(rev):
+                    break
+        chron_revs = rejects + chron_revs  # Reconstruct remaining revs
+        changesets.append(changeset)
+
+    return changesets
git_remote_cvs/cvs.py new file +998 -0

998 lines not on this page · raw message

git_remote_cvs/cvs_symbol_cache.py new file +313 -0

313 lines not on this page · raw message

git_remote_cvs/util.py new file +194 -0

194 lines not on this page · raw message

Signature · 1 line
1.6.5.2.291.gf76a3
#30 lore raw

Re: [PATCH 12/19] 1/2: Add Python support library for CVS remote helper

Quoted 9 lines · Sverre Rabbelier

From: Johan Herland <[email protected]>

This patch introduces parts of a Python package called "git_remote_cvs" containing the building blocks of the CVS remote helper.
The CVS remote helper itself is NOT part of this patch.

This patch has been improved by the following contributions:
- David Aguilar: Lots of Python coding style fixes

Quoted 6 lines

---

This has my patch to util.py squashed in.

Why? Or: why that one, and not the others? Also, you might want to mention your contribution in the commit message itself.

Quoted 6 lines
git_remote_cvs/util.py new file +0 -0
new file mode 100644
index 0000000..d3ca487
@@ -0,0 +1,194 @@

[snip]

Quoted 14 lines
git_remote_cvs/util.py new file +14 -0
+
+def notify(msg, *args):
+	"""Print a message to stderr."""
+	print >> sys.stderr, msg % args
+
+def debug (msg, *args):
+    """Print a debug message to stderr when DEBUG is enabled."""
+    if DEBUG:
+        print >> sys.stderr, msg % args
+
+def error (msg, *args):
+    """Print an error message to stderr."""
+    print >> sys.stderr, "ERROR:", msg % args
+

git_remote_cvs/util.py line 40

Quoted 10 lines
git_remote_cvs/util.py new file +10 -0
+def warn(msg, *args):
+	"""Print a warning message to stderr."""
+	print >> sys.stderr, "warning:", msg % args
+
+def die (msg, *args):
+    """Print as error message to stderr and exit the program."""
+    error(msg, *args)
+    sys.exit(1)
+
+

It seems the two functions you add (notify() and warn()) have a different indentation than the existing code (which uses 4 spaces). Please fix.

(When I first introduced these Python patches, there was a discussion on the differences in indentation/style between the Git C code, and Python code, and it was decided to follow the Python conventions, to make the code more inviting to the Python community.)

...Johan

Signature · 2 lines
Johan Herland, <[email protected]>
www.herland.net
#31 lore raw

Re: [PATCH 12/19] 1/2: Add Python support library for CVS remote helper

Heya,

Quoted 2 lines · Johan Herland

Why? Or: why that one, and not the others? Also, you might want to mention your contribution in the commit message itself.

What others? And I thought my contributions were so minor it doesn't really matter that much :).

Quoted 2 lines

It seems the two functions you add (notify() and warn()) have a different indentation than the existing code (which uses 4 spaces). Please fix.

That's weird, will fix.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#32 lore raw

PATCH 13/19 2/2: Add Python support library for CVS remote helper

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

This patch introduces the rest of a Python package called "git_remote_cvs" containing the building blocks of the CVS remote helper. The CVS remote helper itself is NOT part of this patch.

The patch includes the necessary Makefile additions to build and install the git_remote_cvs Python package along with the rest of Git.

This patch has been improved by the following contributions:
- David Aguilar: Lots of Python coding style fixes
- David Aguilar: DESTDIR support in Makefile

---

Unchanged.

 Makefile                           |    9 +
 git_remote_cvs/.gitignore          |    2 +
 git_remote_cvs/Makefile            |   35 ++
 git_remote_cvs/__init__.py         |   27 ++
 git_remote_cvs/commit_states.py    |   62 ++++
 git_remote_cvs/cvs_revision_map.py |  418 ++++++++++++++++++++++
 git_remote_cvs/git.py              |  680 ++++++++++++++++++++++++++++++++++++
 git_remote_cvs/setup.py            |   17 +
 8 files changed, 1250 insertions(+), 0 deletions(-)
 create mode 100644 git_remote_cvs/.gitignore
 create mode 100644 git_remote_cvs/Makefile
 create mode 100644 git_remote_cvs/__init__.py
 create mode 100644 git_remote_cvs/commit_states.py
 create mode 100644 git_remote_cvs/cvs_revision_map.py
 create mode 100644 git_remote_cvs/git.py
 create mode 100644 git_remote_cvs/setup.py
Makefile +9 -0
index b27a7d6..944f4d0 100644
@@ -1399,6 +1399,9 @@ endif
 ifndef NO_PERL
 	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
 endif
+ifndef NO_PYTHON
+	$(QUIET_SUBDIR0)git_remote_cvs $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
+endif
 	$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
 
 please_set_SHELL_PATH_to_a_more_modern_shell:
@@ -1741,6 +1744,9 @@ install: all
 ifndef NO_PERL
 	$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 endif
+ifndef NO_PYTHON
+	$(MAKE) -C git_remote_cvs prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
+endif
 ifndef NO_TCLTK
 	$(MAKE) -C gitk-git install
 	$(MAKE) -C git-gui gitexecdir='$(gitexec_instdir_SQ)' install
@@ -1855,6 +1861,9 @@ ifndef NO_PERL
 	$(RM) gitweb/gitweb.cgi
 	$(MAKE) -C perl clean
 endif
+ifndef NO_PYTHON
+	$(MAKE) -C git_remote_cvs clean
+endif
 	$(MAKE) -C templates/ clean
 	$(MAKE) -C t/ clean
 ifndef NO_TCLTK
git_remote_cvs/.gitignore new file +2 -0
new file mode 100644
index 0000000..2247d5f
@@ -0,0 +1,2 @@
+/build
+/dist
git_remote_cvs/Makefile new file +35 -0
new file mode 100644
index 0000000..061c247
@@ -0,0 +1,35 @@
+#
+# Makefile for the git_remote_cvs python support modules
+#
+pysetupfile:=setup.py
+
+# Shell quote (do not use $(call) to accommodate ancient setups);
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+
+ifndef PYTHON_PATH
+	PYTHON_PATH = /usr/bin/python
+endif
+ifndef prefix
+	prefix = $(HOME)
+endif
+ifndef V
+	QUIET = @
+	QUIETSETUP = --quiet
+endif
+
+PYLIBDIR=$(shell $(PYTHON_PATH) -c \
+	 "import sys; \
+	 print 'lib/python%i.%i/site-packages' % sys.version_info[:2]")
+
+all: $(pysetupfile)
+	$(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build
+
+install: $(pysetupfile)
+	$(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix)
+
+instlibdir: $(pysetupfile)
+	@echo "$(prefix)/$(PYLIBDIR)"
+
+clean:
+	$(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a
+	$(RM) *.pyo *.pyc
git_remote_cvs/__init__.py new file +27 -0
new file mode 100644
index 0000000..4956d2d
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+"""Support library package for git-remote-cvs.
+
+git-remote-cvs is a Git remote helper command that interfaces with a
+CVS repository to provide automatic import of CVS history into a Git
+repository.
+
+This package provides the support library needed by git-remote-cvs.
+The following modules are included:
+
+- cvs - Interaction with CVS repositories
+
+- cvs_symbol_cache - Local CVS symbol cache
+
+- changeset - Collect individual CVS revisions into commits
+
+- git - Interaction with Git repositories
+
+- commit_states - Map Git commits to CVS states
+
+- cvs_revision_map - Map CVS revisions to various metainformation
+
+- util - General utility functionality use by the other modules in
+         this package, and also used directly by git-remote-cvs.
+
+"""
git_remote_cvs/commit_states.py new file +62 -0

62 lines not on this page · raw message

git_remote_cvs/cvs_revision_map.py new file +418 -0

418 lines not on this page · raw message

git_remote_cvs/git.py new file +680 -0

680 lines not on this page · raw message

git_remote_cvs/setup.py new file +17 -0
new file mode 100644
index 0000000..21f521a
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+"""Distutils build/install script for the git_remote_cvs package."""
+
+from distutils.core import setup
+
+setup(
+    name = 'git_remote_cvs',
+    version = '0.1.0',
+    description = 'Git remote helper program for CVS repositories',
+    license = 'GPLv2',
+    author = 'The Git Community',
+    author_email = '[email protected]',
+    url = 'http://www.git-scm.com/',
+    package_dir = {'git_remote_cvs': ''},
+    packages = ['git_remote_cvs'],
+)
Signature · 1 line
1.6.5.2.291.gf76a3
#33 lore raw

PATCH 14/19 git-remote-cvs: Remote helper program for CVS repositories

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

Implements the import of objects from a local or remote CVS repository.

This helper program uses the "git_remote_cvs" Python package introduced earlier, and provides a working draft implementation of the remote helper API, as described in Documentation/git-remote-helpers.txt. Further details about this specific helper are described in the new Documentation/git-remote-cvs.txt.

This patch has been improved by the following contributions:
- Daniel Barkalow: Updates reflecting changes in remote helper API
- David Aguilar: Lots of Python coding style fixes

Cc Daniel Barkalow <[email protected]>
Cc David Aguilar <[email protected]>

---

Unchanged.

 Documentation/git-remote-cvs.txt |   85 +++++
 Makefile                         |   24 ++
 git-remote-cvs.py                |  683 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 792 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/git-remote-cvs.txt
 create mode 100755 git-remote-cvs.py
Documentation/git-remote-cvs.txt new file +85 -0
new file mode 100644
index 0000000..309ee7f
@@ -0,0 +1,85 @@
+git-remote-cvs(1)
+=================
+
+NAME
+----
+git-remote-cvs - Helper program for interoperation with CVS repositories
+
+SYNOPSIS
+--------
+'git remote-cvs' <remote>
+
+DESCRIPTION
+-----------
+
+Please see the linkgit:git-remote-helpers[1] documentation for general
+information about remote helper programs.
+
+CONFIGURATION
+-------------
+
+remote.*.cvsRoot::
+	The URL of the CVS repository (as found in a `CVSROOT` variable, or
+	in a `CVS/Root` file).
+	Example: "`:pserver:user@server/var/cvs/cvsroot`".
+
+remote.*.cvsModule::
+	The path of the CVS module (as found in a `CVS/Repository` file)
+	within the CVS repository specified in `remote.*.cvsRoot`.
+	Example: "`foo/bar`"
+
+remote.*.cachedSymbolsOnly::
+	When 'true', a cache of CVS symbols is used instead of querying the
+	CVS server for all existing symbols (potentially expensive). In this
+	mode, git-remote-cvs will not discover new CVS symbols unless you add
+	them explicitly with the "`addsymbol <symbol>`" command (on
+	git-remote-cvs's stdin), or request an explicit symbol cache update
+	from the CVS server with the "`syncsymbols`" command (on
+	git-remote-cvs's stdin). When 'false' (the default), the CVS server
+	will be queried whenever a list of CVS symbols is required.
+
+remote.*.usernameMap::
+	The path (absolute, or relative to the repository (NOT the worktree))
+	to the file that contains the mapping from CVS usernames to the
+	corresponding full names and email addresses, as used by Git in the
+	Author and Committer fields of commit objects. When this config
+	variable is set, CVS usernames will be resolved against this file.
+	If no match is found in the file, or if this config variable is unset,
+	or if the variable points to a non-existing file, the original CVS
+	username will be used as the Author/Committer name, and the
+	corresponding email address will be set to "`<username>@example.com`".
++
+The format of the usernameMap file is one entry per line, where each line is
+of the form "`username: Full Name <email@address>`".
+Example: `johndoe: John Doe <[email protected]>`
+Blank lines and lines starting with '#' are ignored.
+
+COMMANDS
+--------
+
+In addition to the commands that constitute the git-remote-helpers API, the
+following extra commands are supported for managing the local symbol cache when
+the `remote.*.cachedSymbolsOnly` config variable is true. The following
+commands can be given on the standard input of git-remote-cvs:
+
+'addsymbol'::
+	Takes one CVS symbol name as argument. The given CVS symbol is
+	fetched from the CVS server and stored into the local CVS symbol
+	cache. If `remote.*.cachedSymbolsOnly` is enabled, this can be used
+	to introduce a new CVS symbol to the CVS helper application.
+
+'syncsymbols'::
+	All CVS symbols that are available from the given remote are
+	fetched from the CVS server and stored into the local CVS symbol
+	cache. This is equivalent to disabling `remote.{asterisk}.cachedSymbolsOnly`,
+	running the "list" command, and then finally re-enabling the
+	`remote.*.cachedSymbolsOnly` config variable. I.e. this command can
+	be used to manually synchronize the CVS symbols available to the
+	CVS helper application.
+
+'verify'::
+	Takes one CVS symbol name as argument. Verifies that the CVS symbol
+	has been successfully imported be checking out the CVS symbol from
+	the CVS server, and comparing the CVS working tree against the Git
+	tree object identified by `refs/cvs/<remote>/<symbol>`. This can be
+	used to verify the correctness of a preceding 'import' command.
Makefile +24 -0
index 944f4d0..a63f44d 100644
@@ -346,6 +346,8 @@ SCRIPT_PERL += git-relink.perl
 SCRIPT_PERL += git-send-email.perl
 SCRIPT_PERL += git-svn.perl
 
+SCRIPT_PYTHON += git-remote-cvs.py
+
 SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
 	  $(patsubst %.perl,%,$(SCRIPT_PERL)) \
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
@@ -1520,6 +1522,28 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
 	mv $@+ $@
 endif # NO_PERL
 
+ifndef NO_PYTHON
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
+	$(QUIET_GEN)$(RM) $@ $@+ && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory instlibdir` && \
+	sed -e '1{' \
+	    -e '	s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
+	    -e '}' \
+	    -e 's|^import sys.*|&; sys.path.insert(0, "@@INSTLIBDIR@@")|' \
+	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
+	    [email protected] >$@+ && \
+	chmod +x $@+ && \
+	mv $@+ $@
+else # NO_PYTHON
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
+	$(QUIET_GEN)$(RM) $@ $@+ && \
+	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
+	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
+	    unimplemented.sh >$@+ && \
+	chmod +x $@+ && \
+	mv $@+ $@
+endif # NO_PYTHON
+
 configure: configure.ac
 	$(QUIET_GEN)$(RM) $@ $<+ && \
 	sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
git-remote-cvs.py new file +683 -0

683 lines not on this page · raw message

Signature · 1 line
1.6.5.2.291.gf76a3
#34 lore raw

PATCH 15/19 Add simple selftests of git-remote-cvs functionality

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

Add two new selftests:

- t9800-remote-cvs-basic: Test the git-remote-cvs implementation of the remote helper API, by verifying the expected output of the git-remote-cvs program when invoking remote helper API commands while doing some simple CVS operations.

- t9801-remote-cvs-fetch: A more high-level test of the fetch/import-side of the git-remote-cvs implementation, by verifying the expected repository state after doing "git fetch" from a CVS remote where a variety of CVS operations are being performed.

---

Unchanged.

 t/t9800-remote-cvs-basic.sh |  524 +++++++++++++++++++++++++++++++++++++++++++
 t/t9801-remote-cvs-fetch.sh |  291 ++++++++++++++++++++++++
 2 files changed, 815 insertions(+), 0 deletions(-)
 create mode 100755 t/t9800-remote-cvs-basic.sh
 create mode 100755 t/t9801-remote-cvs-fetch.sh
t/t9800-remote-cvs-basic.sh new file +524 -0
new file mode 100755
index 0000000..6ddec17
@@ -0,0 +1,524 @@
+#!/bin/sh
+
+test_description='git remote-cvs basic tests'
+. ./test-lib.sh
+
+if ! test_have_prereq PYTHON; then
+	say 'skipping CVS foreign-vcs helper tests, python not available'
+	test_done
+fi
+
+CVS_EXEC=cvs
+CVS_OPTS="-f -q"
+CVS="$CVS_EXEC $CVS_OPTS"
+
+CVSROOT=$(pwd)/cvsroot
+export CVSROOT
+unset CVS_SERVER
+
+CVSMODULE=cvsmodule
+GITREMOTE=cvsremote
+
+if ! type $CVS_EXEC >/dev/null 2>&1
+then
+	say 'skipping remote-cvs tests, $CVS_EXEC not found'
+	test_done
+fi
+
+test_expect_success 'setup cvsroot' '$CVS init'
+
+test_expect_success '#1: setup a cvs module' '
+
+	mkdir "$CVSROOT/$CVSMODULE" &&
+	$CVS co -d module-cvs $CVSMODULE &&
+	(
+		cd module-cvs &&
+		cat <<EOF >o_fortuna &&
+O Fortuna
+velut luna
+statu variabilis,
+
+semper crescis
+aut decrescis;
+vita detestabilis
+
+nunc obdurat
+et tunc curat
+ludo mentis aciem,
+
+egestatem,
+potestatem
+dissolvit ut glaciem.
+EOF
+		$CVS add o_fortuna &&
+		cat <<EOF >message &&
+add "O Fortuna" lyrics
+
+These public domain lyrics make an excellent sample text.
+EOF
+		$CVS commit -f -F message o_fortuna
+	)
+'
+
+test_expect_success 'set up CVS repo as a foreign remote' '
+
+	git config "user.name" "Test User"
+	git config "user.email" "[email protected]"
+	git config "remote.$GITREMOTE.vcs" cvs
+	git config "remote.$GITREMOTE.cvsRoot" "$CVSROOT"
+	git config "remote.$GITREMOTE.cvsModule" "$CVSMODULE"
+	git config "remote.$GITREMOTE.fetch" \
+		"+refs/cvs/$GITREMOTE/*:refs/remotes/$GITREMOTE/*"
+
+'
+
+test_expect_success '#1: git-remote-cvs "capabilities" command' '
+
+	echo "capabilities" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+import
+marks .git/info/cvs/$GITREMOTE/marks
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#1: git-remote-cvs "list" command' '
+
+	echo "list" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+? refs/cvs/$GITREMOTE/HEAD
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#1: git-remote-cvs "import" command' '
+
+	echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+# Importing CVS revision o_fortuna:1.1
+blob
+mark :1
+data 180
+O Fortuna
+velut luna
+statu variabilis,
+
+semper crescis
+aut decrescis;
+vita detestabilis
+
+nunc obdurat
+et tunc curat
+ludo mentis aciem,
+
+egestatem,
+potestatem
+dissolvit ut glaciem.
+
+commit refs/cvs/$GITREMOTE/HEAD
+mark :2
+data 82
+add "O Fortuna" lyrics
+
+These public domain lyrics make an excellent sample text.
+
+M 644 :1 o_fortuna
+
+# Importing note for object 2
+blob
+mark :3
+data 14
+o_fortuna:1.1
+
+commit refs/notes/cvs/$GITREMOTE
+mark :4
+data 46
+Annotate commits imported by "git remote-cvs"
+
+N :3 :2
+
+blob
+mark :5
+data 32
+1 o_fortuna:1.1
+2 o_fortuna:1.1
+
+blob
+mark :6
+data 16
+blob 1
+commit 2
+
+commit refs/cvs/$GITREMOTE/_metadata
+mark :7
+data 42
+Updated metadata used by "git remote-cvs"
+
+M 644 :5 CVS/marks
+M 644 :6 o_fortuna/1.1
+
+EOF
+	grep -v "^committer " actual > actual.filtered &&
+	test_cmp expect actual.filtered
+
+'
+
+test_expect_success '#1: Passing git-remote-cvs output to git-fast-import' '
+
+	git fast-import --quiet \
+		--export-marks=".git/info/cvs/$GITREMOTE/marks" \
+		< actual &&
+	git gc
+
+'
+
+test_expect_success '#1: Verifying correctness of import' '
+
+	echo "verify HEAD" | git remote-cvs "$GITREMOTE"
+
+'
+
+test_expect_success '#2: update cvs module' '
+
+	(
+		cd module-cvs &&
+		cat <<EOF >o_fortuna &&
+O Fortune,
+like the moon
+you are changeable,
+
+ever waxing
+and waning;
+hateful life
+
+first oppresses
+and then soothes
+as fancy takes it;
+
+poverty
+and power
+it melts them like ice.
+EOF
+		cat <<EOF >message &&
+translate to English
+
+My Latin is terrible.
+EOF
+		$CVS commit -f -F message o_fortuna
+	)
+'
+
+test_expect_success '#2: git-remote-cvs "capabilities" command' '
+
+	echo "capabilities" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+import
+marks .git/info/cvs/$GITREMOTE/marks
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#2: git-remote-cvs "list" command' '
+
+	echo "list" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+? refs/cvs/$GITREMOTE/HEAD
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#2: git-remote-cvs "import" command' '
+
+	echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+# Importing CVS revision o_fortuna:1.2
+blob
+mark :8
+data 179
+O Fortune,
+like the moon
+you are changeable,
+
+ever waxing
+and waning;
+hateful life
+
+first oppresses
+and then soothes
+as fancy takes it;
+
+poverty
+and power
+it melts them like ice.
+
+commit refs/cvs/$GITREMOTE/HEAD
+mark :9
+data 44
+translate to English
+
+My Latin is terrible.
+
+from refs/cvs/$GITREMOTE/HEAD^0
+M 644 :8 o_fortuna
+
+# Importing note for object 9
+blob
+mark :10
+data 14
+o_fortuna:1.2
+
+commit refs/notes/cvs/$GITREMOTE
+mark :11
+data 46
+Annotate commits imported by "git remote-cvs"
+
+from refs/notes/cvs/$GITREMOTE^0
+N :10 :9
+
+blob
+mark :12
+data 32
+8 o_fortuna:1.2
+9 o_fortuna:1.2
+
+blob
+mark :13
+data 94
+
+blob
+mark :14
+data 16
+blob 8
+commit 9
+
+commit refs/cvs/$GITREMOTE/_metadata
+mark :15
+data 42
+Updated metadata used by "git remote-cvs"
+
+from refs/cvs/$GITREMOTE/_metadata^0
+M 644 :12 CVS/marks
+M 644 :13 o_fortuna/1.1
+M 644 :14 o_fortuna/1.2
+
+EOF
+	grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered &&
+	test_cmp expect actual.filtered
+
+'
+
+test_expect_success '#2: Passing git-remote-cvs output to git-fast-import' '
+
+	git fast-import --quiet \
+		--import-marks=".git/info/cvs/$GITREMOTE/marks" \
+		--export-marks=".git/info/cvs/$GITREMOTE/marks" \
+		< actual &&
+	git gc
+
+'
+
+test_expect_success '#2: Verifying correctness of import' '
+
+	echo "verify HEAD" | git remote-cvs "$GITREMOTE"
+
+'
+
+test_expect_success '#3: update cvs module' '
+
+	(
+		cd module-cvs &&
+		echo 1 >tick &&
+		$CVS add tick &&
+		$CVS commit -f -m 1 tick
+	)
+
+'
+
+test_expect_success '#3: git-remote-cvs "capabilities" command' '
+
+	echo "capabilities" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+import
+marks .git/info/cvs/$GITREMOTE/marks
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#3: git-remote-cvs "list" command' '
+
+	echo "list" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+? refs/cvs/$GITREMOTE/HEAD
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#3: git-remote-cvs "import" command' '
+
+	echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+# Importing CVS revision tick:1.1
+blob
+mark :16
+data 2
+1
+
+commit refs/cvs/$GITREMOTE/HEAD
+mark :17
+data 2
+1
+
+from refs/cvs/$GITREMOTE/HEAD^0
+M 644 :16 tick
+
+# Importing note for object 17
+blob
+mark :18
+data 23
+o_fortuna:1.2
+tick:1.1
+
+commit refs/notes/cvs/$GITREMOTE
+mark :19
+data 46
+Annotate commits imported by "git remote-cvs"
+
+from refs/notes/cvs/$GITREMOTE^0
+N :18 :17
+
+blob
+mark :20
+data 41
+16 tick:1.1
+17 tick:1.1
+17 o_fortuna:1.2
+
+blob
+mark :21
+data 104
+commit 17
+
+blob
+mark :22
+data 18
+blob 16
+commit 17
+
+commit refs/cvs/$GITREMOTE/_metadata
+mark :23
+data 42
+Updated metadata used by "git remote-cvs"
+
+from refs/cvs/$GITREMOTE/_metadata^0
+M 644 :20 CVS/marks
+M 644 :21 o_fortuna/1.2
+M 644 :22 tick/1.1
+
+EOF
+	grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered &&
+	test_cmp expect actual.filtered
+
+'
+
+test_expect_success '#3: Passing git-remote-cvs output to git-fast-import' '
+
+	git fast-import --quiet \
+		--import-marks=".git/info/cvs/$GITREMOTE/marks" \
+		--export-marks=".git/info/cvs/$GITREMOTE/marks" \
+		< actual &&
+	git gc
+
+'
+
+test_expect_success '#3: Verifying correctness of import' '
+
+	echo "verify HEAD" | git remote-cvs "$GITREMOTE"
+
+'
+
+test_expect_success '#4: git-remote-cvs "capabilities" command' '
+
+	echo "capabilities" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+import
+marks .git/info/cvs/$GITREMOTE/marks
+
+EOF
+	test_cmp expect actual
+
+'
+
+commit=$(git rev-parse "refs/cvs/$GITREMOTE/HEAD")
+
+test_expect_success '#4: git-remote-cvs "list" command' '
+
+	echo "list" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+$commit refs/cvs/$GITREMOTE/HEAD unchanged
+
+EOF
+	test_cmp expect actual
+
+'
+
+test_expect_success '#4: git-remote-cvs "import" command' '
+
+	echo "import refs/cvs/$GITREMOTE/HEAD" | git remote-cvs "$GITREMOTE" > actual &&
+	cat <<EOF >expect &&
+blob
+mark :24
+data 0
+
+blob
+mark :25
+data 142
+
+blob
+mark :26
+data 94
+
+commit refs/cvs/$GITREMOTE/_metadata
+mark :27
+data 42
+Updated metadata used by "git remote-cvs"
+
+from refs/cvs/$GITREMOTE/_metadata^0
+M 644 :24 CVS/marks
+M 644 :25 o_fortuna/1.2
+M 644 :26 tick/1.1
+
+EOF
+	grep -v -e "^committer " -e "\b[0-9a-f]\{40\}\b" actual > actual.filtered &&
+	test_cmp expect actual.filtered
+
+'
+
+test_expect_success '#4: Passing git-remote-cvs output to git-fast-import' '
+
+	git fast-import --quiet \
+		--import-marks=".git/info/cvs/$GITREMOTE/marks" \
+		--export-marks=".git/info/cvs/$GITREMOTE/marks" \
+		< actual &&
+	git gc
+
+'
+
+test_expect_success '#4: Verifying correctness of import' '
+
+	echo "verify HEAD" | git remote-cvs "$GITREMOTE"
+
+'
+
+test_done
t/t9801-remote-cvs-fetch.sh new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
1.6.5.2.291.gf76a3
#35 lore raw

PATCH 16/19 Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvs

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

Junio discovered that the installed git-remote-cvs executable is unable to find the installed git_remote_cvs Python package. This is due to the 'instlibdir' target of git_remote_cvs/Makefile being invoked with insufficient arguments (prefix and DESTDIR). This patch fixes that.

---

Unchanged.

 Makefile                |    2 +-
 git_remote_cvs/Makefile |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Makefile +1 -1
index a63f44d..9fb2747 100644
@@ -1525,7 +1525,7 @@ endif # NO_PERL
 ifndef NO_PYTHON
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory instlibdir` && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' instlibdir` && \
 	sed -e '1{' \
 	    -e '	s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
 	    -e '}' \
git_remote_cvs/Makefile +1 -1
index 061c247..0d9eb31 100644
@@ -28,7 +28,7 @@ install: $(pysetupfile)
 	$(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix)
 
 instlibdir: $(pysetupfile)
-	@echo "$(prefix)/$(PYLIBDIR)"
+	@echo "$(DESTDIR_SQ)$(prefix)/$(PYLIBDIR)"
 
 clean:
 	$(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a
Signature · 1 line
1.6.5.2.291.gf76a3
#36 lore raw

PATCH 17/19 More fixes to the git-remote-cvs installation procedure

In reply to Sverre Rabbelier

From: Johan Herland <[email protected]>

- Makefile: Make sure git-remote-cvs is rebuilt when 'prefix' changes (by adding a dependency on GIT-CFLAGS). This prevents a regular 'make' followed by a 'make prefix=/somewhere/else install' from installing a non-working git-remote-cvs.

- Makefile: When mangling git-remote-cvs to add the git_remote_cvs install location to the Python search path, _replace_ the initial 'current dir' entry in sys.path (instead of merely prepending the install location). Hence, if the git_remote_cvs package is not installed at the correct location (and also not present in any of Python's default package dirs), then git-remote-cvs will fail loudly instead of silently falling back on the git_remote_cvs subdir in git.git.

- Allow for the git_remote_cvs install path to be overridden by the $GITPYTHONLIB environment variable.

- t/test-lib.sh: Set $GITPYTHONLIB (unless $GIT_TEST_INSTALLED is enabled) so that we test the currently built version of git_remote_cvs (the one that is built in git_remote_cvs/build/lib) instead of a previously installed version.

- Another minor check and a line length fix.

---

Unchanged.

 Makefile      |   11 +++++++++--
 t/test-lib.sh |    9 +++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
Makefile +9 -2
index 9fb2747..6d37399 100644
@@ -1523,13 +1523,20 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
 endif # NO_PERL
 
 ifndef NO_PYTHON
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s --no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' instlibdir` && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s \
+		--no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
+		instlibdir` && \
 	sed -e '1{' \
 	    -e '	s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
 	    -e '}' \
-	    -e 's|^import sys.*|&; sys.path.insert(0, "@@INSTLIBDIR@@")|' \
+	    -e 's|^import sys.*|&; \\\
+	           import os; \\\
+	           sys.path[0] = os.environ.has_key("GITPYTHONLIB") and \\\
+	                         os.environ["GITPYTHONLIB"] or \\\
+	                         "@@INSTLIBDIR@@"|' \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
 	    [email protected] >$@+ && \
 	chmod +x $@+ && \
t/test-lib.sh +9 -0
index 0b991db..77ad23e 100644
@@ -638,6 +638,15 @@ test -d ../templates/blt || {
 	error "You haven't built things yet, have you?"
 }
 
+if test -z "$GIT_TEST_INSTALLED"
+then
+	GITPYTHONLIB="$(pwd)/../git_remote_cvs/build/lib"
+	export GITPYTHONLIB
+	test -d ../git_remote_cvs/build || {
+		error "You haven't built git_remote_cvs yet, have you?"
+	}
+fi
+
 if ! test -x ../test-chmtime; then
 	echo >&2 'You need to build test-chmtime:'
 	echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
Signature · 1 line
1.6.5.2.291.gf76a3
#37 lore raw

PATCH 18/19 Refactor git_remote_cvs to a more generic git_remote_helpers

In reply to Sverre Rabbelier

This in an effort to allow future remote helpers written in python to re-use the non-cvs-specific code.

---

This time with -M -C :).

 Makefile                                           |    8 +++---
 git-remote-cvs.py                                  |   14 +++++-----
 git_remote_cvs/__init__.py                         |   27 --------------------
 git_remote_cvs/setup.py                            |   17 ------------
 {git_remote_cvs => git_remote_helpers}/.gitignore  |    0
 {git_remote_cvs => git_remote_helpers}/Makefile    |    2 +-
 git_remote_helpers/__init__.py                     |   27 ++++++++++++++++++++
 .../cvs}/changeset.py                              |    2 +-
 .../cvs}/commit_states.py                          |    4 +-
 {git_remote_cvs => git_remote_helpers/cvs}/cvs.py  |    6 ++--
 .../cvs/revision_map.py                            |    6 ++--
 .../cvs/symbol_cache.py                            |    4 +-
 {git_remote_cvs => git_remote_helpers/git}/git.py  |    4 +-
 git_remote_helpers/setup.py                        |   17 ++++++++++++
 {git_remote_cvs => git_remote_helpers}/util.py     |    0
 t/test-lib.sh                                      |    4 +-
 16 files changed, 71 insertions(+), 71 deletions(-)
 delete mode 100644 git_remote_cvs/__init__.py
 delete mode 100644 git_remote_cvs/setup.py
 rename {git_remote_cvs => git_remote_helpers}/.gitignore (100%)
 rename {git_remote_cvs => git_remote_helpers}/Makefile (92%)
 create mode 100644 git_remote_helpers/__init__.py
 create mode 100644 git_remote_helpers/cvs/__init__.py
 rename {git_remote_cvs => git_remote_helpers/cvs}/changeset.py (98%)
 rename {git_remote_cvs => git_remote_helpers/cvs}/commit_states.py (95%)
 rename {git_remote_cvs => git_remote_helpers/cvs}/cvs.py (99%)
 rename git_remote_cvs/cvs_revision_map.py => git_remote_helpers/cvs/revision_map.py (98%)
 rename git_remote_cvs/cvs_symbol_cache.py => git_remote_helpers/cvs/symbol_cache.py (98%)
 create mode 100644 git_remote_helpers/git/__init__.py
 rename {git_remote_cvs => git_remote_helpers/git}/git.py (99%)
 create mode 100644 git_remote_helpers/setup.py
 rename {git_remote_cvs => git_remote_helpers}/util.py (100%)
Makefile +4 -4
index 6d37399..70b8195 100644
@@ -1402,7 +1402,7 @@ ifndef NO_PERL
 	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
 endif
 ifndef NO_PYTHON
-	$(QUIET_SUBDIR0)git_remote_cvs $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
+	$(QUIET_SUBDIR0)git_remote_helpers $(QUIET_SUBDIR1) PYTHON_PATH='$(PYTHON_PATH_SQ)' prefix='$(prefix_SQ)' all
 endif
 	$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
 
@@ -1526,7 +1526,7 @@ ifndef NO_PYTHON
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_cvs -s \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
 		--no-print-directory prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' \
 		instlibdir` && \
 	sed -e '1{' \
@@ -1776,7 +1776,7 @@ ifndef NO_PERL
 	$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 endif
 ifndef NO_PYTHON
-	$(MAKE) -C git_remote_cvs prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
+	$(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 endif
 ifndef NO_TCLTK
 	$(MAKE) -C gitk-git install
@@ -1893,7 +1893,7 @@ ifndef NO_PERL
 	$(MAKE) -C perl clean
 endif
 ifndef NO_PYTHON
-	$(MAKE) -C git_remote_cvs clean
+	$(MAKE) -C git_remote_helpers clean
 endif
 	$(MAKE) -C templates/ clean
 	$(MAKE) -C t/ clean
git-remote-cvs.py +7 -7
index 94b61e7..f322f96 100755
@@ -36,16 +36,16 @@ configuration details of this remote helper.
 import sys
 import os
 
-from git_remote_cvs.util import (debug, error, die, ProgressIndicator,
+from git_remote_helpers.util import (debug, error, die, ProgressIndicator,
                                  run_command)
-from git_remote_cvs.cvs import CVSState, CVSWorkDir, fetch_revs
-from git_remote_cvs.git import (get_git_dir, parse_git_config, git_config_bool,
+from git_remote_helpers.cvs.cvs import CVSState, CVSWorkDir, fetch_revs
+from git_remote_helpers.git.git import (get_git_dir, parse_git_config, git_config_bool,
                                 valid_git_ref, GitObjectFetcher, GitRefMap,
                                 GitFICommit, GitFastImport, GitNotes)
-from git_remote_cvs.cvs_symbol_cache import CVSSymbolCache
-from git_remote_cvs.commit_states import CommitStates
-from git_remote_cvs.cvs_revision_map import CVSRevisionMap, CVSStateMap
-from git_remote_cvs.changeset import build_changesets_from_revs
+from git_remote_helpers.cvs.symbol_cache import CVSSymbolCache
+from git_remote_helpers.cvs.commit_states import CommitStates
+from git_remote_helpers.cvs.revision_map import CVSRevisionMap, CVSStateMap
+from git_remote_helpers.cvs.changeset import build_changesets_from_revs
 
 
 class Config(object):
git_remote_cvs/__init__.py deleted +0 -27
deleted file mode 100644
index 4956d2d..0000000
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-"""Support library package for git-remote-cvs.
-
-git-remote-cvs is a Git remote helper command that interfaces with a
-CVS repository to provide automatic import of CVS history into a Git
-repository.
-
-This package provides the support library needed by git-remote-cvs.
-The following modules are included:
-
-- cvs - Interaction with CVS repositories
-
-- cvs_symbol_cache - Local CVS symbol cache
-
-- changeset - Collect individual CVS revisions into commits
-
-- git - Interaction with Git repositories
-
-- commit_states - Map Git commits to CVS states
-
-- cvs_revision_map - Map CVS revisions to various metainformation
-
-- util - General utility functionality use by the other modules in
-         this package, and also used directly by git-remote-cvs.
-
-"""
git_remote_cvs/setup.py deleted +0 -17
deleted file mode 100644
index 21f521a..0000000
@@ -1,17 +0,0 @@
-#!/usr/bin/env python
-
-"""Distutils build/install script for the git_remote_cvs package."""
-
-from distutils.core import setup
-
-setup(
-    name = 'git_remote_cvs',
-    version = '0.1.0',
-    description = 'Git remote helper program for CVS repositories',
-    license = 'GPLv2',
-    author = 'The Git Community',
-    author_email = '[email protected]',
-    url = 'http://www.git-scm.com/',
-    package_dir = {'git_remote_cvs': ''},
-    packages = ['git_remote_cvs'],
-)
git_remote_helpers/.gitignore renamed from git_remote_cvs/.gitignore +0 -0
similarity index 100%
rename from git_remote_cvs/.gitignore
rename to git_remote_helpers/.gitignore
git_remote_helpers/Makefile renamed from git_remote_cvs/Makefile +1 -1
similarity index 92%
rename from git_remote_cvs/Makefile
rename to git_remote_helpers/Makefile
index 0d9eb31..c62dfd0 100644
@@ -1,5 +1,5 @@
 #
-# Makefile for the git_remote_cvs python support modules
+# Makefile for the git_remote_helpers python support modules
 #
 pysetupfile:=setup.py
 
git_remote_helpers/__init__.py new file +27 -0
new file mode 100644
index 0000000..38c7b5f
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+"""Support library package for git remote helpers.
+
+Git remote helpers are helper commands that interfaces with a non-git
+repository to provide automatic import of non-git history into a Git
+repository.
+
+This package provides the support library needed by these helpers..
+The following modules are included:
+
+- cvs/cvs - Interaction with CVS repositories
+
+- cvs/symbol_cache - Local CVS symbol cache
+
+- cvs/changeset - Collect individual CVS revisions into commits
+
+- cvs/commit_states - Map Git commits to CVS states
+
+- cvs/revision_map - Map CVS revisions to various metainformation
+
+- git/git - Interaction with Git repositories
+
+- util - General utility functionality use by the other modules in
+         this package, and also used directly by git-remote-cvs.
+
+"""
git_remote_helpers/cvs/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
git_remote_helpers/cvs/changeset.py renamed from git_remote_cvs/changeset.py +1 -1
similarity index 98%
rename from git_remote_cvs/changeset.py
rename to git_remote_helpers/cvs/changeset.py
index 9eea9d2..4865c37 100644
@@ -11,7 +11,7 @@ module tries to reconstruct this notion of related revisions.
 
 """
 
-from git_remote_cvs.util import debug, error, die
+from git_remote_helpers.util import debug, error, die
 
 
 class Changeset(object):
git_remote_helpers/cvs/commit_states.py renamed from git_remote_cvs/commit_states.py +2 -2
similarity index 95%
rename from git_remote_cvs/commit_states.py
rename to git_remote_helpers/cvs/commit_states.py
index 2e0af6c..a796bb1 100644
@@ -2,8 +2,8 @@
 
 """Code for relating Git commits to corresponding CVSState objects."""
 
-from git_remote_cvs.util import debug, error, die
-from git_remote_cvs.cvs import CVSState
+from git_remote_helpers.util import debug, error, die
+from git_remote_helpers.cvs.cvs import CVSState
 
 
 class CommitStates(object):
git_remote_helpers/cvs/cvs.py renamed from git_remote_cvs/cvs.py +3 -3
similarity index 99%
rename from git_remote_cvs/cvs.py
rename to git_remote_helpers/cvs/cvs.py
index f870ae0..a1a02be 100644
@@ -17,9 +17,9 @@ import time
 from calendar import timegm
 import unittest
 
-from git_remote_cvs.util import (debug, error, die, ProgressIndicator,
-                                 start_command, run_command,
-                                 file_reader_method, file_writer_method)
+from git_remote_helpers.util import (debug, error, die, ProgressIndicator,
+                                     start_command, run_command,
+                                     file_reader_method, file_writer_method)
 
 
 class CVSNum(object):
git_remote_helpers/cvs/revision_map.py renamed from git_remote_cvs/cvs_revision_map.py +3 -3
similarity index 98%
rename from git_remote_cvs/cvs_revision_map.py
rename to git_remote_helpers/cvs/revision_map.py
index 0e65ba6..b7b17bc 100644
@@ -18,9 +18,9 @@ CVSStateMap - provides a mapping from CVS states to corresponding
 
 import os
 
-from git_remote_cvs.util import debug, error, die, file_reader_method
-from git_remote_cvs.cvs import CVSNum, CVSDate
-from git_remote_cvs.git import GitFICommit
+from git_remote_helpers.util import debug, error, die, file_reader_method
+from git_remote_helpers.cvs.cvs import CVSNum, CVSDate
+from git_remote_helpers.git.git import GitFICommit
 
 
 class _CVSPathInfo(object):
git_remote_helpers/cvs/symbol_cache.py renamed from git_remote_cvs/cvs_symbol_cache.py +2 -2
similarity index 98%
rename from git_remote_cvs/cvs_symbol_cache.py
rename to git_remote_helpers/cvs/symbol_cache.py
index cc8d88b..6bd1715 100644
@@ -23,8 +23,8 @@ synchronizing _all_ CVS symbols in one operation (by executing
 import sys
 import os
 
-from git_remote_cvs.util import debug, error, die, ProgressIndicator
-from git_remote_cvs.cvs import CVSNum, CVSState, CVSLogParser
+from git_remote_helpers.util import debug, error, die, ProgressIndicator
+from git_remote_helpers.cvs.cvs import CVSNum, CVSState, CVSLogParser
 
 
 class CVSSymbolStateLister(CVSLogParser):
git_remote_helpers/git/__init__.py new file +0 -0
new file mode 100644
index 0000000..e69de29
git_remote_helpers/git/git.py renamed from git_remote_cvs/git.py +2 -2
similarity index 99%
rename from git_remote_cvs/git.py
rename to git_remote_helpers/git/git.py
index cf037e3..8e1bc77 100644
@@ -12,8 +12,8 @@ from binascii import hexlify
 from cStringIO import StringIO
 import unittest
 
-from git_remote_cvs.util import debug, error, die, start_command, run_command
-from git_remote_cvs.cvs import CVSDate
+from git_remote_helpers.util import debug, error, die, start_command, run_command
+from git_remote_helpers.cvs.cvs import CVSDate
 
 
 def get_git_dir ():
git_remote_helpers/setup.py new file +17 -0
new file mode 100644
index 0000000..327f0ff
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+"""Distutils build/install script for the git_remote_helpers package."""
+
+from distutils.core import setup
+
+setup(
+    name = 'git_remote_helpers',
+    version = '0.1.0',
+    description = 'Git remote helper program for non-git repositories',
+    license = 'GPLv2',
+    author = 'The Git Community',
+    author_email = '[email protected]',
+    url = 'http://www.git-scm.com/',
+    package_dir = {'git_remote_helpers': ''},
+    packages = ['git_remote_helpers', 'git_remote_helpers.git', 'git_remote_helpers.cvs'],
+)
git_remote_helpers/util.py renamed from git_remote_cvs/util.py +0 -0
similarity index 100%
rename from git_remote_cvs/util.py
rename to git_remote_helpers/util.py
t/test-lib.sh +2 -2
index 77ad23e..c7530aa 100644
@@ -640,9 +640,9 @@ test -d ../templates/blt || {
 
 if test -z "$GIT_TEST_INSTALLED"
 then
-	GITPYTHONLIB="$(pwd)/../git_remote_cvs/build/lib"
+	GITPYTHONLIB="$(pwd)/../git_remote_helpers/build/lib"
 	export GITPYTHONLIB
-	test -d ../git_remote_cvs/build || {
+	test -d ../git_remote_helpers/build || {
 		error "You haven't built git_remote_cvs yet, have you?"
 	}
 fi
Signature · 1 line
1.6.5.2.291.gf76a3
#38 lore raw

Re: [PATCH 18/19] Refactor git_remote_cvs to a more generic git_remote_helpers

Quoted 5 lines · Sverre Rabbelier

This in an effort to allow future remote helpers written in python to re-use the non-cvs-specific code.

---

[snip]

Quoted 18 lines
(quoted diff) +0 -0
 b/git_remote_helpers/__init__.py new file mode 100644

index 0000000..38c7b5f

git_remote_helpers/__init__.py new file +12 -0
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+"""Support library package for git remote helpers.
+
+Git remote helpers are helper commands that interfaces with a non-git
+repository to provide automatic import of non-git history into a Git
+repository.
+
+This package provides the support library needed by these helpers..
+The following modules are included:
+
+- cvs/cvs - Interaction with CVS repositories

git_remote_helpers/__init__.py line 22

Quoted 10 lines
git_remote_helpers/__init__.py new file +10 -0
+
+- cvs/symbol_cache - Local CVS symbol cache
+
+- cvs/changeset - Collect individual CVS revisions into commits
+
+- cvs/commit_states - Map Git commits to CVS states
+
+- cvs/revision_map - Map CVS revisions to various metainformation
+
+- git/git - Interaction with Git repositories

Since this is Python documentation within a package, I'd rather refer to the python modules as _modules_ and not files. I.e. please use '.' instead of '/':

+- cvs.cvs - Interaction with CVS repositories
+
+- cvs.symbol_cache - Local CVS symbol cache
+
+- cvs.changeset - Collect individual CVS revisions into commits +
+- cvs.commit_states - Map Git commits to CVS states
+
+- cvs.revision_map - Map CVS revisions to various metainformation +
+- git.git - Interaction with Git repositories

git_remote_helpers/__init__.py line 25

Quoted 3 lines
git_remote_helpers/__init__.py new file +3 -0
+
+- util - General utility functionality use by the other modules in
+         this package, and also used directly by git-remote-cvs.

Probably you should drop the direct reference to git-remote-cvs.

Quoted 9 lines
git_remote_helpers/util.py renamed from git_remote_cvs/util.py +0 -0
similarity index 100%
rename from git_remote_cvs/util.py
rename to git_remote_helpers/util.py
t/test-lib.sh +0 -0
index 77ad23e..c7530aa 100644

t/test-lib.sh test -d ../templates/blt || { · line 646

Quoted 9 lines
t/test-lib.sh +2 -2
@@ -640,9 +640,9 @@ test -d ../templates/blt || {
 
 if test -z "$GIT_TEST_INSTALLED"
 then
-	GITPYTHONLIB="$(pwd)/../git_remote_cvs/build/lib"
+	GITPYTHONLIB="$(pwd)/../git_remote_helpers/build/lib"
 	export GITPYTHONLIB
-	test -d ../git_remote_cvs/build || {
+	test -d ../git_remote_helpers/build || {
 		error "You haven't built git_remote_cvs yet, have you?"

Please also s/git_remote_cvs/git_remote_helpers/ in the error message.

Otherwise, it all looks good :)

...Johan

Signature · 2 lines
Johan Herland, <[email protected]>
www.herland.net
#39 lore raw

Re: [PATCH 18/19] Refactor git_remote_cvs to a more generic git_remote_helpers

Heya,

Quoted 5 lines · Johan Herland
Quoted 1 line

+- git/git - Interaction with Git repositories

Since this is Python documentation within a package, I'd rather refer to the python modules as _modules_ and not files. I.e. please use '.' instead of '/':

Ok, will do.

Quoted 4 lines
Quoted 2 lines

+- util - General utility functionality use by the other modules in
+         this package, and also used directly by git-remote-cvs.

Probably you should drop the direct reference to git-remote-cvs.

Ah, yes, my bad.

Quoted 4 lines
Quoted 2 lines

+     test -d ../git_remote_helpers/build || {
              error "You haven't built git_remote_cvs yet, have you?"

Please also s/git_remote_cvs/git_remote_helpers/ in the error message.

That's weird, I thought I did that, ah well, will fix.

Quoted 1 line

Otherwise, it all looks good :)

Thanks for the review.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#40 lore raw

PATCH 19/19 .gitignore: add git-remote-cvs

In reply to Sverre Rabbelier
---
 .gitignore |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
.gitignore +1 -0
index 51a37b1..461f6ee 100644
@@ -105,6 +105,7 @@ git-reflog
 git-relink
 git-remote
 git-remote-curl
+git-remote-cvs
 git-repack
 git-replace
 git-repo-config
Signature · 1 line
1.6.5.2.291.gf76a3
#41 lore raw

Re: [PATCH 19/19] .gitignore: add git-remote-cvs

.gitignore git-reflog · line 111

Quoted 12 lines · Sverre Rabbelier
.gitignore +1 -0
index 51a37b1..461f6ee 100644
@@ -105,6 +105,7 @@ git-reflog
 git-relink
 git-remote
 git-remote-curl
+git-remote-cvs
 git-repack
 git-replace
 git-repo-config

Uh, squash to "[PATCH 14/19] git-remote-cvs: Remote help..." ?

Signature · 1 line
Shawn.
#42 lore raw

Re: [PATCH 19/19] .gitignore: add git-remote-cvs

Heya,

Quoted 1 line · Shawn O. Pearce

Uh, squash to "[PATCH 14/19] git-remote-cvs: Remote help..." ?

Durr, my bad, done locally, not sending another version yet though :P.

Signature · 3 lines
Cheers,

Sverre Rabbelier
#16 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

In reply to Daniel Barkalow

Heya,

Quoted 1 line · Daniel Barkalow

I think you have the sides backwards

Yup, sorry, got them the wrong way around for some reason.

Quoted 12 lines

On the other hand, I think it would make sense to use the same style of refspec between the helper and transport-helper.c such that the helper reports something like:

refs/svn/origin/trunk:refs/heads/trunkr
refs/svn/origin/branches/*:refs/heads/*
refs/svn/origin/tags/*:refs/tags/*

"list" gives:

000000...000 refs/heads/trunkr

Quoted 8 lines

"import refs/heads/trunkr" imports the objects, but the refspecs have to be consulted by transport-helper.c in order to determine what ref to read to get the value of refs/heads/trunkr. Instead of getting the value with read_ref("refs/heads/trunkr", ...) like it does now, it would do read_ref("refs/svn/origin/trunk", ...). And systems like p4 that don't have a useful standard just wouldn't support the "refspec" command and people would have to do site-specific configuration to get anything useful.

Yes, that sounds very reasonable, and I think that's the right way to go. This leaves us with only one thing, we need a remote HEAD for 'git clone hg::/path/to/repo' to work and have it check out a branch, I think a seperate 'head' command might be appropriate? If supported it returns the which local symref (e.g. 'refs/heads/trunkr' in the svn case) should be pointed at by HEAD. If not supported we can just not set it and clone will give the default 'no remote HEAD, nothing checked out' message, which would probably be best for p4?

Signature · 3 lines
Cheers,

Sverre Rabbelier
#17 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Quoted 8 lines · Sverre Rabbelier

Yes, that sounds very reasonable, and I think that's the right way to go. This leaves us with only one thing, we need a remote HEAD for 'git clone hg::/path/to/repo' to work and have it check out a branch, I think a seperate 'head' command might be appropriate? If supported it returns the which local symref (e.g. 'refs/heads/trunkr' in the svn case) should be pointed at by HEAD. If not supported we can just not set it and clone will give the default 'no remote HEAD, nothing checked out' message, which would probably be best for p4?

Why not have the regular list report:

@refs/heads/trunkr HEAD

or whatever it is, again like native git? That is, SVN would have an interaction like:

Quoted 1 line

list

< ? refs/heads/trunkr
< ? refs/heads/my-branch
< ? refs/tags/v1.0
< @refs/heads/trunkr HEAD
<

This is similar to the response from the curl helper, except that it uses "?" for the sha1s because it doesn't know them until they're imported.

-Daniel
*This .sig left intentionally blank*

#18 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Heya,

Quoted 6 lines · Daniel Barkalow

Why not have the regular list report:

@refs/heads/trunkr HEAD

or whatever it is, again like native git? That is, SVN would have an interaction like:

That's fine with me, but earlier you said you didn't like the whole symlinking idea.

You said in another thread you'll be working on some patches, does that include this 'refs' command? I want to avoid duplicate work if possible :).

Signature · 3 lines
Cheers,

Sverre Rabbelier
#19 lore raw

Re: [RFC PATCH 06/19] Factor ref updating out of fetch_with_import

Quoted 5 lines · Sverre Rabbelier

Heya,

Quoted 2 lines · Daniel Barkalow

Why not have the regular list report:

Quoted 7 lines
Quoted 4 lines

@refs/heads/trunkr HEAD

or whatever it is, again like native git? That is, SVN would have an interaction like:

That's fine with me, but earlier you said you didn't like the whole symlinking idea.

Now that you're not using them for other stuff, they're free to use for their normal purpose without confusion. The normal layout for a remote git repository's refs has HEAD as a symlink to something in refs/heads/*, so it's

Quoted 3 lines

You said in another thread you'll be working on some patches, does that include this 'refs' command? I want to avoid duplicate work if possible :).

No, I'm just working on getting the handler to work in a context where there's no local repository, if possible. This will probably generate a bunch of easy conflicts, but not actually overlap with what you're doing here.

-Daniel
*This .sig left intentionally blank*

#26 lore raw

Re: [PATCH 10/19] Allow helpers to request marks for fast-import

In reply to Sverre Rabbelier
Quoted 9 lines · Sverre Rabbelier

Heya,

Quoted 3 lines · Johan Herland

Please drop this patch from the series. The functionality is not needed, since we'll use the fast-import "option" command from the sr/gfi-options series instead.

In that case I will rebase the series on top of sr/gfi-options then as soon as I reroll that one.

Good.

Quoted 1 line

Also, do you need to change anything else in git-remote-cvs to do that?

Yes, the sr/gfi-options series does cause some changes, both in git-remote- cvs, and in the support libraries (adding a couple of methods to the GitFastImport class in git.py).

This conglomeration of patch series is becoming fairly complicated, and it's becoming hard to stay in sync. I suggest that you drop the CVS-specific parts from this series, and work on stabilizing the common infrastructure. Once that has settled, you can send a git-remote-hg series, and I can send a rebased and updated git-remote-cvs series.

Feel free to reorganize the patches so that the git_remote_helpers infrastructure is created in the correct location (instead of reorganizing git_remote_cvs).

...Johan

Signature · 2 lines
Johan Herland, <[email protected]>
www.herland.net
#27 lore raw

Re: [PATCH 10/19] Allow helpers to request marks for fast-import

Heya,

Quoted 6 lines · Johan Herland

On Friday 30 October 2009, Sverre Rabbelier wrote:
This conglomeration of patch series is becoming fairly complicated, and it's becoming hard to stay in sync. I suggest that you drop the CVS-specific parts from this series, and work on stabilizing the common infrastructure. Once that has settled, you can send a git-remote-hg series, and I can send a rebased and updated git-remote-cvs series.

That sounds like a good idea; I want to use the marks in git-remote-hg as well.

Quoted 3 lines

Feel free to reorganize the patches so that the git_remote_helpers infrastructure is created in the correct location (instead of reorganizing git_remote_cvs).

Ok, will do.

Signature · 3 lines
Cheers,

Sverre Rabbelier