~sandy-carter/bzr4idea/compile_errors

« back to all changes in this revision

Viewing changes to src/bzr4idea/annotate/BzrAnnotationProvider.java

  • Committer: Sandy Carter
  • Date: 2013-12-11 16:23:07 UTC
  • Revision ID: sandy.carter@savoirfairelinux.com-20131211162307-1eknokjg70lghahd
Fixed errors in BzrVcs and BzrAnnotation

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
import bzr4idea.i18n.GitBundle;
37
37
import org.jetbrains.annotations.NonNls;
38
38
import org.jetbrains.annotations.NotNull;
39
 
import org.vcs.bazaar.client.IBazaarAnnotation;
40
39
 
41
40
import java.util.Date;
42
41
import java.util.List;
141
140
                                     final VcsFileRevision revision,
142
141
                                     final List<VcsFileRevision> revisions,
143
142
                                     final VirtualFile file) throws VcsException {
144
 
    /* git4idea
145
 
    GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(myProject, repositoryFilePath), GitHandler.ANNOTATE);
146
 
    h.setNoSSH(true);
147
 
    h.setStdoutSuppressed(true);
148
 
    h.setCharset(file.getCharset());
149
 
    h.addParameters("-p", "-l", "-t", "-M");
150
 
    if (revision == null) {
151
 
      h.addParameters("HEAD");
152
 
    }
153
 
    else {
154
 
      h.addParameters(revision.getRevisionNumber().asString());
155
 
    }
156
 
    h.endOptions();
157
 
    h.addRelativePaths(repositoryFilePath);
158
 
    String output = h.run();
159
 
    */
160
143
    Bzr bzr = Bzr.forBzrRoot( GitUtil.getGitRoot(myProject, repositoryFilePath) );
161
 
    IBazaarAnnotation output = bzr.annotate( repositoryFilePath, revision != null ? ((BzrRevisionNumber)revision.getRevisionNumber()).getBzrRevision() : null );
162
 
    GitFileAnnotation annotation = new GitFileAnnotation(myProject, file, revision == null);
163
 
    /* git4idea
164
 
    class CommitInfo {
165
 
      Date date;
166
 
      String author;
167
 
      BzrRevisionNumber revision;
168
 
    }
169
 
    HashMap<String, CommitInfo> commits = new HashMap<String, CommitInfo>();
170
 
    for (StringScanner s = new StringScanner(output); s.hasMoreData();) {
171
 
      // parse header line
172
 
      String commitHash = s.spaceToken();
173
 
      if (commitHash.equals(BzrRevisionNumber.NOT_COMMITED_HASH)) {
174
 
        commitHash = null;
175
 
      }
176
 
      s.spaceToken(); // skip revision line number
177
 
      int lineNum = Integer.parseInt(s.spaceToken());
178
 
      s.nextLine();
179
 
      // parse commit information
180
 
      CommitInfo commit = commits.get(commitHash);
181
 
      if (commit != null) {
182
 
        while (s.hasMoreData() && !s.startsWith('\t')) {
183
 
          s.nextLine();
184
 
        }
185
 
      }
186
 
      else {
187
 
        commit = new CommitInfo();
188
 
        while (s.hasMoreData() && !s.startsWith('\t')) {
189
 
          String key = s.spaceToken();
190
 
          String value = s.line();
191
 
          if (commitHash != null && AUTHOR_KEY.equals(key)) {
192
 
            commit.author = value;
193
 
          }
194
 
          if (commitHash != null && COMMITTER_TIME_KEY.equals(key)) {
195
 
            commit.date = GitUtil.parseTimestamp(value);
196
 
            commit.revision = new BzrRevisionNumber(commitHash, commit.date);
197
 
          }
198
 
        }
199
 
        commits.put(commitHash, commit);
200
 
      }
201
 
      // parse line
202
 
      if (!s.hasMoreData()) {
203
 
        // if the file is empty, the next line will not start with tab and it will be
204
 
        // empty.  
205
 
        continue;
206
 
      }
207
 
      s.skipChars(1);
208
 
      String line = s.line(true);
209
 
      annotation.appendLineInfo(commit.date, commit.revision, commit.author, line, lineNum);
210
 
    }
211
 
    */
212
 
    for ( int linenum = 0; linenum < output.getNumberOfLines(); linenum++ ) {
213
 
      Date annoDate = output.getDate( linenum );
214
 
      annotation.appendLineInfo(
215
 
              annoDate,
216
 
              BzrRevisionNumber.createRevision( output.getRevision( linenum ), annoDate ),
217
 
              output.getAuthor( linenum ),
218
 
              output.getline( linenum ), linenum + 1 );
219
 
      // @TODO: set progress?
220
 
    }
 
144
//    IBazaarAnnotation output = bzr.annotate( repositoryFilePath, revision != null ? ((BzrRevisionNumber)revision.getRevisionNumber()).getBzrRevision() : null );
 
145
    GitFileAnnotation annotation = new GitFileAnnotation(myProject, file, revision == null, revision.getRevisionNumber());
 
146
//    for ( int linenum = 0; linenum < output.getNumberOfLines(); linenum++ ) {
 
147
//      Date annoDate = output.getDate( linenum );
 
148
//      annotation.appendLineInfo(
 
149
//              annoDate,
 
150
//              BzrRevisionNumber.createRevision( output.getRevision( linenum ), annoDate ),
 
151
//              output.getAuthor( linenum ),
 
152
//              output.getline( linenum ), linenum + 1 );
 
153
//      @TODO: set progress?
 
154
//    }
221
155
    annotation.addLogEntries(revisions);
222
156
    return annotation;
223
157
  }