예제 #1
0
            protected override async Task RunAsync()
            {
                try {
                    // A revert operation can create or remove a directory, so the directory
                    // check must be done before and after the revert.

                    bool isDir = Directory.Exists(path);

                    if (toRevision)
                    {
                        //we discard working changes (we are warning the user), it's the more intuitive action
                        await vc.RevertAsync(path, true, Monitor);

                        await vc.RevertToRevisionAsync(path, revision, Monitor);
                    }
                    else
                    {
                        await vc.RevertRevisionAsync(path, revision, Monitor);
                    }

                    if (!(isDir || Directory.Exists(path)))
                    {
                        isDir = false;
                    }

                    Gtk.Application.Invoke((o, args) => {
                        if (!isDir)
                        {
                            // Reload reverted files
                            Document doc = IdeApp.Workbench.GetDocument(path);
                            if (doc != null)
                            {
                                doc.Reload();
                            }
                            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(vc, path, false));
                        }
                        else
                        {
                            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(vc, path, true));
                        }
                    });
                    Monitor.ReportSuccess(GettextCatalog.GetString("Revert operation completed."));
                } catch (OperationCanceledException) {
                    return;
                } catch (Exception ex) {
                    LoggingService.LogError("Revert operation failed", ex);
                    Monitor.ReportError(ex.Message, null);
                }
            }