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;
48
45
public static void parseChanges(Project project,
49
46
VirtualFile vcsRoot,
50
GitRevisionNumber thisRevision,
51
GitRevisionNumber parentRevision,
47
BzrRevisionNumber thisRevision,
48
BzrRevisionNumber parentRevision,
54
51
List<Change> changes,
69
66
status = FileStatus.ADDED;
70
after = GitContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
67
after = BzrContentRevision.createRevision(vcsRoot, path, thisRevision, project, false);
73
70
status = FileStatus.MERGED_WITH_CONFLICTS;
75
72
if (status == null) {
76
73
status = FileStatus.MODIFIED;
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);
82
79
status = FileStatus.DELETED;
83
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true);
80
before = BzrContentRevision.createRevision(vcsRoot, path, parentRevision, project, true);
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);
92
89
throw new VcsException("Unknown file status: " + lines[i]);
211
208
public static Change changeForStatus(
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)
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 );
236
233
else if (status.contains(BazaarStatusKind.CREATED)) {
237
234
if ( LOG.isDebugEnabled() ) LOG.debug( String.format("Change builder <- '%s' passed as new", path ) );
239
after = GitContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
236
after = BzrContentRevision.createRevision( vcsRoot, path, thisRevision, project, false );
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 );
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 );
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
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);
377
374
fullComment = commentBody + "\n\n" + commentSubject;
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.