Java Code Examples for com.intellij.openapi.vcs.history.VcsRevisionNumber#Int
The following examples show how to use
com.intellij.openapi.vcs.history.VcsRevisionNumber#Int .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: P4RemoteFileContentRevision.java From p4ic4idea with Apache License 2.0 | 6 votes |
public static P4RemoteFileContentRevision delayCreation(@NotNull final Project project, @NotNull P4RemoteFile file, @Nullable FilePath path, @NotNull VcsRevisionNumber.Int rev, @Nullable HistoryContentLoader loader, @Nullable Charset charset) { return new P4RemoteFileContentRevision(file, path == null ? new RemoteFilePath(file.getDisplayName(), false) : path, rev, loader, charset, () -> { ProjectConfigRegistry reg = ProjectConfigRegistry.getInstance(project); if (reg == null) { return null; } ClientConfigRoot config = reg.getClientFor(path); if (config == null) { return null; } return config.getClientConfig(); }); }
Example 2
Source File: P4FileRevisionStore.java From p4ic4idea with Apache License 2.0 | 6 votes |
@NotNull public static P4FileRevision read(@NotNull State state) { return new P4FileRevisionImpl( P4RemoteFileStore.read(state.remoteFile), P4ChangelistIdStore.read(state.changelistId), new P4Revision(state.rev), state.action, P4FileType.convert(state.type), P4RemoteFileStore.readNullable(state.integratedFrom), state.revisionNumber < 0 ? null : new VcsRevisionNumber.Int(state.revisionNumber), state.date < 0 ? null : new Date(state.date), state.charset ); }
Example 3
Source File: TFSDiffProvider.java From azure-devops-intellij with MIT License | 5 votes |
private int getChangeset(final VcsRevisionNumber vcsRevisionNumber) { if (vcsRevisionNumber instanceof VcsRevisionNumber.Int) { final VcsRevisionNumber.Int revisionNumber = (VcsRevisionNumber.Int) vcsRevisionNumber; return revisionNumber.getValue(); } return 0; }
Example 4
Source File: P4Vcs.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override @Nullable public VcsRevisionNumber parseRevisionNumber(String revisionNumberString) throws VcsException { try { return new VcsRevisionNumber.Int(Integer.parseInt(revisionNumberString)); } catch (NumberFormatException e) { throw new VcsException(e); } }
Example 5
Source File: AbstractP4FileContentRevision.java From p4ic4idea with Apache License 2.0 | 5 votes |
AbstractP4FileContentRevision( @NotNull FilePath filePath, @NotNull String serverFilePath, @NotNull VcsRevisionNumber.Int rev, @Nullable HistoryContentLoader loader, @Nullable Charset charset) { this.filePath = filePath; this.serverFilePath = serverFilePath; this.loader = loader; this.charset = ContentRevisionUtil.getNonNullCharset(charset); this.rev = rev; }
Example 6
Source File: P4RemoteFileContentRevision.java From p4ic4idea with Apache License 2.0 | 5 votes |
public static P4RemoteFileContentRevision create(@NotNull P4RemoteFile file, @NotNull FilePath path, @NotNull VcsRevisionNumber.Int rev, @NotNull ClientConfig clientConfig, @Nullable HistoryContentLoader loader, @Nullable Charset charset) { return new P4RemoteFileContentRevision(file, path, rev, loader, charset, () -> clientConfig); }
Example 7
Source File: P4RemoteFileContentRevision.java From p4ic4idea with Apache License 2.0 | 5 votes |
private P4RemoteFileContentRevision( @NotNull P4RemoteFile file, @NotNull FilePath path, @NotNull VcsRevisionNumber.Int rev, @Nullable HistoryContentLoader loader, @Nullable Charset charset, @NotNull Supplier<ClientConfig> clientConfigFactory) { super(path, file.getDepotPath(), rev, loader, charset); this.file = file; this.clientConfigFactory = clientConfigFactory; }
Example 8
Source File: TfsFileRevision.java From azure-devops-intellij with MIT License | 4 votes |
@Override public VcsRevisionNumber getRevisionNumber() { return new VcsRevisionNumber.Int(changeset); }
Example 9
Source File: P4CommittedChangesProvider.java From p4ic4idea with Apache License 2.0 | 4 votes |
private P4RemoteFileContentRevision readContentRevision(DataInput dataInput) throws IOException { // 1. Is "revision" set - int int isSet = dataInput.readInt(); if (isSet == 1) { // 2. depot file // 2.a. path - utf String depotPath = dataInput.readUTF(); // 2.b. display name - utf String depotDisplayName = dataInput.readUTF(); // 2.c. is local path non-null - int String localPath; int hasLocalPath = dataInput.readInt(); if (hasLocalPath == 0) { localPath = null; } else { // 2.c.i. local path - utf localPath = dataInput.readUTF(); } P4RemoteFile file = new P4RemoteFileImpl(depotPath, depotDisplayName, localPath); // 3. file path FilePath path; // 3.a. is file path used - int int hasFilePath = dataInput.readInt(); if (hasFilePath == 0) { path = null; } else { // 3.a.i. file path - utf path = VcsUtil.getFilePath(dataInput.readUTF()); } // 4. Revision - int VcsRevisionNumber.Int rev = new VcsRevisionNumber.Int(dataInput.readInt()); // 5. Charset - utf Charset charset = Charset.forName(dataInput.readUTF()); return P4RemoteFileContentRevision.delayCreation(project, file, path, rev, loader, charset); } else { return null; } }
Example 10
Source File: P4DiffProvider.java From p4ic4idea with Apache License 2.0 | 4 votes |
@Nullable @Override public ContentRevision createFileContent(final VcsRevisionNumber revisionNumber, VirtualFile selectedFile) { FilePath local = VcsUtil.getFilePath(selectedFile); final ClientConfigRoot root = getRootFor(local); if (root == null) { if (LOG.isDebugEnabled()) { LOG.debug("Not under perforce root: " + selectedFile); } return null; } String clientName = root.getClientConfig().getClientname(); if (clientName == null) { if (LOG.isDebugEnabled()) { LOG.debug("No client for perforce file: " + selectedFile); } return null; } final VcsRevisionNumber.Int iRev; if (revisionNumber instanceof VcsRevisionNumber.Int) { iRev = (VcsRevisionNumber.Int) revisionNumber; } else { iRev = new VcsRevisionNumber.Int(IFileSpec.HEAD_REVISION); } if (LOG.isDebugEnabled()) { LOG.debug("Generating file content for " + selectedFile + " rev " + iRev); } return new ContentRevision() { @Nullable @Override public String getContent() throws VcsException { try { if (LOG.isDebugEnabled()) { LOG.debug("Loading file content for " + local + " rev " + iRev); } return loader.loadStringContentForLocal( root.getClientConfig(), local, iRev.getValue()); } catch (IOException e) { LOG.info("Problem loading file content for " + local + " rev " + iRev, e); throw new VcsException(e); } } @NotNull @Override public FilePath getFile() { return local; } @NotNull @Override public VcsRevisionNumber getRevisionNumber() { return revisionNumber; } }; }
Example 11
Source File: P4AnnotationProvider.java From p4ic4idea with Apache License 2.0 | 4 votes |
@NotNull @Override public FileAnnotation annotate(@NotNull VirtualFile file, VcsFileRevision revision) throws VcsException { if (ApplicationManager.getApplication().isDispatchThread()) { LOG.info("Fetching annotation from the EDT"); // TODO bundle for error messages throw new VcsException("Does not support fetching annotations from the EDT."); } // TODO use a better location for this constant. int rev = IFileSpec.HEAD_REVISION; if (revision != null) { VcsRevisionNumber revNumber = revision.getRevisionNumber(); if (revNumber instanceof VcsRevisionNumber.Int) { rev = ((VcsRevisionNumber.Int) revNumber).getValue(); } else { LOG.warn("Unknown file revision " + revision + " for " + file + "; using head revision"); } } FilePath fp = VcsUtil.getFilePath(file); if (fp == null) { // TODO bundle for error messages throw new VcsException("No known Perforce server for " + file); } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null) { // TODO bundle for error messages throw new VcsException("Project not configured for showing annotations"); } ClientConfigRoot client = registry.getClientFor(file); if (client == null) { // TODO bundle for error messages throw new VcsException("No known Perforce server for " + file); } String clientname = client.getClientConfig().getClientname(); if (clientname == null) { // TODO bundle for error messages throw new VcsException("No workspace name set for Perforce connection for " + file); } try { return new P4AnnotatedFileImpl(project, fp, messageFormatter, contentLoader, P4ServerComponent .query(project, client.getClientConfig(), new AnnotateFileQuery(fp, rev)) .blockingGet(UserProjectPreferences.getLockWaitTimeoutMillis(project), TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { throw new VcsInterruptedException(e); } }
Example 12
Source File: P4HistoryProvider.java From p4ic4idea with Apache License 2.0 | 4 votes |
@Override public void reportAppendableHistory(@NotNull FilePath path, @Nullable VcsRevisionNumber startingRevision, @NotNull VcsAppendableHistorySessionPartner partner) { partner.reportCreatedEmptySession(createAppendableSession( path, Collections.emptyList(), null)); ClientConfigRoot root = getRootFor(path); if (root == null) { LOG.warn("File not under vcs: " + path); // TODO bundle message partner.reportException(new VcsException("File not under VCS: " + path)); partner.finished(); return; } final int startingRev; if (startingRevision instanceof VcsRevisionNumber.Int) { startingRev = ((VcsRevisionNumber.Int) startingRevision).getValue(); } else { startingRev = 0; if (startingRevision != null) { LOG.warn("Requested reportAppendableHistory with unexpected type " + startingRevision + " (" + startingRevision.getClass() + ")"); } } // Async operation getHistory(root, path, -1) .whenCompleted((r) -> r.getRevisions(formatter, loader).forEach((rev) -> { VcsRevisionNumber rn = rev.getRevisionNumber(); if (rn instanceof VcsRevisionNumber.Int) { VcsRevisionNumber.Int rni = (VcsRevisionNumber.Int) rn; if (rni.getValue() >= startingRev) { partner.acceptRevision(rev); } } else { LOG.warn("VcsFileRevision returned unexpected revision number " + rn + " (" + rn.getClass() + ")"); } }) ) .whenServerError(partner::reportException) .whenAnyState(partner::finished); }
Example 13
Source File: AbstractP4FileContentRevision.java From p4ic4idea with Apache License 2.0 | 4 votes |
@NotNull public VcsRevisionNumber.Int getIntRevisionNumber() { return rev; }
Example 14
Source File: MockAbstractVcs.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nullable public VcsRevisionNumber parseRevisionNumber(final String revisionNumberString) { return new VcsRevisionNumber.Int(Integer.parseInt(revisionNumberString)); }