protected virtual void OnButtonEditClicked(object sender, System.EventArgs e)
        {
            Repository rep = GetSelectedRepository();

            if (rep != null)
            {
                Repository           repCopy = rep.Clone();
                EditRepositoryDialog dlg     = new EditRepositoryDialog(repCopy);
                try {
                    if (MessageService.RunCustomDialog(dlg, this) != (int)Gtk.ResponseType.Ok)
                    {
                        VersionControlService.ResetConfiguration();
                        return;
                    }

                    rep.CopyConfigurationFrom(repCopy);
                    VersionControlService.SaveConfiguration();

                    TreeIter  iter;
                    TreeModel model;
                    if (repoTree.Selection.GetSelected(out model, out iter))
                    {
                        // Update values
                        store.SetValue(iter, RepoNameCol, rep.Name);
                        store.SetValue(iter, VcsName, rep.VersionControlSystem.Name);
                        bool filled = (bool)store.GetValue(iter, FilledCol);
                        if (filled && repoTree.GetRowExpanded(store.GetPath(iter)))
                        {
                            FullRepoNode(rep, iter);
                            repoTree.ExpandRow(store.GetPath(iter), false);
                        }
                        else if (filled)
                        {
                            store.SetValue(iter, FilledCol, false);
                            store.AppendValues(iter, null, "", "", true, "vcs-repository");
                        }
                    }
                    UpdateRepoDescription();
                } finally {
                    dlg.Destroy();
                }
            }
        }
        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();
        }
        // Tests VersionControlService.GetRepositoryReference.
        public void RightRepositoryDetection()
        {
            var path = ((string)LocalPath).TrimEnd(Path.DirectorySeparatorChar);
            var repo = VersionControlService.GetRepositoryReference(path, null);

            Assert.That(repo, IsCorrectType(), "#1");

            while (!String.IsNullOrEmpty(path))
            {
                path = Path.GetDirectoryName(path);
                if (path == null)
                {
                    return;
                }
                Assert.IsNull(VersionControlService.GetRepositoryReference(path, null), "#2." + path);
            }

            // Versioned file
            AddFile("foo", "contents", true, true);
            path = Path.Combine(LocalPath, "foo");
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#2");

            // Versioned directory
            AddDirectory("bar", true, true);
            path = Path.Combine(LocalPath, "bar");
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#3");

            // Unversioned file
            AddFile("bip", "contents", false, false);
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#4");

            // Unversioned directory
            AddDirectory("bop", false, false);
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#5");

            // Nonexistent file
            path = Path.Combine(LocalPath, "do_i_exist");
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#6");

            // Nonexistent directory
            path = Path.Combine(LocalPath, "do", "i", "exist");
            Assert.AreSame(VersionControlService.GetRepositoryReference(path, null), repo, "#6");
        }
Beispiel #4
0
        protected override void Run()
        {
            var             solution = IdeApp.ProjectOperations.CurrentSelectedSolution;
            List <FilePath> paths    = new List <FilePath>();

            //Add Solution
            paths.Add(solution.BaseDirectory);
            //Add linked files.
            foreach (var path in solution.GetItemFiles(true))
            {
                if (!path.IsChildPathOf(solution.BaseDirectory))
                {
                    paths.Add(path);
                }
            }
            var repo = (TFSRepository)VersionControlService.GetRepository(solution);

            ResolveConflictsView.Open(repo, paths);
        }
