File hijacked when added to source control in snapshot view

Technote (troubleshooting)


Problem(Abstract)

This technote explains why a file can become hijacked when added to source control from an IBM® Rational® ClearCase® snapshot view on Microsoft® Windows®, UNIX® or Linux®.

Symptom

Files that become hijacked when added to source control in a snapshot view result in the following error:

Loading "<file>" (X bytes).
cleartool: Error: size of "<file>" is Y, expected X.
cleartool: Warning: This is a "msdos" text mode view.  Is the VOB element's text mode information correct?
cleartool: Error: Errors were encountered in loading "<file>".
cleartool: Warning: VOB updated, but failure updating snapshot view to reflect checkin of "<file>": error detected by ClearCase subsystem.
cleartool: Warning: Version checked in is not selected by view.
Checked in "<file>" version "/main/1".

Cause


The file was added to source control using an MSDOS textmode view (created with -tmode insert_cr) but the file has UNIX (or Linux) type line endings (<LF>).

The size of a text file measured in bytes having UNIX type line endings is equal to the number of characters in the file + one for each line ending (<LF>).

The size of a text file having MSDOS type line endings is equal to the number of characters in the file + two for each line ending (<CR><LF>).

When a file with <LF> line endings is added to source control using an MSDOS text mode view, ClearCase cannot convert <CR><LF> to <LF> as intended. As a result there will be a mismatch between what the view contains and what has been stored in the VOB. Due to the size difference between VOB and view ClearCase thinks the file has been changed in the view without being checked out, and by definition, that's a hijacked file.


Resolving the problem

Depending on the situation there are a few different options:

  1. Use a transparent or Unix type (-tmo strip_cr) view
  2. If the editor used can save the file in different text modes, make sure the file is saved with MSDOS line endings.
  3. Use a transparent view and a pre-op checkin trigger that automatically converts <CR><LF> to <LF>, like for example

    #! /usr/bin/perl

    open ( FILE, $CLEARCASE_PN );
    binmode( FILE );
    @linesoffile = <FILE>;
    close ( FILE );
    unlink $CLEARCASE_PN;
    foreach ( @linesoffile )
    {
    s/\r\n$/\n/;
    }
    open ( FILE, ">" .$CLEARCASE_PN );
    binmode ( FILE );
    print FILE @linesoffile;
    close ( FILE );

Related information

About text modes

Cross reference information
Segment Product Component Platform Version Edition
Software Development Rational ClearCase View: Snapshot

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

Rational ClearCase
View: Snapshot

Software version:

2002.05.00, 2003.06.00

Operating system(s):

AIX, HP-UX, IRIX, Linux, Solaris, Windows

Reference #:

1128064

Modified date:

2008-01-29

Translate my page

Machine Translation

Content navigation