public static void ViewChanges(this FileViewer diffViewer, string revision, string parentRevision, GitItemStatus file, string defaultText) { if (parentRevision == null) { if (file.TreeGuid.IsNullOrEmpty()) { diffViewer.ViewGitItemRevision(file.Name, revision); } else if (!file.IsSubmodule) { diffViewer.ViewGitItem(file.Name, file.TreeGuid); } else { diffViewer.ViewText(file.Name, LocalizationHelpers.GetSubmoduleText(diffViewer.Module, file.Name, file.TreeGuid)); } } else { diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(revision, parentRevision, file); return(selectedPatch ?? defaultText); }); } }
public static void ViewPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file, string defaultText) { IList <GitRevision> revisions = grid.GetSelectedRevisions(); if (revisions.Count == 1 && (revisions[0].ParentGuids == null || revisions[0].ParentGuids.Length == 0)) { if (file.TreeGuid.IsNullOrEmpty()) { diffViewer.ViewGitItemRevision(file.Name, revisions[0].Guid); } else if (!file.IsSubmodule) { diffViewer.ViewGitItem(file.Name, file.TreeGuid); } else { diffViewer.ViewText(file.Name, GitCommandHelpers.GetSubmoduleText(grid.Module, file.Name, file.TreeGuid)); } } else { diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(grid, file); return(selectedPatch ?? defaultText); }); } }
public static Task ViewChangesAsync( this FileViewer diffViewer, [CanBeNull] string firstRevision, string secondRevision, [NotNull] GitItemStatus file, [NotNull] string defaultText) { if (firstRevision == null) { // The previous commit does not exist, nothing to compare with if (file.TreeGuid.IsNullOrEmpty()) { if (secondRevision.IsNullOrWhiteSpace()) { throw new ArgumentException(nameof(secondRevision)); } return(diffViewer.ViewGitItemRevisionAsync(file.Name, secondRevision)); } else { return(diffViewer.ViewGitItemAsync(file.Name, file.TreeGuid)); } } else { return(diffViewer.ViewPatchAsync(() => { string selectedPatch = diffViewer.GetSelectedPatch(firstRevision, secondRevision, file); return selectedPatch ?? defaultText; })); } }
public static Task ViewChanges(this FileViewer diffViewer, string firstRevision, string secondRevision, GitItemStatus file, string defaultText) { return(diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(firstRevision, secondRevision, file); return selectedPatch ?? defaultText; })); }
public static void ViewChanges(this FileViewer diffViewer, string revision, string parentRevision, GitItemStatus file, string defaultText) { diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(revision, parentRevision, file); return(selectedPatch ?? defaultText); }); }
public static Task ViewChangesAsync(this FileViewer diffViewer, [CanBeNull] ObjectId firstId, [CanBeNull] GitRevision selectedRevision, [NotNull] GitItemStatus file, [NotNull] string defaultText, [CanBeNull] Action openWithDifftool = null) { if (firstId == null && selectedRevision != null) { firstId = selectedRevision.FirstParentGuid; } openWithDifftool = openWithDifftool ?? OpenWithDifftool; if (file.IsNew && selectedRevision?.ObjectId == ObjectId.WorkTreeId) { return(diffViewer.ViewFileAsync(file.Name, openWithDifftool: openWithDifftool)); } if (firstId == null || FileHelper.IsImage(file.Name)) { // The previous commit does not exist, nothing to compare with if (file.TreeGuid != null) { // blob guid exists return(diffViewer.ViewGitItemAsync(file, openWithDifftool)); } if (selectedRevision == null) { throw new ArgumentNullException(nameof(selectedRevision)); } // Get blob guid from revision return(diffViewer.ViewGitItemRevisionAsync(file, selectedRevision.ObjectId, openWithDifftool)); } string selectedPatch = diffViewer.GetSelectedPatch(firstId, selectedRevision.ObjectId, file); if (selectedPatch == null) { return(diffViewer.ViewPatchAsync(file.Name, text: defaultText, openWithDifftool: null /* not applicable */, isText: true)); } return(diffViewer.ViewPatchAsync(file.Name, text: selectedPatch, openWithDifftool: openWithDifftool, isText: file.IsSubmodule)); void OpenWithDifftool() { diffViewer.Module.OpenWithDifftool( file.Name, file.OldName, firstId?.ToString(), selectedRevision?.ToString(), "", file.IsTracked); } }
public static void ViewPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file, string defaultText) { diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(grid, file); return(selectedPatch ?? defaultText); }); }
public static Task ViewChangesAsync( this FileViewer diffViewer, [CanBeNull] ObjectId firstRevision, ObjectId secondRevision, [NotNull] GitItemStatus file, [NotNull] string defaultText, [CanBeNull] Action openWithDifftool) { if (firstRevision == null) { // The previous commit does not exist, nothing to compare with if (file.TreeGuid != null) { if (secondRevision == null) { throw new ArgumentNullException(nameof(secondRevision)); } return(diffViewer.ViewGitItemRevisionAsync(file.Name, secondRevision)); } else { return(diffViewer.ViewGitItemAsync(file.Name, file.TreeGuid)); } } else { return(diffViewer.ViewPatchAsync(() => { string selectedPatch = diffViewer.GetSelectedPatch(firstRevision, secondRevision, file); if (selectedPatch == null) { return (text: defaultText, openWithDifftool: null /* not applicable */); } return (text: selectedPatch, openWithDifftool: openWithDifftool ?? OpenWithDifftool); void OpenWithDifftool() { diffViewer.Module.OpenWithDifftool( file.Name, null, firstRevision.ToString(), firstRevision.ToString(), "", file.IsTracked); } })); } }
public static void ViewPatch(this FileViewer diffViewer, RevisionGrid grid, GitItemStatus file, string defaultText) { IList <GitRevision> revisions = grid.GetSelectedRevisions(); if (revisions.Count == 1 && (revisions[0].ParentGuids == null || revisions[0].ParentGuids.Length == 0)) { diffViewer.ViewGitItem(file.Name, file.TreeGuid); } else { diffViewer.ViewPatch(() => { string selectedPatch = diffViewer.GetSelectedPatch(grid, file); return(selectedPatch ?? defaultText); }); } }
public static Task ViewChangesAsync(this FileViewer diffViewer, [CanBeNull] ObjectId firstId, [CanBeNull] GitRevision selectedRevision, [NotNull] GitItemStatus file, [NotNull] string defaultText, [CanBeNull] Action openWithDifftool = null) { if (firstId == null && selectedRevision != null) { firstId = selectedRevision.FirstParentGuid; } openWithDifftool ??= OpenWithDifftool; if (file.IsNew || firstId == null || FileHelper.IsImage(file.Name)) { // The previous commit does not exist, nothing to compare with if (selectedRevision == null) { throw new ArgumentNullException(nameof(selectedRevision)); } // View blob guid from revision, or file for worktree return(diffViewer.ViewGitItemRevisionAsync(file, selectedRevision.ObjectId, openWithDifftool)); } string selectedPatch = diffViewer.GetSelectedPatch(firstId, selectedRevision.ObjectId, file); return(diffViewer.ViewPatchAsync(file.Name, text: selectedPatch ?? defaultText, openWithDifftool: openWithDifftool, isText: file.IsSubmodule || selectedPatch == null)); void OpenWithDifftool() { diffViewer.Module.OpenWithDifftool( file.Name, file.OldName, firstId?.ToString(), selectedRevision?.ToString(), "", file.IsTracked); } }