File hijacked when added to source control in snapshot view
| Problem |
| 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™.. |
|
| Cause |
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".
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.
|
|
| Solution |
Depending on the situation there are a few different options: - Use a transparent or Unix type (-tmo strip_cr) view
- If the editor used can save the file in different text modes, make sure the file is saved with MSDOS line endings.
- 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 );
|
搜索更多相关主题的帖子:
snapshot source control added