public VcsHistorySession createSessionFor()

in src/net/sourceforge/transparent/History/CCaseHistoryProvider.java [106:162]


  public VcsHistorySession createSessionFor( FilePath filePath ) throws VcsException
  {
    String log;
    String path = filePath.getPath();
    if( host.renamedFiles.containsKey( path ) )
      path = host.renamedFiles.get( path );

    //  Cleartool can not handle history for hijacked files. Thus we have to
    //  construct "versioned" path, which directly points to the vob-object.
    VirtualFile vfile = filePath.getVirtualFile();
    if( vfile != null )
    {
      FileStatus status = FileStatusManager.getInstance( project ).getStatus( vfile );
      if( status == FileStatus.HIJACKED )
      {
        path += "@@";
      }
    }

    final List<String> commandParts = new ArrayList<>();
    commandParts.add(HISTORY_CMD);
    if (host.getConfig().isHistoryResticted) {
      int margin = host.getConfig().getHistoryRevisionsMargin();
      commandParts.add(LIMITED_SWITCH);
      commandParts.add(String.valueOf( margin ));
    }
    CCaseHistoryParser.fillParametersTail(commandParts);
    commandParts.add(path);

    log = TransparentVcs.cleartoolWithOutput(ArrayUtil.toStringArray(commandParts));

    //  There may exist files for which we know nothing.
    ArrayList<VcsFileRevision> revisions = new ArrayList<>();
    if( log.contains( NOT_A_VOB_OBJECT )) {
      throw new VcsException( log );
    } else {
      ArrayList<CCaseHistoryParser.SubmissionData> changes = CCaseHistoryParser.parse( log );
      for( CCaseHistoryParser.SubmissionData change : changes )
      {
        //  When file is being committed into the repository, "lshistory"
        //  returns a intermediate record with commit date in the invalid format
        //  which can not be parsed (actually, it contains only full date wihtout
        //  time information delimited by '.'). Just skip this record.
        try
        {
          VcsFileRevision rev = new CCaseFileRevision(change, path, project);
          revisions.add( rev );
        }
        catch( NullPointerException e)
        {
          TransparentVcs.LOG.info( "Can not parse history record, found intermediate record.");
        }
      }
    }

    return new CCaseHistorySession(revisions, filePath);
  }