summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pyne <mpyne@kde.org>2012-08-03 23:52:41 (GMT)
committerMichael Pyne <mpyne@kde.org>2012-08-03 23:52:41 (GMT)
commit9a7a4d6330fa247e5cd57ea8e196b26229f34222 (patch)
tree5c8340f5da7ad35c31c305b5a0d1936cfe9d59da
parent9d0f34cefd1f7233cc90cf3f17b8566a280dd3f8 (diff)
Upgrade svn 1.7 repositories automatically.
Subversion 1.7 requires a manual upgrade of the working copy in order to do anything (even to run svn status). Luckily there's an error message ID for this case so it's not too hard to grep for situations where this is necessary. One problematic element is that since even 'svn info' doesn't work in this situation, --pretend mode doesn't work either for svn modules. For now I just throw an exception (after the check) when in pretend mode so avoid follow-on useless error messages. It was interesting how I still had the old 1.6.17 for so long -- turns out I had forgot to rename my subversion selector asking for unstable versions in Gentoo (at some point their package name changed from dev-util/subversion to dev-vcs/subversion, which I didn't keep up with). Thanks Will Stephenson for the bug report. BUG:304415
-rwxr-xr-xkdesrc-build69
1 files changed, 66 insertions, 3 deletions
diff --git a/kdesrc-build b/kdesrc-build
index c5b4966..d25f57f 100755
--- a/kdesrc-build
+++ b/kdesrc-build
@@ -3205,6 +3205,8 @@ EOF
our @ISA = ('UpdateHandler');
+ use IPC::Open3 qw(open3);
+
# Returns true if a module has a base component to their name (e.g. KDE/,
# extragear/, or playground). Note that modules that aren't in trunk/KDE
# don't necessary meet this criteria (e.g. kdereview is a module itself).
@@ -3370,20 +3372,24 @@ EOF
# URL. If not, a warning is printed out.
# First parameter: module to check.
# Return: Nothing.
- sub check_module_validity
+ sub _verifyCorrectServerURL
{
my $self = assert_isa(shift, 'SvnUpdate');
- my $module = $self->module();
- my $source_dir = $module->fullpath('source');
+
my $module_expected_url = $self->svn_module_url();
my $module_actual_url = $self->svnInfo('URL');
+ if (!$module_actual_url) {
+ croak_runtime ("Unable to determine working copy's svn URL for " . $self->module());
+ }
+
$module_expected_url =~ s{/+$}{}; # Remove trailing slashes
$module_actual_url =~ s{/+$}{}; # Remove trailing slashes
if ($module_actual_url ne $module_expected_url)
{
# Check if the --src-only flag was passed.
+ my $module = $self->module();
if ($module->buildContext()->getOption('#allow-auto-repo-move'))
{
note ("g[$module] is checked out from a different location than expected.");
@@ -3413,6 +3419,63 @@ EOF
}
}
+ # This procedure should be run before any usage of a local working copy to
+ # ensure it is valid. This should only be run if there's actually a local
+ # copy.
+ #
+ # Any errors will be fatal, so a 'Runtime' exception would be raised.
+ sub check_module_validity
+ {
+ my $self = assert_isa(shift, 'SvnUpdate');
+ my $module = $self->module();
+
+ # svn 1.7 has a different working copy format that must be manually
+ # converted. This will mess up everything else so make this our first
+ # check.
+ p_chdir($module->fullpath('source'));
+
+ # gensym makes a symbol that can be made a filehandle by open3
+ use Symbol qw(gensym);
+
+ # Can't use filter_program_output as that doesn't capture STDERR on
+ # purpose. We, on the other hand, just want STDERR.
+ my $stderrReader = gensym();
+ my $pid = open3(undef, undef, $stderrReader,
+ 'svn', '--non-interactive', 'status');
+
+ my @errorLines = grep { /:\s*E155036:/ } (<$stderrReader>);
+ waitpid ($pid, 0);
+
+ if (@errorLines) {
+ warning (<<EOF);
+ y[*] A new version of svn has been installed which requires a b[one-time] update
+ y[*] Currently running b[svn upgrade], this may take some time but should only
+ y[*] be needed once.
+EOF
+
+ if (0 != log_command($module, 'svn-upgrade', ['svn', '--non-interactive', 'upgrade'])) {
+ error (<<EOF);
+ r[*] Unable to run b[svn upgrade] for b[r[$module]!
+ r[*] If you have no local changes you should try deleting the $module
+ r[*] source directory, and re-run b[kdesrc-build], which will re-download.
+ r[*]
+ r[*] There is no way for kdesrc-build to safely make this check for you as
+ r[*] the old version of b[svn] is required to read the current repository!
+EOF
+ croak_runtime("Unable to run svn upgrade for $module");
+ }
+
+ # By this point svn-upgrade should have run successfully, unless
+ # we're in pretend mode.
+ if (pretending()) {
+ croak_runtime("Unable to use --pretend for svn module $module until svn-upgrade is run");
+ }
+ }
+
+ # Ensure the URLs are correct.
+ $self->_verifyCorrectServerURL();
+ }
+
# Subroutine used to handle the checkout-only option. It handles updating
# subdirectories of an already-checked-out module.
#