public override void Commit(ChangeSet changeSet, MonoDevelop.Core.IProgressMonitor monitor)
        {
            List <string> files       = new List <string> ();
            string        basePath    = MercurialRepository.GetLocalBasePath(changeSet.BaseLocalPath),
                          pyfiles     = string.Empty,
                          messageFile = Path.GetTempFileName();

            if (!basePath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                basePath += Path.DirectorySeparatorChar;
            }

            foreach (ChangeSetItem item in changeSet.Items)
            {
                files.Add(string.Format("os.path.realpath('{0}')", item.LocalPath.FullPath));
            }

            if (!(0 == files.Count || (1 == files.Count && string.Empty.Equals(files[0], StringComparison.Ordinal))))
            {
                pyfiles = string.Format("{0},", string.Join(",", files.ToArray()));
            }

            try {
                File.WriteAllText(messageFile, changeSet.GlobalComment);
                RunMercurialRepoCommand(basePath, "commands.commit(repo.ui,repo,{1}logfile='{0}')", messageFile, pyfiles);
            } finally {
                try {
                    File.Delete(messageFile);
                } catch { }
            }
        }
Example #2
0
        }        // Branch

        public override Repository GetRepositoryReference(FilePath path, string id)
        {
            // System.Console.WriteLine ("Requested repository reference for {0}", path);
            try {
                string url = MercurialRepository.GetLocalBasePath(path.FullPath);
                if (string.IsNullOrEmpty(url))
                {
                    return(null);
                }
                return(new MercurialRepository(this, string.Format("file://{0}", url)));
            } catch (Exception ex) {
                // No bzr
                LoggingService.LogError(ex.ToString());
                return(null);
            }
        } // GetRepositoryReference
Example #3
0
        protected void OnMercurialPublish()
        {
            VersionControlItem              vcitem   = GetItems()[0];
            MercurialRepository             repo     = ((MercurialRepository)vcitem.Repository);
            Dictionary <string, BranchType> branches = repo.GetKnownBranches(vcitem.Path);
            string defaultBranch = string.Empty,
                   localPath     = vcitem.IsDirectory? (string)vcitem.Path.FullPath: Path.GetDirectoryName(vcitem.Path.FullPath);

            if (repo.IsModified(MercurialRepository.GetLocalBasePath(vcitem.Path.FullPath)))
            {
                MessageDialog md = new MessageDialog(MonoDevelop.Ide.IdeApp.Workbench.RootWindow, DialogFlags.Modal,
                                                     MessageType.Question, ButtonsType.YesNo,
                                                     GettextCatalog.GetString("You have uncommitted local changes. Push anyway?"));
                try {
                    if ((int)ResponseType.Yes != md.Run())
                    {
                        return;
                    }
                } finally {
                    md.Destroy();
                }
            }            // warn about uncommitted changes

            foreach (KeyValuePair <string, BranchType> branch in branches)
            {
                if (BranchType.Parent == branch.Value)
                {
                    defaultBranch = branch.Key;
                    break;
                }
            }            // check for parent branch

            Dialogs.BranchSelectionDialog bsd = new Dialogs.BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, true, true, true);
            try {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    MercurialTask worker = new MercurialTask();
                    worker.Description = string.Format("Pushing to {0}", bsd.SelectedLocation);
                    worker.Operation   = delegate { repo.Push(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, bsd.OmitHistory, worker.ProgressMonitor); };
                    worker.Start();
                }
            } finally {
                bsd.Destroy();
            }
        }        // OnPublish
        public override void RevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
        {
            if (IsModified(MercurialRepository.GetLocalBasePath(localPath)))
            {
                MessageDialog md = new MessageDialog(MonoDevelop.Ide.IdeApp.Workbench.RootWindow, DialogFlags.Modal,
                                                     MessageType.Question, ButtonsType.YesNo,
                                                     GettextCatalog.GetString("You have uncommitted local changes. Revert anyway?"));
                try {
                    if ((int)ResponseType.Yes != md.Run())
                    {
                        return;
                    }
                } finally {
                    md.Destroy();
                }
            }            // warn about uncommitted changes

            MercurialRevision brev = (null == revision)? new MercurialRevision(this, MercurialRevision.HEAD): (MercurialRevision)revision;

            Client.Revert(localPath.FullPath, true, monitor, brev);
        }
Example #5
0
        protected void OnGetOutgoing()
        {
            VersionControlItem              vcitem   = GetItems()[0];
            MercurialRepository             repo     = ((MercurialRepository)vcitem.Repository);
            Dictionary <string, BranchType> branches = repo.GetKnownBranches(vcitem.Path);
            string defaultBranch = string.Empty,
                   localPath     = vcitem.IsDirectory? (string)vcitem.Path.FullPath: Path.GetDirectoryName(vcitem.Path.FullPath);

            foreach (KeyValuePair <string, BranchType> branch in branches)
            {
                if (BranchType.Parent == branch.Value)
                {
                    defaultBranch = branch.Key;
                    break;
                }
            }            // check for parent branch

            Dialogs.BranchSelectionDialog bsd = new Dialogs.BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, false, false, false);
            try {
                if ((int)Gtk.ResponseType.Ok == bsd.Run())
                {
                    MercurialTask worker = new MercurialTask();
                    worker.Description = string.Format("Outgoing to {0}", bsd.SelectedLocation);
                    worker.Operation   = delegate {
                        repo.LocalBasePath = MercurialRepository.GetLocalBasePath(localPath);
                        Revision[] history = repo.GetOutgoing(bsd.SelectedLocation);
                        DispatchService.GuiDispatch(() => {
                            var view = new MonoDevelop.VersionControl.Views.LogView(localPath, true, history, repo);
                            IdeApp.Workbench.OpenDocument(view, true);
                        });
                    };
                    worker.Start();
                }
            } finally {
                bsd.Destroy();
            }
        } // OnGetOutgoing