Beispiel #5
0
        TreeIter AppendFileInfo(VersionInfo n)
        {
            Xwt.Drawing.Image statusicon = VersionControlService.LoadIconForStatus(n.Status);
            string            lstatus    = VersionControlService.GetStatusLabel(n.Status);

            Xwt.Drawing.Image rstatusicon = VersionControlService.LoadIconForStatus(n.RemoteStatus);
            string            rstatus     = VersionControlService.GetStatusLabel(n.RemoteStatus);

            string scolor = n.HasLocalChanges && n.HasRemoteChanges ? "red" : null;

            string localpath = n.LocalPath.ToRelative(filepath);

            if (localpath.Length > 0 && localpath[0] == Path.DirectorySeparatorChar)
            {
                localpath = localpath.Substring(1);
            }
            if (localpath == "")
            {
                localpath = ".";
            }                                                     // not sure if this happens

            bool hasComment = GetCommitMessage(n.LocalPath).Length > 0;
            bool commit     = changeSet.ContainsFile(n.LocalPath);

            Xwt.Drawing.Image fileIcon;
            if (n.IsDirectory)
            {
                fileIcon = ImageService.GetIcon(MonoDevelop.Ide.Gui.Stock.ClosedFolder, Gtk.IconSize.Menu);
            }
            else
            {
                fileIcon = DesktopService.GetIconForFile(n.LocalPath, Gtk.IconSize.Menu);
            }

            TreeIter it = filestore.AppendValues(statusicon, lstatus, GLib.Markup.EscapeText(localpath).Split('\n'), rstatus, commit, false, n.LocalPath.ToString(), true, hasComment, fileIcon, n.HasLocalChanges, rstatusicon, scolor, n.HasRemoteChange(VersionStatus.Modified));

            if (!n.IsDirectory)
            {
                filestore.AppendValues(it, statusicon, "", new string[0], "", false, true, n.LocalPath.ToString(), false, false, fileIcon, false, null, null, false);
            }
            return(it);
        }
Beispiel #6
0
            protected override async Task RunAsync()
            {
                success = true;
                try {
                    // store global comment before commit.
                    VersionControlService.SetCommitComment(changeSet.BaseLocalPath, changeSet.GlobalComment, true);

                    await vc.CommitAsync(changeSet, Monitor);

                    Monitor.ReportSuccess(GettextCatalog.GetString("Commit operation completed."));

                    // Reset the global comment on successful commit.
                    VersionControlService.SetCommitComment(changeSet.BaseLocalPath, "", true);
                } catch (Exception ex) {
                    LoggingService.LogError("Commit operation failed", ex);
                    Monitor.ReportError(ex.Message, null);
                    success = false;
                    throw;
                }
            }
Beispiel #7
0
        void HandleDocumentOpened(object sender, Ide.Gui.DocumentEventArgs e)
        {
            if (e.Document.Project == null)
            {
                return;
            }
            var repo = VersionControlService.GetRepository(e.Document.Project);

            if (repo == null)
            {
                return;
            }
            if (!e.Document.IsFile || !repo.GetVersionInfo(e.Document.FileName).IsVersioned)
            {
                return;
            }
            var item = new VersionControlItem(repo, e.Document.Project, e.Document.FileName, false, null);

            DiffView.AttachViewContents(e.Document, item);
        }
Beispiel #8
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();
            }
        }
        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 #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
        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 #13
0
        protected override void OnResponse(Gtk.ResponseType type)
        {
            base.OnResponse(type);

            if (type != Gtk.ResponseType.Ok)
            {
                changeSet.GlobalComment = oldMessage;
                EndCommit(false);
            }
            else if (!ButtonCommitClicked())
            {
                return;
            }

            if (type == Gtk.ResponseType.Ok)
            {
                VersionControlService.NotifyBeforeCommit(vc, changeSet);
                new CommitWorker(vc, changeSet, this).StartAsync();
                return;
            }
        }
Beispiel #14
0
        void HandleDocumentOpened(object sender, Ide.Gui.DocumentEventArgs e)
        {
            if (!e.Document.IsFile || e.Document.Project == null)
            {
                return;
            }

            var repo = VersionControlService.GetRepository(e.Document.Project);

            if (repo == null || !repo.GetVersionInfo(e.Document.FileName).IsVersioned)
            {
                return;
            }

            var item = new VersionControlItem(repo, e.Document.Project, e.Document.FileName, false, null);

            TryAttachView <IDiffView> (e.Document, item, DiffCommand.DiffViewHandlers);
            TryAttachView <IBlameView> (e.Document, item, BlameCommand.BlameViewHandlers);
            TryAttachView <ILogView> (e.Document, item, LogCommand.LogViewHandlers);
            TryAttachView <IMergeView> (e.Document, item, MergeCommand.MergeViewHandlers);
        }
Beispiel #15
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");
             }
         }
     }
 }
