GetRepository() public static method

public static GetRepository ( WorkspaceObject entry ) : Repository
entry WorkspaceObject
return Repository
コード例 #1
0
        Repository GetRepository(FilePath path)
        {
            path = path.FullPath;

            Project p = IdeApp.Workspace.GetProjectContainingFile(path);

            if (p != null)
            {
                return(VersionControlService.GetRepository(p));
            }

            foreach (Project prj in IdeApp.Workspace.GetAllProjects())
            {
                if (path == prj.BaseDirectory || path.IsChildPathOf(prj.BaseDirectory))
                {
                    return(VersionControlService.GetRepository(prj));
                }
            }
            return(null);
        }
コード例 #2
0
        public static VersionControlItem CreateItem(object obj, bool projRecurse = true)
        {
            string           path;
            bool             isDir;
            IWorkspaceObject pentry;
            Repository       repo;
            VersionInfo      versionInfo = null;

            if (obj is ProjectFile)
            {
                ProjectFile file = (ProjectFile)obj;
                path        = file.FilePath;
                isDir       = false;
                pentry      = file.Project;
                versionInfo = file.ExtendedProperties [typeof(VersionInfo)] as VersionInfo;
            }
            else if (obj is SystemFile)
            {
                SystemFile file = (SystemFile)obj;
                path   = file.Path;
                isDir  = false;
                pentry = file.ParentWorkspaceObject;
            }
            else if (obj is ProjectFolder)
            {
                ProjectFolder f = (ProjectFolder)obj;
                path   = f.Path;
                isDir  = true;
                pentry = f.ParentWorkspaceObject;
            }
            else if (!projRecurse && obj is Solution)
            {
                Solution sol = (Solution)obj;
                path   = sol.FileName;
                isDir  = false;
                pentry = sol;
            }
            else if (!projRecurse && obj is Project)
            {
                Project proj = (Project)obj;
                path   = proj.FileName;
                isDir  = false;
                pentry = proj;
            }
            else if (!projRecurse && obj is UnknownSolutionItem)
            {
                UnknownSolutionItem item = (UnknownSolutionItem)obj;
                path   = item.FileName;
                isDir  = false;
                pentry = item;
            }
            else if (obj is IWorkspaceObject)
            {
                pentry = ((IWorkspaceObject)obj);
                path   = pentry.BaseDirectory;
                isDir  = true;
            }
            else
            {
                return(null);
            }

            if (pentry == null)
            {
                return(null);
            }

            repo = VersionControlService.GetRepository(pentry);
            return(new VersionControlItem(repo, pentry, path, isDir, versionInfo));
        }
コード例 #3
0
ファイル: PublishCommand.cs プロジェクト: zheref/monodevelop
        public static bool Publish(IWorkspaceObject entry, FilePath localPath, bool test)
        {
            if (test)
            {
                return(VersionControlService.CheckVersionControlInstalled() && VersionControlService.GetRepository(entry) == null);
            }

            List <FilePath> files = new List <FilePath> ();

            // Build the list of files to be checked in
            string moduleName = entry.Name;

            if (localPath == entry.BaseDirectory)
            {
                GetFiles(files, entry);
            }
            else if (entry is Project)
            {
                foreach (ProjectFile file in ((Project)entry).Files.GetFilesInPath(localPath))
                {
                    if (file.Subtype != Subtype.Directory)
                    {
                        files.Add(file.FilePath);
                    }
                }
            }
            else
            {
                return(false);
            }

            if (files.Count == 0)
            {
                return(false);
            }

            SelectRepositoryDialog dlg = new SelectRepositoryDialog(SelectRepositoryMode.Publish);

            try {
                dlg.ModuleName = moduleName;
                dlg.Message    = GettextCatalog.GetString("Initial check-in of module {0}", moduleName);
                do
                {
                    if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok && dlg.Repository != null)
                    {
                        AlertButton publishButton = new AlertButton("_Publish");
                        if (MessageService.AskQuestion(GettextCatalog.GetString("Are you sure you want to publish the project?"), GettextCatalog.GetString("The project will be published to the repository '{0}', module '{1}'.", dlg.Repository.Name, dlg.ModuleName), AlertButton.Cancel, publishButton) == publishButton)
                        {
                            PublishWorker w = new PublishWorker(dlg.Repository, dlg.ModuleName, localPath, files.ToArray(), dlg.Message);
                            w.Start();
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                } while (true);
            } finally {
                dlg.Destroy();
            }
            return(true);
        }
コード例 #4
0
        public override void BuildNode(ITreeBuilder builder, object dataObject, NodeInfo nodeInfo)
        {
            if (!builder.Options["ShowVersionControlOverlays"])
            {
                return;
            }

            // Add status overlays

            if (dataObject is WorkspaceObject)
            {
                WorkspaceObject ce  = (WorkspaceObject)dataObject;
                Repository      rep = VersionControlService.GetRepository(ce);
                if (rep != null)
                {
                    rep.GetDirectoryVersionInfoAsync(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.GetDirectoryVersionInfoAsync(ce.Path, false, false);
                        AddFolderOverlay(rep, ce.Path, nodeInfo, true);
                    }
                }
                return;
            }

            WorkspaceObject 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;
            }

            if (repo.TryGetVersionInfo(file, out var vi))
            {
                var overlay = VersionControlService.LoadOverlayIconForStatus(vi.Status);
                if (overlay != null)
                {
                    nodeInfo.OverlayBottomRight = overlay;
                }
            }
        }
コード例 #5
0
        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;
                ClearDirCache(ce.BaseDirectory);
                Repository rep = VersionControlService.GetRepository(ce);
                if (rep != null)
                {
                    AddFolderOverlay(rep, ce.BaseDirectory, ref icon, ref closedIcon);
                }
                return;
            }
            else if (dataObject is ProjectFolder)
            {
                ProjectFolder ce = (ProjectFolder)dataObject;
                if (ce.ParentWorkspaceObject != null)
                {
                    ClearDirCache(ce.Path);
                    Repository rep = VersionControlService.GetRepository(ce.ParentWorkspaceObject);
                    if (rep != null)
                    {
                        AddFolderOverlay(rep, ce.Path, ref icon, ref closedIcon);
                    }
                }
                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 = GetVersionInfo(repo, file);

            if (dataObject is ProjectFile)
            {
                ((ProjectFile)dataObject).ExtendedProperties [typeof(VersionInfo)] = vi;
            }

            Gdk.Pixbuf overlay = VersionControlService.LoadOverlayIconForStatus(vi.Status);
            if (overlay != null)
            {
                AddOverlay(ref icon, overlay);
            }
        }
コード例 #6
0
        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
            FilePath file;

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

            IWorkspaceObject prj;

            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 = GetVersionInfo(repo, file.CanonicalPath, dataObject, false);

            if (vi == null)
            {
                // Console.WriteLine ("Cache miss for {0}", file.CanonicalPath);
                ThreadPool.QueueUserWorkItem(x => {
                    VersionInfo info = GetVersionInfo(repo, file.CanonicalPath, dataObject, true);
                    if (info != null)
                    {
                        DispatchService.GuiDispatch(() => UpdatePath(file.CanonicalPath));
                    }
                });
                vi = VersionInfo.CreateUnversioned(file.CanonicalPath, false);
            }

            if (dataObject is ProjectFile)
            {
                ((ProjectFile)dataObject).ExtendedProperties [typeof(VersionInfo)] = vi;
            }

            Gdk.Pixbuf overlay = VersionControlService.LoadOverlayIconForStatus(vi.Status);
            if (overlay != null)
            {
                AddOverlay(ref icon, overlay);
            }
        }