本文整理汇总了Java中com.intellij.vcsUtil.VcsUtil类的典型用法代码示例。如果您正苦于以下问题:Java VcsUtil类的具体用法?Java VcsUtil怎么用?Java VcsUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VcsUtil类属于com.intellij.vcsUtil包,在下文中一共展示了VcsUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testKeepOneUnderRenamed
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Test
public void testKeepOneUnderRenamed() throws Exception {
final SubTree tree = new SubTree(myWorkingCopyDir);
checkin();
final File was2 = new File(tree.myS2File.getPath());
final String editedText = "s1 edited";
VcsTestUtil.editFileInCommand(myProject, tree.myS1File, editedText);
VcsTestUtil.editFileInCommand(myProject, tree.myS2File, "s2 edited");
VcsTestUtil.renameFileInCommand(myProject, tree.mySourceDir, "renamed");
myDirtyScopeManager.markEverythingDirty();
myChangeListManager.ensureUpToDate(false);
final Change dirChange = assertRenamedChange(tree.mySourceDir);
final Change s1Change = assertMovedChange(tree.myS1File);
final Change s2Change = assertMovedChange(tree.myS2File);
final FilePath fp = VcsUtil.getFilePath(was2, false);
rollbackIMpl(Arrays.asList(dirChange, s1Change), Arrays.asList(new Change(
new SimpleContentRevision("1", fp, "1"), new SimpleContentRevision("1", fp, SVNRevision.WORKING.getName()))));
}
示例2: updateEverything
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
/**
* Based on the selected option and entered path to the target directory,
* enable/disable the 'OK' button, show error text and update mySelectedDir.
*/
private void updateEverything() {
if (myShowDialog && myCreateRepositoryForTheRadioButton.isSelected()) {
enableOKAction();
mySelectedDir = myProject.getBaseDir();
} else {
final VirtualFile vf = VcsUtil.getVirtualFile(myTextFieldBrowser.getText());
if (vf == null) {
disableOKAction();
mySelectedDir = null;
return;
}
vf.refresh(false, false);
if (vf.exists() && vf.isValid() && vf.isDirectory()) {
enableOKAction();
mySelectedDir = vf;
} else {
disableOKAction();
mySelectedDir = null;
}
}
}
示例3: getRevision
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Nullable
private static VcsRevisionNumber getRevision(final ProjectLevelVcsManager vcsManager, final UpdatedFile file) {
final String vcsName = file.getVcsName();
final String revision = file.getRevision();
if (vcsName != null && revision != null) {
AbstractVcs vcs = vcsManager.findVcsByName(vcsName);
if (vcs != null) {
try {
return vcs.parseRevisionNumber(revision, VcsUtil.getFilePath(file.getPath()));
}
catch (VcsException e) {
//
}
}
}
return null;
}
示例4: beforeFileDeletion
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Override
public void beforeFileDeletion(@NotNull final VirtualFileEvent event) {
final VirtualFile file = event.getFile();
if (isEventIgnored(event, true)) {
return;
}
if (!myChangeListManager.isIgnoredFile(file)) {
addFileToDelete(file);
return;
}
// files are ignored, directories are handled recursively
if (event.getFile().isDirectory()) {
final List<VirtualFile> list = new LinkedList<VirtualFile>();
VcsUtil.collectFiles(file, list, true, isDirectoryVersioningSupported());
for (VirtualFile child : list) {
if (!myChangeListManager.isIgnoredFile(child)) {
addFileToDelete(child);
}
}
}
}
示例5: testDeleteDirRecursively
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Test
public void testDeleteDirRecursively() throws Exception {
GuiUtils.runOrInvokeAndWait(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
final VirtualFile dir = myProjectRoot.findChild("dir");
myDirtyScope.addDirtyDirRecursively(VcsUtil.getFilePath(dir));
FileUtil.delete(VfsUtilCore.virtualToIoFile(dir));
}
});
}
});
assertChanges(new VirtualFile[] { dir_ctxt, subdir_dtxt },
new FileStatus[] { DELETED, DELETED });
}
示例6: isEnabled
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
protected boolean isEnabled(VcsContext context) {
VirtualFile[] selectedFiles = context.getSelectedFiles();
if (selectedFiles == null) return false;
if (selectedFiles.length == 0) return false;
VirtualFile file = selectedFiles[0];
Project project = context.getProject();
if (project == null) return false;
final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
final BackgroundableActionEnabledHandler handler =
vcsManager.getBackgroundableActionHandler(VcsBackgroundableActions.HISTORY_FOR_SELECTION);
if (handler.isInProgress(VcsBackgroundableActions.keyFrom(file))) return false;
AbstractVcs vcs = vcsManager.getVcsFor(file);
if (vcs == null) return false;
VcsHistoryProvider vcsHistoryProvider = vcs.getVcsBlockHistoryProvider();
if (vcsHistoryProvider == null) return false;
if (! AbstractVcs.fileInVcsByFileStatus(project, VcsUtil.getFilePath(file))) return false;
VcsSelection selection = VcsSelectionUtil.getSelection(context);
if (selection == null) {
return false;
}
return true;
}
示例7: getFile
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Nullable
@Override
protected VirtualFile getFile(@NotNull AnActionEvent e) {
VcsFileRevision revision = getFileRevision(e);
if (revision == null) return null;
final FileType currentFileType = myAnnotation.getFile().getFileType();
FilePath filePath =
(revision instanceof VcsFileRevisionEx ? ((VcsFileRevisionEx)revision).getPath() : VcsUtil.getFilePath(myAnnotation.getFile()));
return new VcsVirtualFile(filePath.getPath(), revision, VcsFileSystem.getInstance()) {
@NotNull
@Override
public FileType getFileType() {
FileType type = super.getFileType();
if (!type.isBinary()) return type;
if (!currentFileType.isBinary()) return currentFileType;
return PlainTextFileType.INSTANCE;
}
};
}
示例8: getLastRevision
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Nullable
public ItemLatestState getLastRevision(VirtualFile file) {
if (file.isDirectory()) {
return null;
}
if (!ourGoodStatuses.contains(myStatusManager.getStatus(file))) {
return null;
}
try {
return GitHistoryUtils.getLastRevision(myProject, VcsUtil.getFilePath(file.getPath()));
}
catch (VcsException e) {
return null;
}
}
示例9: setNewBase
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
public void setNewBase(final VirtualFile base) {
myBase = base;
myNewContentRevision = null;
myCurrentRevision = null;
myConflicts = null;
final String beforeName = myPatch.getBeforeName();
if (beforeName != null) {
myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), beforeName);
myCurrentBase = myIoCurrentBase == null ? null : VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
myBaseExists = (myCurrentBase != null) && myCurrentBase.exists();
}
else {
// creation
final String afterName = myPatch.getAfterName();
myBaseExists = true;
myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), afterName);
myCurrentBase = VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
}
}
示例10: processGroup
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
private boolean processGroup(final FileGroup group, final List<IncomingChangeListData> incomingData,
final ReceivedChangeListTracker tracker) {
boolean haveUnaccountedUpdatedFiles = false;
final List<Pair<String,VcsRevisionNumber>> list = group.getFilesAndRevisions(myVcsManager);
for(Pair<String, VcsRevisionNumber> pair: list) {
final String file = pair.first;
FilePath path = VcsUtil.getFilePath(file, false);
if (!path.isUnder(myRootPath, false) || pair.second == null) {
continue;
}
if (group.getId().equals(FileGroup.REMOVED_FROM_REPOSITORY_ID)) {
haveUnaccountedUpdatedFiles |= processDeletedFile(path, incomingData, tracker);
}
else {
haveUnaccountedUpdatedFiles |= processFile(path, pair.second, incomingData, tracker);
}
}
for(FileGroup childGroup: group.getChildren()) {
haveUnaccountedUpdatedFiles |= processGroup(childGroup, incomingData, tracker);
}
return haveUnaccountedUpdatedFiles;
}
示例11: createFileContent
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
public ContentRevision createFileContent(VcsRevisionNumber revisionNumber, VirtualFile file) {
if (file == null) {
return null;
}
VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, file);
if (vcsRoot == null) {
return null;
}
HgRevisionNumber hgRevisionNumber = (HgRevisionNumber) revisionNumber;
if (hgRevisionNumber.isWorkingVersion()) {
throw new IllegalStateException("Should not compare against working copy");
}
HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
return HgContentRevision.create(project, hgFile, hgRevisionNumber);
}
示例12: performMoveRename
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
@Override
protected void performMoveRename(List<MovedFileInfo> movedFiles) {
(new VcsBackgroundTask<MovedFileInfo>(myProject,
HgVcsMessages.message("hg4idea.move.progress"),
VcsConfiguration.getInstance(myProject).getAddRemoveOption(),
movedFiles) {
protected void process(final MovedFileInfo file) throws VcsException {
final FilePath source = VcsUtil.getFilePath(file.myOldPath);
final FilePath target = VcsUtil.getFilePath(file.myNewPath);
VirtualFile sourceRoot = VcsUtil.getVcsRootFor(myProject, source);
VirtualFile targetRoot = VcsUtil.getVcsRootFor(myProject, target);
if (sourceRoot != null && targetRoot != null) {
(new HgMoveCommand(myProject)).execute(new HgFile(sourceRoot, source), new HgFile(targetRoot, target));
}
dirtyScopeManager.fileDirty(source);
dirtyScopeManager.fileDirty(target);
}
}).queue();
}
示例13: add
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
/**
* For the given VirtualFile constructs a FilePathImpl object without referring to the initial VirtualFile object
* and adds this FilePathImpl to the set of files for proper VcsDirtyScopeManager - to mark these files dirty
* when the set will be populated.
* @param file file which path is to be added.
* @param addToFiles If true, then add to dirty files even if it is a directory. Otherwise add to the proper set.
*/
private void add(VirtualFile file, boolean addToFiles) {
if (file == null) { return; }
final boolean isDirectory = file.isDirectory();
FilePath path = VcsUtil.getFilePath(file.getPath(), isDirectory);
final Collection<VcsDirtyScopeManager> managers = getManagers(file);
for (VcsDirtyScopeManager manager : managers) {
Couple<HashSet<FilePath>> filesAndDirs = map.get(manager);
if (filesAndDirs == null) {
filesAndDirs = Couple.of(new HashSet<FilePath>(), new HashSet<FilePath>());
map.put(manager, filesAndDirs);
}
if (addToFiles || !isDirectory) {
filesAndDirs.first.add(path);
} else {
filesAndDirs.second.add(path);
}
}
}
示例14: check
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
public boolean check() throws IOException {
final String[] pieces = RelativePathCalculator.split(myAfterName);
final VirtualFile parent = makeSureParentPathExists(pieces);
if (parent == null) {
setErrorMessage(fileNotFoundMessage(myAfterName));
return false;
}
String name = pieces[pieces.length - 1];
File afterFile = new File(parent.getPath(), name);
//if user already accepted overwriting, we shouldn't have created a new one
final VirtualFile file = myDelayedPrecheckContext.getOverridenPaths().contains(VcsUtil.getFilePath(afterFile))
? parent.findChild(name)
: createFile(parent, name);
if (file == null) {
setErrorMessage(fileNotFoundMessage(myAfterName));
return false;
}
myAddedPaths.add(VcsUtil.getFilePath(file));
if (! checkExistsAndValid(file, myAfterName)) {
return false;
}
addPatch(myPatch, file);
return true;
}
示例15: updateExpectAuthCanceled
import com.intellij.vcsUtil.VcsUtil; //导入依赖的package包/类
private void updateExpectAuthCanceled(File wc1, String expectedText) {
Assert.assertTrue(wc1.isDirectory());
final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(wc1);
final UpdatedFiles files = UpdatedFiles.create();
final UpdateSession session =
myVcs.getUpdateEnvironment().updateDirectories(new FilePath[]{VcsUtil.getFilePath(vf)}, files, new EmptyProgressIndicator(),
new Ref<SequentialUpdatesContext>());
Assert.assertTrue(session.getExceptions() != null && ! session.getExceptions().isEmpty());
Assert.assertTrue(!session.isCanceled());
Assert.assertTrue(session.getExceptions().get(0).getMessage().contains(expectedText));
if (myIsSecure) {
++ myExpectedCreds;
++ myExpectedCert;
}
}