Beispiel #16
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            var ob  = (WorkspaceObject)dataObject;
            var rep = VersionControlService.GetRepository(ob) as GitRepository;

            if (rep != null)
            {
                WorkspaceObject rob;
                if (repos.TryGetValue(rep.RootPath, out rob))
                {
                    if (ob == rob)
                    {
                        string branch = rep.GetCurrentBranch();
                        if (branch == "(no branch)")
                        {
                            branch = rep.RootRepository.ObjectDatabase.ShortenObjectId(rep.RootRepository.Head.Tip);
                        }
                        nodeInfo.Label += " (" + branch + ")";
                    }
                }
            }
        }
        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 #18
0
        TreeIter AppendFileInfo(ChangeSetItem n)
        {
            Gdk.Pixbuf statusicon = VersionControlService.LoadIconForStatus(n.Status);
            string     lstatus    = VersionControlService.GetStatusLabel(n.Status);

            string scolor = null;

            string localpath = n.LocalPath.ToRelative(changeSet.BaseLocalPath);

            if (localpath.Length > 0 && localpath[0] == System.IO.Path.DirectorySeparatorChar)
            {
                localpath = localpath.Substring(1);
            }
            if (localpath == "")
            {
                localpath = ".";
            }                               // not sure if this happens

            bool hasComment = false;        //GetCommitMessage (n.LocalPath).Length > 0;
            bool commit     = true;         //changeSet.ContainsFile (n.LocalPath);

            Gdk.Pixbuf fileIcon;
            if (n.IsDirectory)
            {
                fileIcon = ImageService.GetPixbuf(MonoDevelop.Ide.Gui.Stock.ClosedFolder, Gtk.IconSize.Menu);
            }
            else
            {
                fileIcon = DesktopService.GetPixbufForFile(n.LocalPath, Gtk.IconSize.Menu);
            }

            TreeIter it = filestore.AppendValues(statusicon, lstatus, GLib.Markup.EscapeText(localpath).Split('\n'), commit, false, n.LocalPath.ToString(), true, hasComment, fileIcon, n.HasLocalChanges, scolor);

            if (!n.IsDirectory)
            {
                filestore.AppendValues(it, statusicon, "", new string[0], false, true, n.LocalPath.ToString(), false, false, fileIcon, false, null);
            }
            return(it);
        }
        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);
        }
Beispiel #20
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 #21
0
        void HandleDocumentChanged(object sender, EventArgs e)
        {
            var document = Ide.IdeApp.Workbench.ActiveDocument;

            try
            {
                if (document == null || !document.IsFile || document.Project == null || document.Window.FindView <IDiffView> () >= 0)
                {
                    return;
                }

                var repo = VersionControlService.GetRepository(document.Project);
                if (repo == null)
                {
                    return;
                }

                var versionInfo = repo.GetVersionInfo(document.FileName);
                if (!versionInfo.IsVersioned)
                {
                    return;
                }

                var item   = new VersionControlItem(repo, document.Project, document.FileName, false, null);
                var vcInfo = new VersionControlDocumentInfo(document.PrimaryView, item, item.Repository);
                TryAttachView <IDiffView> (document, vcInfo, DiffCommand.DiffViewHandlers);
                TryAttachView <IBlameView> (document, vcInfo, BlameCommand.BlameViewHandlers);
                TryAttachView <ILogView> (document, vcInfo, LogCommand.LogViewHandlers);
                TryAttachView <IMergeView> (document, vcInfo, MergeCommand.MergeViewHandlers);
            }
            catch (Exception ex)
            {
                // If a user is hitting this, it will show a dialog box every time they
                // switch to a document or open a document, so suppress the crash dialog
                // This bug *should* be fixed already, but it's hard to tell.
                LogReportingService.ReportUnhandledException(ex, false, true);
            }
        }
Beispiel #22
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 #23
0
        public async Task PublishArtifacts_ItemCountMismatch_ThrowsBadRequestException()
        {
            _versionControlRepository.Setup(
                a => a.GetDiscardPublishStates(It.IsAny <int>(), It.IsAny <IEnumerable <int> >(), It.IsAny <IDbTransaction>()))
            .ReturnsAsync(new List <SqlDiscardPublishState>
            {
                new SqlDiscardPublishState()
            });
            var versionControlService = new VersionControlService(
                _versionControlRepository.Object,
                _publishRepository.Object,
                _revisionRepository.Object,
                _sqlHelper.Object);

            var publishParameters = new PublishParameters {
                ArtifactIds = new List <int>()
                {
                    1, 2, 3
                }
            };

            await versionControlService.PublishArtifacts(publishParameters);
        }
