Usages of

com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Item.getDeletionID()
@Override public void onDestroy(final DestroyEvent event) { final Item destroyedItem = event.getDestroyedItem(); String itemString = destroyedItem.getServerItem(); if (destroyedItem.getDeletionID() != 0) { itemString += ";X" + destroyedItem.getDeletionID(); //$NON-NLS-1$ } getDisplay().printLine(MessageFormat.format(Messages.getString("Command.DestroyedFormat"), itemString)); //$NON-NLS-1$ }
public TFSItemNode(final Item item, final VersionControlClient vcClient) { // code omitted ... /* * The AItem that we were instantiated with may not contain a download URL. * If that's the case, we need to requery the server. */ @Override protected Item getDownloadItem() { if (downloadItem == null) { if (item.getDownloadURL() != null) { downloadItem = item; } else { downloadItem = vcClient.getItem( item.getServerItem(), new ChangesetVersionSpec(item.getChangeSetID()), item.getDeletionID(), true); // downloadItem = vcClient.getItem(item.getItemID(), // item.getChangeSetID(), true); } } return downloadItem; }
@Override protected void doRun(final TFSRepository repository) { final Change change = (Change) adaptSelectionFirstElement(Change.class); final Item item = change.getItem(); final Compare compare = new Compare(); compare.setModified(new TFSItemNode(item, repository.getVersionControlClient())); compare.setOriginal( new ServerItemByItemVersionGenerator( repository, new ItemSpec(item.getServerItem(), RecursionType.NONE, item.getDeletionID()), new ChangesetVersionSpec(item.getChangeSetID()), new ChangesetVersionSpec(item.getChangeSetID() - 1))); compare.addComparator(TFSItemContentComparator.INSTANCE); compare.setUIType(compareUIType); compare.setExternalCompareHandler(new UserPreferenceExternalCompareHandler(shell)); compare.open(); }
@Override protected void doRun(final TFSRepository repository) { final Change change = (Change) adaptSelectionFirstElement(Change.class); final Item item = change.getItem(); final Compare compare = new Compare(); compare.setModified(new TFSItemNode(item, repository.getVersionControlClient())); compare.setOriginal( new ServerItemByItemVersionGenerator( repository, new ItemSpec(item.getServerItem(), RecursionType.NONE, item.getDeletionID()), new ChangesetVersionSpec(item.getChangeSetID()), LatestVersionSpec.INSTANCE)); compare.addComparator(TFSItemContentComparator.INSTANCE); compare.setUIType(compareUIType); compare.setExternalCompareHandler(new UserPreferenceExternalCompareHandler(shell)); compare.open(); }
private String formatDirectoryItem(final Item item) { final StringBuffer sb = new StringBuffer(); /* * This looks dumb to me, but Microsoft's client puts a $ (not "$/") * before each folder item, instead of something like "/" after it. */ if (item.getItemType() == ItemType.FOLDER) { sb.append(ServerPath.ROOT_NAME_ONLY); } final String itemName = VersionedFileSpec.formatPathWithDeletionIfNecessary( ServerPath.getFileName(item.getServerItem()), item.getDeletionID()); sb.append(itemName); return sb.toString(); }
@Override public boolean isValid(final boolean forEdit, final WorkItem linkingWorkItem) { if (forEdit) { return true; } final String inputPath = versionedItemText.getText().trim(); if (inputPath.length() == 0) { errorMessage = Messages.getString("VersionedItemLinkProvider.EnterPathToVersionedItem"); //$NON-NLS-1$ return false; } if (!inputPath.startsWith("$/")) //$NON-NLS-1$ { errorMessage = Messages.getString("VersionedItemLinkProvider.VersionedItemPathInvalid"); //$NON-NLS-1$ return false; } VersionSpec versionSpec; int changesetId = -1; if (!latestVersionMode) { final String inputChangeset = changesetText.getText(); if (inputChangeset.trim().length() == 0) { errorMessage = Messages.getString("VersionedItemLinkProvider.MustSpecifyChangesetId"); //$NON-NLS-1$ return false; } try { changesetId = Integer.parseInt(inputChangeset); } catch (final NumberFormatException ex) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.InvalidChangesetIdFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputChangeset); return false; } if (changesetId <= 0) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.MustBeGreaterThanZeroFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, Integer.toString(changesetId)); return false; } versionSpec = new ChangesetVersionSpec(changesetId); } else { versionSpec = LatestVersionSpec.INSTANCE; } VersionControlClient client; try { client = (VersionControlClient) server.getConnection().getClient(VersionControlClient.class); } catch (final Exception e) { throw new RuntimeException(e); } Item item = null; try { item = client.getItem(inputPath, versionSpec); } catch (final Exception ex) { errorMessage = ex.getLocalizedMessage(); return false; } if (item == null) { if (latestVersionMode) { final String messageFormat = Messages.getString("VersionedItemLinkProvider.SpecifiedVersionNotFoundFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputPath); } else { final String messageFormat = Messages.getString("VersionedItemLinkProvider.ItemDoesNotExistFormat"); //$NON-NLS-1$ errorMessage = MessageFormat.format(messageFormat, inputPath, Integer.toString(changesetId)); } return false; } String toolSpecificId; String artifactType; if (latestVersionMode) { toolSpecificId = String.valueOf(item.getItemID()); artifactType = VersionControlConstants.LATEST_ITEM_ARTIFACT_TYPE; } else { try { /* * Skip the leading $/ when creating the input path, then URL * escape it. This is to escape any special URL characters (eg, * '&'). Yes, we encode the item twice. This is what the server * expects and requires, and very bad things can happen if you * do not do this. */ final String escapedPath = URLEncoder.encode(inputPath.substring(2), URL_ENCODING); toolSpecificId = URLEncoder.encode(escapedPath + "&changesetVersion=" //$NON-NLS-1$ + changesetId + "&deletionId=" //$NON-NLS-1$ + item.getDeletionID(), URL_ENCODING); } catch (final UnsupportedEncodingException e) { throw new RuntimeException(e); } artifactType = VersionControlConstants.VERSIONED_ITEM_ARTIFACT_TYPE; } versionedItemArtifactId = new ArtifactID(ToolNames.VERSION_CONTROL, artifactType, toolSpecificId); return true; }
private List<String> getTargets( final TFSRepository repository, final String sourcePath, final IProgressMonitor progressMonitor) throws Exception { final ArrayList<String> targets = new ArrayList<String>(); final ItemSpec itemSpec = new ItemSpec(sourcePath, RecursionType.NONE); try { if (repository.getVersionControlClient().getServiceLevel().getValue() >= WebServiceLevel.TFS_2010.getValue()) { final ItemIdentifier[] items = repository.getVersionControlClient().queryMergeRelationships(sourcePath); if (items != null) { for (int i = 0; i < items.length; i++) { if (progressMonitor.isCanceled()) { return null; } if (items[i].getDeletionID() == 0 && items[i].getItem() != null && items[i].getItem().length() > 0) { targets.add(items[i].getItem()); } } } } else { final BranchHistory branchHistory = repository.getWorkspace().getBranchHistory(itemSpec, LatestVersionSpec.INSTANCE); if (branchHistory != null && branchHistory.getRequestedItem() != null) { final BranchHistoryTreeItem requestedItem = branchHistory.getRequestedItem(); // Add parent history item. if (requestedItem.getParentBranchHistoryTreeItem() != null && requestedItem.getParentBranchHistoryTreeItem().getItem() != null && requestedItem.getParentBranchHistoryTreeItem().getItem().getDeletionID() == 0 && requestedItem.getParentBranchHistoryTreeItem().getItem().getServerItem() != null) { targets.add(requestedItem.getParentBranchHistoryTreeItem().getItem().getServerItem()); } // Add child history items if (requestedItem.hasChildren()) { for (final Iterator<BranchHistoryTreeItem> children = requestedItem.getChildrenAsList().iterator(); children.hasNext();) { if (progressMonitor.isCanceled()) { return null; } final Item item = children.next().getItem(); if (item != null && item.getDeletionID() == 0 && item.getServerItem() != null) { targets.add(item.getServerItem()); } } } } } } catch (final Exception e) { log.error("Could not determine branch targets", e); //$NON-NLS-1$ throw e; } return targets; }
public HistoryInput getHistoryInput() throws ValidationException { final ChangesetRange range = getRange(); String path = getPath(); RecursionType recursionType; VersionSpec itemVersion = LatestVersionSpec.INSTANCE; if (path == null) { path = ServerPath.ROOT; recursionType = RecursionType.FULL; } else { final VersionSpec itemQueryVersion = LatestVersionSpec.INSTANCE; /* * VS control always includes deleted items and source renames. */ Item item = null; try { item = repository.getVersionControlClient().getItem( path, itemQueryVersion, DeletedState.ANY, GetItemsOptions.INCLUDE_SOURCE_RENAMES); } catch (final Exception e) { throw new ValidationException(e.getLocalizedMessage()); } if (item == null) { throw new ValidationException( MessageFormat.format( Messages.getString("FindChangesetOptionsControl.ItemNotFoundInSourceControlAtVersionFormat"), //$NON-NLS-1$ path, itemQueryVersion)); } path = item.getServerItem(); recursionType = (item.getItemType() == ItemType.FILE ? RecursionType.NONE : RecursionType.FULL); if (item.getDeletionID() != 0) { itemVersion = new ChangesetVersionSpec(item.getChangeSetID() - 1); } } final HistoryInput.Builder builder = new HistoryInput.Builder(getShell(), repository, path, itemVersion, recursionType); builder.setUserFilter(IdentityHelper.getUniqueNameIfCurrentUser( repository.getConnection().getAuthorizedIdentity(), getUsername())); builder.setVersionFrom(range.getStartRange()); builder.setVersionTo(range.getEndRange()); /* * Use slot mode for 2010, item mode for previous. This is a slight hack * (and different from VS's query behavior in this same dialog) because * our history table control isn't perfect. * * VS sets slot mode false always, because its history table control * handles expansion along branches and renames for 2010 and item mode * is the correct behavior for 2005 and 2008. TEE's history control * shows too many rows for item mode in 2010 (it queries as slot mode), * so do a simple switch on server version to work around this. */ builder.setSlotMode( repository.getVersionControlClient().getServiceLevel().getValue() >= WebServiceLevel.TFS_2010.getValue()); return builder.build(); }
@Override protected void populate(final PropertyHolder propertyHolder) { final Item item = change.getItem(); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ChangeTypesPropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ChangeTypesPropertyDescription"), //$NON-NLS-1$ change.getChangeType().toUIString(true, item)); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ChangesetIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getChangeSetID())); final Calendar c = item.getCheckinDate(); Object value = (c != null ? dateFormat.format(c.getTime()) : null); propertyHolder.addProperty( Messages.getString("ChangePropertySource.CheckinDatePropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.CheckinDatePropertyDescription"), //$NON-NLS-1$ value); propertyHolder.addProperty( Messages.getString("ChangePropertySource.DeletionIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getDeletionID())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.EncodingPropertyName"), //$NON-NLS-1$ String.valueOf(item.getEncoding())); final ItemType itemType = item.getItemType(); value = (itemType != null ? itemType.toString() : null); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ItemTypePropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ItemTypePropertyDescription"), //$NON-NLS-1$ value); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ItemIdPropertyName"), //$NON-NLS-1$ String.valueOf(item.getItemID())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.ServerItemPropertyName"), //$NON-NLS-1$ Messages.getString("ChangePropertySource.ServerItemPropertyDescription"), //$NON-NLS-1$ item.getServerItem()); propertyHolder.addProperty(Messages.getString("ChangePropertySource.TimeZonePropertyName"), item.getTimeZone()); //$NON-NLS-1$ propertyHolder.addProperty( Messages.getString("ChangePropertySource.TimeZoneOffsetPropertyName"), //$NON-NLS-1$ item.getTimeZoneO()); final byte[] hash = item.getContentHashValue(); value = (hash != null ? ArrayUtils.byteArrayToHexString(hash) : null); propertyHolder.addProperty(Messages.getString("ChangePropertySource.HashValuePropertyName"), value); //$NON-NLS-1$ propertyHolder.addProperty( Messages.getString("ChangePropertySource.ContentLengthPropertyName"), //$NON-NLS-1$ String.valueOf(item.getContentLength())); propertyHolder.addProperty( Messages.getString("ChangePropertySource.DownloadUrlPropertyName"), //$NON-NLS-1$ item.getDownloadURL()); }
/** * Prints a branch history item, recursing into its children. * * @param branchHistoryTreeItem * the branch history item to print (not null). */ private void printBranchHistoryItem(final BranchHistoryTreeItem branchHistoryTreeItem) { Check.notNull(branchHistoryTreeItem, "branchHistoryTreeItem"); //$NON-NLS-1$ final StringBuffer sb = new StringBuffer(); for (int i = 0; i < branchHistoryTreeItem.getLevel(); i++) { sb.append(INDENT); } /* * A null "to" item (target) means no permission. */ final Item targetItem = branchHistoryTreeItem.getItem(); if (targetItem == null) { sb.append(Messages.getString("CommandBranches.NoPermissionToReadBranchItem")); //$NON-NLS-1$ } else { sb.append( VersionedFileSpec.formatPathWithDeletionIfNecessary( targetItem.getServerItem(), targetItem.getDeletionID())); } sb.append(INDENT); /* * Unlike the "to" item (target), the "from" item (source) can be null * to indicate the root of the branch history. */ if (branchHistoryTreeItem.getFromItemChangesetID() != 0) { final Item sourceItem = branchHistoryTreeItem.getFromItem(); if (sourceItem == null) { sb.append(Messages.getString("CommandBranches.NoPermissionToReadBranchItem")); //$NON-NLS-1$ } else { final String messageFormat = Messages.getString("CommandBranches.BranchedFromVersionFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, Integer.toString(sourceItem.getChangeSetID())); sb.append(message); } } /* * The requested item was the one the query was originally performed on, * so it should get a highlight. */ if (branchHistoryTreeItem.isRequested()) { sb.insert(0, ">> "); //$NON-NLS-1$ sb.append(" <<"); //$NON-NLS-1$ } getDisplay().printLine(sb.toString()); if (branchHistoryTreeItem.getChildren() != null) { for (int i = 0; i < branchHistoryTreeItem.getChildren().length; i++) { printBranchHistoryItem((BranchHistoryTreeItem) branchHistoryTreeItem.getChildren()[i]); } } }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes