[PATCH] VCP::Filter::changesets bug causing revision loss

Chia-liang Kao <[email protected]> Sat, 17 Jul 2004 18:47:07 +0100
Newsgroups gmane.comp.version-control.revml
Message-ID <[email protected]>
--FCuugMFkClbJLl1L
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

This is finally tracked down and fixed after a few hours. Please see
the log and apply the patch below. We all love Perl.

On Tue, Jun 01, 2004 at 02:24:42PM +0100, Chia-liang Kao wrote:
> I have a smaller test case of missing revs, it's neither on branch nor
> using --continue.
>=20
> vcp cvs::pserver:[email protected]:/var/cvs/modules:Apache-MVC/...=
 \
>     map: '(...)<>' '$1<>' '...' '<<delete>>' -- \
>     p4:/tmp/p4-maypole://depot/maypole/...  --run-p4d --init-p4d
>=20
> (303 revs total)
>=20
> % p4 filelog //depot/maypole/doc/About.pod
> //depot/maypole/doc/About.pod
> ... #1 change 79 add on 2004/03/10 by simon@vcp_tmp_95595 (text) 'Doc out=
line. '
>=20
> while you could find there are other revs obviously at:
>=20
> http://cvs.simon-cozens.org/viewcvs.cgi/Apache-MVC/doc/About.pod

----------------------------------------------------------------------
r1116:  clkao | 2004-07-17T17:41:37.945934Z

VCP::Filter::changesets always loses the 49th revision and causes the
descendents of it all lost. This is because the 'w' packed index is
not checked safely. Also fix a dangerous "my $foo =3D $bar if $baz"
construct.

----------------------------------------------------------------------
--- local/lib/VCP/Filter/changesets.pm  (revision 1115)
+++ local/lib/VCP/Filter/changesets.pm  (revision 1116)
@@ -666,8 +666,8 @@ sub split_and_send_changes {
          if ( !$change ) {
             my @future_indexes =3D
                grep $_ !=3D $r_index,
-               unpack "w*", $changes->[$change_index]
-               if $changes->[$change_index];
+               unpack "w*",
+               exists $changes->[$change_index] ? $changes->[$change_index=
] : '';
=20
             undef $changes->[$change_index];
=20
@@ -780,7 +780,7 @@ sub split_and_send_changes {
=20
          my $r_index =3D delete $self->{INDEXES_BY_ID}->{$r->id};
=20
-         if ( $children->[$r_index] ) {
+         if ( exists $children->[$r_index] ) {
             push @cur_indexes, unpack "w*", $children->[$r_index];
          }
          undef $children->[$r_index];  ## undef $foo releases extra memory

Cheers,
CLK

--FCuugMFkClbJLl1L
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFA+WYbk1XldlEkA5YRAuUcAJ4ubTa3ODRaYE02DXlq718p49AynQCfeH3g
mkv9N/kP2UzGDZhD7iGfIx0=
=WRZs
-----END PGP SIGNATURE-----

--FCuugMFkClbJLl1L--