Package: git-cvs
Version: 1:1.7.2.5-3
Tags: patch
Because of the way cvs doesn't track merges, best practice with cvs
was to tag a branch before merging it. That is, it is best practice
to make a tag on the branch-to-be-merged. That way, if you want to
merge the same branch again, you can use cvs up -j -j to ensure that
you attempt to merge only the diffs since your last merge.
In several cvs repos I had the practice of recording the merge by
stating in the cvs log message the exact arguments to "cvs update".
For example,
Merge !tell feature. cvs up -j branchpoint-2001-10-09-tell -j
merge-2001-10-09-tell
and
Merge up from trunk. cvs up -j branchpoint-2001-10-09-tell -j
mergeup-1-2001-10-09-tell
I tried to specify a -M rune when importing this:
git-cvsimport -d ~/CVS -i -k -u -a -C out -M 'cvs up -j.* -j \
(merge[-0-9a-z]+\b)' project
But this fails because the "branch name" extracted by the regexp is
not the cvs branch name. It is the name of the tag. Also, no message
is produced by git-cvsimport to explain why, despite the regexp
matching, a merge commit is not produced.
To fix this, I wrote the patch below. This has two effects:
* Firstly, it looks in refs/tags/ as well as in the branch namespace.
As far as I can tell the literal refs/tags/ is right, because
tags from remote repos aren't namespaced the way that branches are.
(We need to pass the found $sha1 to -p rather than the ref name,
as otherwise we'd need to record which ref name was found.
And the message printed on success is adjusted accordingly.)
* Secondly, if the referenced branch or tag doesn't seem to exist,
we print a message. I think this is a message worth printing even
if -v is not specified. Perhaps it should even go to stderr, but
I decided not to go that far.
With this I was able to import the repository.
Thanks,
Ian.
--- /usr/lib/git-core/git-cvsimport 2011-09-21 18:36:04.000000000 +0100
+++ /u/ijackson/junk/d/git-cvsimport 2013-11-11 16:47:07.000000000 +0000
@@ -790,9 +790,12 @@
foreach my $rx (@mergerx) {
next unless $logmsg =~ $rx && $1;
my $mparent = $1 eq 'HEAD' ? $opt_o : $1;
- if (my $sha1 = get_headref("$remote/$mparent")) {
- push @commit_args, '-p', "$remote/$mparent";
- print "Merge parent branch: $mparent\n" if $opt_v;
+ if (my $sha1 = get_headref("$remote/$mparent") ||
+ get_headref("refs/tags/$mparent")) {
+ push @commit_args, '-p', $sha1;
+ print "Merge parent: $mparent\n" if $opt_v;
+ } else {
+ print "Merge not found: $mparent\n";
}
}
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]