public MercurialRepository(MercurialVersionControl vcs, string url) : base(vcs)
 {
     Init();
     Url    = url;
     Client = new MercurialCommandClient(new Uri(url).AbsolutePath, null);
     Ide.IdeApp.Workspace.SolutionUnloaded += HandleSolutionUnloaded;
 }
        protected void OnInit()
        {
            MercurialVersionControl bvc    = null;
            MercurialRepository     repo   = null;
            VersionControlItem      vcitem = GetItems()[0];
            string          path           = vcitem.Path;
            List <FilePath> addFiles       = null;
            Solution        solution       = (Solution)vcitem.WorkspaceObject;

            foreach (VersionControlSystem vcs in VersionControlService.GetVersionControlSystems())
            {
                if (vcs is MercurialVersionControl)
                {
                    bvc = (MercurialVersionControl)vcs;
                }
            }

            if (null == bvc || !bvc.IsInstalled)
            {
                throw new Exception("Can't use mercurial");
            }

            bvc.Init(path);

            repo     = new MercurialRepository(bvc, string.Format("file://{0}", path));
            addFiles = GetAllFiles(solution);

            repo.Add(addFiles.ToArray(), false, null);
            solution.NeedsReload = true;
        }        // OnInit
        protected override void Update(CommandInfo info)
        {
            MercurialVersionControl bvc = null;

            foreach (VersionControlSystem vcs in VersionControlService.GetVersionControlSystems())
            {
                if (vcs is MercurialVersionControl)
                {
                    bvc = (MercurialVersionControl)vcs;
                }
            }

            info.Visible = (null != bvc && bvc.IsInstalled);
        }
        /// <summary>
        /// Performs a mercurial clone
        /// </summary>
        /// <param name="location">
        /// A <see cref="System.String"/>: The from location
        /// </param>
        /// <param name="localPath">
        /// A <see cref="System.String"/>: The to location
        /// </param>
        /// <param name="monitor">
        /// A <see cref="IProgressMonitor"/>: The progress monitor to be used
        /// </param>
        private static void DoBranch(string location, string localPath, IProgressMonitor monitor)
        {
            MercurialVersionControl bvc = null;

            foreach (VersionControlSystem vcs in VersionControlService.GetVersionControlSystems())
            {
                if (vcs is MercurialVersionControl)
                {
                    bvc = (MercurialVersionControl)vcs;
                }
            }

            if (null == bvc || !bvc.IsInstalled)
            {
                throw new Exception("Mercurial is not installed");
            }

            // Branch
            bvc.Branch(location, localPath, monitor);

            // Search for solution/project file in local branch;
            // open if found
            string[] list = System.IO.Directory.GetFiles(localPath);

            ProjectCheck[] checks =
            {
                delegate(string path) { return(path.EndsWith(".mds")); },
                delegate(string path) { return(path.EndsWith(".mdp")); },
                MonoDevelop.Projects.Services.ProjectService.IsWorkspaceItemFile
            };

            foreach (ProjectCheck check in checks)
            {
                foreach (string file in list)
                {
                    if (check(file))
                    {
                        Gtk.Application.Invoke(delegate(object o, EventArgs ea) {
                            IdeApp.Workspace.OpenWorkspaceItem(file);
                        });
                        return;
                    } // found a project file
                }     // on each file
            }         // run check
        }             // DoBranch