public SvnDirectory GetDirectory(string path) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } lock (_lock) { SvnDirectory dir; if (_dirMap.TryGetValue(path, out dir)) { return(dir); } SvnItem item = this[path]; if (item.IsDirectory) { dir = new SvnDirectory(Context, path); dir.Add(item); return(dir); } else { return(null); } } }
public void CommitMultipleRepositories() { // we need a second repos string repos2Path = Path.Combine(@"\tmp", "repos2"); string repos2Url = ExtractRepos("Ankh.Tests.repos2.zip", repos2Path, this.GetType()); string wc2Path = this.FindDirName(Path.Combine(@"\tmp", "wc2")); this.RunCommand("svn", String.Format("co {0} {1}", repos2Url, wc2Path)); string path1 = Path.Combine(wc2Path, "AssemblyInfo.cs"); this.Modify(path1); SvnItem item1 = this.ctx.StatusCache[path1]; string path2 = Path.Combine(this.WcPath, "Class1.cs"); this.Modify(path2); SvnItem item2 = this.ctx.StatusCache[path2]; Assert.AreEqual(item1.Status.TextStatus, StatusKind.Modified); Assert.AreEqual(item2.Status.TextStatus, StatusKind.Modified); this.uiShell.CommitItems = new SvnItem[] { item1, item2 }; this.cmd.Execute(this.ctx, ""); Assert.AreEqual(item1.Status.TextStatus, StatusKind.Normal); Assert.AreEqual(item2.Status.TextStatus, StatusKind.Normal); Assert.IsTrue(this.ctx.Description.IndexOf(item1.Status.Entry.Uuid) >= 0); Assert.IsTrue(this.ctx.Description.IndexOf(item2.Status.Entry.Uuid) >= 0); }
/// <summary> /// Called from RefreshPath's call to <see cref="SvnClient::Status"/> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// All information we receive here is live from SVN and Disk and is therefore propagated /// in all SvnItems wishing information /// </remarks> void RefreshCallback(object sender, SvnStatusEventArgs e) { // Note: There is a lock(_lock) around this in our caller SvnStatusData status = new SvnStatusData(e); string path = e.FullPath; // Fully normalized SvnItem item; if (!_map.TryGetValue(path, out item) || !NewFullPathOk(item, path, status)) { // We only create an item if we don't have an existing // with a valid path. (No casing changes allowed!) SvnItem newItem = CreateItem(path, status); StoreItem(newItem); if (item != null) { ((ISvnItemUpdate)item).RefreshTo(newItem); item.Dispose(); } item = newItem; } else { ((ISvnItemUpdate)item).RefreshTo(status); } // Note: There is a lock(_lock) around this in our caller }
internal void OnCleanup() { lock (_lock) { _postedCleanup = false; while (_cleanup.Count > 0) { SvnDirectory dir = _cleanup[0]; string path = dir.FullPath; _cleanup.RemoveAt(0); for (int i = 0; i < dir.Count; i++) { SvnItem item = dir[i]; if (((ISvnItemUpdate)item).ShouldClean()) { RemoveItem(item); dir.RemoveAt(i--); } } if (dir.Count == 0) { // We cache the path before.. as we don't want the svnitem to be generated again _dirMap.Remove(path); } } } }
public void ScheduleSvnRefresh(List <SvnClientAction> sccRefreshItems) { if (sccRefreshItems == null) { throw new ArgumentNullException("sccRefreshItems"); } CommandService.PostIdleAction( delegate { bool sorted = false; foreach (SccProjectData project in ProjectMap.AllSccProjects) { if (project.WebLikeFileHandling && !string.IsNullOrEmpty(project.ProjectDirectory)) { string dir = project.ProjectDirectory; foreach (SvnClientAction action in sccRefreshItems) { if (SvnItem.IsBelowRoot(action.FullPath, dir)) { if (!sorted) { sorted = true; sccRefreshItems.Sort(); } project.PerformRefresh(sccRefreshItems); break; } } } } }); }
string SafeRepositoryPath(SvnItem item) { if (item == null || item.Uri == null) { return(""); } SvnWorkingCopy wc = item.WorkingCopy; if (wc != null) { Uri root = wc.RepositoryRoot; if (root != null) { Uri relative = root.MakeRelativeUri(item.Uri); if (!relative.IsAbsoluteUri) { string v = SvnTools.UriPartToPath(relative.ToString()).Replace(Path.DirectorySeparatorChar, '/'); if (!string.IsNullOrEmpty(v) && !v.StartsWith("/") && !v.StartsWith("../") && v != ".") { return("^/" + v); } } } } return(item.Uri.ToString()); }
public void RefreshText(IAnkhServiceProvider context) { if (context == null) { throw new ArgumentNullException("context"); } ISvnStatusCache cache = context.GetService <ISvnStatusCache>(); ImageIndex = PendingChange.IconIndex; SvnItem item = cache[FullPath]; if (item == null) { throw new InvalidOperationException(); // Item no longer valued } PendingChangeStatus pcs = PendingChange.Change ?? new PendingChangeStatus(PendingChangeKind.None); SetValues( pcs.PendingCommitText, PendingChange.ChangeList, GetDirectory(item), PendingChange.FullPath, item.IsLocked ? PCResources.LockedValue : "", // Locked SafeDate(item.Modified), // Modified PendingChange.Name, PendingChange.RelativePath, PendingChange.Project, context.GetService <IFileIconMapper>().GetFileType(item), SafeWorkingCopy(item)); }
public SynchronizeListItem(SynchronizeListView list, SvnItem item, SvnStatusEventArgs status) : base(list) { if (item == null) { throw new ArgumentNullException("item"); } _item = item; _status = status; _localChange = PendingChange.CombineStatus(status.LocalContentStatus, status.LocalTextStatus, status.LocalPropertyStatus, item.IsTreeConflicted, item); _remoteChange = PendingChange.CombineStatus(status.RemoteContentStatus, status.RemoteTextStatus, status.RemotePropertyStatus, false, null); if (_remoteChange == PendingChangeKind.None) { if (status.RemoteLock != null) { _remoteChange = PendingChangeKind.LockedOnly; } } _localStatus = new PendingChangeStatus(_localChange); _remoteStatus = new PendingChangeStatus(_remoteChange); UpdateText(); }
public SvnUriTarget GetCopyOrigin(SvnItem item) { if (item == null) throw new ArgumentNullException("item"); // TODO: Maybe handle cases where the parent was copied instead of the child? SvnUriTarget copiedFrom = null; using (SvnClient client = GetService<ISvnClientPool>().GetNoUIClient()) { SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; ia.Depth = SvnDepth.Empty; client.Info(item.FullPath, ia, delegate(object sender, SvnInfoEventArgs ee) { if (ee.CopyFromUri != null) { copiedFrom = new SvnUriTarget(ee.CopyFromUri, ee.CopyFromRevision); } }); } return copiedFrom; }
/// <summary> /// Adds all new parents of files to add to subversion /// </summary> /// <param name="state">The state.</param> /// <returns></returns> private bool PreCommit_AddNeededParents(PendingCommitState state) { foreach (string path in new List <string>(state.CommitPaths)) { SvnItem item = state.Cache[path]; if (item.IsNewAddition) { SvnItem parent = item.Parent; SvnWorkingCopy wc = item.WorkingCopy; if (wc == null) { // This should be impossible. A node can't be added and not in a WC item.MarkDirty(); continue; } string wcPath = wc.FullPath; while (parent != null && !string.Equals(parent.FullPath, wcPath, StringComparison.OrdinalIgnoreCase) && parent.IsNewAddition) { if (!state.CommitPaths.Contains(parent.FullPath)) { state.CommitPaths.Add(parent.FullPath); } parent = parent.Parent; } } } return(true); }
public void TestItemAutoAddedTwice() { ContextBase ctx = this.CreateContextAndLoad(); string path = Path.Combine(this.WcPath, "File.cs"); File.CreateText(path).Close(); SvnItem item = ctx.StatusCache[path]; ctx.Client.Add(path, Recurse.None); // unless the sink refreshes the item, it will be // seen as unversioned and it will try to add it. ctx.DTE.Solution.Projects.Item(1 ).ProjectItems.AddFromFile(path); // verify that no exception was thrown ctx.CheckForException(); // verify that the file is correctly added. Assert.AreEqual(StatusKind.Added, ctx.Client.SingleStatus(path).TextStatus); }
private bool PreCommit_VerifySingleRoot(PendingCommitState state) { SvnWorkingCopy wc = null; foreach (PendingChange pc in state.Changes) { SvnItem item = pc.SvnItem; if (item.IsVersioned || item.IsVersionable) { SvnWorkingCopy w = item.WorkingCopy; if (wc == null) { wc = w; } else if (w != null && w != wc && w.RepositoryRoot != wc.RepositoryRoot) { StringBuilder sb = new StringBuilder(); sb.AppendLine(PccStrings.CommitSingleWc); sb.AppendFormat(PccStrings.WorkingCopyXFromRepositoryY, wc.FullPath, wc.RepositoryRoot); sb.AppendLine(); sb.AppendFormat(PccStrings.WorkingCopyXFromRepositoryY, w.FullPath, wc.RepositoryRoot); sb.AppendLine(); state.MessageBox.Show(sb.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } } return(true); }
public void TestCommitAddedFile() { string path = Path.Combine(this.WcPath, "NewFile.cs"); this.Modify(path); this.ctx.Client.Add(path, Recurse.None); SvnItem item = this.ctx.StatusCache[path]; Assert.AreEqual(StatusKind.Added, item.Status.TextStatus); this.uiShell.CommitItems = this.explorer.Selection = new object[] { item }; this.uiShell.LogMessage = "42"; this.cmd.Execute(this.ctx, ""); Assert.IsTrue(this.uiShell.ShowCommitDialogModalCalled); item.Refresh(this.ctx.Client); Assert.AreEqual(StatusKind.Normal, item.Status.TextStatus); ctx.Client.Log(new string[] { item.Path }, Revision.Head, Revision.Head, false, false, new LogMessageReceiver(this.Receiver)); Assert.AreEqual("42", this.message.Message); }
public SvnUriTarget GetCopyOrigin(SvnItem item) { if (item == null) { throw new ArgumentNullException("item"); } // TODO: Maybe handle cases where the parent was copied instead of the child? SvnUriTarget copiedFrom = null; using (SvnClient client = GetService <ISvnClientPool>().GetNoUIClient()) { SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; ia.Depth = SvnDepth.Empty; client.Info(item.FullPath, ia, delegate(object sender, SvnInfoEventArgs ee) { if (ee.CopyFromUri != null) { copiedFrom = new SvnUriTarget(ee.CopyFromUri, ee.CopyFromRevision); } }); } return(copiedFrom); }
public static bool IsPending(SvnItem item) { if (item == null) { throw new ArgumentNullException("item"); } bool create = false; if (item.IsConflicted) { create = true; // Tree conflict (unversioned) or other conflict } else if (item.IsModified) { create = true; // Must commit } else if (item.InSolution && !item.IsVersioned && !item.IsIgnored && item.IsVersionable && !item.IsSccExcluded) { create = true; // To be added } else if (item.IsVersioned && item.IsDocumentDirty) { create = true; } else if (item.IsLocked) { create = true; } return(create); }
public void RefreshItem(SvnItem item, SvnNodeKind nodeKind) { if (item == null) { throw new ArgumentNullException("item"); } RefreshPath(item.FullPath, nodeKind); var updateItem = (ISvnItemUpdate)item; if (!updateItem.IsStatusClean()) { // Ok, the status update did not refresh the item requesting to be refreshed // That means the item is not here or RefreshPath would have added it SvnItem other; if (Map.TryGetValue(item.FullPath, out other) && other != item) { updateItem.RefreshTo(other); // This item is no longer current; but we have the status anyway } else { Debug.Assert(false, "RefreshPath did not deliver up to date information", "The RefreshPath public api promises delivering up to date data, but none was received"); updateItem.RefreshTo(item.Exists ? NoSccStatus.NotVersioned : NoSccStatus.NotExisting, SvnNodeKind.Unknown); } } Debug.Assert(updateItem.IsStatusClean(), "The item requesting to be updated is updated"); }
static bool NewFullPathOk(SvnItem item, string fullPath, SvnStatusData status) { if (item == null) { throw new ArgumentNullException("item"); } else if (status == null) { throw new ArgumentNullException("status"); } if (fullPath == item.FullPath) { return(true); } switch (status.LocalNodeStatus) { case SvnStatus.Added: case SvnStatus.Conflicted: case SvnStatus.Merged: case SvnStatus.Modified: case SvnStatus.Normal: case SvnStatus.Replaced: case SvnStatus.Deleted: case SvnStatus.Incomplete: return(false); default: return(true); } }
public void SelectSubNode(SvnItem item) { if (item == null) { return; } FileSystemTreeNode fstn = SelectedNode as FileSystemTreeNode; if (fstn != null) { if (fstn.SvnItem == item) { return; } } SelectedNode.Expand(); foreach (FileSystemTreeNode tn in SelectedNode.Nodes) { if (tn.SvnItem == item) { SelectedNode = tn; return; } } // Walk up recursively SelectSubNode(item.Parent); // Walk back down (step down is taken by setting SelectedNode one deeper above) SelectSubNode(item); }
public int OnItemAdded(uint itemidParent, uint itemidSiblingPrev, uint itemidAdded) { ThreadHelper.ThrowIfNotOnUIThread(); string r; object var; if (VSErr.Succeeded(ProjectHierarchy.GetProperty(itemidAdded, (int)__VSHPROPID.VSHPROPID_IsNonMemberItem, out var)) && (bool)var) { return VSErr.S_OK; // Extra item for show all files } if (_loaded) { if (VSErr.Succeeded(VsProject.GetMkDocument(itemidAdded, out r)) && SvnItem.IsValidPath(r)) { // Check out VSHPROPID_IsNewUnsavedItem if (!SvnItem.PathExists(r)) { SetPreCreatedItem(itemidAdded); } else { SetPreCreatedItem(VSItemId.Nil); SetDirty(); } } } return VSErr.S_OK; }
internal static ISvnWcReference CalculateWorkingCopy(IAnkhServiceProvider context, SvnItem svnItem) { if (svnItem == null) { throw new ArgumentNullException("svnItem"); } // We can assume the SvnItem is a directory; this is verified in SvnItem.WorkingCopy SvnItem parent = svnItem.Parent; if (parent != null) { if (!svnItem.IsVersioned) { return(parent); } if (parent.IsVersioned && !svnItem.IsWCRoot) { return(parent); } } return(new SvnWorkingCopy(context, svnItem)); }
public void RemoveItem(SvnItem item, uint id) { int found; VsProject.RemoveItem(0, id, out found); _map.Clear(); // Flush the cache to make sure ids stay valid }
public static Uri DisplayBrowseDialogAndGetResult(WizardPage page, SvnItem target, Uri baseUri) { IAnkhServiceProvider context = ((MergeWizard)page.Wizard).Context; if (((MergeWizard)page.Wizard).MergeTarget.IsDirectory) { using (RepositoryFolderBrowserDialog dlg = new RepositoryFolderBrowserDialog()) { dlg.SelectedUri = baseUri; if (dlg.ShowDialog(context) == DialogResult.OK) { return dlg.SelectedUri; } } } else { using (RepositoryOpenDialog dlg = new RepositoryOpenDialog()) { string fileName = Path.GetFileName(target.FullPath); dlg.Context = context; dlg.Filter = fileName + "|" + fileName + "|All Files (*.*)|*"; dlg.SelectedUri = baseUri; if (dlg.ShowDialog(context) == DialogResult.OK) return dlg.SelectedUri; } } return null; }
private bool LoadSolutionProperties(SettingsCache cache, SvnItem item) { // Subversion loads all properties in memory at once; loading them // all is always faster than loading a few // We must change this algorithm if Subversions implementation changes using (SvnClient client = GetService <ISvnClientPool>().GetNoUIClient()) { string value; if (client.TryGetProperty(item.FullPath, AnkhSccPropertyNames.ProjectRoot, out value)) { SetProjectRootViaProperty(cache, value); } SvnPropertyCollection pc; if (client.TryGetAllInheritedProperties(item.FullPath, out pc)) { foreach (SvnPropertyValue pv in pc) { LoadPropertyBoth(cache, pv); } return(true); // Got properties for solution and parent dirs } return(false); } }
/// <summary> /// Gets the directory nodes below the specified path /// </summary> /// <param name="path">The path.</param> /// <param name="canRead">if set to <c>true</c> [can read].</param> /// <returns></returns> public static IEnumerable <SccFileSystemNode> GetDirectoryNodes(string path, out bool canRead) { if (string.IsNullOrEmpty(path)) { throw new ArgumentNullException("path"); } var fullPath = path; if (!path.EndsWith("\\")) { path += "\\"; } fullPath = path + "*"; if (fullPath.Length > 240) { fullPath = SvnItem.MakeLongPath(fullPath); } NativeMethods.WIN32_FIND_DATA data; var sh = NativeMethods.FindFirstFileW(fullPath, out data); if (sh.IsInvalid) { canRead = false; return(new SccFileSystemNode[0]); } else { canRead = true; return(DoGetDirectoryNodes(new SccFileSystemNode(path, data.cFileName, (FileAttributes)data.dwFileAttributes), sh)); } }
/// <summary> /// Initializes a new instance of the <see cref="SvnOrigin"/> class from a SvnTarget /// </summary> /// <param name="context">The context.</param> /// <param name="target">The target.</param> /// <param name="reposRoot">The repos root or <c>null</c> to retrieve the repository root from target</param> public SvnOrigin(IAnkhServiceProvider context, SvnTarget target, Uri reposRoot) { if (context == null) { throw new ArgumentNullException("context"); } else if (target == null) { throw new ArgumentNullException("target"); } SvnPathTarget pt = target as SvnPathTarget; if (pt != null) { SvnItem item = context.GetService <ISvnStatusCache>()[pt.FullPath]; if (item == null || !item.IsVersioned) { throw new InvalidOperationException("Can only create a SvnOrigin from versioned items"); } _target = target; _uri = item.Status.Uri; _reposRoot = item.WorkingCopy.RepositoryRoot; // BH: Prefer the actual root over the provided return; } SvnUriTarget ut = target as SvnUriTarget; if (ut != null) { _target = ut; _uri = ut.Uri; if (reposRoot != null) { _reposRoot = reposRoot; } else { using (SvnClient client = context.GetService <ISvnClientPool>().GetClient()) { _reposRoot = client.GetRepositoryRoot(ut.Uri); if (_reposRoot == null) { throw new InvalidOperationException("Can't retrieve the repository root of the UriTarget"); } #if DEBUG Debug.Assert(!_reposRoot.MakeRelativeUri(_uri).IsAbsoluteUri); #endif } } return; } throw new InvalidOperationException("Invalid target type"); }
public void OnUpdate(CommandUpdateEventArgs e) { foreach (SccProject p in e.Selection.GetSelectedProjects(false)) { ISccProjectInfo pi = e.GetService <IProjectFileMapper>().GetProjectInfo(p); if (p == null || pi == null || string.IsNullOrEmpty(pi.ProjectFile)) { break; // No project file } if (!string.IsNullOrEmpty(pi.ProjectDirectory) && string.Equals(pi.ProjectDirectory, pi.ProjectFile, StringComparison.OrdinalIgnoreCase)) { break; // Project file is directory } SvnItem item = e.GetService <ISvnStatusCache>()[pi.ProjectFile]; if (item != null && item.IsDirectory) { break; // Project file is not file } return; // Show the menu } e.Enabled = e.Visible = false; }
/// <summary> /// Schedules a dirty check for the specified document /// </summary> /// <param name="item">The item.</param> public void ScheduleDirtyCheck(SvnItem item) { if (item == null) { throw new ArgumentNullException("path"); } if (!item.IsVersioned || item.IsModified || DocumentTracker.NoDirtyCheck(item)) { return; // Not needed } lock (_lock) { if (_dirtyCheck == null) { _dirtyCheck = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); } if (!_dirtyCheck.Contains(item.FullPath)) { _dirtyCheck.Add(item.FullPath); } PostIdle(); } }
/// <summary> /// Gets the "project root" /// </summary> /// <param name="e"></param> /// <returns></returns> private static SvnItem GetRoot(BaseCommandEventArgs e) { SvnItem item = null; switch (e.Command) { case AnkhCommand.SolutionIssueTrackerSetup: IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>(); if (ss == null) { return(null); } string root = ss.ProjectRoot; if (string.IsNullOrEmpty(root)) { return(null); } item = e.GetService <ISvnStatusCache>()[root]; break; } return(item); }
/// <summary> /// Stores the item in the caching dictionary/ies /// </summary> /// <param name="item"></param> public void StoreItem(SvnItem item) { if (item == null) { throw new ArgumentNullException("item"); } Map[item.FullPath] = item; SvnDirectory dir; if (DirectoryMap.TryGetValue(item.FullPath, out dir)) { if (item.IsDirectory) { ((ISvnDirectoryUpdate)dir).Store(item); } else { ScheduleForCleanup(dir); } } var parentDir = SvnTools.GetNormalizedDirectoryName(item.FullPath); if (string.IsNullOrEmpty(parentDir) || parentDir == item.FullPath) { return; // Skip root directory } if (DirectoryMap.TryGetValue(item.FullPath, out dir)) { ((ISvnDirectoryUpdate)dir)?.Store(item); } }
internal string MakeBackup(string fullPath) { if (string.IsNullOrEmpty(fullPath)) { throw new ArgumentNullException("fullPath"); } if (SvnItem.PathExists(fullPath)) { string tmp; int n = 0; do { tmp = string.Format("{0}.tmp{1}", fullPath, n++); }while (SvnItem.PathExists(tmp)); DirectoryInfo source = new DirectoryInfo(fullPath); DirectoryInfo dest = Directory.CreateDirectory(tmp); RecursiveCopy(source, dest); return(tmp); } else { return(null); } }
private void okButton_Click(object sender, EventArgs e) { string path = directory.Text; if (!SvnItem.IsValidPath(path) || File.Exists(path)) { MessageBox.Show(this, "Path is not valid", "Open Project from Subversion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } directory.Text = path = SvnTools.GetNormalizedFullPath(path); if (Directory.Exists(path)) { DirectoryInfo di = new DirectoryInfo(path); if (EnumTools.GetFirst(di.GetFileSystemInfos()) != null) { if (MessageBox.Show(this, string.Format("{0} already contains files or directories.\nWould you like to continue?", path) , "Open Project from Subversion", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes) { return; } } } else { Directory.CreateDirectory(path); } DialogResult = DialogResult.OK; }
void CheckForMatch(string newItem, string maybeFrom) { string v; if (_fileOrigins.TryGetValue(newItem, out v) && v != null) { return; } FileInfo newInfo = new FileInfo(newItem); FileInfo maybeInfo = new FileInfo(maybeFrom); if (maybeInfo.Exists && newInfo.Exists && maybeInfo.Length == newInfo.Length) { // BH: Don't verify filedates, etc; as they shouldn't be copied if (FileContentsEquals(maybeInfo.FullName, newInfo.FullName)) { _fileOrigins[newItem] = maybeFrom; } } else if (!maybeInfo.Exists) { // Handles Delete followed by add. Triggered from Cut&Paste SvnItem svnItem = SvnCache[maybeInfo.FullName]; if (svnItem.IsVersioned) { _fileOrigins[newItem] = svnItem.FullPath; } } }
public EditReadOnlyFileDialog(SvnItem item) : this() { if(item == null) throw new ArgumentNullException("item"); label1.Text = string.Format(label1.Text, item.Name); }
public static Uri DisplayBrowseDialogAndGetResult(WizardPage page, SvnItem target, string baseUri) { Uri u; if(Uri.TryCreate(baseUri, UriKind.Absolute, out u)) return DisplayBrowseDialogAndGetResult(page, target, u); page.Message = MergeUtils.INVALID_FROM_URL; return null; }
internal virtual ICollection<Uri> GetMergeSources(SvnItem target) { SvnMergeSourcesCollection sources = Wizard.MergeUtils.GetSuggestedMergeSources(target); List<Uri> rslt = new List<Uri>(sources.Count); foreach (SvnMergeSource s in sources) rslt.Add(s.Uri); return rslt; }
public FileSystemTreeNode(WCTreeNode wcNode, SvnItem item) { if (wcNode == null) throw new ArgumentNullException("wcNode"); _wcNode = wcNode; Text = wcNode.Title; _item = item; wcNode.TreeNode = this; }
public FileSystemListViewItem(SmartListView view, SvnItem item) : base(view) { if (item == null) throw new ArgumentNullException("item"); _svnItem = item; ImageIndex = View.IconMapper.GetIcon(item.FullPath); RefreshValues(); }
public WCSolutionNode(IAnkhServiceProvider context, SvnItem item) : base(context, null, item) { string file = Context.GetService<IAnkhSolutionSettings>().SolutionFilename; IFileIconMapper iconMapper = context.GetService<IFileIconMapper>(); if (string.IsNullOrEmpty(file)) _imageIndex = iconMapper.GetIconForExtension(".sln"); else _imageIndex = iconMapper.GetIcon(file); }
internal override ICollection<Uri> GetMergeSources(SvnItem target) { SvnMergeItemCollection items = Wizard.MergeUtils.GetAppliedMerges(target); List<Uri> rslt = new List<Uri>(items == null ? 0 : items.Count); if (items != null) { foreach (SvnMergeItem i in items) rslt.Add(i.Uri); } return rslt; }
/// <summary> /// Constructor. /// </summary> /// <param name="utils"></param> public MergeWizard(IAnkhServiceProvider context, SvnItem mergeTarget) { InitializeComponent(); DefaultPageImage = MergeStrings.MergeWizardHeaderImage; MergeUtils = new MergeUtils(context); MergeTarget = mergeTarget; Text = MergeStrings.MergeWizardTitle; mergeTypePage = new MergeTypePage(); bestPracticesPage = new MergeBestPracticesPage(); mergeSourceRangeOfRevisionsPage = new MergeSourceRangeOfRevisionsPage(); mergeSourceReintegratePage = new MergeSourceReintegratePage(); mergeSourceTwoDifferentTreesPage = new MergeSourceTwoDifferentTreesPage(); mergeSourceManuallyRecordPage = new MergeSourceManuallyRecordPage(); mergeSourceManuallyRemovePage = new MergeSourceManuallyRemovePage(); mergeRevisionsSelectionPage = new MergeRevisionsSelectionPage(); mergeOptionsPage = new MergeOptionsPage(); mergeSummaryPage = new MergeSummaryPage(); }
public SynchronizeListItem(SynchronizeListView list, SvnItem item, SvnStatusEventArgs status) : base(list) { if (item == null) throw new ArgumentNullException("item"); _item = item; _status = status; _localChange = PendingChange.CombineStatus(status.LocalContentStatus, status.LocalPropertyStatus, item.IsTreeConflicted, item); _remoteChange = PendingChange.CombineStatus(status.RemoteContentStatus, status.RemotePropertyStatus, false, null); if (_remoteChange == PendingChangeKind.None) { if (status.RemoteLock != null) _remoteChange = PendingChangeKind.LockedOnly; } _localStatus = new PendingChangeStatus(_localChange); _remoteStatus = new PendingChangeStatus(_remoteChange); UpdateText(); }
static void SetSolutionManaged(bool shouldActivate, SvnItem item, IAnkhSccService scc) { if (shouldActivate) scc.RegisterAsPrimarySccProvider(); scc.SetProjectManaged(null, true); item.MarkDirty(); // This clears the solution settings cache to retrieve its properties }
static bool HandleUnmanagedOrUnversionedSolution(CommandEventArgs e, SvnItem solutionItem) { IAnkhSccService scc = e.GetService<IAnkhSccService>(); AnkhMessageBox mb = new AnkhMessageBox(e.Context); bool shouldActivate = false; if (!scc.IsActive) { if (e.State.OtherSccProviderActive) return false; // Can't switch in this case.. Nothing to do // Ankh is not the active provider, we should register as active shouldActivate = true; } if (scc.IsSolutionManaged && solutionItem.IsVersioned) return true; // Projects should still be checked bool confirmed = false; if (solutionItem.IsVersioned) { /* File is in subversion; just enable */ } else if (solutionItem.IsVersionable) { if (!AddVersionableSolution(e, solutionItem, ref confirmed)) return false; } else { if (!CheckoutWorkingCopyForSolution(e, ref confirmed)) return false; } if (!confirmed && !e.DontPrompt && !e.IsInAutomation && DialogResult.Yes != mb.Show(string.Format(CommandResources.MarkXAsManaged, Path.GetFileName(e.Selection.SolutionFilename)), "", MessageBoxButtons.YesNo)) { return false; } SetSolutionManaged(shouldActivate, solutionItem, scc); return true; }
static SvnItem GetVersionedParent(SvnItem child) { if (!child.IsVersionable) return null; if (!child.IsVersioned) return GetVersionedParent(child.Parent); return child; }
static bool AddVersionableSolution(CommandEventArgs e, SvnItem solutionItem, ref bool confirmed) { AnkhMessageBox mb = new AnkhMessageBox(e.Context); SvnItem parentDir = GetVersionedParent(solutionItem); // File is not versioned but is inside a versioned directory if (!e.DontPrompt && !e.IsInAutomation) { if (!solutionItem.Parent.IsVersioned) { AddPathToSubversion(e, e.Selection.SolutionFilename); return true; } DialogResult rslt = mb.Show(string.Format(CommandResources.AddXToExistingWcY, Path.GetFileName(e.Selection.SolutionFilename), parentDir.FullPath), AnkhId.PlkProduct, MessageBoxButtons.YesNoCancel); if (rslt == DialogResult.Cancel) return false; if (rslt == DialogResult.No) { // Checkout new working copy return CheckoutWorkingCopyForSolution(e, ref confirmed); } if (rslt == DialogResult.Yes) { // default case: Add to existing workingcopy AddPathToSubversion(e, e.Selection.SolutionFilename); return true; } return false; } confirmed = true; return true; }
static bool Skip(SvnItem item) { return (item.IsVersioned || item.IsIgnored || !item.IsVersionable || !item.Exists); }
string SafeRepositoryPath(SvnItem item) { if (item == null || item.Uri == null) return ""; SvnWorkingCopy wc = item.WorkingCopy; if (wc != null) { Uri root = wc.RepositoryRoot; if (root != null) { Uri relative = root.MakeRelativeUri(item.Uri); if (!relative.IsAbsoluteUri) { string v = SvnTools.UriPartToPath(relative.ToString()).Replace(Path.DirectorySeparatorChar, '/'); if (!string.IsNullOrEmpty(v) && !v.StartsWith("/") && !v.StartsWith("../") && v != ".") return "^/" + v; } } } return item.Uri.ToString(); }
tagVSQuerySaveResult QueryReadOnlyFile(SvnItem item) { Debug.Assert(item.IsReadOnly && !item.IsReadOnlyMustLock, "item.IsReadOnly && !item.IsReadOnlyMustLock"); // Now we have to ask the user wether to overwrite, or to save as using (SccQuerySaveReadonlyDialog dlg = new SccQuerySaveReadonlyDialog()) { dlg.File = item.Name; DialogResult result = dlg.ShowDialog(Context); switch (result) { case DialogResult.Yes: // Force the caller to show a save-as dialog for this file return tagVSQuerySaveResult.QSR_ForceSaveAs; case DialogResult.No: // User wants to overwrite existing file try { FileAttributes attrs = File.GetAttributes(item.FullPath); File.SetAttributes(item.FullPath, attrs & ~FileAttributes.ReadOnly); } catch (IOException) // Includes PathTooLongException { } catch (SystemException) // Includes UnauthorizedAccessException { } // it's no longer read-only, so save is OK return tagVSQuerySaveResult.QSR_SaveOK; case DialogResult.Cancel: return tagVSQuerySaveResult.QSR_NoSave_Cancel; default: throw new InvalidOperationException("Dialog returned unexpected DialogResult"); } // switch(dialogResult) } // using dialog }
public void RemoveItem(SvnItem item, uint id) { int found; VsProject.RemoveItem(0, id, out found); _map.Clear(); // Flush the cache to make sure ids stay valid }
public string GetFileType(SvnItem item) { if (item == null) throw new ArgumentNullException("item"); string extension = Path.GetExtension(item.FullPath).TrimStart('.'); if (item.IsDirectory && !item.FullPath.EndsWith("\\")) { return SolutionExplorerStrings.ExplorerDirectoryName; } string rslt; lock (_fileTypeMap) { if (_fileTypeMap.TryGetValue(extension, out rslt)) return rslt; } rslt = GetTypeName(item.FullPath); lock (_fileTypeMap) { if (extension.Length > 0) _fileTypeMap[extension] = rslt; } return rslt; }
private bool AddItem(SvnItem item, out uint parentId) { string itemDir = item.Directory; if (itemDir == null) { parentId = VSConstants.VSITEMID_NIL; return false; } else if (string.Equals(itemDir, ProjectDirectory, StringComparison.OrdinalIgnoreCase)) parentId = VSConstants.VSITEMID_ROOT; else { parentId = GetId(itemDir, VSConstants.VSITEMID_ROOT); if (parentId == VSConstants.VSITEMID_NIL) { if (!AddItem(item.Parent, out parentId)) return false; parentId = GetId(itemDir, parentId); if (parentId == VSConstants.VSITEMID_NIL) return false; } } VSADDRESULT[] result = new VSADDRESULT[1]; return ErrorHandler.Succeeded(VsProject.AddItem(parentId, VSADDITEMOPERATION.VSADDITEMOP_OPENFILE, item.FullPath, 1, new string[] { item.FullPath }, IntPtr.Zero, result)) && result[0] == VSADDRESULT.ADDRESULT_Success; }
public void TestExistingFileType() { var statusCache = new Mock<IFileStatusCache>(); string tempFile = Path.GetTempFileName(); string exeTempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".exe"); using (File.CreateText(exeTempFile)) { } try { var item = new SvnItem(statusCache.Object, tempFile, NoSccStatus.Unknown, SharpSvn.SvnNodeKind.File); Assert.That(mapper.GetFileType(item), Is.EqualTo("TMP File")); item = new SvnItem(statusCache.Object, exeTempFile, NoSccStatus.Unknown, SharpSvn.SvnNodeKind.File); Assert.That(mapper.GetFileType(item), Is.EqualTo("Application")); item = new SvnItem(statusCache.Object, "C:\\", NoSccStatus.Unknown, SharpSvn.SvnNodeKind.Directory); Assert.That(mapper.GetFileType(item), Is.EqualTo("Local Disk")); } finally { File.Delete(tempFile); File.Delete(exeTempFile); } }
private static void AddIgnore(Dictionary<string, List<string>> add, SvnItem item, string name) { if (item == null) return; if (!item.IsVersioned) return; List<string> toAdd; if (!add.TryGetValue(item.FullPath, out toAdd)) { toAdd = new List<string>(); add.Add(item.FullPath, toAdd); } if (!toAdd.Contains(name)) toAdd.Add(name); }
bool ShouldIgnore(SvnItem item) { while (item != null) { SvnStatus lc = item.Status.LocalContentStatus; if (lc == SvnStatus.Ignored) return true; else if (lc != SvnStatus.NotVersioned) return false; item = item.Parent; } return false; }
private string GetStatus(SvnItem dirItem, ISvnProjectInfo projectInfo, string file) { if (dirItem == null || !dirItem.Exists || !dirItem.IsVersioned) return "<not found>"; if (projectInfo == null) { if (Scc.IsSolutionManaged) return "Connected"; // Solution itself + Connected else return "Not Connected"; } if (dirItem.IsBelowPath(SolutionSettings.ProjectRootSvnItem) && dirItem.WorkingCopy == SolutionSettings.ProjectRootSvnItem.WorkingCopy) { // In master working copy if (Scc.IsSolutionManaged && Scc.IsProjectManaged(_project)) return "Connected"; else return "Valid"; // In master working copy } else if (Scc.IsSolutionManaged && Scc.IsProjectManaged(_project)) return "Connected"; // Required information in solution else return "Detached"; // Separate working copy }
/// <summary> /// Returns a list of strings for the suggested merge sources. /// </summary> internal SvnMergeSourcesCollection GetSuggestedMergeSources(SvnItem target) { using (SvnClient client = GetClient()) { SvnMergeSourcesCollection mergeSources = null; SvnGetSuggestedMergeSourcesArgs args = new SvnGetSuggestedMergeSourcesArgs(); args.ThrowOnError = false; client.GetSuggestedMergeSources(target.FullPath, args, out mergeSources); return mergeSources ?? new SvnMergeSourcesCollection(); } }
string SafeRepositoryRoot(SvnItem item) { if (item == null || item.WorkingCopy == null) return ""; Uri root = item.WorkingCopy.RepositoryRoot; if (root != null) return root.ToString(); return ""; }
public PropertyEditorDialog(SvnItem svnItem) : this(svnItem.FullPath) { _currentNodeKind = svnItem.NodeKind; }
internal SvnMergeItemCollection GetAppliedMerges(SvnItem target) { using (SvnClient client = GetClient()) { SvnGetAppliedMergeInfoArgs args = new SvnGetAppliedMergeInfoArgs(); SvnAppliedMergeInfo mergeInfo; args.ThrowOnError = false; if (!client.GetAppliedMergeInfo(target.Uri, args, out mergeInfo)) return null; return mergeInfo.AppliedMerges; } }
static DateTime GetCreated(SvnItem item) { try { return File.GetCreationTimeUtc(item.FullPath); } catch { return DateTime.UtcNow; } }