public ItemSecurity[] QueryItemPermissions(string[] identityNames, string[] items, RecursionType recursion) { Message msg = new Message(GetWebRequest(new Uri(Url)), "QueryItemPermissions"); msg.Body.WriteStartElement("itemSpecs"); foreach (string item in items) { ItemSpec spec = new ItemSpec(item, recursion); spec.ToXml(msg.Body, "ItemSpec"); } msg.Body.WriteEndElement(); List <ItemSecurity> itemSecurities = new List <ItemSecurity>(); using (HttpWebResponse response = Invoke(msg)) { XmlReader results = msg.ResponseReader(response); while (results.Read()) { if (results.NodeType == XmlNodeType.Element && results.Name == "ItemSecurity") { itemSecurities.Add(ItemSecurity.FromXml(this, results)); } } } return(itemSecurities.ToArray()); }
public override void Run() { if (Arguments.Length < 3) { Console.WriteLine("Usage: tf label <label> <itemSpec>"); Environment.Exit((int)ExitCode.Failure); } string labelName = Arguments[0]; string itemPath = Path.GetFullPath(Arguments[2]); // parse arguments LabelChildOption childOption = (LabelChildOption)Enum.Parse(typeof(LabelChildOption), OptionChild, true); RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; ItemSpec itemSpec = new ItemSpec(itemPath, rtype); VersionControlLabel label = new VersionControlLabel(VersionControlServer, labelName, OwnerFromString(OptionOwner), null, OptionComment); List <LabelItemSpec> labelItemSpecs = new List <LabelItemSpec>(); Workspace workspace = GetWorkspaceFromCache(); labelItemSpecs.Add(new LabelItemSpec(itemSpec, new WorkspaceVersionSpec(workspace), false)); LabelResult[] results = VersionControlServer.CreateLabel(label, labelItemSpecs.ToArray(), childOption); foreach (LabelResult result in results) { Console.WriteLine("{0} label {1}@{2}", result.Status, result.Label, result.Scope); } }
public ItemSet GetItems(string path, RecursionType recursionType) { ItemSpec itemSpec = new ItemSpec(path, recursionType); return(GetItems(itemSpec, VersionSpec.Latest, DeletedState.NonDeleted, ItemType.Any, false)); }
/// <summary> /// Retrieves the latest changeset ID associated with a path /// </summary> /// <param name="localPath">A path on the local filesystem</param> /// <param name="credentials">Credentials used to authenticate against the serer</param> /// <returns></returns> public int GetLatestChangesetId(string localPath, ICredentials credentials) { int latestChangesetId = 0; string server; Workstation workstation = new Workstation(versionControlClientAssembly); WorkspaceInfo workspaceInfo = workstation.GetLocalWorkspaceInfo(localPath); server = workspaceInfo.ServerUri.ToString(); VersionControlServer sourceControl = new VersionControlServer(clientAssembly, versionControlClientAssembly, server, credentials); Workspace workspace = sourceControl.GetWorkspace(localPath); WorkspaceVersionSpec workspaceVersionSpec = new WorkspaceVersionSpec(versionControlClientAssembly, workspace); VersionSpec versionSpec = new VersionSpec(versionControlClientAssembly); RecursionType recursionType = new RecursionType(versionControlClientAssembly); IEnumerable history = sourceControl.QueryHistory(localPath, versionSpec.Latest, recursionType.Full, workspaceVersionSpec); IEnumerator historyEnumerator = history.GetEnumerator(); Changeset latestChangeset = new Changeset(versionControlClientAssembly); if (historyEnumerator.MoveNext()) { latestChangeset = new Changeset(versionControlClientAssembly, historyEnumerator.Current); } if (latestChangeset.Instance != null) { latestChangesetId = latestChangeset.ChangesetId; } return(latestChangesetId); }
public ChangesetMerge[] QueryMerges(string sourcePath, VersionSpec sourceVersion, string targetPath, VersionSpec targetVersion, VersionSpec versionFrom, VersionSpec versionTo, RecursionType recursion) { string workspaceName = String.Empty; string workspaceOwner = String.Empty; if (!VersionControlPath.IsServerItem(targetPath)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(targetPath); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } ItemSpec sourceItem = null; if (!String.IsNullOrEmpty(sourcePath)) { sourceItem = new ItemSpec(sourcePath, recursion); } ItemSpec targetItem = new ItemSpec(targetPath, recursion); ChangesetMerge[] merges = repository.QueryMerges(workspaceName, workspaceOwner, sourceItem, sourceVersion, targetItem, targetVersion, versionFrom, versionTo, Int32.MaxValue); return(merges); }
protected override void ExecuteTask() { //TODO: Adding the alternet use of a fileset instead of the LocalItem property Workspace MyWorkspace = this.WorkspaceHelper.GetWorkspace(this.WorkspaceName, this.LocalItem, this.ServerConnection); GetOptions Options = this.GetGetOptions(); this.ServerConnection.SourceControl.Getting += new GettingEventHandler(OnGet); if (!String.IsNullOrEmpty(this.ServerItem)) { RecursionType Recursion = RecursionType.None; if (this.Recursive) { Recursion = RecursionType.Full; } GetRequest GetReq = new GetRequest(new ItemSpec(this.ServerItem, Recursion), this.VersionSpec.GetVersionSpec()); MyWorkspace.Get(GetReq, Options); } else { MyWorkspace.Get(this.VersionSpec.GetVersionSpec(), Options); } this.ServerConnection.SourceControl.Getting -= new GettingEventHandler(OnGet); }
public PendingChange[] GetPendingChanges(string item, RecursionType rtype, bool includeDownloadInfo) { string[] items = new string[1]; items[0] = item; return(GetPendingChanges(items, rtype, includeDownloadInfo)); }
public List <PendingChange> GetPendingChanges(string[] items, RecursionType rtype, bool includeDownloadInfo) { var itemSpecs = new List <ItemSpec>(items.Select(i => new ItemSpec(i, rtype))); return(this.VersionControlService.QueryPendingChangesForWorkspace(this, itemSpecs, includeDownloadInfo)); }
public int PendEdit(string path, RecursionType recursionType) { string[] paths = new string[1]; paths[0] = path; return(PendEdit(paths, recursionType)); }
public GetStatus UpdatePathFromServer(string[] paths) { // process command options RecursionType folderRecursion = OptionRecursive ? RecursionType.Full : RecursionType.OneLevel; bool getSetting = Settings.Current.GetAsBool("Get.Recursive"); if (getSetting) { folderRecursion = RecursionType.Full; } VersionSpec version = VersionFromString(OptionVersion); List <GetRequest> requests = new List <GetRequest>(); foreach (string path in paths) { RecursionType recursion = RecursionType.None; if (Directory.Exists(path)) { recursion = folderRecursion; } if (path[0] != '$') { requests.Add(new GetRequest(Path.GetFullPath(path), recursion, version)); } else { requests.Add(new GetRequest(path, recursion, version)); } } return(workspace.Get(requests.ToArray(), GetOptionFlags())); }
/// <see cref="IVersionControl.GetItemsAsync(string,Microsoft.TeamFoundation.VersionControl.Client.RecursionType)"/> public Task <IReadOnlyList <IVersionedItem> > GetItemsAsync(string path, RecursionType recursion) => Task.Factory.StartNew <IReadOnlyList <IVersionedItem> >(() => _versionControl.GetItems(path, recursion) .Items .Select(i => new VersionedItem(i)) .ToList <IVersionedItem>(), CancellationToken.None, TaskCreationOptions.None, _scheduler);
private bool CheckOut(string Path, RecursionType RecursionLevel) { bool result = false; //CommonHelper.WriteMessage(string.Format("Get All LocalWorkspaceInfos.")); WorkspaceInfo[] wsis = Workstation.Current.GetAllLocalWorkspaceInfo(); foreach (WorkspaceInfo wsi in wsis) { //Ensure that all this processing is for the current server. if (!wsi.ServerUri.DnsSafeHost.ToLower().Equals(collectionUrl.ToLower().Replace("http://", "").Split('/')[0])) { continue; } Workspace ws = GetWorkspace(wsi); //CommonHelper.WriteMessage(string.Format("Check-Out {0}.", Path)); int status = ws.PendEdit(new string[] { Path }, (RecursionType)RecursionLevel, null, LockLevel.CheckOut, false); //CommonHelper.WriteMessage(string.Format("Checked-Out {0}.", Path)); result = true; break; } return(result); }
private bool UndoPendingChange(string Path, RecursionType RecursionLevel) { bool result = false; WorkspaceInfo[] wsis = Workstation.Current.GetAllLocalWorkspaceInfo(); foreach (WorkspaceInfo wsi in wsis) { //Ensure that all this processing is for the current server. if (!wsi.ServerUri.DnsSafeHost.ToLower().Equals(collectionUrl.ToLower().Replace("http://", "").Split('/')[0])) { continue; } Workspace ws = GetWorkspace(wsi); PendingChange[] pendingChanges = ws.GetPendingChanges(new ItemSpec[] { new ItemSpec(Path, RecursionLevel) }, false); ws.Undo(pendingChanges); result = true; break; } return(result); }
public override void Run() { RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; VersionSpec version = VersionFromString(OptionVersion); List <ItemSpec> itemSpecs = new List <ItemSpec>(); foreach (string item in Arguments) { string fpath = (VersionControlPath.IsServerItem(item))? item : Path.GetFullPath(item); itemSpecs.Add(new ItemSpec(fpath, rtype)); } BranchHistoryTreeItem[][] treeItemsArray = VersionControlServer.GetBranchHistory(itemSpecs.ToArray(), version); foreach (BranchHistoryTreeItem[] treeItems in treeItemsArray) { //Console.WriteLine("New TreeItem"); foreach (BranchHistoryTreeItem treeItem in treeItems) { //Console.WriteLine("Relative: " + treeItem.Relative); //Console.WriteLine(treeItem.Relative.ServerItem); foreach (Object obj in treeItem.Children) { BranchRelative branch = obj as BranchRelative; Item fromItem = branch.BranchFromItem; Console.WriteLine(fromItem.ServerItem); Item toItem = branch.BranchToItem; Console.Write(">> \t" + toItem.ServerItem); Console.WriteLine("\tBranched from version " + fromItem.ChangesetId + " <<"); } } } }
private bool GetLatestVersion(string Path, RecursionType RecursionLevel) { bool result = false; WorkspaceInfo[] wsis = Workstation.Current.GetAllLocalWorkspaceInfo(); foreach (WorkspaceInfo wsi in wsis) { //Ensure that all this processing is for the current server. if (!wsi.ServerUri.DnsSafeHost.ToLower().Equals(collectionUrl.ToLower().Replace("http://", "").Split('/')[0])) { continue; } Workspace ws = GetWorkspace(wsi); //CommonHelper.WriteMessage(string.Format("Check-Out {0}.", Path)); GetRequest request = new GetRequest(new ItemSpec(Path, RecursionType.Full), VersionSpec.Latest); GetStatus status = ws.Get(request, GetOptions.Overwrite); //CommonHelper.WriteMessage(string.Format("Checked-Out {0}.", Path)); result = true; break; } return(result); }
public override void Run() { if (Arguments.Length < 2) { Console.WriteLine("Usage: tf unlabel <label> <itemSpec>"); Environment.Exit((int)ExitCode.Failure); } string labelName = Arguments[0]; string itemPath = Path.GetFullPath(Arguments[1]); // parse arguments RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; List <ItemSpec> itemSpecs = new List <ItemSpec>(); itemSpecs.Add(new ItemSpec(itemPath, rtype)); LabelResult[] results = VersionControlServer.UnlabelItem(labelName, null, itemSpecs.ToArray(), VersionFromString(OptionVersion)); foreach (LabelResult result in results) { Console.WriteLine("{0} label {1}@{2}", result.Status, result.Label, result.Scope); } }
public override void Run() { RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.None; Workspace workspace = GetWorkspaceFromCache(); List <string> paths = new List <string>(); if (Arguments.Length < 1) { PendingChange[] pendingChanges = workspace.GetPendingChanges(); foreach (PendingChange pendingChange in pendingChanges) { paths.Add(pendingChange.LocalItem); } } else { ConfirmFilesSpecified(); for (int i = 0; i < Arguments.Length; i++) { paths.Add(Path.GetFullPath(Arguments[i])); } } int rc = workspace.Undo(paths.ToArray(), rtype); if (rc > 0) { Console.WriteLine("{0} file(s) undone.", rc); } else { Console.WriteLine("Nothing to do."); } }
public override void Run() { string path = Environment.CurrentDirectory; if (Arguments.Length > 0) { path = Arguments[0]; } if (!VersionControlPath.IsServerItem(path)) { path = Path.GetFullPath(path); } // process command options RecursionType rtype = OptionRecursive ? RecursionType.Full : RecursionType.OneLevel; DeletedState dstate = OptionDeleted ? DeletedState.Any : DeletedState.NonDeleted; ItemSpec itemSpec = new ItemSpec(path, rtype); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, VersionFromString(OptionVersion), dstate, ItemType.Any, false); Item[] items = itemSet.Items; foreach (Item item in items) { Console.Write(item.ServerItem); if ((item.ItemType == ItemType.Folder) && (!item.ServerItem.EndsWith(Path.DirectorySeparatorChar.ToString()))) { Console.Write("/"); } Console.WriteLine(); } Console.WriteLine(items.Length + " item(s)"); }
internal void ToXml(XmlWriter writer, string element) { if (String.IsNullOrEmpty(item)) { return; } writer.WriteStartElement(element); if (this.RecursionType != RecursionType.None) { writer.WriteAttributeString("recurse", RecursionType.ToString()); } if (this.DeletionId != 0) { writer.WriteAttributeString("did", DeletionId.ToString()); } // only convert local path specs from platform paths to tfs paths if (VersionControlPath.IsServerItem(Item)) { writer.WriteAttributeString("item", Item); } else { writer.WriteAttributeString("item", TfsPath.FromPlatformPath(Item)); } writer.WriteEndElement(); }
public ChangeRequest(string path, RequestType requestType, ItemType itemType, RecursionType recursion, LockLevel lockLevel) { this.item = new ItemSpec(path, recursion); this.requestType = requestType; this.itemType = itemType; this.lockLevel = lockLevel; }
public FolderDiffWrapper(string assemblyPath, string srcPath, VersionSpec srcSpec, string targetPath, VersionSpec targetSpec, VersionControlServer server, RecursionType recursion) { _vcControlsAssembly = Assembly.LoadFrom(assemblyPath); //internal FolderDiff(string path1, VersionSpec spec1, string path2, VersionSpec spec2, VersionControlServer server, RecursionType recursion); FolderDiff = AccessPrivateWrapper.FromType(_vcControlsAssembly, FolderDiffTypeName, srcPath, srcSpec, targetPath, targetSpec, server, recursion); SetupTypesFromAssembly(); }
public ItemSpec(string item, RecursionType recursionType) { if (String.IsNullOrEmpty(item)) throw new ArgumentException("Value cannot be null or empty."); this.item = item; this.recursionType = recursionType; }
public static Form ShowDialogFolderDiff(string path1, VersionSpec spec1, string path2, VersionSpec spec2, RecursionType recursion, bool modal = true) { dynamic d = CreateDialogFolderDiff(path1, spec1, path2, spec2, recursion); ShowDynamicDialog(d, modal); return((Form)d); }
public ChangeRequest(string path, RequestType requestType, ItemType itemType, RecursionType recursion, LockLevel lockLevel, VersionSpec version) { this.Item = new ItemSpec(path, recursion); this.RequestType = requestType; this.ItemType = itemType; this.LockLevel = lockLevel; this.VersionSpec = version; }
protected override void ExecuteTask() { RecursionType TypeOfRecursion = this.GetRecustiveOption(); VersionSpec FromVersion = this.GetFromVersion(); VersionSpec Version = FromVersion; if (Version == null) { Version = VersionSpec.Latest; } VersionSpec ToVersion = this.GetToVersion(); using (XmlTextWriter DocWriter = new XmlTextWriter(this.ReportFile, System.Text.Encoding.UTF8)) { DocWriter.Formatting = Formatting.Indented; DocWriter.WriteStartDocument(); XmlWriterHelper Write = new XmlWriterHelper(DocWriter); Write.ElementBegining("History"); IEnumerable ChangesetList = this.ServerConnection.SourceControl.QueryHistory( this.ItemSpec, Version, 0, TypeOfRecursion, null, FromVersion, ToVersion, int.MaxValue, true, false); foreach (Changeset CurrentChangeset in ChangesetList) { Write.ElementBegining("ChangeSet"); Write.Attribute("ChangesetId", CurrentChangeset.ChangesetId.ToString()); Write.Attribute("Committer", CurrentChangeset.Committer); Write.Attribute("Comment", CurrentChangeset.Comment); Write.Attribute("CreationDate", CurrentChangeset.CreationDate.ToString()); Log(Level.Verbose, CurrentChangeset.ToString()); foreach (Change CurrentChange in CurrentChangeset.Changes) { Write.ElementBegining("Change"); Write.Attribute("ChangeType", CurrentChange.ChangeType.ToString()); Write.Attribute("CheckinDate", CurrentChange.Item.CheckinDate.ToString()); Write.Attribute("ItemType", CurrentChange.Item.ItemType.ToString()); Write.Attribute("ArtifactUri", CurrentChange.Item.ArtifactUri.ToString()); Write.Attribute("ServerItem", CurrentChange.Item.ServerItem); Write.ElementEnd(); } Write.ElementEnd(); } Write.ElementEnd(); } }
public ItemSpec(string item, RecursionType recursionType, int deletionId) { if (string.IsNullOrEmpty(item)) throw new ArgumentException("Value cannot be null or empty."); this.Item = item; this.RecursionType = recursionType; this.DeletionId = deletionId; }
public ItemSpec(string item, RecursionType recursionType) { if (string.IsNullOrEmpty(item)) { throw new ArgumentException("Value cannot be null or empty."); } this.Item = item; this.RecursionType = recursionType; }
public IEnumerable QueryHistory(string path, VersionSpec version, int deletionId, RecursionType recursion, string user, VersionSpec versionFrom, VersionSpec versionTo, int maxCount, bool includeChanges, bool slotMode) { return(QueryHistory(path, version, deletionId, recursion, user, versionFrom, versionTo, maxCount, includeChanges, slotMode, false)); }
private RecursionType GetRecustiveOption() { RecursionType TypeOfRecursion = RecursionType.None; if (this.Recursive) { TypeOfRecursion = RecursionType.Full; } return(TypeOfRecursion); }
public override bool Execute() { Server = ""; //TODO: Fill the TFS Server Root = @"$/DotNetNuke/src/DotNetNuke_CS/"; Committer = ""; //TODO: Fill the committer username. #pragma warning disable 612,618 TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(Server); #pragma warning restore 612,618 var vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); string path = Root; VersionSpec version = VersionSpec.Latest; const int deletionId = 0; const RecursionType recursion = RecursionType.Full; string user = null; VersionSpec versionFrom = null; VersionSpec versionTo = null; const int maxCount = 100; const bool includeChanges = true; const bool slotMode = true; const bool includeDownloadInfo = true; IEnumerable enumerable = vcs.QueryHistory(path, version, deletionId, recursion, user, versionFrom, versionTo, maxCount, includeChanges, slotMode, includeDownloadInfo); var c = new List <Changeset>(); foreach (var i in enumerable) { var cs = (i as Changeset); if (cs != null && cs.Committer != Committer) { foreach (var change in cs.Changes) { if (!change.Item.ServerItem.Contains("Professional")) { c.Add(cs); } } } } return(true); }
public QueryModel() { RevisionFrom = new ChangesetVersionSpec(1); RevisionTo = VersionSpec.Latest; MaxRevisions = int.MaxValue; Author = new Author(); IncludeChanges = true; DeletionId = 0; SlotMode = false; RecursionType = RecursionType.Full; }
private RecursionType GetRecustiveOption() { RecursionType TypeOfRecursion = RecursionType.None; if (this.Recursive) { TypeOfRecursion = RecursionType.Full; } Log(Level.Verbose, "Type of Recursion is {0}", TypeOfRecursion.ToString()); return(TypeOfRecursion); }
public ItemSpec(string item, RecursionType recursionType, int deletionId) { if (String.IsNullOrEmpty(item)) { throw new ArgumentException("Value cannot be null or empty."); } this.item = item; this.recursionType = recursionType; this.deletionId = deletionId; }
public GetStatus Get(string[] items, VersionSpec version, RecursionType recursion, GetOptions options) { List <GetRequest> requests = new List <GetRequest>(); foreach (string item in items) { requests.Add(new GetRequest(item, recursion, version)); } return(Get(requests.ToArray(), options, null, null)); }
private bool DeleteItem(string path, RecursionType recursionType) { string fullPath = GetFullPath(path); var pendingChanges = Workspace.GetPendingChanges(fullPath); // If there are any pending deletes then do nothing if (pendingChanges.Any(c => c.IsDelete)) { return true; } // Undo other pending changes Workspace.Undo(pendingChanges); return Workspace.PendDelete(fullPath, recursionType); }
public int Undo(string path, RecursionType recursionType) { string[] paths = new string[1]; paths[0] = path; return Undo(paths, recursionType); }
public int SetLock(string[] paths, LockLevel lockLevel, RecursionType recursion) { List<ChangeRequest> changes = new List<ChangeRequest>(); foreach (string path in paths) { ItemType itemType = ItemType.File; if (Directory.Exists(path)) itemType = ItemType.Folder; changes.Add(new ChangeRequest(path, RequestType.Lock, itemType, recursion, lockLevel)); } if (changes.Count == 0) return 0; GetOperation[] operations = Repository.PendChanges(this, changes.ToArray()); return operations.Length; }
public List<ExtendedItem> GetItems(List<FilePath> paths, RecursionType recursionType) { lock(locker) { List<ExtendedItem> items = new List<ExtendedItem>(); var workspaceFilesMapping = new Dictionary<Workspace, List<ItemSpec>>(); foreach (var path in paths) { var workspace = repo.GetWorkspaceByLocalPath(path); if (workspace == null) continue; var serverPath = workspace.GetServerPathForLocalPath(path); if (HasItem(serverPath) && recursionType == RecursionType.None) { items.Add(GetItem(serverPath)); continue; } if (workspaceFilesMapping.ContainsKey(workspace)) workspaceFilesMapping[workspace].Add(new ItemSpec(serverPath, recursionType)); else workspaceFilesMapping.Add(workspace, new List<ItemSpec> { new ItemSpec(serverPath, recursionType) }); } foreach (var workspaceMap in workspaceFilesMapping) { var extendedItems = workspaceMap.Key.GetExtendedItems(workspaceMap.Value, DeletedState.NonDeleted, ItemType.Any).Distinct(); AddToCache(extendedItems); items.AddRange(extendedItems); } return items; } }
private VersionInfo[] GetItemsVersionInfo(List<FilePath> paths, bool getRemoteStatus, RecursionType recursive) { List<VersionInfo> infos = new List<VersionInfo>(); var extendedItems = cache.GetItems(paths, recursive); foreach (var item in extendedItems.Where(i => i.IsInWorkspace || (!i.IsInWorkspace && i.ChangeType.HasFlag(ChangeType.Delete))).Distinct()) { infos.AddRange(GetItemVersionInfo(item, getRemoteStatus)); } foreach (var path in paths) { var path1 = path; if (infos.All(i => path1.CanonicalPath != i.LocalPath.CanonicalPath)) { infos.Add(VersionInfo.CreateUnversioned(path1, FileHelper.HasFolder(path1))); } } return infos.ToArray(); }
public ItemSecurity[] GetPermissions(string[] identityNames, string[] items, RecursionType recursion) { return Repository.QueryItemPermissions(identityNames, items, recursion); }
public bool PendDelete(IEnumerable<string> fullPaths, RecursionType recursionType) { if (fullPaths == null) { throw new ArgumentNullException("fullPaths"); } var pathsArray = fullPaths.ToArray(); if (pathsArray.Length > 0) { return _workspace.PendDelete(pathsArray, recursionType) > 0; } return false; }
public IEnumerable<ITfsPendingChange> GetPendingChanges(string fullPath, RecursionType recursionType) { return _workspace.GetPendingChangesEnumerable(fullPath, recursionType) .Select(p => new TfsPendingChangeWrapper(p)); }
public PendingChange[] GetPendingChanges(string[] items, RecursionType rtype) { return GetPendingChanges(items, rtype, false); }
public PendingChange[] GetPendingChanges(string item, RecursionType rtype, bool includeDownloadInfo) { string[] items = new string[1]; items[0] = item; return GetPendingChanges(items, rtype, includeDownloadInfo); }
public GetStatus Get(string[] items, VersionSpec version, RecursionType recursion, GetOptions options) { List<GetRequest> requests = new List<GetRequest>(); foreach (string item in items) { requests.Add(new GetRequest(item, recursion, version)); } return Get(requests.ToArray(), options, null, null); }
public IEnumerable QueryHistory(string path, VersionSpec version, int deletionId, RecursionType recursion, string user, VersionSpec versionFrom, VersionSpec versionToOrig, int maxCount, bool includeChanges, bool slotMode, bool includeDownloadInfo) { ItemSpec itemSpec = new ItemSpec(path, recursion, deletionId); string workspaceName = String.Empty; string workspaceOwner = String.Empty; if (!VersionControlPath.IsServerItem(itemSpec.Item)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(itemSpec.Item); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } List<Changeset> changes = new List<Changeset>(); int total = maxCount; VersionSpec versionTo = versionToOrig; while (total > 0) { int batchMax = Math.Min(256, total); int batchCnt = repository.QueryHistory(workspaceName, workspaceOwner, itemSpec, version, user, versionFrom, versionTo, batchMax, includeChanges, slotMode, includeDownloadInfo, ref changes); if (batchCnt < batchMax) break; total -= batchCnt; Changeset lastChangeset = changes[changes.Count - 1]; versionTo = new ChangesetVersionSpec(lastChangeset.ChangesetId - 1); } return changes.ToArray(); }
public ChangesetMerge[] QueryMerges(string sourcePath, VersionSpec sourceVersion, string targetPath, VersionSpec targetVersion, VersionSpec versionFrom, VersionSpec versionTo, RecursionType recursion) { string workspaceName = String.Empty; string workspaceOwner = String.Empty; if (!VersionControlPath.IsServerItem(targetPath)) { WorkspaceInfo info = Workstation.Current.GetLocalWorkspaceInfo(targetPath); if (info != null) { workspaceName = info.Name; workspaceOwner = info.OwnerName; } } ItemSpec sourceItem = null; if (!String.IsNullOrEmpty(sourcePath)) sourceItem = new ItemSpec(sourcePath, recursion); ItemSpec targetItem = new ItemSpec(targetPath, recursion); ChangesetMerge[] merges = repository.QueryMerges(workspaceName, workspaceOwner, sourceItem, sourceVersion, targetItem, targetVersion, versionFrom, versionTo, Int32.MaxValue); return merges; }
public int Undo(string[] paths, RecursionType recursionType) { List<ItemSpec> specs = new List<ItemSpec>(); foreach (string path in paths) { specs.Add(new ItemSpec(path, recursionType)); } // is this the same logic as a workspace Get? // can we make one function to handle both cases? GetOperation[] getOperations = Repository.UndoPendingChanges(Name, OwnerName, specs.ToArray()); foreach (GetOperation getOperation in getOperations) { if (getOperation.ChangeType == ChangeType.Edit || getOperation.ChangeType == ChangeType.Delete) { string uPath = getOperation.TargetLocalItem; string directory = uPath; if (getOperation.ItemType == ItemType.File) directory = Path.GetDirectoryName(uPath); // directory is null if file is deleted on server, you haven't that // version yet, you've marked it deleted locally, then you try to // undo because it won't you let you checkin the delete because // its already deleted on the server if (!Directory.Exists(directory) && !String.IsNullOrEmpty(directory)) Directory.CreateDirectory(directory); if (getOperation.ItemType == ItemType.File) { DownloadFile.WriteTo(uPath, Repository, getOperation.ArtifactUri); SetFileAttributes(uPath); } } } return getOperations.Length; }
public IEnumerable<PendingChange> GetPendingChanges(string fullPath, RecursionType recursionType) { return _workspace.GetPendingChangesEnumerable(fullPath, recursionType); }
public PendingChange[] GetPendingChanges(string[] items, RecursionType rtype, bool includeDownloadInfo) { List<ItemSpec> itemSpecs = new List<ItemSpec>(); foreach (string item in items) { itemSpecs.Add(new ItemSpec(item, rtype)); } Failure[] failures = null; PendingChange[] changes = Repository.QueryPendingSets(Name, OwnerName, Name, OwnerName, itemSpecs.ToArray(), includeDownloadInfo, out failures); foreach (Failure failure in failures) { Console.WriteLine(failure.ToString()); } return changes; }
public bool PendDelete(string fullPath, RecursionType recursionType) { return _workspace.PendDelete(fullPath, recursionType) > 0; }
public int PendDelete(string[] paths, RecursionType recursionType) { List<ChangeRequest> changes = new List<ChangeRequest>(); foreach (string path in paths) { ItemType itemType = ItemType.File; if (Directory.Exists(path)) itemType = ItemType.Folder; changes.Add(new ChangeRequest(path, RequestType.Delete, itemType)); } if (changes.Count == 0) return 0; GetOperation[] operations = Repository.PendChanges(this, changes.ToArray()); UpdateLocalVersionQueue updates = new UpdateLocalVersionQueue(this); // first delete all files foreach (GetOperation operation in operations) { if (operation.ItemType != ItemType.File) continue; if (!File.Exists(operation.SourceLocalItem)) continue; UnsetFileAttributes(operation.SourceLocalItem); File.Delete(operation.SourceLocalItem); updates.QueueUpdate(operation.ItemId, null, operation.VersionServer); } // then any directories foreach (GetOperation operation in operations) { if (operation.ItemType != ItemType.Folder) continue; if (!Directory.Exists(operation.SourceLocalItem)) continue; //DirectoryInfo dir = new DirectoryInfo(operation.SourceLocalItem); //FileInfo[] localFiles = dir.GetFiles("*", SearchOption.AllDirectories); //foreach (FileInfo file in localFiles) // UnsetFileAttributes(file.FullName); Directory.Delete(operation.SourceLocalItem, true); updates.QueueUpdate(operation.ItemId, null, operation.VersionServer); } updates.Flush(); return operations.Length; }
public IEnumerable QueryHistory(string path, VersionSpec version, int deletionId, RecursionType recursion, string user, VersionSpec versionFrom, VersionSpec versionTo, int maxCount, bool includeChanges, bool slotMode) { return QueryHistory(path, version, deletionId, recursion, user, versionFrom, versionTo, maxCount, includeChanges, slotMode, false); }
public int PendEdit(string path, RecursionType recursionType) { string[] paths = new string[1]; paths[0] = path; return PendEdit(paths, recursionType); }
public ItemSecurity[] GetPermissions(string[] items, RecursionType recursion) { return GetPermissions(null, items, recursion); }
public int PendEdit(string[] paths, RecursionType recursionType) { List<ChangeRequest> changes = new List<ChangeRequest>(); foreach (string path in paths) { changes.Add(new ChangeRequest(path, RequestType.Edit, ItemType.File)); } if (changes.Count == 0) return 0; GetOperation[] getOperations = Repository.PendChanges(this, changes.ToArray()); foreach (GetOperation getOperation in getOperations) { UnsetFileAttributes(getOperation.TargetLocalItem); } return getOperations.Length; }
public int SetLock(string path, LockLevel lockLevel, RecursionType recursion) { string[] paths = new string[1]; paths[0] = path; return SetLock(paths, lockLevel, recursion); }
/// <summary> /// Retrieves the latest changeset ID associated with a path /// </summary> /// <param name="localPath">A path on the local filesystem</param> /// <param name="credentials">Credentials used to authenticate against the serer</param> /// <returns></returns> public int GetLatestChangesetId(string localPath, ICredentials credentials) { int latestChangesetId = 0; string server; Workstation workstation = new Workstation(versionControlClientAssembly); WorkspaceInfo workspaceInfo = workstation.GetLocalWorkspaceInfo(localPath); server = workspaceInfo.ServerUri.ToString(); VersionControlServer sourceControl = new VersionControlServer(clientAssembly, versionControlClientAssembly, server, credentials); Workspace workspace = sourceControl.GetWorkspace(localPath); WorkspaceVersionSpec workspaceVersionSpec = new WorkspaceVersionSpec(versionControlClientAssembly, workspace); VersionSpec versionSpec = new VersionSpec(versionControlClientAssembly); RecursionType recursionType = new RecursionType(versionControlClientAssembly); IEnumerable history = sourceControl.QueryHistory(localPath, versionSpec.Latest, recursionType.Full, workspaceVersionSpec); IEnumerator historyEnumerator = history.GetEnumerator(); Changeset latestChangeset = new Changeset(versionControlClientAssembly); if (historyEnumerator.MoveNext()) { latestChangeset = new Changeset(versionControlClientAssembly, historyEnumerator.Current); } if (latestChangeset.Instance != null) { latestChangesetId = latestChangeset.ChangesetId; } return latestChangesetId; }