public GetVersionInfo ( IEnumerable |
||
paths | IEnumerable |
/// A list of files or directories /// |
queryFlags | VersionInfoQueryFlags | /// Use VersionInfoQueryFlags enum for options. /// |
return | IEnumerable |
public override async Task <bool> SupportsController(DocumentController controller) { if (!(controller is FileDocumentController fileController) || !IdeApp.IsInitialized) { return(false); } project = controller.Owner; if (project == null) { // Fix for broken .csproj and .sln files not being seen as having a project. foreach (var projItem in Ide.IdeApp.Workspace.GetAllItems <UnknownSolutionItem> ()) { if (projItem.FileName == fileController.FilePath) { project = projItem; } } if (project == null) { return(false); } } repo = VersionControlService.GetRepository(project); if (repo == null) { return(false); } var versionInfo = repo.GetVersionInfo(fileController.FilePath); return(versionInfo.IsVersioned); }
public static void Commit(Repository vc, ChangeSet changeSet) { try { if (vc.GetVersionInfo(changeSet.BaseLocalPath).CanCommit) { if (!VersionControlService.NotifyPrepareCommit(vc, changeSet)) { return; } CommitDialog dlg = new CommitDialog(changeSet); try { if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { if (VersionControlService.NotifyBeforeCommit(vc, changeSet)) { new CommitWorker(vc, changeSet, dlg).Start(); return; } } dlg.EndCommit(false); } finally { dlg.Destroy(); } VersionControlService.NotifyAfterCommit(vc, changeSet, false); } } catch (Exception ex) { MessageService.ShowException(ex, GettextCatalog.GetString("Version control command failed.")); } }
public static void Commit (Repository vc, ChangeSet changeSet) { try { if (vc.GetVersionInfo (changeSet.BaseLocalPath).CanCommit) { if (!VersionControlService.NotifyPrepareCommit (vc, changeSet)) return; CommitDialog dlg = new CommitDialog (changeSet); try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) { if (VersionControlService.NotifyBeforeCommit (vc, changeSet)) { new CommitWorker (vc, changeSet, dlg).Start(); return; } } dlg.EndCommit (false); } finally { dlg.Destroy (); } VersionControlService.NotifyAfterCommit (vc, changeSet, false); } } catch (Exception ex) { MessageService.ShowException (ex, GettextCatalog.GetString ("Version control command failed.")); } }
void AddFolderOverlay(Repository rep, string folder, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { Gdk.Pixbuf overlay = null; VersionInfo vinfo = rep.GetVersionInfo(folder, false); if (vinfo == null || !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); } } }
private static bool RevertRevisions (Repository vc, string path, Revision revision, bool test, bool toRevision) { try { if (test) { return (vc.GetVersionInfo (path).CanRevert); } string question = GettextCatalog.GetString ( "Are you sure you want to revert the selected resources to the revision specified (all local changes will be discarded)?"); if (!toRevision) question = GettextCatalog.GetString ( "Are you sure you want to revert the changes from the revision selected on these resources?"); if (MessageService.AskQuestion (question, GettextCatalog.GetString ("Note: The reversion will occur in your working copy, so you will still need to perform a commit to complete it."), AlertButton.Cancel, AlertButton.Revert) != AlertButton.Revert) return false; new RevertWorker(vc, path, revision, toRevision).Start(); return true; } catch (Exception ex) { if (test) LoggingService.LogError (ex.ToString ()); else MessageService.ShowException (ex, GettextCatalog.GetString ("Version control command failed.")); return false; } }
/* public override void PrepareChildNodes (object dataObject) * { * if (dataObject is IWorkspaceObject) { * IWorkspaceObject ce = (IWorkspaceObject) dataObject; * Repository rep = VersionControlService.GetRepository (ce); * if (rep != null) * rep.GetDirectoryVersionInfo (ce.BaseDirectory, false, false); * } 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); * } * } * base.PrepareChildNodes (dataObject); * } */ static void AddFolderOverlay(Repository rep, string folder, NodeInfo nodeInfo, bool skipVersionedOverlay) { Xwt.Drawing.Image overlay = null; VersionInfo vinfo = rep.GetVersionInfo(folder); if (vinfo == null || !vinfo.IsVersioned) { overlay = VersionControlService.LoadOverlayIconForStatus(VersionStatus.Unversioned); } else if (vinfo.IsVersioned && !vinfo.HasLocalChanges) { if (!skipVersionedOverlay) { overlay = VersionControlService.overlay_controled; } } else { overlay = VersionControlService.LoadOverlayIconForStatus(vinfo.Status); } if (overlay != null) { nodeInfo.OverlayBottomRight = overlay; } }
public static bool CanPublish(Repository vc, string path, bool isDir) { if (!vc.GetVersionInfo(path).IsVersioned&& isDir) { return(true); } return(false); }
public static bool CanPublish (Repository vc, string path, bool isDir) { if (!VersionControlService.CheckVersionControlInstalled ()) return false; if (!vc.GetVersionInfo (path).IsVersioned && isDir) return true; return false; }
public static bool Commit(Repository vc, ChangeSet changeSet, bool test) { try { if (changeSet.IsEmpty) { if (!test) { MessageService.ShowMessage(GettextCatalog.GetString("There are no changes to be committed.")); } return(false); } if (vc.GetVersionInfo(changeSet.BaseLocalPath).CanCommit) { if (test) { return(true); } if (!VersionControlService.NotifyPrepareCommit(vc, changeSet)) { return(false); } CommitDialog dlg = new CommitDialog(changeSet); try { if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok) { if (VersionControlService.NotifyBeforeCommit(vc, changeSet)) { new CommitWorker(vc, changeSet, dlg).Start(); return(true); } } dlg.EndCommit(false); } finally { dlg.Destroy(); } VersionControlService.NotifyAfterCommit(vc, changeSet, false); } return(false); } catch (Exception ex) { if (test) { LoggingService.LogError(ex.ToString()); } else { MessageService.ShowException(ex, GettextCatalog.GetString("Version control command failed.")); } return(false); } }
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); }
VersionStatus GetVersionInfo(Repository vc, string filepath) { VersionInfo node = vc.GetVersionInfo(filepath, false); if (node != null) { return(node.Status); } return(VersionStatus.Unversioned); }
static void OnEntryAdded(object o, SolutionItemEventArgs args) { // 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. ArrayList files = new ArrayList(); files.Add(path); SolutionItemAddFiles(path, entry, files); files.Sort(); using (IProgressMonitor monitor = GetStatusMonitor()) { string[] paths = (string[])files.ToArray(typeof(string)); foreach (string p in paths) { if (repo.GetVersionInfo(p).CanAdd) { repo.Add(p, false, monitor); } } } NotifyFileStatusChanged(new FileUpdateEventArgs(repo, parent.BaseDirectory, true)); }
public static bool CanPublish(Repository vc, string path, bool isDir) { if (!VersionControlService.CheckVersionControlInstalled()) { return(false); } if (!vc.GetVersionInfo(path).IsVersioned&& isDir) { return(true); } return(false); }
void AddFolderOverlay (Repository rep, string folder, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon) { Gdk.Pixbuf overlay = null; VersionInfo vinfo = rep.GetVersionInfo (folder, false); if (vinfo == null || !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); } }
static void OnEntryAdded(object o, SolutionItemEventArgs args) { // 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; string path = entry.BaseDirectory; if (!repo.GetVersionInfo(path).CanAdd) { return; } // 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. ArrayList files = new ArrayList(); files.Add(path); SolutionItemAddFiles(path, entry, files); files.Sort(); using (IProgressMonitor monitor = GetStatusMonitor()) { string[] paths = (string[])files.ToArray(typeof(string)); for (int i = 0; i < paths.Length; i++) { repo.Add(paths[i], false, monitor); } } NotifyFileStatusChanged(new FileUpdateEventArgs(repo, parent.BaseDirectory, true)); }
private static bool RevertRevisions(Repository vc, string path, Revision revision, bool test, bool toRevision) { try { if (test) { return(vc.GetVersionInfo(path).CanRevert); } string question = GettextCatalog.GetString( "Are you sure you want to revert the selected resources to the revision specified (all local changes will be discarded)?"); if (!toRevision) { question = GettextCatalog.GetString( "Are you sure you want to revert the changes from the revision selected on these resources?"); } if (MessageService.AskQuestion(question, GettextCatalog.GetString("Note: The reversion will occur in your working copy, so you will still need to perform a commit to complete it."), AlertButton.Cancel, AlertButton.Revert) != AlertButton.Revert) { return(false); } new RevertWorker(vc, path, revision, toRevision).Start(); return(true); } catch (Exception ex) { if (test) { LoggingService.LogError(ex.ToString()); } else { MessageService.ShowException(ex, GettextCatalog.GetString("Version control command failed.")); } return(false); } }
public static bool Commit (Repository vc, ChangeSet changeSet, bool test) { try { if (changeSet.IsEmpty) { if (!test) MessageService.ShowMessage (GettextCatalog.GetString ("There are no changes to be committed.")); return false; } if (vc.GetVersionInfo (changeSet.BaseLocalPath).CanCommit) { if (test) return true; if (!VersionControlService.NotifyPrepareCommit (vc, changeSet)) return false; CommitDialog dlg = new CommitDialog (changeSet); try { if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) { if (VersionControlService.NotifyBeforeCommit (vc, changeSet)) { new CommitWorker (vc, changeSet, dlg).Start(); return true; } } dlg.EndCommit (false); } finally { dlg.Destroy (); } VersionControlService.NotifyAfterCommit (vc, changeSet, false); } return false; } catch (Exception ex) { if (test) LoggingService.LogError (ex.ToString ()); else MessageService.ShowException (ex, GettextCatalog.GetString ("Version control command failed.")); return false; } }
//static void OnFileChanged (object s, ProjectFileEventArgs args) //{ // Repository repo = GetRepository (args.Project); // if (repo != null) // NotifyFileStatusChanged (repo, args.ProjectFile.FilePath, false); //} static void OnFileAdded(object s, ProjectFileEventArgs e) { FileUpdateEventArgs vargs = new FileUpdateEventArgs(); IProgressMonitor monitor = null; try { foreach (var repoFiles in e.GroupBy(i => i.Project)) { Repository repo = GetRepository(repoFiles.Key); if (repo == null) { continue; } var versionInfos = repo.GetVersionInfo(repoFiles.Select(f => f.ProjectFile.FilePath)); FilePath[] paths = versionInfos.Where(i => i.CanAdd).Select(i => i.LocalPath).ToArray(); if (paths.Length > 0) { if (monitor == null) { monitor = GetStatusMonitor(); } repo.Add(paths, false, monitor); } vargs.AddRange(repoFiles.Select(i => new FileUpdateEventInfo(repo, i.ProjectFile.FilePath, i.ProjectFile.Subtype == Subtype.Directory))); } } finally { if (monitor != null) { monitor.Dispose(); } } if (vargs.Count > 0) { NotifyFileStatusChanged(vargs); } }
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 PrepareChildNodes (object dataObject) { if (dataObject is IWorkspaceObject) { IWorkspaceObject ce = (IWorkspaceObject) dataObject; Repository rep = VersionControlService.GetRepository (ce); if (rep != null) rep.GetDirectoryVersionInfo (ce.BaseDirectory, false, false); } 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); } } base.PrepareChildNodes (dataObject); } */ static void AddFolderOverlay (Repository rep, string folder, NodeInfo nodeInfo, bool skipVersionedOverlay) { Xwt.Drawing.Image overlay = null; VersionInfo vinfo = rep.GetVersionInfo (folder); if (vinfo == null || !vinfo.IsVersioned) { overlay = VersionControlService.LoadOverlayIconForStatus (VersionStatus.Unversioned); } else if (vinfo.IsVersioned && !vinfo.HasLocalChanges) { if (!skipVersionedOverlay) overlay = VersionControlService.overlay_controled; } else { overlay = VersionControlService.LoadOverlayIconForStatus (vinfo.Status); } nodeInfo.OverlayBottomRight = overlay; }
public ChangeSetItem AddFile(FilePath file) { return(AddFile(repo.GetVersionInfo(file, false))); }
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; }
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); }
VersionStatus GetVersionInfo (Repository vc, string filepath) { VersionInfo node = vc.GetVersionInfo (filepath, false); if (node != null) return node.Status; return VersionStatus.Unversioned; }
public static bool CanPublish (Repository vc, string path, bool isDir) { if (!vc.GetVersionInfo (path).IsVersioned && isDir) return true; return 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 virtual void UpdateIsDone() { AddFile ("testfile", null, true, true); PostCommit (Repo); // Checkout a second repository. FilePath second = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar); Checkout (second, RemoteUrl); Repo2 = GetRepo (second, RemoteUrl); ModifyPath (Repo2, ref second); string added = second + "testfile2"; File.Create (added).Close (); Repo2.Add (added, false, new NullProgressMonitor ()); ChangeSet changes = Repo2.CreateChangeSet (Repo2.RootPath); changes.AddFile (Repo2.GetVersionInfo (added, VersionInfoQueryFlags.IgnoreCache)); changes.GlobalComment = "test2"; Repo2.Commit (changes, new NullProgressMonitor ()); PostCommit (Repo2); Repo.Update (Repo.RootPath, true, new NullProgressMonitor ()); Assert.True (File.Exists (LocalPath + "testfile2")); Repo2.Dispose (); DeleteDirectory (second); }
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); } }