[interchange-cvs] interchange - heins modified dist/lib/UI/Primitive.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Fri Aug 2 00:40:01 2002
User: heins
Date: 2002-08-02 04:39:16 GMT
Modified: dist/lib/UI Primitive.pm
Log:
* Cap the number of backup copies at some reasonable number.
Revision Changes Path
2.18 +12 -3 interchange/dist/lib/UI/Primitive.pm
rev 2.18, prev_rev 2.17
Index: Primitive.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /anon_cvs/repository/interchange/dist/lib/UI/Primitive.pm,v
retrieving revision 2.17
retrieving revision 2.18
diff -u -r2.17 -r2.18
--- Primitive.pm 17 Jun 2002 22:24:06 -0000 2.17
+++ Primitive.pm 2 Aug 2002 04:39:16 -0000 2.18
@@ -1,6 +1,6 @@
# UI::Primitive - Interchange configuration manager primitives
=20
-# $Id: Primitive.pm,v 2.17 2002/06/17 22:24:06 jon Exp $
+# $Id: Primitive.pm,v 2.18 2002/08/02 04:39:16 mheins Exp $
=20
# Copyright (C) 1998-2002 Red Hat, Inc. <interchange@redhat.com>
=20
@@ -25,7 +25,7 @@
=20
package UI::Primitive;
=20
-$VERSION =3D substr(q$Revision: 2.17 $, 10);
+$VERSION =3D substr(q$Revision: 2.18 $, 10);
=20
$DEBUG =3D 0;
=20
@@ -568,11 +568,11 @@
=20
my $motion =3D $options->{Motion} || 'save';
=20
+ $options->{max} =3D 10 if ! defined $options->{max};
=20
$dir =3D~ s:/+$::;
=20
if("\L$motion" eq 'save' and ! -f "$dir/$base+") {
- require File::Copy;
File::Copy::copy("$dir/$base", "$dir/$base+")
or die "copy $dir/$base to $dir/$base+: $!\n";
}
@@ -604,6 +604,10 @@
my $base_exists =3D -f $base;
push @forward, $base if $base_exists;
=20
+ if (@forward > $options->{max}) {
+ $#forward =3D $options->{max};
+ }
+
for(reverse sort @forward) {
next unless -f $_;
rename $_, $_ . $add or die "rename $_ =3D> $_+: $!\n";
@@ -614,6 +618,11 @@
@backward =3D sort @backward;
=20
unshift @backward, $base;
+
+ if (@backward > $options->{max}) {
+ $#backward =3D $options->{max};
+ }
+
my $i;
for($i =3D 0; $i < $#backward; $i++) {
rename $backward[$i+1], $backward[$i]