public SvnCommittedChangesProvider(final Project project) { myProject = project; myVcs = SvnVcs.getInstance(myProject); myZipper = new MyZipper(); myConnection = myProject.getMessageBus().connect(); myConnection.subscribe( VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE, new VcsConfigurationChangeListener.DetailedNotification() { public void execute( final Project project, final VirtualFile vcsRoot, final List<CommittedChangeList> cachedList) { ApplicationManager.getApplication() .invokeLater( new Runnable() { public void run() { if (project.isDisposed()) { return; } for (CommittedChangeList committedChangeList : cachedList) { if ((committedChangeList instanceof SvnChangeList) && ((vcsRoot == null) || (vcsRoot.equals( ((SvnChangeList) committedChangeList).getVcsRoot())))) { ((SvnChangeList) committedChangeList).forceReloadCachedInfo(true); } } } }); } }); }
// only refresh might have changed; for branches/roots change, another method is used public MergeCheckResult getState( final WCInfoWithBranches info, final SvnChangeList list, final WCInfoWithBranches.Branch selectedBranch, final String branchPath) { final String currentUrl = info.getRootUrl(); final String branchUrl = selectedBranch.getUrl(); MyCurrentUrlData rootMapping = myState.getCurrentUrlMapping().get(currentUrl); BranchInfo mergeChecker = null; if (rootMapping == null) { rootMapping = new MyCurrentUrlData(); myState.getCurrentUrlMapping().put(currentUrl, rootMapping); } else { mergeChecker = rootMapping.getBranchInfo(branchPath); } if (mergeChecker == null) { mergeChecker = new BranchInfo( SvnVcs.getInstance(myProject), info.getRepoUrl(), branchUrl, currentUrl, info.getTrunkRoot()); rootMapping.addBranchInfo(branchPath, mergeChecker); } return mergeChecker.checkList(list, branchPath); }
public void update(final AnActionEvent e) { final FileGroupInfo fileGroupInfo = new FileGroupInfo(); myHelperAction.setFileIterationListener(fileGroupInfo); myHelperAction.update(e); myGetterStub.setDelegate(fileGroupInfo); if ((e.getPresentation().isEnabled())) { removeAll(); if (myHelperAction.allAreIgnored()) { final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); SvnVcs vcs = SvnVcs.getInstance(project); final Ref<Boolean> filesOk = new Ref<Boolean>(Boolean.FALSE); final Ref<Boolean> extensionOk = new Ref<Boolean>(Boolean.FALSE); // virtual files parameter is not used -> can pass null SvnPropertyService.doCheckIgnoreProperty( vcs, project, null, fileGroupInfo, fileGroupInfo.getExtensionMask(), filesOk, extensionOk); if (Boolean.TRUE.equals(filesOk.get())) { myRemoveExactAction.setActionText( fileGroupInfo.oneFileSelected() ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.UndoIgnore.text")); add(myRemoveExactAction); } if (Boolean.TRUE.equals(extensionOk.get())) { myRemoveExtensionAction.setActionText(fileGroupInfo.getExtensionMask()); add(myRemoveExtensionAction); } e.getPresentation().setText(SvnBundle.message("group.RevertIgnoreChoicesGroup.text")); } else if (myHelperAction.allCanBeIgnored()) { final String ignoreExactlyName = (fileGroupInfo.oneFileSelected()) ? fileGroupInfo.getFileName() : SvnBundle.message("action.Subversion.Ignore.ExactMatch.text"); myAddExactAction.setActionText(ignoreExactlyName); add(myAddExactAction); if (fileGroupInfo.sameExtension()) { myAddExtensionAction.setActionText(fileGroupInfo.getExtensionMask()); add(myAddExtensionAction); } e.getPresentation().setText(SvnBundle.message("group.IgnoreChoicesGroup.text")); } } }
public SvnFormatWorker( final Project project, final WorkingCopyFormat newFormat, final List<WCInfo> wcInfos) { super(project, SvnBundle.message("action.change.wcopy.format.task.title"), false, DEAF); myProject = project; myNewFormat = newFormat; myExceptions = new ArrayList<Throwable>(); myWcInfos = wcInfos; myVcs = SvnVcs.getInstance(myProject); }
private void processDeletedFiles(Project project) { final List<Pair<FilePath, WorkingCopyFormat>> deletedFiles = new ArrayList<Pair<FilePath, WorkingCopyFormat>>(); final Collection<FilePath> filesToProcess = new ArrayList<FilePath>(); List<VcsException> exceptions = new ArrayList<VcsException>(); final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project); try { fillDeletedFiles(project, deletedFiles, filesToProcess); if (deletedFiles.isEmpty() && filesToProcess.isEmpty() || myUndoingMove) return; SvnVcs vcs = SvnVcs.getInstance(project); final VcsShowConfirmationOption.Value value = vcs.getDeleteConfirmation().getValue(); if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) { if (!deletedFiles.isEmpty()) { final Collection<FilePath> confirmed = promptAboutDeletion(deletedFiles, vcs, value, vcsHelper); if (confirmed != null) { filesToProcess.addAll(confirmed); } } if (filesToProcess != null && !filesToProcess.isEmpty()) { runInBackground( project, "Deleting files from Subversion", createDeleteRunnable(project, vcs, filesToProcess, exceptions)); } final List<FilePath> deletedFilesFiles = ObjectsConvertor.convert( deletedFiles, new Convertor<Pair<FilePath, WorkingCopyFormat>, FilePath>() { @Override public FilePath convert(Pair<FilePath, WorkingCopyFormat> o) { return o.getFirst(); } }); for (FilePath file : deletedFilesFiles) { final FilePath parent = file.getParentPath(); if (parent != null) { myFilesToRefresh.add(parent.getVirtualFile()); } } if (filesToProcess != null) { deletedFilesFiles.removeAll(filesToProcess); } for (FilePath file : deletedFilesFiles) { FileUtil.delete(file.getIOFile()); } } } catch (SVNException e) { exceptions.add(new VcsException(e)); } if (!exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title")); } }
@Override public void setUp() throws Exception { super.setUp(); clManager = (ChangeListManagerImpl) ChangeListManager.getInstance(myProject); enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE); myVcs = SvnVcs.getInstance(myProject); myMainUrl = myRepoUrl + "/root/source"; myExternalURL = myRepoUrl + "/root/target"; }
@Test public void testSimpleNotMerged() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE); final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk"); trunk.mkdir(); Thread.sleep(100); final File folder = new File(trunk, "folder"); folder.mkdir(); Thread.sleep(100); final File f1 = new File(folder, "f1.txt"); f1.createNewFile(); new File(folder, "f2.txt").createNewFile(); Thread.sleep(100); verify(runSvn("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk")); verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); FileUtil.delete(trunk); verify(runSvn("co", myRepoUrl + "/trunk", trunk.getAbsolutePath())); verify(runSvn("co", myRepoUrl + "/branch", myBranchVcsRoot.getAbsolutePath())); // rev 3 final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f1); editFileInCommand(myProject, vf, "123\n456\n123"); Thread.sleep(100); verify(runSvn("ci", "-m", "test", trunk.getAbsolutePath())); final SvnVcs vcs = SvnVcs.getInstance(myProject); final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider = vcs.getCommittedChangesProvider(); final List<SvnChangeList> changeListList = committedChangesProvider.getCommittedChanges( committedChangesProvider.createDefaultSettings(), new SvnRepositoryLocation(myRepoUrl + "/trunk"), 0); final SvnChangeList changeList = changeListList.get(0); final BranchInfo branchInfo = new BranchInfo( vcs, myRepoUrl, myRepoUrl + "/branch", myRepoUrl + "/trunk", myRepoUrl + "/trunk", vcs.createWCClient()); final SvnMergeInfoCache.MergeCheckResult result = branchInfo.checkList(changeList, myBranchVcsRoot.getAbsolutePath()); assert SvnMergeInfoCache.MergeCheckResult.NOT_MERGED.equals(result); }
public static SvnAuthenticationManager createForTmpDir( final Project project, final File dir, @Nullable final SvnInteractiveAuthenticationProvider provider) { final SvnVcs vcs = SvnVcs.getInstance(project); final SvnAuthenticationManager interactive = new SvnAuthenticationManager(project, dir); interactive.setRuntimeStorage(RUNTIME_AUTH_CACHE); final SvnInteractiveAuthenticationProvider interactiveProvider = provider == null ? new SvnInteractiveAuthenticationProvider(vcs, interactive) : provider; interactive.setAuthenticationProvider(interactiveProvider); return interactive; }
public QuickMerge( Project project, String sourceUrl, WCInfo wcInfo, final String branchName, final VirtualFile root) { myProject = project; myBranchName = branchName; myRoot = root; myVcs = SvnVcs.getInstance(project); mySourceUrl = sourceUrl; myWcInfo = wcInfo; myTitle = "Merge from " + myBranchName; myContinuation = Continuation.createFragmented(myProject, true); }
public void realRefresh() { final SvnVcs vcs = SvnVcs.getInstance(myProject); final VirtualFile[] roots = myHelper.executeDefended(myProject); final CopiesApplier copiesApplier = new CopiesApplier(); final CopiesDetector copiesDetector = new CopiesDetector( vcs, copiesApplier, new Getter<NestedCopiesData>() { public NestedCopiesData get() { return myTempSink.receive(); } }); // do not send additional request for nested copies when in init state copiesDetector.detectCopyRoots(roots, init()); }
public void conflictResolvedForFile(@NotNull VirtualFile file) { // TODO: Add possibility to resolve content conflicts separately from property conflicts. SvnVcs vcs = SvnVcs.getInstance(myProject); File path = new File(file.getPath()); try { // TODO: Probably false should be passed to "resolveTree", but previous logic used true // implicitly vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true); } catch (VcsException e) { LOG.warn(e); } // the .mine/.r## files have been deleted final VirtualFile parent = file.getParent(); if (parent != null) { parent.refresh(true, false); } }
@Nullable public static SvnBranchConfigurationNew loadDefaultConfiguration( final Project project, final VirtualFile vcsRoot) { try { final SvnVcs vcs = SvnVcs.getInstance(project); File rootFile = new File(vcsRoot.getPath()); final Info info = vcs.getInfo(rootFile); if (info == null || info.getURL() == null) { LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl()); return null; } SVNURL baseUrl = info.getURL(); final SvnBranchConfigurationNew result = new SvnBranchConfigurationNew(); result.setTrunkUrl(baseUrl.toString()); while (true) { final String s = SVNPathUtil.tail(baseUrl.getPath()); if (s.equalsIgnoreCase(DEFAULT_TRUNK_NAME) || s.equalsIgnoreCase(DEFAULT_BRANCHES_NAME) || s.equalsIgnoreCase(DEFAULT_TAGS_NAME)) { SVNURL rootPath = baseUrl.removePathTail(); SvnTarget target = SvnTarget.fromURL(rootPath); vcs.getFactory(target) .createBrowseClient() .list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath)); break; } if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) { break; } baseUrl = baseUrl.removePathTail(); } return result; } catch (SVNException e) { LOG.info(e); return null; } catch (VcsException e) { LOG.info(e); return null; } }
public boolean isBinary(@NotNull final VirtualFile file) { SvnVcs vcs = SvnVcs.getInstance(myProject); try { File ioFile = new File(file.getPath()); PropertyClient client = vcs.getFactory(ioFile).createPropertyClient(); PropertyValue value = client.getProperty( SvnTarget.fromFile(ioFile), SvnPropertyKeys.SVN_MIME_TYPE, false, SVNRevision.WORKING); if (value != null && isBinaryMimeType(value.toString())) { return true; } } catch (VcsException e) { LOG.warn(e); } return false; }
public void run(@NotNull final ProgressIndicator indicator) { ProjectLevelVcsManager.getInstanceChecked(myProject).startBackgroundVcsOperation(); indicator.setIndeterminate(true); final boolean supportsChangelists = myNewFormat.supportsChangelists(); if (supportsChangelists) { myBeforeChangeLists = ChangeListManager.getInstance(myProject).getChangeListsCopy(); } final SVNWCClient wcClient = myVcs.createWCClient(); try { for (WCInfo wcInfo : myWcInfos) { File path = new File(wcInfo.getPath()); if (!wcInfo.isIsWcRoot()) { path = SvnUtil.getWorkingCopyRoot(path); } indicator.setText( SvnBundle.message( "action.change.wcopy.format.task.progress.text", path.getAbsolutePath(), SvnUtil.formatRepresentation(wcInfo.getFormat()), SvnUtil.formatRepresentation(myNewFormat))); try { wcClient.doSetWCFormat(path, myNewFormat.getFormat()); } catch (Throwable e) { myExceptions.add(e); } } } finally { ProjectLevelVcsManager.getInstance(myProject).stopBackgroundVcsOperation(); // to map to native if (supportsChangelists) { SvnVcs.getInstance(myProject).processChangeLists(myBeforeChangeLists); } ApplicationManager.getApplication().getMessageBus().syncPublisher(SvnVcs.WC_CONVERTED).run(); } }
public void checkIfCopyRootWasReported() { if (!myMetCurrentItem && myCurrentItem.isIsInnerCopyRoot()) { myMetCurrentItem = true; final SVNStatus statusInner = SvnUtil.getStatus(SvnVcs.getInstance(myProject), myCurrentItem.getPath().getIOFile()); if (statusInner == null) return; final SVNStatusType status = statusInner.getNodeStatus(); if (SVNStatusType.OBSTRUCTED.equals(status) || SVNStatusType.STATUS_IGNORED.equals(status) || SVNStatusType.STATUS_NONE.equals(status) || SVNStatusType.STATUS_UNVERSIONED.equals(status) || SVNStatusType.UNKNOWN.equals(status)) { return; } if (myCurrentItem.getPath().getVirtualFile() != null) { myReceiver.processCopyRoot( myCurrentItem.getPath().getVirtualFile(), statusInner.getURL(), WorkingCopyFormat.getInstance(statusInner.getWorkingCopyFormat())); } } }
private void fillMapping(final SvnMapping mapping, final List<SvnCopyRootSimple> list) { final LocalFileSystem lfs = LocalFileSystem.getInstance(); for (SvnCopyRootSimple simple : list) { final VirtualFile copyRoot = lfs.findFileByIoFile(new File(simple.myCopyRoot)); final VirtualFile vcsRoot = lfs.findFileByIoFile(new File(simple.myVcsRoot)); if (copyRoot == null || vcsRoot == null) continue; final SvnVcs vcs = SvnVcs.getInstance(myProject); final SVNInfo svnInfo = vcs.getInfo(copyRoot); if ((svnInfo == null) || (svnInfo.getRepositoryRootURL() == null)) continue; final RootUrlInfo info = new RootUrlInfo( svnInfo.getRepositoryRootURL(), svnInfo.getURL(), SvnFormatSelector.getWorkingCopyFormat(svnInfo.getFile()), copyRoot, vcsRoot); mapping.add(info); } }
private void processAddedFiles(Project project) { SvnVcs vcs = SvnVcs.getInstance(project); List<VirtualFile> addedVFiles = new ArrayList<VirtualFile>(); Map<VirtualFile, File> copyFromMap = new HashMap<VirtualFile, File>(); final Set<VirtualFile> recursiveItems = new HashSet<VirtualFile>(); fillAddedFiles(project, vcs, addedVFiles, copyFromMap, recursiveItems); if (addedVFiles.isEmpty()) return; final VcsShowConfirmationOption.Value value = vcs.getAddConfirmation().getValue(); if (value != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) { final AbstractVcsHelper vcsHelper = AbstractVcsHelper.getInstance(project); final Collection<VirtualFile> filesToProcess = promptAboutAddition(vcs, addedVFiles, value, vcsHelper); if (filesToProcess != null && !filesToProcess.isEmpty()) { final List<VcsException> exceptions = new ArrayList<VcsException>(); runInBackground( project, "Adding files to Subversion", createAdditionRunnable(project, vcs, copyFromMap, filesToProcess, exceptions)); if (!exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("add.files.errors.title")); } } } }
private void fillDeletedFiles( Project project, List<Pair<FilePath, WorkingCopyFormat>> deletedFiles, Collection<FilePath> deleteAnyway) throws SVNException { final SvnVcs vcs = SvnVcs.getInstance(project); final Collection<File> files = myDeletedFiles.remove(project); for (final File file : files) { final SVNStatus status = new RepeatSvnActionThroughBusy() { @Override protected void executeImpl() throws SVNException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus()); final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); if (isAdded) { deleteAnyway.add(filePath); } else { deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file))); } } }
protected VirtualFile[] execute(Project project) { return myPlVcsManager.getRootsUnderVcs(SvnVcs.getInstance(project)); }
public CopiesPanel(final Project project) { myProject = project; myConnection = myProject.getMessageBus().connect(myProject); myVcs = SvnVcs.getInstance(myProject); myCurrentInfoList = null; final Runnable focus = new Runnable() { public void run() { IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true); } }; final Runnable refreshView = new Runnable() { public void run() { final List<WCInfo> infoList = myVcs.getAllWcInfos(); if (myCurrentInfoList != null) { final List<OverrideEqualsWrapper<WCInfo>> newList = ObjectsConvertor.convert( infoList, new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() { public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) { return new OverrideEqualsWrapper<WCInfo>( InfoEqualityPolicy.getInstance(), o); } }, ObjectsConvertor.NOT_NULL); if (Comparing.haveEqualElements(newList, myCurrentInfoList)) { myRefreshLabel.setEnabled(true); return; } myCurrentInfoList = newList; } Collections.sort(infoList, WCComparator.getInstance()); updateList(infoList); myRefreshLabel.setEnabled(true); SwingUtilities.invokeLater(focus); } }; myConnection.subscribe( SvnVcs.ROOTS_RELOADED, new Runnable() { public void run() { ApplicationManager.getApplication().invokeLater(refreshView, ModalityState.NON_MODAL); } }); final JPanel holderPanel = new JPanel(new BorderLayout()); FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont()); myTextHeight = (int) (fm.getHeight() * 1.3); myPanel = new JPanel(new GridBagLayout()); final JPanel panel = new JPanel(new BorderLayout()); panel.add(myPanel, BorderLayout.NORTH); holderPanel.add(panel, BorderLayout.WEST); myRefreshLabel = new MyLinkLabel( myTextHeight, "Refresh", new LinkListener() { public void linkSelected(LinkLabel aSource, Object aLinkData) { if (myRefreshLabel.isEnabled()) { myVcs.invokeRefreshSvnRoots(true); myRefreshLabel.setEnabled(false); } } }); myHolder = ScrollPaneFactory.createScrollPane(holderPanel); myHolder.setBorder(null); setFocusableForLinks(myRefreshLabel); refreshView.run(); initView(); }
public static boolean share(final Project project, final VirtualFile file) throws VcsException { return performImpl(project, SvnVcs.getInstance(project), file); }
@Test public void testWhenInfoInRepo() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE); final File fullBranch = new File(myTempDirFixture.getTempDirPath(), "fullBranch"); fullBranch.mkdir(); final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk"); trunk.mkdir(); Thread.sleep(100); final File folder = new File(trunk, "folder"); folder.mkdir(); Thread.sleep(100); final File f1 = new File(folder, "f1.txt"); f1.createNewFile(); // this will be taken as branch wc root final File folder1 = new File(folder, "folder1"); folder1.mkdir(); final File f2 = new File(folder1, "f2.txt"); f2.createNewFile(); Thread.sleep(100); verify(runSvn("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk")); verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); FileUtil.delete(trunk); verify(runSvn("co", myRepoUrl + "/trunk", trunk.getAbsolutePath())); verify(runSvn("co", myRepoUrl + "/branch", fullBranch.getAbsolutePath())); verify(runSvn("co", myRepoUrl + "/branch/folder/folder1", myBranchVcsRoot.getAbsolutePath())); // rev 3 : f2 changed final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f2); editFileInCommand(myProject, vf, "123\n456\n123"); Thread.sleep(100); verify(runSvn("ci", "-m", "test", trunk.getAbsolutePath())); // rev 4: record as merged into branch using full branch WC verify( runSvn( "merge", "-c", "3", myRepoUrl + "/trunk", fullBranch.getAbsolutePath(), "--record-only")); Thread.sleep(100); verify(runSvn("ci", "-m", "test", fullBranch.getAbsolutePath())); Thread.sleep(100); verify(runSvn("up", myBranchVcsRoot.getAbsolutePath())); final SvnVcs vcs = SvnVcs.getInstance(myProject); final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider = vcs.getCommittedChangesProvider(); final List<SvnChangeList> changeListList = committedChangesProvider.getCommittedChanges( committedChangesProvider.createDefaultSettings(), new SvnRepositoryLocation(myRepoUrl + "/trunk"), 0); final SvnChangeList changeList3 = changeListList.get(0); assert changeList3.getNumber() == 3; final String encodedRepoUrl = SVNURL.parseURIDecoded(myRepoUrl).toString(); final BranchInfo branchInfo = new BranchInfo( vcs, encodedRepoUrl, encodedRepoUrl + "/branch", encodedRepoUrl + "/trunk", encodedRepoUrl + "/trunk", vcs.createWCClient()); SvnMergeInfoCache.MergeCheckResult result = branchInfo.checkList(changeList3, myBranchVcsRoot.getAbsolutePath()); assert SvnMergeInfoCache.MergeCheckResult.MERGED.equals(result); }
@Test public void testSimpleMerged() throws Exception { enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD); enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE); final File trunk = new File(myTempDirFixture.getTempDirPath(), "trunk"); trunk.mkdir(); Thread.sleep(100); final File folder = new File(trunk, "folder"); folder.mkdir(); Thread.sleep(100); final File f1 = new File(folder, "f1.txt"); f1.createNewFile(); new File(folder, "f2.txt").createNewFile(); Thread.sleep(100); verify(runSvn("import", "-m", "test", trunk.getAbsolutePath(), myRepoUrl + "/trunk")); verify(runSvn("copy", "-m", "test", myRepoUrl + "/trunk", myRepoUrl + "/branch")); FileUtil.delete(trunk); verify(runSvn("co", myRepoUrl + "/trunk", trunk.getAbsolutePath())); verify(runSvn("co", myRepoUrl + "/branch", myBranchVcsRoot.getAbsolutePath())); // rev 3 final VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(f1); editFileInCommand(myProject, vf, "123\n456\n123"); Thread.sleep(100); verify(runSvn("ci", "-m", "test", trunk.getAbsolutePath())); // rev 4: record as merged into branch verify( runSvn( "merge", "-c", "3", myRepoUrl + "/trunk", myBranchVcsRoot.getAbsolutePath(), "--record-only")); Thread.sleep(100); verify(runSvn("ci", "-m", "test", myBranchVcsRoot.getAbsolutePath())); Thread.sleep(100); verify(runSvn("up", myBranchVcsRoot.getAbsolutePath())); final SvnVcs vcs = SvnVcs.getInstance(myProject); final SVNWCClient wcClient = vcs.createWCClient(); final SVNPropertyData data = wcClient.doGetProperty( myBranchVcsRoot, "svn:mergeinfo", SVNRevision.UNDEFINED, SVNRevision.WORKING); assert data != null && data.getValue() != null && "/trunk:3".equals(data.getValue().getString()); final CommittedChangesProvider<SvnChangeList, ChangeBrowserSettings> committedChangesProvider = vcs.getCommittedChangesProvider(); final List<SvnChangeList> changeListList = committedChangesProvider.getCommittedChanges( committedChangesProvider.createDefaultSettings(), new SvnRepositoryLocation(myRepoUrl + "/trunk"), 0); final SvnChangeList changeList = changeListList.get(0); final String encodedRepoUrl = SVNURL.parseURIDecoded(myRepoUrl).toString(); final BranchInfo branchInfo = new BranchInfo( vcs, encodedRepoUrl, encodedRepoUrl + "/branch", encodedRepoUrl + "/trunk", encodedRepoUrl + "/trunk", vcs.createWCClient()); final SvnMergeInfoCache.MergeCheckResult result = branchInfo.checkList(changeList, myBranchVcsRoot.getAbsolutePath()); assert SvnMergeInfoCache.MergeCheckResult.MERGED.equals(result); }
public AbstractVcs getVcs(Project project) { return SvnVcs.getInstance(project); }
public void execute() { ApplicationManager.getApplication().saveAll(); chanceToFillRoots(); if (myRoots.length == 0) return; final List<Pair<VcsException, VirtualFile>> exceptions = new LinkedList<Pair<VcsException, VirtualFile>>(); final SvnVcs vcs = SvnVcs.getInstance(myProject); final Task.Backgroundable task = new Task.Backgroundable( myProject, SvnBundle.message(myTitleKey), true, BackgroundFromStartOption.getInstance()) { public void run(@NotNull final ProgressIndicator indicator) { indicator.setIndeterminate(true); VirtualFile currentRoot; for (VirtualFile root : myRoots) { currentRoot = root; try { final File path = new File(root.getPath()); indicator.setText( SvnBundle.message("action.Subversion.cleanup.progress.text", path)); ISVNEventHandler handler = new ISVNEventHandler() { @Override public void handleEvent(SVNEvent event, double progress) throws SVNException {} @Override public void checkCancelled() throws SVNCancelException { if (indicator.isCanceled()) throw new SVNCancelException(); } }; vcs.getFactory(path).createCleanupClient().cleanup(path, handler); } catch (VcsException ex) { exceptions.add(Pair.create(ex, currentRoot)); } } } @Override public void onCancel() { onSuccess(); } @Override public void onSuccess() { if (myProject.isDisposed()) { return; } final VcsDirtyScopeManager manager = VcsDirtyScopeManager.getInstance(myProject); ApplicationManager.getApplication() .invokeLater( new Runnable() { public void run() { ApplicationManager.getApplication() .runWriteAction( new Runnable() { public void run() { if (myProject.isDisposed()) { return; } for (final VirtualFile root : myRoots) { root.refresh(false, true); } } }); } }); for (final VirtualFile root : myRoots) { if (root.isDirectory()) { manager.dirDirtyRecursively(root); } else { manager.fileDirty(root); } } if (!exceptions.isEmpty()) { final List<VcsException> vcsExceptions = new LinkedList<VcsException>(); for (Pair<VcsException, VirtualFile> pair : exceptions) { final VcsException exception = pair.first; vcsExceptions.add( new VcsException( SvnBundle.message( "action.Subversion.cleanup.error.message", FileUtil.toSystemDependentName(pair.second.getPath()), ((exception == null) ? "" : exception.getMessage())))); } final AbstractVcsHelper helper = AbstractVcsHelper.getInstance(myProject); helper.showErrors(vcsExceptions, SvnBundle.message(myTitleKey)); } } }; ProgressManager.getInstance().run(task); }
public CopiesPanel(final Project project) { myProject = project; myConnection = myProject.getMessageBus().connect(myProject); myVcs = SvnVcs.getInstance(myProject); myCurrentInfoList = null; final Runnable focus = new Runnable() { @Override public void run() { IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true); } }; final Runnable refreshView = new Runnable() { @Override public void run() { final List<WCInfo> infoList = myVcs.getWcInfosWithErrors(); final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty(); final List<WorkingCopyFormat> supportedFormats = getSupportedFormats(); Runnable runnable = new Runnable() { @Override public void run() { if (myCurrentInfoList != null) { final List<OverrideEqualsWrapper<WCInfo>> newList = ObjectsConvertor.convert( infoList, new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() { @Override public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) { return new OverrideEqualsWrapper<WCInfo>( InfoEqualityPolicy.getInstance(), o); } }, ObjectsConvertor.NOT_NULL); if (Comparing.haveEqualElements(newList, myCurrentInfoList)) { myRefreshLabel.setEnabled(true); return; } myCurrentInfoList = newList; } Collections.sort(infoList, WCComparator.getInstance()); updateList(infoList, supportedFormats); myRefreshLabel.setEnabled(true); showErrorNotification(hasErrors); SwingUtilities.invokeLater(focus); } }; ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL); } }; final Consumer<Boolean> refreshOnPooled = new Consumer<Boolean>() { @Override public void consume(Boolean somethingNew) { if (Boolean.TRUE.equals(somethingNew)) { if (ApplicationManager.getApplication().isUnitTestMode()) { refreshView.run(); } else { ApplicationManager.getApplication().executeOnPooledThread(refreshView); } } else { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { myRefreshLabel.setEnabled(true); } }, ModalityState.NON_MODAL); } } }; myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled); final JPanel holderPanel = new JPanel(new BorderLayout()); FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont()); myTextHeight = (int) (fm.getHeight() * 1.3); myPanel = new JPanel(new GridBagLayout()); final JPanel panel = new JPanel(new BorderLayout()); panel.add(myPanel, BorderLayout.NORTH); holderPanel.add(panel, BorderLayout.WEST); myRefreshLabel = new MyLinkLabel( myTextHeight, "Refresh", new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { if (myRefreshLabel.isEnabled()) { myVcs.invokeRefreshSvnRoots(); myRefreshLabel.setEnabled(false); } } }); final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel); myHolder = pane; final JScrollBar vBar = pane.getVerticalScrollBar(); vBar.setBlockIncrement(vBar.getBlockIncrement() * 5); vBar.setUnitIncrement(vBar.getUnitIncrement() * 5); myHolder.setBorder(null); setFocusableForLinks(myRefreshLabel); refreshOnPooled.consume(true); initView(); }