GetDirectoryVersionInfo() public method

public GetDirectoryVersionInfo ( FilePath localDirectory, bool getRemoteStatus, bool recursive ) : MonoDevelop.VersionControl.VersionInfo[]
localDirectory FilePath
getRemoteStatus bool
recursive bool
return MonoDevelop.VersionControl.VersionInfo[]
示例#1
0
        static void OnEntryAdded(object o, SolutionItemEventArgs args)
        {
            if (args is SolutionItemChangeEventArgs && ((SolutionItemChangeEventArgs)args).Reloading)
            {
                return;
            }

            // handles addition of solutions and projects
            SolutionItem parent = (SolutionItem)args.SolutionItem.ParentFolder;

            if (parent == null)
            {
                return;
            }

            Repository repo = GetRepository(parent);

            if (repo == null)
            {
                return;
            }

            SolutionItem entry       = args.SolutionItem;
            Repository   currentRepo = GetRepository(entry);

            if (currentRepo != null && currentRepo.VersionControlSystem != repo.VersionControlSystem)
            {
                // If the item is already under version control using a different version control system
                // don't add it to the parent repo.
                return;
            }

            string path = entry.BaseDirectory;

            // While we /could/ call repo.Add with `recursive = true', we don't
            // necessarily want to add files under the project/solution directory
            // that may not be a part of this project/solution.

            var files = new HashSet <string> {
                path
            };

            SolutionItemAddFiles(path, entry, files);

            using (IProgressMonitor monitor = GetStatusMonitor()) {
                var status = repo.GetDirectoryVersionInfo(path, false, true);
                foreach (var v in status)
                {
                    if (!v.IsVersioned && files.Contains(v.LocalPath))
                    {
                        repo.Add(v.LocalPath, false, monitor);
                    }
                }
            }

            NotifyFileStatusChanged(new FileUpdateEventArgs(repo, parent.BaseDirectory, true));
        }
示例#2
0
        VersionInfo GetVersionInfo(Repository vc, FilePath filepath, object dataObject, bool allowCacheMiss = true)
        {
            FilePath dir = filepath;

            dir = dir.ParentDirectory.CanonicalPath;

            DirData data;

            if (filePaths.TryGetValue(dir, out data))
            {
                var fileData = data.FileData;
                if (fileData == null && allowCacheMiss)
                {
                    fileData = new Dictionary <FilePath, VersionInfo> ();
                    foreach (VersionInfo vin in vc.GetDirectoryVersionInfo(dir, false, false))
                    {
                        // Console.WriteLine ("Storing {0} for {1}", vin.Status, vin.LocalPath.CanonicalPath);
                        fileData [vin.LocalPath.CanonicalPath] = vin;
                    }

                    data.Timestamp = DateTime.Now;
                    DispatchService.GuiDispatch(() => data.FileData = fileData);
                }
                VersionInfo vi;
                if (data.FileData != null && data.FileData.TryGetValue(filepath.CanonicalPath, out vi))
                {
                    return(vi);
                }
            }

            if (allowCacheMiss)
            {
                VersionInfo node = vc.GetVersionInfo(filepath, false);
                if (node != null)
                {
                    if (data == null)
                    {
                        data          = new DirData();
                        data.Object   = dataObject;
                        data.FileData = new Dictionary <FilePath, VersionInfo> ();
                        DispatchService.GuiDispatch(() => filePaths[dir] = data);
                    }
                    // Console.WriteLine ("Storing {0} for {1}", node.Status, filepath.CanonicalPath);
                    data.Timestamp = DateTime.Now;
                    DispatchService.GuiDispatch(() => { if (data.FileData != null)
                                                        {
                                                            data.FileData [filepath.CanonicalPath] = node;
                                                        }
                                                });
                    return(node);
                }
            }


            return(null);
        }
