Beispiel #1
0
        protected async void OnButtonFetchClicked(object sender, EventArgs e)
        {
            if (!treeRemotes.Selection.GetSelected(out var it))
            {
                return;
            }

            bool toplevel = !storeRemotes.IterParent(out var parent, it);

            string remoteName = string.Empty;

            if (toplevel)
            {
                remoteName = (string)storeRemotes.GetValue(it, 4);
            }
            else
            {
                remoteName = (string)storeRemotes.GetValue(parent, 4);
            }

            if (string.IsNullOrEmpty(remoteName))
            {
                return;
            }

            await System.Threading.Tasks.Task.Run(() => repo.Fetch(VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Fetching remote...")), remoteName));

            FillRemotes();
        }
Beispiel #2
0
        public static void Push(GitRepository repo)
        {
            var dlg = new PushDialog(repo);

            try {
                if (MessageService.RunCustomDialog(dlg) != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                string remote = dlg.SelectedRemote;
                string branch = dlg.SelectedRemoteBranch;

                IProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Pushing changes..."));
                System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        repo.Push(monitor, remote, branch);
                    } catch (Exception ex) {
                        monitor.ReportError(ex.Message, ex);
                    } finally {
                        monitor.Dispose();
                    }
                });
            } finally {
                dlg.Destroy();
            }
        }
Beispiel #3
0
        public static void ShowMergeDialog(GitRepository repo, bool rebasing)
        {
            MergeDialog dlg = new MergeDialog(repo, rebasing);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    dlg.Hide();
                    if (rebasing)
                    {
                        using (IProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Rebasing branch '{0}'...", dlg.SelectedBranch))) {
                            if (dlg.IsRemote)
                            {
                                repo.Fetch(monitor);
                            }
                            repo.Rebase(dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor);
                        }
                    }
                    else
                    {
                        using (IProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Merging branch '{0}'...", dlg.SelectedBranch))) {
                            if (dlg.IsRemote)
                            {
                                repo.Fetch(monitor);
                            }
                            repo.Merge(dlg.SelectedBranch, dlg.StageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor);
                        }
                    }
                }
            } finally {
                dlg.Destroy();
            }
        }
Beispiel #4
0
        public static void ShowMergeDialog(GitRepository repo, bool rebasing)
        {
            MergeDialog dlg = new MergeDialog(repo, rebasing);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    dlg.Hide();
                    using (IProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Merging branch '{0}'...", dlg.SelectedBranch))) {
                        repo.Merge(dlg.SelectedBranch, dlg.StageChanges, monitor);
                    }
                }
            } finally {
                dlg.Destroy();
            }
        }
Beispiel #5
0
        public static void ShowMergeDialog(GitRepository repo, bool rebasing)
        {
            var dlg = new MergeDialog(repo, rebasing);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    var selectedBranch = dlg.SelectedBranch;
                    var isRemote       = dlg.IsRemote;
                    var remoteName     = dlg.RemoteName;
                    var stageChanges   = dlg.StageChanges;
                    dlg.Hide();

                    Task.Run((Func <Task>)(async() => {
                        try {
                            if (rebasing)
                            {
                                using (var monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Rebasing branch '{0}'...", selectedBranch))) {
                                    if (isRemote)
                                    {
                                        await repo.FetchAsync((ProgressMonitor)monitor, (string)remoteName);
                                    }
                                    await repo.RebaseAsync(selectedBranch, stageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor);
                                }
                            }
                            else
                            {
                                using (var monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Merging branch '{0}'...", selectedBranch))) {
                                    if (isRemote)
                                    {
                                        await repo.FetchAsync((ProgressMonitor)monitor, (string)remoteName);
                                    }
                                    await repo.MergeAsync(selectedBranch, stageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor, FastForwardStrategy.NoFastForward);
                                }
                            }
                        } catch (Exception e) {
                            LoggingService.LogError("Error while showing merge dialog.", e);
                        }
                    }));
                }
            } finally {
                dlg.Destroy();
                dlg.Dispose();
            }
        }
