aboutsummaryrefslogtreecommitdiffstats
path: root/copypage.pl
diff options
context:
space:
mode:
authorJavier Fernandez-Sanguino Peña <jfs>2010-10-15 22:42:17 +0000
committerJavier Fernandez-Sanguino Peña <jfs>2010-10-15 22:42:17 +0000
commitc712588222b619a83c4495b812cbf160e2718387 (patch)
tree3a9ac19c2301f0d804f43d8a9ea0dc33bc50fb19 /copypage.pl
parent7db5af31c9cf77283dd7b1f76133cead33277b73 (diff)
Code rewrite to clarify what the code does and the different situations, avoid nested ifs as this seems to confuse people
CVS version numbers copypage.pl: 1.34 -> 1.35
Diffstat (limited to 'copypage.pl')
-rwxr-xr-xcopypage.pl92
1 files changed, 50 insertions, 42 deletions
diff --git a/copypage.pl b/copypage.pl
index af6c28174b9..291f27c9d19 100755
--- a/copypage.pl
+++ b/copypage.pl
@@ -338,53 +338,61 @@ sub find_files_attic
# to look for files in the Attic
system "LC_ALL=C cvs status '$file' >$tmpfile 2>&1";
+ if ( $? != 0 ) {
+ # CVS returns an error, then cleanup and return
+ # Do not complain because this might happen just because we
+ # have no network access, just cleanup the temporary file
+ unlink $tmpfile;
+ return 0;
+ }
+
# If CVS does not return an error then there is a file in CVS
# even if $dstfile is not in the filesystem
# There could be two reasons for this:
# - The user has removed it but somebody else put it in CVS
# - It resides in the Attic
- if ( $? == 0 ) {
- my $deleted_version = "<latest_version>";
- my $previous_version = "<version_before_deletion>";
- my $cvs_location = "";
-
- # Parse the result of cvs status
- open(TF, $tmpfile) || die ("Cannot open temporary file: $?");
- while ($line = <TF>) {
- chomp $line;
- if ( $line =~ /Repository revision:\s+(\d+)\.(\d+)\s+(.*)$/ ) {
- $cvs_location = $3;
- $deleted_version = $1.".".$2 ;
- $previous_version = $1.".".($2-1);
- }
+ my $deleted_version = "<latest_version>";
+ my $previous_version = "<version_before_deletion>";
+ my $cvs_location = "";
+
+ # Parse the result of cvs status
+ open(TF, $tmpfile) || die ("Cannot open temporary file: $?");
+ while ($line = <TF>) {
+ chomp $line;
+ if ( $line =~ /Repository revision:\s+(\d+)\.(\d+)\s+(.*)$/ ) {
+ $cvs_location = $3;
+ $deleted_version = $1.".".$2 ;
+ $previous_version = $1.".".($2-1);
}
- close TF;
- unlink $tmpfile;
-
- # Now determine in which situation we are in
- if ( $cvs_location ne "" ) {
- # We need CVS information to continue here
- if ( $cvs_location =~ /Attic\// ) {
- # Situation 1 - There is a translation in the Attic
- # Give information on how to restore
- print STDERR "ERROR: An old translation exists in the Attic, you should restore it using:\n";
- print STDERR "\tcvs update -j $deleted_version -j $previous_version $dstfile\n";
- print STDERR "\t[Edit and update the file]\n";
- print STDERR "\tcvs ci $dstfile\n";
- die ("Old translation found\n");
- } else {
- # Situation 2 - There is already a file in CVS with this
- # name, since it does not exist in the local copy maybe
- # the local copy is not up to date
- die ("ERROR: A translation already exist in CVS for this file.\nPlease update your CVS copy using 'cvs update'.\n");
- } # of if $cvs_location Attic
- } # of if $cvs_location ne ""
- } # of if $?
-# Nothing to do if cvs returns an error, maybe its because we have
-# no network access
-
-# Cleanup
- unlink $tmpfile;
- return 0;
+ }
+ close TF;
+ unlink $tmpfile; # File is not used from here on, delete it
+
+ # Now determine in which situation we are in:
+
+ if ( $cvs_location eq "" ) {
+# Situation 0 - This happens when the return text is
+# "Repository revision: No revision control file"
+ return 0; # Nothing to do here
+
+ }
+
+ if ( $cvs_location =~ /Attic\// ) {
+# Situation 1 - There is a translation in the Attic
+# Give information on how to restore
+
+ print STDERR "ERROR: An old translation exists in the Attic, you should restore it using:\n";
+ print STDERR "\tcvs update -j $deleted_version -j $previous_version $dstfile\n";
+ print STDERR "\t[Edit and update the file]\n";
+ print STDERR "\tcvs ci $dstfile\n";
+ die ("Old translation found\n");
+ }
+
+ # Situation 2 - There is already a file in CVS with this
+ # name, since it does not exist in the local copy maybe
+ # the local copy is not up to date
+ print STDERR "ERROR: A translation already exist in CVS for this file.\n";
+ print STDERR "\tPlease update your CVS copy using 'cvs update'.\n";
+ die ("Translation already exists\n");
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy