コード例 #1
0
        /// <summary>
        /// Checks whether the project might have been renamed
        /// </summary>
        /// <param name="oldName">The old name.</param>
        /// <param name="newName">The new name.</param>
        public void CheckProjectRename(string oldName, string newName)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_checkedProjectFile && oldName == ProjectFile)
            {
                _checkedProjectFile = false;
                _projectFile        = null;
                _svnProjectInstance = null;
            }
        }
コード例 #2
0
        public bool IsProjectManaged(SccProject project)
        {
            if (!IsActive)
            {
                return(false);
            }

            if (project == null)
            {
                return(IsSolutionManaged);
            }

            return(IsProjectManagedRaw(project.RawHandle));
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ChangeSourceControlRow"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="project">The project.</param>
        public ChangeSourceControlRow(IAnkhServiceProvider context, SccProject project)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            _context = context;
            _project = project;
        }
コード例 #4
0
 public void SetProjectManaged(SccProject project, bool managed)
 {
     if (!IsActive)
     {
         return; // Perhaps allow clearing management settings?
     }
     if (project == null)
     {
         SetProjectManagedRaw(null, managed);
     }
     else
     {
         SetProjectManagedRaw(project.RawHandle, managed);
     }
 }
コード例 #5
0
        public void Load()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (_loaded || !_opened)
            {
                return;
            }

            _loaded             = true;
            _checkedProjectFile = false;
            _projectFile        = null;
            _svnProjectInstance = null;

            if (ExcludedFromScc)
            {
                return;
            }

            _inLoad = true;
            try
            {
                Debug.Assert(_files.Count == 0);

                ISccProjectWalker walker = GetService <ISccProjectWalker>();

                if (walker != null)
                {
                    Dictionary <string, uint> ids = new Dictionary <string, uint>(StringComparer.OrdinalIgnoreCase);
                    foreach (string file in walker.GetSccFiles(ProjectHierarchy, VSItemId.Root, ProjectWalkDepth.AllDescendantsInHierarchy, ids))
                    {
                        AddPath(file, ids); // GetSccFiles returns normalized paths
                    }
                }

                IFileStatusMonitor monitor = GetService <IFileStatusMonitor>();
                if (monitor != null)
                {
                    // Make sure we see all files as possible pending changes
                    monitor.ScheduleGlyphUpdate(GetAllFiles());
                }
                Hook(true);
            }
            finally
            {
                _inLoad = false;
            }
        }
コード例 #6
0
        public bool IsProjectManaged(SccProject project)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!IsActive)
            {
                return(false);
            }

            if (project == null)
            {
                return(IsSolutionManaged);
            }

            return(IsProjectManagedRaw(project.RawHandle));
        }
コード例 #7
0
        public IEnumerable <string> GetAllFilesOf(SccProject project, bool exceptExcluded)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            ThreadHelper.ThrowIfNotOnUIThread();

            if (project.IsSolution)
            {
                string sf = SolutionFilename;

                if (sf != null && (!exceptExcluded || !IsSccExcluded(SolutionFilename)))
                {
                    yield return(sf);
                }

                yield break;
            }

            project = ResolveRawProject(project);

            IVsSccProject2 scc = project.RawHandle;
            SccProjectData data;

            if (scc == null || !TryGetSccProject(scc, out data))
            {
                yield break;
            }

            foreach (string file in data.GetAllFiles())
            {
                if (file[file.Length - 1] != '\\') // Don't return paths
                {
                    if (exceptExcluded && IsSccExcluded(file))
                    {
                        continue;
                    }

                    yield return(file);
                }
            }
        }
コード例 #8
0
        private static SvnItem GetRoot(BaseCommandEventArgs e)
        {
            SvnItem item = null;

            switch (e.Command)
            {
            case AnkhCommand.SolutionBranch:
                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;

            case AnkhCommand.ProjectBranch:
                SccProject p = EnumTools.GetSingle(e.Selection.GetSelectedProjects(false));
                if (p == null)
                {
                    break;
                }

                ISccProjectInfo info = e.GetService <IProjectFileMapper>().GetProjectInfo(p);

                if (info == null || info.ProjectDirectory == null)
                {
                    break;
                }

                item = e.GetService <ISvnStatusCache>()[info.ProjectDirectory];
                break;
            }

            return(item);
        }
コード例 #9
0
        public void NotifyGlyphsChanged()
        {
            if (ExcludedFromScc || DontAddToProjectWindow)
            {
                return;
            }

            try
            {
                if (!PerNodeGlyphChange)
                {
                    SccProject.SccGlyphChanged(0, null, null, null);
                }
                else
                {
                    ForceGlyphChanges();
                }
            }
            catch { }
        }
コード例 #10
0
ファイル: SccProjectMap.cs プロジェクト: windygu/AnkhSVN
        public SccProject ResolveRawProject(SccProject project)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (project.RawHandle == null && !project.IsSolution)
            {
                SccProjectFile file;

                if (TryGetFile(project.FullPath, out file))
                {
                    foreach (SccProjectData p in file.GetOwnerProjects())
                    {
                        return(p.SvnProject);
                    }
                }
            }

            return(project);
        }
コード例 #11
0
        internal void ForceGlyphChanges()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            uint[]   idsArray;
            string[] namesArray;
            {
                List <uint>   ids   = new List <uint>(_files.Count);
                List <string> names = new List <string>(_files.Count);

                foreach (SccProjectFileReference r in _files)
                {
                    uint id = r.ProjectItemId;
                    if (id == VSItemId.Nil)
                    {
                        continue;
                    }

                    string name = r.ProjectFile.FullPath;
                    if (string.IsNullOrEmpty(name))
                    {
                        continue;
                    }

                    ids.Add(id);
                    names.Add(name);
                }
                idsArray   = ids.ToArray();
                namesArray = names.ToArray();
            }

            VsStateIcon[] newGlyphs = new VsStateIcon[idsArray.Length];
            uint[]        sccState  = new uint[idsArray.Length];

            if (VSErr.Succeeded(Map.GetSccGlyph(namesArray, newGlyphs, sccState)))
            {
                SccProject.SccGlyphChanged(idsArray.Length, idsArray, newGlyphs, sccState);
            }
        }
コード例 #12
0
ファイル: SccProjectMap.cs プロジェクト: windygu/AnkhSVN
        public ISccProjectInfo GetProjectInfo(SccProject project)
        {
            if (project == null)
            {
                return(null);
            }

            project = ResolveRawProject(project);

            if (project == null || project.RawHandle == null)
            {
                return(null);
            }

            SccProjectData pd;

            if (TryGetSccProject(project.RawHandle, out pd))
            {
                return(new WrapProjectInfo(pd));
            }

            return(null);
        }
コード例 #13
0
        private IEnumerable <SvnItem> GetSingleProjectRoots(SccProject project)
        {
            SccProjectData pd;

            if (project.RawHandle == null || !ProjectMap.TryGetSccProject(project.RawHandle, out pd))
            {
                yield break;
            }

            SvnItem projectRootItem = null;

            if (!string.IsNullOrEmpty(pd.ProjectDirectory))
            {
                projectRootItem = StatusCache[pd.ProjectDirectory];

                if (projectRootItem.IsVersioned)
                {
                    yield return(projectRootItem);
                }
            }

            string file = pd.ProjectFile;

            if (string.IsNullOrEmpty(file) || !SvnItem.IsValidPath(file))
            {
                yield break;
            }

            SvnItem projectFileItem = StatusCache[file];

            if (projectFileItem.IsVersioned &&
                (projectRootItem == null || !projectFileItem.IsBelowPath(projectRootItem.FullPath)))
            {
                yield return(projectFileItem);
            }
        }
コード例 #14
0
 public void EnsureCheckOutReference(SccProject project)
 {
     // NOOP for today
 }
コード例 #15
0
 public IEnumerable <string> GetAllFilesOf(SccProject project)
 {
     return(ProjectMap.GetAllFilesOf(project, false));
 }
コード例 #16
0
        public IEnumerable <string> GetAllFilesOf(ICollection <SccProject> projects, bool exceptExcluded)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            SortedList <string, string> files = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase);
            Hashtable handled = new Hashtable();

            foreach (SccProject p in projects)
            {
                SccProject project = ResolveRawProject(p);

                IVsSccProject2 scc = project.RawHandle;
                SccProjectData data;

                if (scc == null || !TryGetSccProject(scc, out data))
                {
                    if (p.IsSolution && SolutionFilename != null && !files.ContainsKey(SolutionFilename))
                    {
                        files.Add(SolutionFilename, SolutionFilename);

                        if (exceptExcluded && IsSccExcluded(SolutionFilename))
                        {
                            continue;
                        }

                        yield return(SolutionFilename);
                    }

                    continue;
                }

                if (handled.Contains(data))
                {
                    continue;
                }

                handled.Add(data, data);

                foreach (string file in data.GetAllFiles())
                {
                    if (file[file.Length - 1] == '\\') // Don't return paths
                    {
                        continue;
                    }

                    if (files.ContainsKey(file))
                    {
                        continue;
                    }

                    files.Add(file, file);

                    if (exceptExcluded && IsSccExcluded(file))
                    {
                        continue;
                    }

                    yield return(file);
                }
            }
        }
コード例 #17
0
ファイル: LogCommand.cs プロジェクト: windygu/AnkhSVN
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            int i;

            switch (e.Command)
            {
            case AnkhCommand.ProjectHistory:
                SccProject p = EnumTools.GetFirst(e.Selection.GetSelectedProjects(false));
                if (p == null)
                {
                    break;
                }

                ISccProjectInfo pi = e.GetService <IProjectFileMapper>().GetProjectInfo(p);

                if (pi == null || string.IsNullOrEmpty(pi.ProjectDirectory))
                {
                    break;     // No project location
                }
                if (e.GetService <ISvnStatusCache>()[pi.ProjectDirectory].HasCopyableHistory)
                {
                    return; // Ok, we have history!
                }
                break;      // No history

            case AnkhCommand.SolutionHistory:
                IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>();

                if (ss == null || string.IsNullOrEmpty(ss.ProjectRoot))
                {
                    break;
                }

                if (e.GetService <ISvnStatusCache>()[ss.ProjectRoot].HasCopyableHistory)
                {
                    return; // Ok, we have history!
                }
                break;      // No history

            case AnkhCommand.DocumentHistory:
                SvnItem docitem = e.Selection.ActiveDocumentSvnItem;
                if (docitem != null && docitem.HasCopyableHistory)
                {
                    return;
                }
                break;     // No history

            case AnkhCommand.Log:
                int itemCount        = 0;
                int needsRemoteCount = 0;
                foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false))
                {
                    if (!item.IsVersioned)
                    {
                        e.Enabled = false;
                        return;
                    }

                    if (item.IsReplaced || item.IsAdded)
                    {
                        if (item.HasCopyableHistory)
                        {
                            needsRemoteCount++;
                        }
                        else
                        {
                            e.Enabled = false;
                            return;
                        }
                    }
                    itemCount++;
                }
                if (itemCount == 0 || (needsRemoteCount != 0 && itemCount > 1))
                {
                    e.Enabled = false;
                    return;
                }
                if (needsRemoteCount >= 1)
                {
                    // One remote log
                    Debug.Assert(needsRemoteCount == 1);
                    return;
                }

                // Local log only
                return;

            case AnkhCommand.ReposExplorerLog:
                i = 0;
                foreach (ISvnRepositoryItem item in e.Selection.GetSelection <ISvnRepositoryItem>())
                {
                    if (item == null || item.Origin == null)
                    {
                        continue;
                    }
                    i++;
                    break;
                }
                if (i >= 1)
                {
                    return;
                }
                break;

            case AnkhCommand.AnnotateShowLog:
                IAnnotateSection section = EnumTools.GetSingle(e.Selection.GetSelection <IAnnotateSection>());
                if (section != null && section.Revision >= 0)
                {
                    return;
                }
                break;
            }
            e.Enabled = false;
        }
