public void checkForOutsideCopies() { boolean canceled = false; for (Iterator<WCInfo> iterator = myWcInfos.iterator(); iterator.hasNext(); ) { final WCInfo wcInfo = iterator.next(); if (!wcInfo.isIsWcRoot()) { File path = new File(wcInfo.getPath()); path = SvnUtil.getWorkingCopyRoot(path); int result = Messages.showYesNoCancelDialog( SvnBundle.message("upgrade.format.clarify.for.outside.copies.text", path), SvnBundle.message("action.change.wcopy.format.task.title"), Messages.getWarningIcon()); if (DialogWrapper.CANCEL_EXIT_CODE == result) { canceled = true; break; } else if (DialogWrapper.OK_EXIT_CODE != result) { // no - for this copy only. maybe other iterator.remove(); } } } if (canceled) { myWcInfos.clear(); } }
private void changeFormat( @NotNull final WCInfo wcInfo, @NotNull final Collection<WorkingCopyFormat> supportedFormats) { ChangeFormatDialog dialog = new ChangeFormatDialog(myProject, new File(wcInfo.getPath()), false, !wcInfo.isIsWcRoot()); dialog.setSupported(supportedFormats); dialog.setData(wcInfo.getFormat()); dialog.show(); if (!dialog.isOK()) { return; } final WorkingCopyFormat newFormat = dialog.getUpgradeMode(); if (!wcInfo.getFormat().equals(newFormat)) { ApplicationManager.getApplication().saveAll(); final Task.Backgroundable task = new SvnFormatWorker(myProject, newFormat, wcInfo) { @Override public void onSuccess() { super.onSuccess(); myRefreshLabel.doClick(); } }; ProgressManager.getInstance().run(task); } }
public int getHashCode(WCInfo value) { final HashCodeBuilder builder = new HashCodeBuilder(); builder.append(value.getPath()); builder.append(value.getUrl()); builder.append(value.getFormat()); builder.append(value.getType()); builder.append(value.getStickyDepth()); return builder.getCode(); }
private void insertMergeAll(final List<TaskDescriptor> queue) { queue.add(new LocalChangesPrompt(true, null, null)); final MergeAllWithBranchCopyPoint mergeAllExecutor = new MergeAllWithBranchCopyPoint(); queue.add( myVcs .getSvnBranchPointsCalculator() .getFirstCopyPointTask( myWcInfo.getRepositoryRoot(), mySourceUrl, myWcInfo.getRootUrl(), mergeAllExecutor)); queue.add(mergeAllExecutor); }
public static Set<WorkingCopyFormat> getUpgradeFormats( @NotNull WCInfo info, @NotNull List<WorkingCopyFormat> supportedFormats) { Set<WorkingCopyFormat> canUpgradeTo = EnumSet.noneOf(WorkingCopyFormat.class); for (WorkingCopyFormat format : supportedFormats) { if (format.isOrGreater(info.getFormat())) { canUpgradeTo.add(format); } } canUpgradeTo.add(info.getFormat()); return canUpgradeTo; }
private boolean checkForSwitchedRoots() { final List<WCInfo> infoList = myVcs.getAllWcInfos(); boolean switchedFound = false; for (WCInfo wcInfo : infoList) { if (FileUtil.isAncestor(new File(myWcInfo.getPath()), new File(wcInfo.getPath()), true) && NestedCopyType.switched.equals(wcInfo.getType())) { switchedFound = true; break; } } if (switchedFound) { return prompt("There are some switched paths in the working copy. Do you want to continue?"); } return true; }
private void changeFormat(final WCInfo wcInfo) { ChangeFormatDialog dialog = new ChangeFormatDialog(myProject, new File(wcInfo.getPath()), false, !wcInfo.isIsWcRoot()); dialog.setData(true, wcInfo.getFormat().getOption()); dialog.show(); if (!dialog.isOK()) { return; } final String newMode = dialog.getUpgradeMode(); if (!wcInfo.getFormat().getOption().equals(newMode)) { final WorkingCopyFormat newFormat = WorkingCopyFormat.getInstance(newMode); final Task.Backgroundable task = new SvnFormatWorker(myProject, newFormat, wcInfo) { @Override public void onSuccess() { super.onSuccess(); myRefreshLabel.doClick(); } }; ProgressManager.getInstance().run(task); } }
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(); } }
// "Calculating not merged revisions" @Override public void run(ContinuationContext context) { if (myCopyData == null) { finishWithError(context, "Merge start wasn't found", true); return; } final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); myIsReintegrate = myCopyData.isInvertedSense(); if (!myWcInfo.getFormat().supportsMergeInfo()) return; final SvnBranchPointsCalculator.BranchCopyData data = myCopyData.getTrue(); final long sourceLatest = data.getTargetRevision(); final SvnCommittedChangesProvider committedChangesProvider = (SvnCommittedChangesProvider) myVcs.getCommittedChangesProvider(); final ChangeBrowserSettings settings = new ChangeBrowserSettings(); settings.CHANGE_AFTER = Long.toString(sourceLatest); settings.USE_CHANGE_AFTER_FILTER = true; String local = SVNPathUtil.getRelativePath(myWcInfo.getRepositoryRoot(), myWcInfo.getRootUrl()); final String relativeLocal = (local.startsWith("/") ? local : "/" + local); final LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list = new LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>(); try { committedChangesProvider.getCommittedChangesWithMergedRevisons( settings, new SvnRepositoryLocation(mySourceUrl), 0, new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() { public void consume(SvnChangeList svnList, TreeStructureNode<SVNLogEntry> tree) { indicator.checkCanceled(); if (sourceLatest >= svnList.getNumber()) return; list.add(new Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>(svnList, tree)); } }); } catch (VcsException e) { finishWithError( context, "Checking revisions for merge fault", Collections.singletonList(e)); } indicator.setText("Checking merge information..."); // to do not go into file system while asking something on the net for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) { final SvnChangeList svnList = pair.getFirst(); final SvnMergeInfoCache.MergeCheckResult checkResult = myMergeChecker.checkList(svnList); indicator.setText2("Processing revision " + svnList.getNumber()); if (SvnMergeInfoCache.MergeCheckResult.NOT_MERGED.equals(checkResult)) { // additionally check for being 'local' final List<TreeStructureNode<SVNLogEntry>> children = pair.getSecond().getChildren(); boolean localChange = false; for (TreeStructureNode<SVNLogEntry> child : children) { if (isLocalRevisionMergeIteration(child, relativeLocal, indicator)) { localChange = true; break; } } if (!localChange) { myNotMerged.add(svnList); } } } if (myNotMerged.isEmpty()) { finishWithError(context, "Everything is up-to-date", false); return; } context.next(new ShowRevisionSelector(myCopyData)); }
public int compare(WCInfo o1, WCInfo o2) { return o1.getPath().compareTo(o2.getPath()); }
public boolean isEqual(WCInfo val1, WCInfo val2) { if (val1 == val2) return true; if (val1 == null || val2 == null || val1.getClass() != val2.getClass()) return false; if (!Comparing.equal(val1.getFormat(), val2.getFormat())) return false; if (!Comparing.equal(val1.getPath(), val2.getPath())) return false; if (!Comparing.equal(val1.getStickyDepth(), val2.getStickyDepth())) return false; if (!Comparing.equal(val1.getType(), val2.getType())) return false; if (!Comparing.equal(val1.getUrl(), val2.getUrl())) return false; return true; }
private String formatWc(WCInfo info) { final StringBuilder sb = new StringBuilder() .append("<html><head>") .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())) .append("</head><body><table bgColor=\"") .append(ColorUtil.toHex(UIUtil.getPanelBackground())) .append("\">"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><b>") .append(info.getPath()) .append("</b></td></tr>"); sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\">") .append(info.getRootUrl()) .append("</td></tr>"); if (!WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat())) { // can convert sb.append("<tr valign=\"top\"><td>Format:</td><td>") .append(info.getFormat().getName()) .append("</td><td><a href=\"") .append(CHANGE_FORMAT) .append("\">Change</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">") .append(info.getFormat().getName()) .append("</td></tr>"); } if (!SVNDepth.INFINITY.equals(info.getStickyDepth())) { // can fix sb.append("<tr valign=\"top\"><td>Depth:</td><td>") .append(info.getStickyDepth().getName()) .append("</td><td><a href=\"") .append(FIX_DEPTH) .append("\">Fix</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Depth:</td><td colspan=\"2\">") .append(info.getStickyDepth().getName()) .append("</td></tr>"); } final NestedCopyType type = info.getType(); if (NestedCopyType.external.equals(type) || NestedCopyType.switched.equals(type)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append(type.getName()) .append("</i></td></tr>"); } if (info.isIsWcRoot()) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append("Working copy root</i></td></tr>"); } sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(CONFIGURE_BRANCHES) .append("\">Configure Branches</a></td></tr>"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(MERGE_FROM) .append("\"><b>Merge From...</b></a></i></td></tr>"); sb.append("</table></body></html>"); return sb.toString(); }
private void updateList(final List<WCInfo> infoList) { myPanel.removeAll(); final Insets nullIndent = new Insets(1, 3, 1, 0); final GridBagConstraints gb = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(2, 2, 0, 0), 0, 0); gb.insets.left = 4; myPanel.add(myRefreshLabel, gb); gb.insets.left = 1; final LocalFileSystem lfs = LocalFileSystem.getInstance(); final Insets topIndent = new Insets(10, 3, 0, 0); for (final WCInfo wcInfo : infoList) { final VirtualFile vf = lfs.refreshAndFindFileByIoFile(new File(wcInfo.getPath())); final VirtualFile root = (vf == null) ? wcInfo.getVcsRoot() : vf; final JEditorPane editorPane = new JEditorPane(UIUtil.HTML_MIME, ""); editorPane.setEditable(false); editorPane.setFocusable(true); editorPane.setBackground(UIUtil.getPanelBackground()); editorPane.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (CONFIGURE_BRANCHES.equals(e.getDescription())) { if (!checkRoot(root, wcInfo.getPath(), " invoke Configure Branches")) return; BranchConfigurationDialog.configureBranches(myProject, root, true); } else if (FIX_DEPTH.equals(e.getDescription())) { final int result = Messages.showOkCancelDialog( myVcs.getProject(), "You are going to checkout into '" + wcInfo.getPath() + "' with 'infinity' depth.\n" + "This will update your working copy to HEAD revision as well.", "Set working copy infinity depth", Messages.getWarningIcon()); if (result == 0) { // update of view will be triggered by roots changed event SvnCheckoutProvider.checkout( myVcs.getProject(), new File(wcInfo.getPath()), wcInfo.getRootUrl(), SVNRevision.HEAD, SVNDepth.INFINITY, false, null, wcInfo.getFormat()); } } else if (CHANGE_FORMAT.equals(e.getDescription())) { changeFormat(wcInfo); } else if (MERGE_FROM.equals(e.getDescription())) { if (!checkRoot(root, wcInfo.getPath(), " invoke Merge From")) return; mergeFrom(wcInfo, root, editorPane); } } } private boolean checkRoot( VirtualFile root, final String path, final String actionName) { if (root == null) { Messages.showWarningDialog( myProject, "Invalid working copy root: " + path, "Can not " + actionName); return false; } return true; } }); editorPane.setBorder(null); editorPane.setText(formatWc(wcInfo)); final JPanel copyPanel = new JPanel(new GridBagLayout()); final GridBagConstraints gb1 = new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, nullIndent, 0, 0); gb1.insets.top = 1; gb1.gridwidth = 3; gb.insets = topIndent; gb.fill = GridBagConstraints.HORIZONTAL; ++gb.gridy; final JPanel contForCopy = new JPanel(new BorderLayout()); contForCopy.add(copyPanel, BorderLayout.WEST); myPanel.add(contForCopy, gb); copyPanel.add(editorPane, gb1); gb1.insets = nullIndent; } myPanel.revalidate(); myPanel.repaint(); }
@SuppressWarnings("MethodMayBeStatic") private String formatWc( @NotNull WCInfo info, @NotNull Collection<WorkingCopyFormat> upgradeFormats) { final StringBuilder sb = new StringBuilder() .append("<html><head>") .append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())) .append("</head><body><table bgColor=\"") .append(ColorUtil.toHex(UIUtil.getPanelBackground())) .append("\">"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><b>") .append(info.getPath()) .append("</b></td></tr>"); if (info.hasError()) { sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\" color=\"") .append(ColorUtil.toHex(JBColor.red)) .append("\">") .append(info.getErrorMessage()) .append("</td></tr>"); } else { sb.append("<tr valign=\"top\"><td>URL:</td><td colspan=\"2\">") .append(info.getRootUrl()) .append("</td></tr>"); } if (upgradeFormats.size() > 1) { sb.append("<tr valign=\"top\"><td>Format:</td><td>") .append(info.getFormat().getName()) .append("</td><td><a href=\"") .append(CHANGE_FORMAT) .append("\">Change</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">") .append(info.getFormat().getName()) .append("</td></tr>"); } if (!Depth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { // can fix sb.append("<tr valign=\"top\"><td>Depth:</td><td>") .append(info.getStickyDepth().getName()) .append("</td><td><a href=\"") .append(FIX_DEPTH) .append("\">Fix</a></td></tr>"); } else { sb.append("<tr valign=\"top\"><td>Depth:</td><td colspan=\"2\">") .append(info.getStickyDepth().getName()) .append("</td></tr>"); } final NestedCopyType type = info.getType(); if (NestedCopyType.external.equals(type) || NestedCopyType.switched.equals(type)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append(type.getName()) .append("</i></td></tr>"); } if (info.isIsWcRoot()) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>") .append("Working copy root</i></td></tr>"); } if (!info.hasError()) { if (info.getFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(CLEANUP) .append("\">Cleanup</a></td></tr>"); } sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(CONFIGURE_BRANCHES) .append("\">Configure Branches</a></td></tr>"); sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"") .append(MERGE_FROM) .append("\"><b>Merge From...</b></a></i></td></tr>"); sb.append("</table></body></html>"); } return sb.toString(); }