~sandy-carter/bzr4idea/compile_errors

« back to all changes in this revision

Viewing changes to src/bzr4idea/changes/GitChangeUtils.java

  • Committer: Patrik Beno
  • Date: 2009-04-19 15:52:06 UTC
  • Revision ID: patrik.beno@gmail.com-20090419155206-a8v8ds3r5ks063g9
BZR-79 refactoring; some bzr4idea/* classes renamed

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeListImpl;
10
10
import com.intellij.openapi.vfs.VirtualFile;
11
11
import com.intellij.openapi.diagnostic.Logger;
12
 
import bzr4idea.GitContentRevision;
13
 
import bzr4idea.GitRevisionNumber;
14
 
import bzr4idea.GitUtil;
15
 
import bzr4idea.BzrFileStatus;
 
12
import bzr4idea.BzrContentRevision;
16
13
import bzr4idea.commands.GitHandler;
17
14
import bzr4idea.commands.GitSimpleHandler;
18
15
import org.jetbrains.annotations.NonNls;
21
18
 
22
19
import java.util.*;
23
20
 
24
 
import bzr4idea.BzrException;
 
21
import bzr4idea.*;
25
22
 
26
23
/**
27
24
 * Change related utilities
47
44
   */
48
45
  public static void parseChanges(Project project,
49
46
                                  VirtualFile vcsRoot,
50
 
                                  GitRevisionNumber thisRevision,
51
 
                                  GitRevisionNumber parentRevision,
 
47
                                  BzrRevisionNumber thisRevision,
 
48
                                  BzrRevisionNumber parentRevision,
52
49
                                  String[] lines,
53
50
                                  int startIndex,
54
51
                                  List<Change> changes,
67
64
        case 'A':
68
65
          before = null;
69
66
          status = FileStatus.ADDED;
70
 
          after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
 
67
          after = BzrContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
71
68
          break;
72
69
        case 'U':
73
70
          status = FileStatus.MERGED_WITH_CONFLICTS;
75
72
          if (status == null) {
76
73
            status = FileStatus.MODIFIED;
77
74
          }
78
 
          before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false);
79
 
          after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
 
75
          before = BzrContentRevision.createRevision(vcsRoot, path, parentRevision, project, false);
 
76
          after = BzrContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
80
77
          break;
81
78
        case 'D':
82
79
          status = FileStatus.DELETED;
83
 
          before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true);
 
80
          before = BzrContentRevision.createRevision(vcsRoot, path, parentRevision, project, true);
84
81
          after = null;
85
82
          break;
86
83
        case 'R':
87
84
          status = FileStatus.MODIFIED;
88
 
          before = GitContentRevision.createRevision(vcsRoot, tokens[1], parentRevision, project, true);
89
 
          after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
 
85
          before = BzrContentRevision.createRevision(vcsRoot, tokens[1], parentRevision, project, true);
 
86
          after = BzrContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
90
87
          break;
91
88
        default:
92
89
          throw new VcsException("Unknown file status: " + lines[i]);
211
208
  public static Change changeForStatus(
212
209
                             Project project,
213
210
                             final VirtualFile vcsRoot,
214
 
                             GitRevisionNumber thisRevision,
215
 
                             GitRevisionNumber parentRevision,
 
211
                             BzrRevisionNumber thisRevision,
 
212
                             BzrRevisionNumber parentRevision,
216
213
                             final IBazaarStatus status,
217
214
                             final String previousPath,
218
215
                             final boolean isPreviousDeleted
230
227
             status.contains(BazaarStatusKind.X_BIT_CHANGED)
231
228
    ) {
232
229
      if ( LOG.isDebugEnabled() ) LOG.debug( String.format("Change builder <- '%s' as modified", path ) );
233
 
      before = GitContentRevision.createRevision( vcsRoot, previousPath, parentRevision, project, isPreviousDeleted );
234
 
      after = GitContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
 
230
      before = BzrContentRevision.createRevision( vcsRoot, previousPath, parentRevision, project, isPreviousDeleted );
 
231
      after = BzrContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
235
232
    }
236
233
    else if (status.contains(BazaarStatusKind.CREATED)) {
237
234
      if ( LOG.isDebugEnabled() ) LOG.debug( String.format("Change builder <- '%s' passed as new", path ) );
238
235
      before = null;
239
 
      after = GitContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
 
236
      after = BzrContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
240
237
    }
241
238
    else if (status.contains(BazaarStatusKind.RENAMED)) {
242
239
      if ( LOG.isDebugEnabled() ) LOG.debug( String.format("Change builder <- '%s' as renamed", path ) );
243
 
      before = GitContentRevision.createRevision( vcsRoot, status.getPreviousPath(), parentRevision, project, true );
244
 
      after = GitContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
 
240
      before = BzrContentRevision.createRevision( vcsRoot, status.getPreviousPath(), parentRevision, project, true );
 
241
      after = BzrContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
245
242
    }
246
243
    else if (status.contains(BazaarStatusKind.DELETED)) {
247
244
      if ( LOG.isDebugEnabled() ) LOG.debug( String.format("Change builder <- '%s' as deleted", path ) );
248
 
      before = GitContentRevision.createRevision( vcsRoot, path, parentRevision, project, true );
 
245
      before = BzrContentRevision.createRevision( vcsRoot, path, parentRevision, project, true );
249
246
      after = null;
250
247
    }
251
248
    // @FIXME: (ast) nonfunc, since no way to check if file is missing from bzr status
291
288
   * @throws VcsException if there is a problem with running git
292
289
   */
293
290
  @SuppressWarnings({"SameParameterValue"})
294
 
  public static GitRevisionNumber loadRevision(final Project project, final VirtualFile vcsRoot, @NonNls final String revisionNumber)
 
291
  public static BzrRevisionNumber loadRevision(final Project project, final VirtualFile vcsRoot, @NonNls final String revisionNumber)
295
292
    throws VcsException {
296
293
    GitSimpleHandler handler = new GitSimpleHandler(project, vcsRoot, GitHandler.REV_LIST);
297
294
    handler.addParameters("--timestamp", "--max-count=1", revisionNumber);
301
298
    String output = handler.run();
302
299
    StringTokenizer stk = new StringTokenizer(output, "\n\r \t", false);
303
300
    Date timestamp = GitUtil.parseTimestamp(stk.nextToken());
304
 
    return new GitRevisionNumber(stk.nextToken(), timestamp);
 
301
    return new BzrRevisionNumber(stk.nextToken(), timestamp);
305
302
  }
306
303
 
307
304
  /**
376
373
      else {
377
374
        fullComment = commentBody + "\n\n" + commentSubject;
378
375
      }
379
 
      GitRevisionNumber thisRevision = new GitRevisionNumber(revisionNumber, commitDate);
380
 
      GitRevisionNumber parentRevision = parents.length > 0 ? loadRevision(project, root, parents[0]) : null;
 
376
      BzrRevisionNumber thisRevision = new BzrRevisionNumber(revisionNumber, commitDate);
 
377
      BzrRevisionNumber parentRevision = parents.length > 0 ? loadRevision(project, root, parents[0]) : null;
381
378
      long number = Long.parseLong(revisionNumber.substring(0, 15), 16) << 4 + Integer.parseInt(revisionNumber.substring(15, 16), 16);
382
379
      if (parents.length <= 1) {
383
380
        // This is the first or normal commit with the single parent.