Beispiel #24
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.");
                    }
                }
            }
        }
Beispiel #25
0
        void LoadChangeset(IEnumerable <ChangeSetItem> items)
        {
            fileList.Model = null;
            store.Clear();

            foreach (ChangeSetItem info in items)
            {
                Xwt.Drawing.Image statusicon = VersionControlService.LoadIconForStatus(info.Status);
                string            lstatus    = VersionControlService.GetStatusLabel(info.Status);
                string            localpath;

                if (info.IsDirectory)
                {
                    localpath = (!info.LocalPath.IsChildPathOf(changeSet.BaseLocalPath) ?
                                 "." :
                                 (string)info.LocalPath.ToRelative(changeSet.BaseLocalPath));
                }
                else
                {
                    localpath = System.IO.Path.GetFileName((string)info.LocalPath);
                }

                if (localpath.Length > 0 && localpath [0] == System.IO.Path.DirectorySeparatorChar)
                {
                    localpath = localpath.Substring(1);
                }
                if (localpath == "")
                {
                    localpath = ".";
                }                                                         // not sure if this happens

                store.AppendValues(statusicon, lstatus, localpath, true, info);
                selected.Add(info.LocalPath);
            }

            fileList.Model = store;
        }
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            var ob  = (WorkspaceObject)dataObject;
            var rep = VersionControlService.GetRepository(ob) as GitRepository;

            if (rep != null)
            {
                WorkspaceObject rob;
                if (repos.TryGetValue(rep.RootPath, out rob))
                {
                    if (ob == rob)
                    {
                        string branch = rep.CachedCurrentBranch;
                        //FIXME: we need to find a better way to get this sync
                        using (var cts = new CancellationTokenSource()) {
                            var getBranch = rep.GetCurrentBranchAsync(cts.Token);
                            if (!getBranch.Wait(250))
                            {
                                cts.Cancel();
                                LoggingService.LogError("Getting current Git branch timed out");
                            }
                            else if (!getBranch.IsFaulted)
                            {
                                branch = getBranch.Result;
                            }
                        }

                        if (branch == GitRepository.DefaultNoBranchName)
                        {
                            using (var RootRepository = new LibGit2Sharp.Repository(rep.RootPath))
                                branch = RootRepository.ObjectDatabase.ShortenObjectId(RootRepository.Head.Tip);
                        }
                        nodeInfo.Label += " (" + branch + ")";
                    }
                }
            }
        }
Beispiel #27
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 #28
0
        protected override void Update(CommandInfo info)
        {
            if (VersionControlService.IsGloballyDisabled)
            {
                info.Visible = false;
                return;
            }

            var solution = IdeApp.ProjectOperations.CurrentSelectedSolution;

            if (solution == null)
            {
                info.Visible = false;
                return;
            }

            var repo = VersionControlService.GetRepository(solution) as TFSRepository;

            if (repo == null)
            {
                info.Visible = false;
                return;
            }
        }
Beispiel #29
0
        public override bool RequestFileWritePermission(params FilePath[] paths)
        {
            var toLock = new List <FilePath>();

            foreach (var path in paths)
            {
                if (!File.Exists(path) || !Svn.HasNeedLock(path) || (File.GetAttributes(path) & FileAttributes.ReadOnly) == 0)
                {
                    continue;
                }
                toLock.Add(path);
            }

            if (toLock.Count == 0)
            {
                return(true);
            }

            AlertButton but = new AlertButton("Lock File");

            if (!MessageService.Confirm(GettextCatalog.GetString("The following files must be locked before editing."),
                                        String.Join("\n", toLock.Select(u => u.ToString())), but))
            {
                return(false);
            }

            try {
                Svn.Lock(null, "", false, toLock.ToArray());
            } catch (SubversionException ex) {
                MessageService.ShowError(GettextCatalog.GetString("File could not be unlocked."), ex.Message);
                return(false);
            }

            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(this, toLock.ToArray()));
            return(true);
        }
        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);
            }
        }