コード例 #18
0
ファイル: AddToSccCommands.cs プロジェクト: windygu/AnkhSVN
        /// <summary>
        /// Returns false if the AddToSubversionDialog has been cancelled, true otherwise
        /// </summary>
        /// <param name="e"></param>
        /// <param name="projectInfo"></param>
        /// <param name="solutionReposRoot"></param>
        /// <param name="shouldMarkAsManaged"></param>
        /// <param name="storeReference"></param>
        /// <returns></returns>
        static bool CheckoutWorkingCopyForProject(CommandEventArgs e, SccProject project, ISccProjectInfo projectInfo, Uri solutionReposRoot, out bool shouldMarkAsManaged, out bool storeReference)
        {
            shouldMarkAsManaged = false;
            storeReference      = false;
            using (SvnClient cl = e.GetService <ISvnClientPool>().GetClient())
                using (AddProjectToSubversion dialog = new AddProjectToSubversion())
                {
                    dialog.Context          = e.Context;
                    dialog.PathToAdd        = projectInfo.ProjectDirectory;
                    dialog.RepositoryAddUrl = solutionReposRoot;

                    if (e.Argument is IAnkhSccService)
                    {
                        dialog.CommitAllVisible = false;
                        dialog.CommitAllFiles   = false;
                    }
                    else
                    {
                        dialog.CommitAllFiles = true;
                    }

                    if (dialog.ShowDialog(e.Context) != DialogResult.OK)
                    {
                        return(false); // User cancelled the "Add to subversion" dialog, don't set as managed by Ankh
                    }
                    if (!dialog.CommitAllFiles)
                    {
                        Collection <SvnInfoEventArgs> info;
                        SvnInfoArgs ia = new SvnInfoArgs();
                        ia.ThrowOnError = false;
                        if (!cl.GetInfo(dialog.RepositoryAddUrl, ia, out info))
                        {
                            // Target uri doesn't exist in the repository, let's create
                            if (!RemoteCreateDirectory(e, dialog.Text, dialog.RepositoryAddUrl, cl))
                            {
                                return(false); // Create failed; bail out
                            }
                        }

                        // Create working copy
                        SvnCheckOutArgs coArg = new SvnCheckOutArgs();
                        coArg.AllowObstructions = true;
                        cl.CheckOut(dialog.RepositoryAddUrl, dialog.WorkingCopyDir, coArg);
                    }
                    else
                    {
                        // Cache some values before thread marshalling
                        HybridCollection <string> projectFiles = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
                        string wcDir    = dialog.WorkingCopyDir;
                        Uri    reposUrl = dialog.RepositoryAddUrl;
                        string logMessage;

                        projectFiles.UniqueAddRange(e.GetService <IProjectFileMapper>().GetAllFilesOf(project));
                        using (CreateDirectoryDialog dlg = new CreateDirectoryDialog())
                        {
                            dlg.Text                 = CommandStrings.ImportingTitle;
                            dlg.NewDirectoryName     = reposUrl.ToString();
                            dlg.NewDirectoryReadonly = true;

                            if (dlg.ShowDialog(e.Context) != DialogResult.OK)
                            {
                                return(false);
                            }

                            logMessage = dlg.LogMessage;
                        }
                        IAnkhOpenDocumentTracker documentTracker = e.GetService <IAnkhOpenDocumentTracker>();

                        documentTracker.SaveDocuments(projectFiles); // Make sure all files are saved before updating/merging!

                        using (DocumentLock lck = documentTracker.LockDocuments(projectFiles, DocumentLockType.NoReload))
                            using (lck.MonitorChangesForReload())
                            {
                                e.GetService <IProgressRunner>().RunModal(CommandStrings.ImportingTitle,
                                                                          delegate(object sender, ProgressWorkerArgs a)
                                {
                                    SvnImportArgs importArgs = new SvnImportArgs();
                                    importArgs.LogMessage    = logMessage;
                                    importArgs.Filter       +=
                                        delegate(object ieSender, SvnImportFilterEventArgs ie)
                                    {
                                        if (ie.NodeKind != SvnNodeKind.Directory)
                                        {
                                            ie.Filter = !projectFiles.Contains(ie.FullPath);
                                        }
                                        else
                                        {
                                            bool filter = true;
                                            foreach (string p in projectFiles)
                                            {
                                                if (SvnItem.IsBelowRoot(p, ie.FullPath))
                                                {
                                                    filter = false;
                                                    break;
                                                }
                                            }
                                            if (filter)
                                            {
                                                ie.Filter = true;
                                            }
                                        }
                                    };
                                    a.Client.Import(wcDir, reposUrl, importArgs);
                                });
                            }
                    }

                    shouldMarkAsManaged = dialog.MarkAsManaged;
                    storeReference      = dialog.WriteCheckOutInformation;
                }
            return(true);
        }