I am using SVN and have a stable production branch and an unstable trunk. For each release we cherry pick the items from trunk to be merged to production.
I have cloned my SVN repo with git svn so that I can take advantage of faster searches for commits that I need to merge (since I search on the JIRA id in the commit message). However, I still do my merges with svn merge at the end of it.
One of the issues with this long lived production branch is that there are potentially commits left behind in trunk that don't get merged.
To address this I occasionally run:
svn mergeinfo --show-revs eligible https://my.server/svn/trunk https://my.server/svn/branches/PROD_V3.00
However, this is really slow. The equivalent in git is
git log prod..master
However, this seems to just list all the commits.
Is this due to git not recognising the svn merges and the svn:mergeinfo property?
Is there any way for me to get the eligible commits quickly using git?
EDIT:
I tried Joes answer, however, git cherry
just outputs the SHA and I need the SVN revision to do the merge.
Therefore, I had to pipe it through git svn find-rev
to find the SVN ids to get what I needed.
git cherry prod master|cut -d' ' -f2|while read -r line; do git svn find-rev "$line"; done;
Unfortunately, this is slower than svn mergeinfo --show-revs eligible
.
If the commits have been cherry-picked then you now have two copies of those commits. Git will show you all the commits in master
even if they have a copy in prod
.
The equivalent is probably:
git cherry master prod
which will show you any commits in master
that don't appear to have been cherry-picked into prod
.
If you are at all able to work in Perl, git-svn is simply a big perl script, and git svn find-rev is a function inside that perl script. You could code using that, which would avoid having to read in the rev_map file every time.
So, what I'm thinking is that this:
git cherry prod master|cut -d' ' -f2|while read -r line; do git svn find-rev "$line"; done
Becomes something more like this (not complete and hasn't been run b/c I no longer have a git-svn repo):
#!/usr/bin/perl
use Carp;
use Git::SVN;
# use ...the rest of the Git::SVN module...
# ...initialize whatever is necessary...
open(ELIGIBLE_COMMITS, "git cherry prod master") || croak "Couldn't do git cherry";
while (<ELIGIBLE_COMMITS>) {
($ignore, $sha1) = split;
my (undef, $rev, undef) = cmt_metadata($sha1);
print "$rev\n";
}
close(ELIGIBLE_COMMITS);
You might also consider just modifying the git-svn
script's cmd_find_rev
to take an additional option that specifies multiple revisions to find, e.g.,
find-rev --file <filename>
Where filename could be "-" to specify STDIN.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With