protected override IEnumerable <VersionInfo> OnGetVersionInfo(IEnumerable <FilePath> paths, bool getRemoteStatus)
 {
     foreach (var p in paths)
     {
         yield return(VersionInfo.CreateUnversioned(p, System.IO.Directory.Exists(p)));
     }
 }
Ejemplo n.º 2
0
        protected override Task <IReadOnlyList <VersionInfo> > OnGetVersionInfoAsync(IEnumerable <FilePath> paths, bool getRemoteStatus, CancellationToken cancellationToken)
        {
            var result = new List <VersionInfo> ();

            foreach (var p in paths)
            {
                result.Add(VersionInfo.CreateUnversioned(p, System.IO.Directory.Exists(p)));
            }
            return(Task.FromResult((IReadOnlyList <VersionInfo>)result));
        }
        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));
        }
Ejemplo n.º 4
0
        void AddFolderOverlay(Repository rep, string folder, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon, object dataObject)
        {
            Gdk.Pixbuf  overlay = null;
            VersionInfo vinfo   = GetVersionInfo(rep, folder, dataObject, false);

            if (vinfo == null)
            {
                ThreadPool.QueueUserWorkItem(x => {
                    VersionInfo info = GetVersionInfo(rep, folder, dataObject, true);
                    if (info != null)
                    {
                        DispatchService.GuiDispatch(() => UpdatePath(folder));
                    }
                });
                vinfo = VersionInfo.CreateUnversioned(folder, true);
            }
            else if (!vinfo.IsVersioned)
            {
                overlay = VersionControlService.LoadOverlayIconForStatus(VersionStatus.Unversioned);
            }
            else if (vinfo.IsVersioned && !vinfo.HasLocalChanges)
            {
                overlay = VersionControlService.overlay_controled;
            }
            else
            {
                overlay = VersionControlService.LoadOverlayIconForStatus(vinfo.Status);
            }
            if (overlay != null)
            {
                AddOverlay(ref icon, overlay);
                if (closedIcon != null)
                {
                    AddOverlay(ref closedIcon, overlay);
                }
            }
        }
Ejemplo n.º 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
            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);
            }
        }