Beispiel #6
0
        protected void OnButtonFetchClicked(object sender, EventArgs e)
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                return;
            }

            string remoteName = (string)storeRemotes.GetValue(it, 4);

            if (remoteName == null)
            {
                return;
            }

            repo.Fetch(VersionControlService.GetProgressMonitor("Fetching remote..."), remoteName);
            FillRemotes();
        }
        protected async void OnButtonFetchClicked(object sender, EventArgs e)
        {
            TreeIter it;

            if (!treeRemotes.Selection.GetSelected(out it))
            {
                return;
            }

            string remoteName = (string)storeRemotes.GetValue(it, 4);

            if (remoteName == null)
            {
                return;
            }

            await System.Threading.Tasks.Task.Run(() => repo.Fetch(VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Fetching remote...")), remoteName));

            FillRemotes();
        }
Beispiel #8
0
        public static void ShowMergeDialog(GitRepository repo, bool rebasing)
        {
            var dlg = new MergeDialog(repo, rebasing);

            try {
                if (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                {
                    var selectedBranch = dlg.SelectedBranch;
                    var isRemote       = dlg.IsRemote;
                    var remoteName     = dlg.RemoteName;
                    var stageChanges   = dlg.StageChanges;
                    dlg.Hide();

                    Task.Run(() => {
                        if (rebasing)
                        {
                            using (ProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Rebasing branch '{0}'...", selectedBranch))) {
                                if (isRemote)
                                {
                                    repo.Fetch(monitor, remoteName);
                                }
                                repo.Rebase(selectedBranch, stageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor);
                            }
                        }
                        else
                        {
                            using (ProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Merging branch '{0}'...", selectedBranch))) {
                                if (isRemote)
                                {
                                    repo.Fetch(monitor, remoteName);
                                }
                                repo.Merge(selectedBranch, stageChanges ? GitUpdateOptions.SaveLocalChanges : GitUpdateOptions.None, monitor, FastForwardStrategy.NoFastForward);
                            }
                        }
                    });
                }
            } finally {
                dlg.Destroy();
                dlg.Dispose();
            }
        }
 internal static void Open(List <ExtendedItem> items, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
 {
     using (var dialog = new CheckOutDialog())
     {
         dialog.FillStore(items);
         if (dialog.Run(Xwt.Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
         {
             var itemsToCheckOut = dialog.SelectedItems;
             using (var progress = VersionControlService.GetProgressMonitor("Check Out", VersionControlOperationType.Pull))
             {
                 progress.BeginTask("Check Out", itemsToCheckOut.Count);
                 foreach (var item in itemsToCheckOut)
                 {
                     var path = item.IsInWorkspace ? item.LocalItem : workspace.GetLocalPathForServerPath(item.ServerPath);
                     workspace.Get(new GetRequest(item.ServerPath, RecursionType.Full, VersionSpec.Latest), GetOptions.None, progress);
                     progress.Log.WriteLine("Check out item: " + item.ServerPath);
                     var failures = workspace.PendEdit(new List <FilePath> {
                         path
                     }, RecursionType.Full, dialog.LockLevel);
                     if (failures != null && failures.Any())
                     {
                         if (failures.Any(f => f.SeverityType == SeverityType.Error))
                         {
                             foreach (var failure in failures.Where(f => f.SeverityType == SeverityType.Error))
                             {
                                 progress.ReportError(failure.Code, new Exception(failure.Message));
                             }
                             break;
                         }
                         foreach (var failure in failures.Where(f => f.SeverityType == SeverityType.Warning))
                         {
                             progress.ReportWarning(failure.Message);
                         }
                     }
                 }
                 progress.EndTask();
                 progress.ReportSuccess("Finish Check Out.");
             }
         }
     }
 }
Beispiel #10
0
        public static void Push(GitRepository repo)
        {
            bool hasCommits = false;

            using (var RootRepository = new LibGit2Sharp.Repository(repo.RootPath))
                hasCommits = RootRepository.Commits.Any();
            if (!hasCommits)
            {
                MessageService.ShowMessage(
                    GettextCatalog.GetString("There are no changes to push."),
                    GettextCatalog.GetString("Create an initial commit first.")
                    );
                return;
            }

            var dlg = new PushDialog(repo);

            try {
                if (MessageService.RunCustomDialog(dlg) != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                string remote = dlg.SelectedRemote;
                string branch = dlg.SelectedRemoteBranch ?? repo.GetCurrentBranch();

                ProgressMonitor monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Pushing changes..."), VersionControlOperationType.Push);
                Task.Run(async() => {
                    try {
                        await repo.PushAsync(monitor, remote, branch);
                    } catch (Exception ex) {
                        monitor.ReportError(ex.Message, ex);
                    } finally {
                        monitor.Dispose();
                    }
                });
            } finally {
                dlg.Destroy();
                dlg.Dispose();
            }
        }
Beispiel #11
0
 internal static void Open(List <ExtendedItem> items, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
 {
     using (var dialog = new CheckInDialog())
     {
         dialog.FillStore(items, workspace);
         if (dialog.Run(Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
         {
             using (var progress = VersionControlService.GetProgressMonitor("CheckIn", VersionControlOperationType.Push))
             {
                 progress.BeginTask("Check In", 1);
                 var result = workspace.CheckIn(dialog.SelectedChanges, dialog.Comment, dialog.SelectedWorkItems);
                 foreach (var failure in result.Failures.Where(f => f.SeverityType == SeverityType.Error))
                 {
                     progress.ReportError(failure.Code, new Exception(failure.Message));
                 }
                 progress.EndTask();
                 progress.ReportSuccess("Finish Check In");
             }
         }
     }
 }
        private void GetLatestVersion(List <ExtendedItem> items)
        {
            List <GetRequest> requests = new List <GetRequest>();

            foreach (var item in items)
            {
                RecursionType recursion = item.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full;
                requests.Add(new GetRequest(item.ServerPath, recursion, VersionSpec.Latest));
            }
            using (var progress = VersionControlService.GetProgressMonitor("Get", VersionControlOperationType.Pull))
            {
                var option = GetOptions.None;
                progress.Log.WriteLine("Start downloading items. GetOption: " + option);
                foreach (var request in requests)
                {
                    progress.Log.WriteLine(request);
                }
                _currentWorkspace.Get(requests, option, progress);
                progress.ReportSuccess("Finish Downloading.");
            }
            RefreshList(items);
        }
        void OnGet(object sender, System.EventArgs e)
        {
            var requests = new List <GetRequest>();

            for (int row = 0; row < listStore.RowCount; row++)
            {
                var isChecked = listStore.GetValue(row, isSelectedField);
                if (isChecked)
                {
                    var item    = listStore.GetValue(row, itemField);
                    var spec    = new ItemSpec(item.ServerPath, item.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full);
                    var version = (int)versionBox.SelectedItem == 0 ? new ChangesetVersionSpec(Convert.ToInt32(changeSetNumber.Value)) : VersionSpec.Latest;
                    requests.Add(new GetRequest(spec, version));
                    if (forceGet.State == CheckBoxState.On)
                    {
                        workspace.ResetDownloadStatus(item.ItemId);
                    }
                }
            }
            var option = GetOptions.None;

            if (forceGet.State == CheckBoxState.On)
            {
                option |= GetOptions.GetAll;
            }
//            if (overrideGet.State == CheckBoxState.On)
//                option |= GetOptions.Overwrite;
            using (var progress = VersionControlService.GetProgressMonitor("Get", VersionControlOperationType.Pull))
            {
                progress.Log.WriteLine("Start downloading items. GetOption: " + option);
                foreach (var request in requests)
                {
                    progress.Log.WriteLine(request);
                }
                workspace.Get(requests, option, progress);
                progress.ReportSuccess("Finish Downloading.");
            }
            Respond(Command.Ok);
        }
Beispiel #14
0
        protected async void OnButtonFetchClicked(object sender, EventArgs e)
        {
            if (!treeRemotes.Selection.GetSelected(out var it))
            {
                return;
            }

            bool toplevel = !storeRemotes.IterParent(out var parent, it);

            string remoteName = string.Empty;

            if (toplevel)
            {
                remoteName = (string)storeRemotes.GetValue(it, 4);
            }
            else
            {
                remoteName = (string)storeRemotes.GetValue(parent, 4);
            }

            if (string.IsNullOrEmpty(remoteName))
            {
                return;
            }

            var monitor = VersionControlService.GetProgressMonitor(GettextCatalog.GetString("Fetching remote..."));
            await System.Threading.Tasks.Task.Run(() => {
                try {
                    repo.Fetch(monitor, remoteName);
                } catch (Exception ex) {
                    monitor.ReportError(GettextCatalog.GetString("Fetching remote failed"), ex);
                } finally {
                    monitor.Dispose();
                }
            });

            FillRemotes();
        }
Beispiel #15
0
 internal static void Open(List <ExtendedItem> items, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
 {
     using (var dialog = new UndoDialog())
     {
         dialog.FillStore(items, workspace);
         if (dialog.Run(Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
         {
             var changesToUndo = dialog.SelectedItems;
             using (var progress = VersionControlService.GetProgressMonitor("Undo", VersionControlOperationType.Pull))
             {
                 progress.BeginTask("Undo", changesToUndo.Count);
                 var itemSpecs = new List <ItemSpec>();
                 foreach (var change in changesToUndo)
                 {
                     itemSpecs.Add(new ItemSpec(change.LocalItem, change.ItemType == ItemType.File ? RecursionType.None : RecursionType.Full));
                 }
                 workspace.Undo(itemSpecs, progress);
                 progress.EndTask();
                 progress.ReportSuccess("Finish Undo");
             }
         }
     }
 }
Beispiel #16
0
        internal static void Open(List <ExtendedItem> items, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
        {
            using (var dialog = new LockDialog())
            {
                dialog.FillStore(items);
                if (dialog.Run(Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
                {
                    var itemsToLock = dialog.SelectedItems;
                    var lockLevel   = dialog.LockLevel;

                    using (var progress = VersionControlService.GetProgressMonitor("Lock Files", VersionControlOperationType.Pull))
                    {
                        progress.BeginTask("Lock Files", itemsToLock.Count);
                        var folders = new List <string>(itemsToLock.Where(i => i.ItemType == ItemType.Folder).Select(i => (string)i.ServerPath));
                        var files   = new List <string>(itemsToLock.Where(i => i.ItemType == ItemType.File).Select(i => (string)i.ServerPath));
                        workspace.LockFolders(folders, lockLevel);
                        workspace.LockFiles(files, lockLevel);
                        progress.EndTask();
                        progress.ReportSuccess("Finish locking.");
                    }
                }
            }
        }
        internal static string Open(ExtendedItem item, Microsoft.TeamFoundation.VersionControl.Client.Workspace workspace)
        {
            using (var dialog = new RenameDialog(item))
            {
                if (dialog.Run(Xwt.Toolkit.CurrentEngine.WrapWindow(MessageService.RootWindow)) == Command.Ok)
                {
                    using (var progress = VersionControlService.GetProgressMonitor("Undo", VersionControlOperationType.Pull))
                    {
                        progress.BeginTask("Rename", 1);
                        List <Failure> failures;
                        if (item.ItemType == Microsoft.TeamFoundation.VersionControl.Client.Enums.ItemType.File)
                        {
                            workspace.PendRenameFile(item.LocalItem, dialog.NewPath, out failures);
                        }
                        else
                        {
                            workspace.PendRenameFolder(item.LocalItem, dialog.NewPath, out failures);
                        }

                        if (failures != null && failures.Any(f => f.SeverityType == Microsoft.TeamFoundation.VersionControl.Client.Enums.SeverityType.Error))
                        {
                            progress.EndTask();
                            foreach (var failure in failures.Where(f => f.SeverityType == Microsoft.TeamFoundation.VersionControl.Client.Enums.SeverityType.Error))
                            {
                                progress.ReportError(failure.Code, new Exception(failure.Message));
                            }
                            return(string.Empty);
                        }
                        progress.EndTask();
                        progress.ReportSuccess("Finish Undo");
                        return(dialog.NewPath);
                    }
                }
                return(string.Empty);
            }
        }