示例#3
0
        public static bool Commit(VersionControlItemList items, bool test)
        {
            int filesToCommit = 0;

            VersionControlItemList[] itemListsByRepo = items.SplitByRepository();

            foreach (VersionControlItemList itemList in itemListsByRepo)
            {
                // Generate base folder path.
                FilePath basePath = itemList.FindMostSpecificParent(FilePath.Null);

                Repository repo = itemList.First().Repository;

                ChangeSet cset = repo.CreateChangeSet(basePath);
                cset.GlobalComment = VersionControlService.GetCommitComment(cset.BaseLocalPath);

                foreach (var item in itemList)
                {
                    if (!item.VersionInfo.CanCommit)
                    {
                        continue;
                    }

                    if (test)
                    {
                        return(true);
                    }

                    foreach (VersionInfo vi in repo.GetDirectoryVersionInfo(item.Path, false, true))
                    {
                        if (vi.HasLocalChanges)
                        {
                            filesToCommit++;
                            if (test)
                            {
                                continue;
                            }

                            cset.AddFile(vi);
                        }
                    }
                }

                if (!cset.IsEmpty)
                {
                    Commit(repo, cset, false);
                }
                else if (!test)
                {
                    MessageService.ShowMessage(GettextCatalog.GetString("There are no changes to be committed."));
                    continue;
                }
            }
            return(filesToCommit != 0);
        }
        VersionInfo GetVersionInfo(Repository vc, FilePath filepath)
        {
            FilePath dir = filepath;

            dir = dir.ParentDirectory.CanonicalPath;

            DirData data;

            if (filePaths.TryGetValue(dir, out data))
            {
                if (data.FileData == null)
                {
                    data.FileData = new Dictionary <FilePath, VersionInfo> ();
                    foreach (VersionInfo vin in vc.GetDirectoryVersionInfo(dir, false, false))
                    {
                        data.FileData [vin.LocalPath.CanonicalPath] = vin;
                    }
                    data.Timestamp = DateTime.Now;
                }
                VersionInfo vi;
                if (data.FileData.TryGetValue(filepath.CanonicalPath, out vi))
                {
                    return(vi);
                }
            }

            VersionInfo node = vc.GetVersionInfo(filepath, false);

            if (node != null)
            {
                if (data != null)
                {
                    data.FileData [filepath] = node;
                }
                return(node);
            }
            return(VersionInfo.CreateUnversioned(filepath, false));
        }
		VersionInfo GetVersionInfo (Repository vc, FilePath filepath)
		{
			FilePath dir = filepath;
			dir = dir.ParentDirectory.CanonicalPath;

			DirData data;
			if (filePaths.TryGetValue (dir, out data)) {
				if (data.FileData == null) {
					data.FileData = new Dictionary<FilePath, VersionInfo> ();
					foreach (VersionInfo vin in vc.GetDirectoryVersionInfo (dir, false, false))
						data.FileData [vin.LocalPath.CanonicalPath] = vin;
					data.Timestamp = DateTime.Now;
				}
				VersionInfo vi;
				if (data.FileData.TryGetValue (filepath.CanonicalPath, out vi))
					return vi;
			}
			
			VersionInfo node = vc.GetVersionInfo (filepath, false);
			if (node != null) {
				if (data != null)
					data.FileData [filepath] = node;
				return node;
			}
			return VersionInfo.CreateUnversioned (filepath, false);
		}
        public override void BuildNode(ITreeBuilder builder, object dataObject, NodeInfo nodeInfo)
        {
            if (!builder.Options["ShowVersionControlOverlays"])
            {
                return;
            }

            // Add status overlays

            if (dataObject is IWorkspaceObject)
            {
                IWorkspaceObject ce  = (IWorkspaceObject)dataObject;
                Repository       rep = VersionControlService.GetRepository(ce);
                if (rep != null)
                {
                    rep.GetDirectoryVersionInfo(ce.BaseDirectory, false, false);
                    AddFolderOverlay(rep, ce.BaseDirectory, nodeInfo, false);
                }
                return;
            }
            else if (dataObject is ProjectFolder)
            {
                ProjectFolder ce = (ProjectFolder)dataObject;
                if (ce.ParentWorkspaceObject != null)
                {
                    Repository rep = VersionControlService.GetRepository(ce.ParentWorkspaceObject);
                    if (rep != null)
                    {
                        rep.GetDirectoryVersionInfo(ce.Path, false, false);
                        AddFolderOverlay(rep, ce.Path, nodeInfo, true);
                    }
                }
                return;
            }

            IWorkspaceObject prj;
            FilePath         file;

            if (dataObject is ProjectFile)
            {
                ProjectFile pfile = (ProjectFile)dataObject;
                prj  = pfile.Project;
                file = pfile.FilePath;
            }
            else
            {
                SystemFile pfile = (SystemFile)dataObject;
                prj  = pfile.ParentWorkspaceObject;
                file = pfile.Path;
            }

            if (prj == null)
            {
                return;
            }

            Repository repo = VersionControlService.GetRepository(prj);

            if (repo == null)
            {
                return;
            }

            VersionInfo vi = repo.GetVersionInfo(file);

            nodeInfo.OverlayBottomRight = VersionControlService.LoadOverlayIconForStatus(vi.Status);
        }
        public override void BuildNode(ITreeBuilder builder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            if (!builder.Options["ShowVersionControlOverlays"])
            {
                return;
            }

            // Add status overlays

            if (dataObject is IWorkspaceObject)
            {
                IWorkspaceObject ce  = (IWorkspaceObject)dataObject;
                Repository       rep = VersionControlService.GetRepository(ce);
                if (rep != null)
                {
                    AddFolderOverlay(rep, ce.BaseDirectory, ref icon, ref closedIcon, false);
                    rep.GetDirectoryVersionInfo(ce.BaseDirectory, false, false);
                }
                return;
            }
            else if (dataObject is ProjectFolder)
            {
                ProjectFolder ce = (ProjectFolder)dataObject;
                if (ce.ParentWorkspaceObject != null)
                {
                    Repository rep = VersionControlService.GetRepository(ce.ParentWorkspaceObject);
                    if (rep != null)
                    {
                        AddFolderOverlay(rep, ce.Path, ref icon, ref closedIcon, true);
                        rep.GetDirectoryVersionInfo(ce.Path, false, false);
                    }
                }
                return;
            }

            IWorkspaceObject prj;
            FilePath         file;

            if (dataObject is ProjectFile)
            {
                ProjectFile pfile = (ProjectFile)dataObject;
                prj  = pfile.Project;
                file = pfile.FilePath;
            }
            else
            {
                SystemFile pfile = (SystemFile)dataObject;
                prj  = pfile.ParentWorkspaceObject;
                file = pfile.Path;
            }

            if (prj == null)
            {
                return;
            }

            Repository repo = VersionControlService.GetRepository(prj);

            if (repo == null)
            {
                return;
            }

            VersionInfo vi = repo.GetVersionInfo(file);

            Gdk.Pixbuf overlay = VersionControlService.LoadOverlayIconForStatus(vi.Status);
            if (overlay != null)
            {
                AddOverlay(ref icon, overlay);
            }
        }
		VersionInfo GetVersionInfo (Repository vc, FilePath filepath, object dataObject, bool allowCacheMiss = true)
		{
			FilePath dir = filepath;
			dir = dir.ParentDirectory.CanonicalPath;

			DirData data;

				if (filePaths.TryGetValue (dir, out data)) {
					var fileData = data.FileData;
					if (fileData == null && allowCacheMiss) {
						fileData = new Dictionary<FilePath, VersionInfo> ();
						foreach (VersionInfo vin in vc.GetDirectoryVersionInfo (dir, false, false)) {
							// Console.WriteLine ("Storing {0} for {1}", vin.Status, vin.LocalPath.CanonicalPath);
							fileData [vin.LocalPath.CanonicalPath] = vin;
						}
						
						data.Timestamp = DateTime.Now;
						DispatchService.GuiDispatch(() => data.FileData = fileData);
					}
					VersionInfo vi;
					if (data.FileData != null && data.FileData.TryGetValue (filepath.CanonicalPath, out vi))
						return vi;
				}
				
				if (allowCacheMiss) {
					VersionInfo node = vc.GetVersionInfo (filepath, false);
					if (node != null) {
						if (data == null) {
							data = new DirData ();
							data.Object = dataObject;
							data.FileData = new Dictionary<FilePath, VersionInfo> ();
							DispatchService.GuiDispatch (() => filePaths[dir] = data);
						}
						// Console.WriteLine ("Storing {0} for {1}", node.Status, filepath.CanonicalPath);
						data.Timestamp = DateTime.Now;
						DispatchService.GuiDispatch (() => { if (data.FileData != null) data.FileData [filepath.CanonicalPath] = node; });
						return node;
					}
				}
			
			
			return null;
		}