Skip to content

Commit

Permalink
Merge pull request #241 from matthewrmshin/fix-rosie-branch-delete-wa…
Browse files Browse the repository at this point in the history
…rning

branch-delete: fix Perl warning on rosie branches
  • Loading branch information
paulcresswell authored Dec 5, 2016
2 parents d9f9930 + 628e159 commit 3ad09f0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/FCM1/CmBranch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -675,14 +675,14 @@ sub del {

# Create a temporary file for the commit log message
my $temp_handle = $self->_commit_message(
sprintf("Deleted %s.\n", $self->branch_path()), 'D', $non_interactive,
sprintf("Deleted %s.\n", $self->branch_path()), 'D', $non_interactive,
);

# Check with the user to see if he/she wants to go ahead
# ----------------------------------------------------------------------------
if (not $non_interactive) {
if (!$non_interactive) {
my $mesg = '';
if (!$self->layout()->is_owned_by_user()) {
if ($self->branch_owner() && !$self->layout()->is_owned_by_user()) {
$mesg .= "\n";

if (exists $FCM1::CmUrl::owner_keywords{$self->branch_owner()}) {
Expand Down
28 changes: 17 additions & 11 deletions lib/FCM1/CmUrl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,26 @@ sub svnlog {

# Check whether a "svn log" run is necessary
# ----------------------------------------------------------------------------
my $need_update = ! ($revs [0] == $revs [1] and exists $self->{LOG}{$revs [0]});
my @ranges = @revs;
if ($need_update and $self->{LOG_RANGE}) {
my %log_range = %{ $self->{LOG_RANGE} };

if ($stop_on_copy) {
$ranges [1] = $log_range{UPPER} if $ranges [1] >= $log_range{LOWER_SOC};

} else {
$ranges [1] = $log_range{UPPER} if $ranges [1] >= $log_range{LOWER};
my $need_update = !($revs[0] == $revs[1] && exists($self->{LOG}{$revs [0]}));
my @ranges = @revs;
if ($need_update && $self->{LOG_RANGE}) {
my %log_range = %{$self->{LOG_RANGE}};
$log_range{LOWER_SOC} ||= 0;
$log_range{LOWER} ||= 0;

if ($stop_on_copy && $ranges[1] >= $log_range{LOWER_SOC}) {
if ($ranges[1] >= $log_range{LOWER_SOC}) {
$ranges[1] = $log_range{UPPER};
}
}
else {
if ($ranges[1] >= $log_range{LOWER}) {
$ranges[1] = $log_range{UPPER};
}
}
}

$need_update = 0 if $ranges [0] < $ranges [1];
$need_update = 0 if $ranges[0] < $ranges[1];

if ($need_update) {
my @entries = @{$SVN->get_log(
Expand Down
2 changes: 1 addition & 1 deletion t/fcm-add-trac-env/00-basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ for NAME in bus car lorry taxi; do
# Subversion repository paths in place
if [[ -d "srv/svn/$NAME" ]]; then
file_grep "$TEST_KEY-repository_dir" \
"repository_dir=$PWD/srv/svn/$NAME" \
"dir=$PWD/srv/svn/$NAME" \
"$PWD/srv/trac/$NAME/conf/trac.ini"
fi
done
Expand Down
39 changes: 39 additions & 0 deletions t/fcm-branch-delete/02-rosie.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# (C) British Crown Copyright 2006-16 Met Office.
#
# This file is part of FCM, tools for managing and building source code.
#
# FCM is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# FCM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with FCM. If not, see <http://www.gnu.org/licenses/>.
# ------------------------------------------------------------------------------
# Test "fcm branch-delete" does not produce warnings for rosie branches.
#-------------------------------------------------------------------------------
. "$(dirname "$0")/test_header"
tests 3
#-------------------------------------------------------------------------------
# Tests fcm branch-delete with bad argument, and in a working copy
TEST_KEY="${TEST_KEY_BASE}"
setup
init_repos_layout_roses
svn copy -q -m 'create a branch' \
"${REPOS_URL}/a/a/0/0/0/trunk" "${REPOS_URL}/a/a/0/0/0/my-branch"
run_pass "${TEST_KEY}" \
fcm branch-delete --non-interactive "${REPOS_URL}/a/a/0/0/0/my-branch"
file_cmp "${TEST_DIR}/${TEST_KEY}.err" "${TEST_KEY}.err" <'/dev/null'
run_pass "${TEST_KEY}.out" \
grep -q -F "Deleting branch ${REPOS_URL}/a/a/0/0/0/my-branch ..." \
"../${TEST_KEY}.out"
teardown
#-------------------------------------------------------------------------------
exit
3 changes: 1 addition & 2 deletions t/lib/bash/svn_test_header
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ function init_repos_layout_roses() {
svnadmin create --fs-type fsfs $TEST_DIR/test_repos
REPOS_URL="file://$TEST_DIR/test_repos"
fi
svn mkdir -q --parents $REPOS_URL/a/a/0/0/0/trunk
svn import -q $TEST_SOURCE_DIR/../etc/repo_files \
$REPOS_URL/a/a/0/0/0/trunk -m "initial trunk import"
$REPOS_URL/a/a/0/0/0/trunk/ -m "initial trunk import"
TMPFILE=$(mktemp)
cat >$TMPFILE <<__LAYOUT__
depth-project = 5
Expand Down

0 comments on commit 3ad09f0

Please sign in to comment.