public VersionControlItem (Repository repository, IWorkspaceObject workspaceObject, FilePath path, bool isDirectory, VersionInfo versionInfo) { Path = path; Repository = repository; WorkspaceObject = workspaceObject; IsDirectory = isDirectory; this.versionInfo = versionInfo; }
public bool Equals (VersionInfo obj) { if (obj == null) return false; return LocalPath == obj.LocalPath && RepositoryPath == obj.RepositoryPath && IsDirectory == obj.IsDirectory && Status == obj.Status && Revision == obj.Revision && RemoteStatus == obj.RemoteStatus && RemoteRevision == obj.RemoteRevision && AllowedOperations == obj.AllowedOperations; }
public bool Equals (VersionInfo obj) { if (obj == null) return false; return localPath == obj.localPath && repositoryPath == obj.repositoryPath && isDirectory == obj.isDirectory && status == obj.status && revision == obj.revision && remoteStatus == obj.remoteStatus && remoteRevision == obj.remoteRevision && AllowedOperations == obj.AllowedOperations; }
public void SetStatus (VersionInfo versionInfo, bool notify = true) { lock (fileStatus) { VersionInfo vi; if (fileStatus.TryGetValue (versionInfo.LocalPath, out vi) && vi.Equals (versionInfo)) { vi.RequiresRefresh = false; return; } versionInfo.Init (repo); fileStatus [versionInfo.LocalPath] = versionInfo; } if (notify) VersionControlService.NotifyFileStatusChanged (new FileUpdateEventArgs (repo, versionInfo.LocalPath, versionInfo.IsDirectory)); }
public VersionControlItem (Repository repository, WorkspaceObject workspaceObject, FilePath path, bool isDirectory, VersionInfo versionInfo) { Path = path; Repository = repository; WorkspaceObject = workspaceObject; IsDirectory = isDirectory; this.versionInfo = versionInfo; var obj = workspaceObject; while (obj != null) { var p = obj as Project; if (p != null) ContainerProject = p; obj = obj.ParentObject; } }
internal protected virtual Task <VersionControlOperation> GetSupportedOperationsAsync(VersionInfo vinfo, CancellationToken cancellationToken = default) { VersionControlOperation operations = VersionControlOperation.None; bool exists = !vinfo.LocalPath.IsNullOrEmpty && (File.Exists(vinfo.LocalPath) || Directory.Exists(vinfo.LocalPath)); if (vinfo.IsVersioned) { operations = VersionControlOperation.Commit | VersionControlOperation.Update; if (!vinfo.HasLocalChange(VersionStatus.ScheduledAdd)) { operations |= VersionControlOperation.Log; } if (exists) { if (!vinfo.HasLocalChange(VersionStatus.ScheduledDelete)) { operations |= VersionControlOperation.Remove; } if (vinfo.HasLocalChanges || vinfo.IsDirectory) { operations |= VersionControlOperation.Revert; } } if (AllowLocking && !vinfo.IsDirectory) { if (!vinfo.HasLocalChanges && (vinfo.Status & VersionStatus.LockOwned) == 0) { operations |= VersionControlOperation.Lock; } if ((vinfo.Status & VersionStatus.LockOwned) != 0) { operations |= VersionControlOperation.Unlock; } } } else if (exists) { operations = VersionControlOperation.Add; } return(Task.FromResult(operations)); }
/// <summary> /// Returns the versioning status of a set of files or directories /// </summary> /// <param name='paths'> /// A list of files or directories /// </param> /// <param name='queryFlags'> /// Use VersionInfoQueryFlags enum for options. /// </param> public IEnumerable<VersionInfo> GetVersionInfo (IEnumerable<FilePath> paths, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None) { if ((queryFlags & VersionInfoQueryFlags.IgnoreCache) != 0) { // We shouldn't use IEnumerable because elements don't save property modifications. var res = OnGetVersionInfo (paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0).ToList (); infoCache.SetStatus (res); return res; } List<FilePath> pathsToQuery = new List<FilePath> (); var result = new List<VersionInfo> (); foreach (var p in paths) { var vi = infoCache.GetStatus (p); if (vi != null) { result.Add (vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) pathsToQuery.Add (p); } else { // If there is no cached status, query it asynchronously vi = new VersionInfo (p, "", Directory.Exists (p), VersionStatus.Versioned, null, VersionStatus.Versioned, null); infoCache.SetStatus (vi, false); result.Add (vi); pathsToQuery.Add (p); } // Console.WriteLine ("GetVersionInfo " + string.Join (", ", paths.Select (p => p.FullPath))); } if (pathsToQuery.Count > 0) AddQuery (new VersionInfoQuery () { Paths = pathsToQuery, QueryFlags = queryFlags }); return result; }
static VersionInfo CreateVersionInfo (Repository repo, SvnStatusEventArgs ent) { VersionStatus rs = VersionStatus.Unversioned; Revision rr = null; // TODO: Fix remote status for Win32 Svn. if (ent.IsRemoteUpdated) { rs = ConvertStatus (SvnSchedule.Normal, ent.RemoteContentStatus); rr = new SvnRevision (repo, (int) ent.RemoteUpdateRevision, ent.RemoteUpdateCommitTime, ent.RemoteUpdateCommitAuthor, "(unavailable)", null); } SvnSchedule sched = ent.WorkingCopyInfo != null ? ent.WorkingCopyInfo.Schedule : SvnSchedule.Normal; VersionStatus status = ConvertStatus (sched, ent.LocalContentStatus); bool readOnly = File.Exists (ent.FullPath) && (File.GetAttributes (ent.FullPath) & FileAttributes.ReadOnly) != 0; if (ent.WorkingCopyInfo != null) { if (ent.RemoteLock != null || ent.WorkingCopyInfo.LockToken != null) { status |= VersionStatus.LockRequired; if (ent.WorkingCopyInfo.LockToken != null || (ent.RemoteLock != null && ent.RemoteLock.Token != null)) status |= VersionStatus.LockOwned; else status |= VersionStatus.Locked; } else if (readOnly) status |= VersionStatus.LockRequired; } string repoPath = ent.Uri != null ? ent.Uri.ToString () : null; SvnRevision newRev = null; if (ent.WorkingCopyInfo != null) newRev = new SvnRevision (repo, (int) ent.WorkingCopyInfo.Revision); VersionInfo ret = new VersionInfo (ent.FullPath, repoPath, ent.NodeKind == SvnNodeKind.Directory, status, newRev, rs, rr); return ret; }
public virtual void CopyFrom (ChangeSetItem other) { versionInfo = other.versionInfo; }
public void AddFiles (VersionInfo[] fileVersionInfos) { foreach (VersionInfo vi in fileVersionInfos) AddFile (vi); }
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); } }
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); } }
/// <summary> /// Returns the versioning status of a set of files or directories /// </summary> /// <param name='paths'> /// A list of files or directories /// </param> /// <param name='queryFlags'> /// Use VersionInfoQueryFlags enum for options. /// </param> public async Task <IReadOnlyList <VersionInfo> > GetVersionInfoAsync(IEnumerable <FilePath> paths, VersionInfoQueryFlags queryFlags = VersionInfoQueryFlags.None, CancellationToken cancellationToken = default) { if ((queryFlags & VersionInfoQueryFlags.IgnoreCache) != 0) { var task = await ExclusiveOperationFactory.StartNew(delegate { // We shouldn't use IEnumerable because elements don't save property modifications. return(OnGetVersionInfoAsync(paths, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0, cancellationToken)); }).ConfigureAwait(false); var res = await task.ConfigureAwait(false); foreach (var vi in res) { if (!vi.IsInitialized) { await vi.InitAsync(this, cancellationToken).ConfigureAwait(false); } } await infoCache.SetStatusAsync(res, cancellationToken : cancellationToken).ConfigureAwait(false); return(res); } var pathsToQuery = new List <FilePath> (); var result = new List <VersionInfo> (); foreach (var path in paths) { var vi = infoCache.GetStatus(path); if (vi != null) { result.Add(vi); // This status has been invalidated, query it asynchronously if (vi.RequiresRefresh) { pathsToQuery.Add(path); } } else { // If there is no cached status, query it asynchronously vi = new VersionInfo(path, "", Directory.Exists(path), VersionStatus.Versioned, null, VersionStatus.Versioned, null); await infoCache.SetStatusAsync(vi, false).ConfigureAwait(false); result.Add(vi); pathsToQuery.Add(path); } // Console.WriteLine ("GetVersionInfo " + string.Join (", ", paths.Select (p => p.FullPath))); } if (pathsToQuery.Count > 0) { ExclusiveOperationFactory.StartNew(async delegate { var status = await OnGetVersionInfoAsync(pathsToQuery, (queryFlags & VersionInfoQueryFlags.IncludeRemoteStatus) != 0, cancellationToken).ConfigureAwait(false); foreach (var vi in status) { if (!vi.IsInitialized) { await vi.InitAsync(this, cancellationToken).ConfigureAwait(false); } } await infoCache.SetStatusAsync(status, cancellationToken).ConfigureAwait(false); }).Ignore(); } return(result); }
public bool TryGetVersionInfo(FilePath localPath, VersionInfoQueryFlags queryFlags, out VersionInfo info) { var result = TryGetVersionInfo(new FilePath [] { localPath }, queryFlags, out var infos); if (!result || infos == null) { info = null; return(false); } if (infos.Count != 1) { LoggingService.LogError("VersionControl returned {0} items for {1}", infos.Count, localPath); LoggingService.LogError("The infos were: {0}", string.Join(" ::: ", infos.Select(i => i.LocalPath))); } info = infos [0]; return(result); }
public bool TryGetVersionInfo(FilePath localPath, out VersionInfo info) { return(TryGetVersionInfo(localPath, VersionInfoQueryFlags.None, out info)); }
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 ChangeSetItem AddFile (VersionInfo fileVersionInfo) { ChangeSetItem item = new ChangeSetItem (fileVersionInfo); items.Add (item); return item; }
public VersionControlItem(Repository repository, WorkspaceObject workspaceObject, FilePath path, bool isDirectory, VersionInfo versionInfo) { Path = path; Repository = repository; WorkspaceObject = workspaceObject; IsDirectory = isDirectory; this.versionInfo = versionInfo; var obj = workspaceObject; while (obj != null) { var p = obj as Project; if (p != null) { ContainerProject = p; } obj = obj.ParentObject; } }
internal ChangeSetItem (VersionInfo versionInfo) { this.versionInfo = versionInfo; }
internal ChangeSetItem(VersionInfo versionInfo) { this.versionInfo = versionInfo; }
public ChangeSetItem AddFile (VersionInfo fileVersionInfo) { ChangeSetItem item = GetFileItem (fileVersionInfo.LocalPath); if (item != null) return item; item = new ChangeSetItem (fileVersionInfo); items.Add (item); return item; }
public virtual void CopyFrom(ChangeSetItem other) { versionInfo = other.versionInfo; }
public void SetDirectoryStatus (FilePath localDirectory, VersionInfo[] versionInfos, bool hasRemoteStatus) { lock (directoryStatus) { DirectoryStatus vis; if (directoryStatus.TryGetValue (localDirectory.CanonicalPath, out vis)) { if (versionInfos.Length == vis.FileInfo.Length && (hasRemoteStatus == vis.HasRemoteStatus)) { bool allEqual = false; for (int n=0; n<versionInfos.Length; n++) { if (!versionInfos[n].Equals (vis.FileInfo[n])) { allEqual = false; break; } } if (allEqual) { vis.RequiresRefresh = false; return; } } } directoryStatus [localDirectory.CanonicalPath] = new DirectoryStatus { FileInfo = versionInfos, HasRemoteStatus = hasRemoteStatus }; SetStatus (versionInfos); } }
public VersionControlItem(Repository repository, IWorkspaceObject workspaceObject, FilePath path, bool isDirectory, VersionInfo versionInfo) { this.path = path; this.repository = repository; this.workspaceObject = workspaceObject; this.isDirectory = isDirectory; this.versionInfo = versionInfo; }
internal protected virtual VersionControlOperation GetSupportedOperations (VersionInfo vinfo) { VersionControlOperation operations = VersionControlOperation.None; bool exists = !vinfo.LocalPath.IsNullOrEmpty && (File.Exists (vinfo.LocalPath) || Directory.Exists (vinfo.LocalPath)); if (vinfo.IsVersioned) { operations = VersionControlOperation.Commit | VersionControlOperation.Update; if (!vinfo.HasLocalChange (VersionStatus.ScheduledAdd)) operations |= VersionControlOperation.Log; if (exists) { if (!vinfo.HasLocalChange (VersionStatus.ScheduledDelete)) operations |= VersionControlOperation.Remove; if (vinfo.HasLocalChanges || vinfo.IsDirectory) operations |= VersionControlOperation.Revert; } if (AllowLocking && !vinfo.IsDirectory) { if (!vinfo.HasLocalChanges && (vinfo.Status & VersionStatus.LockOwned) == 0) operations |= VersionControlOperation.Lock; if ((vinfo.Status & VersionStatus.LockOwned) != 0) operations |= VersionControlOperation.Unlock; } } else if (exists) { operations = VersionControlOperation.Add; } return operations; }
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)); }
public virtual DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo versionInfo) { return null; }
public virtual DiffInfo GenerateDiff(FilePath baseLocalPath, VersionInfo versionInfo) { return(null); }
public override VersionInfo GetVersionInfo(FilePath localPath, bool getRemoteStatus) { if (!IsVersioned(localPath)) return null; var status = GetLocalStatus(localPath); var vi = new VersionInfo(localPath, localPath /*repositoryPath*/, Directory.Exists(localPath), status.VersionStatus, new GitRevision(this, status.Revision), VersionStatus.Unversioned, null); return vi; }
public virtual Task <DiffInfo> GenerateDiffAsync(FilePath baseLocalPath, VersionInfo versionInfo) { return(TaskUtil.Default <DiffInfo> ()); }