Beispiel #1
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff        = DiffFiles.SelectedItemParents.Any(item => item.Guid == DiffFiles.CombinedDiffGuid);
            bool isExactlyOneItemSelected = DiffFiles.SelectedItems.Count() == 1;
            bool isAnyItemSelected        = DiffFiles.SelectedItems.Any();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);
            bool singleFileExists = isExactlyOneItemSelected && File.Exists(_fullPathResolver.Resolve(DiffFiles.SelectedItem.Name));

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             isSingleGitItemSelected: isExactlyOneItemSelected,
                                                             isAnyItemSelected: isAnyItemSelected,
                                                             isBareRepository: isBareRepository,
                                                             singleFileExists: singleFileExists,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);
        }
Beispiel #2
0
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents.Select(item => item.ObjectId), DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff    = DiffFiles.SelectedItemParents.Any(item => item.ObjectId == ObjectId.CombinedDiffId);
            int  selectedGitItemCount = DiffFiles.SelectedItems.Count();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnyIndex       = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.Index);
            bool isAnyWorkTree    = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.WorkTree);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);
            bool allFilesExist    = DiffFiles.SelectedItems.All(item => File.Exists(_fullPathResolver.Resolve(item.Name)));

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             selectedGitItemCount: selectedGitItemCount,
                                                             isAnyItemIndex: isAnyIndex,
                                                             isAnyItemWorkTree: isAnyWorkTree,
                                                             isBareRepository: isBareRepository,
                                                             allFilesExist: allFilesExist,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);
        }
        private ContextMenuSelectionInfo GetSelectionInfo()
        {
            // First (A) is parent if one revision selected or if parent, then selected
            bool firstIsParent = _gitRevisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents.Select(item => item.ObjectId), DiffFiles.Revision);

            // Combined diff is a display only diff, no manipulations
            bool isAnyCombinedDiff    = DiffFiles.SelectedItemParents.Any(item => item.ObjectId == ObjectId.CombinedDiffId);
            int  selectedGitItemCount = DiffFiles.SelectedItems.Count();

            // No changes to files in bare repos
            bool isBareRepository = Module.IsBareRepository();
            bool isAnyTracked     = DiffFiles.SelectedItems.Any(item => item.IsTracked);
            bool isAnyIndex       = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.Index);
            bool isAnyWorkTree    = DiffFiles.SelectedItems.Any(item => item.Staged == StagedStatus.WorkTree);
            bool isAnySubmodule   = DiffFiles.SelectedItems.Any(item => item.IsSubmodule);

            (bool allFilesExist, bool allFilesOrUntrackedDirectoriesExist) = FileOrUntrackedDirExists(DiffFiles.SelectedItems);

            var selectionInfo = new ContextMenuSelectionInfo(DiffFiles.Revision,
                                                             firstIsParent: firstIsParent,
                                                             isAnyCombinedDiff: isAnyCombinedDiff,
                                                             selectedGitItemCount: selectedGitItemCount,
                                                             isAnyItemIndex: isAnyIndex,
                                                             isAnyItemWorkTree: isAnyWorkTree,
                                                             isBareRepository: isBareRepository,
                                                             allFilesExist: allFilesExist,
                                                             allFilesOrUntrackedDirectoriesExist: allFilesOrUntrackedDirectoriesExist,
                                                             isAnyTracked: isAnyTracked,
                                                             isAnySubmodule: isAnySubmodule);

            return(selectionInfo);

            (bool allFilesExist, bool allFilesOrUntrackedDirectoriesExist) FileOrUntrackedDirExists(IEnumerable <GitItemStatus> items)
            {
                bool allFilesExist = true;
                bool allFilesOrUntrackedDirectoriesExist = true;

                foreach (var item in items)
                {
                    var path       = _fullPathResolver.Resolve(item.Name);
                    var fileExists = File.Exists(path);
                    allFilesExist = allFilesExist && fileExists;
                    var fileOrUntrackedDirectoryExists = fileExists || (!item.IsTracked && Directory.Exists(path));
                    allFilesOrUntrackedDirectoriesExist = allFilesOrUntrackedDirectoriesExist && fileOrUntrackedDirectoryExists;

                    if (allFilesExist == false && allFilesOrUntrackedDirectoriesExist == false)
                    {
                        break;
                    }
                }

                return(allFilesExist, allFilesOrUntrackedDirectoriesExist);
            }
        }
Beispiel #4
0
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            var  parentIds     = DiffFiles.SelectedItems.FirstIds().ToList();
            bool firstIsParent = _revisionTester.AllFirstAreParentsToSelected(parentIds, _headRevision);
            bool localExists   = _revisionTester.AnyLocalFileExists(DiffFiles.SelectedItems.Select(i => i.Item));

            bool allAreNew     = DiffFiles.SelectedItems.All(i => i.Item.IsNew);
            bool allAreDeleted = DiffFiles.SelectedItems.All(i => i.Item.IsDeleted);

            return(new ContextMenuDiffToolInfo(
                       _headRevision,
                       parentIds,
                       allAreNew: allAreNew,
                       allAreDeleted: allAreDeleted,
                       firstIsParent: firstIsParent,
                       localExists: localExists));
        }
Beispiel #5
0
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _revisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _revisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            var  selectedItemParentRevs = DiffFiles.SelectedItemParents.Select(i => i.ObjectId).ToList();
            bool allAreNew     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);

            return(new ContextMenuDiffToolInfo(
                       _headRevision,
                       selectedItemParentRevs,
                       allAreNew: allAreNew,
                       allAreDeleted: allAreDeleted,
                       firstIsParent: firstIsParent,
                       firstParentsValid: _firstParentIsValid,
                       localExists: localExists));
        }
Beispiel #6
0
        private ContextMenuDiffToolInfo GetContextMenuDiffToolInfo()
        {
            bool firstIsParent = _revisionTester.AllFirstAreParentsToSelected(DiffFiles.SelectedItemParents, DiffFiles.Revision);
            bool localExists   = _revisionTester.AnyLocalFileExists(DiffFiles.SelectedItemsWithParent.Select(i => i.Item));

            IEnumerable <string> selectedItemParentRevs = DiffFiles.Revision.ParentGuids;
            bool allAreNew         = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsNew);
            bool allAreDeleted     = DiffFiles.SelectedItemsWithParent.All(i => i.Item.IsDeleted);
            var  revisions         = _revisionGrid.GetSelectedRevisions();
            bool firstParentsValid = revisions != null && revisions.Count > 1;

            var selectionInfo = new ContextMenuDiffToolInfo(_headRevision, selectedItemParentRevs,
                                                            allAreNew: allAreNew,
                                                            allAreDeleted: allAreDeleted,
                                                            firstIsParent: firstIsParent,
                                                            firstParentsValid: firstParentsValid,
                                                            localExists: localExists);

            return(selectionInfo);
        }