Example #1
0
        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
Example #2
0
        protected void OnMerge()
        {
            VersionControlItem  vcitem = GetItems()[0];
            MercurialRepository repo   = ((MercurialRepository)vcitem.Repository);

            repo.Merge();
        }        // OnMerge
        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 { }
            }
        }
        public MergeDialog(MercurialRepository repo, bool rebasing)
        {
            this.Build ();

            this.repo = repo;
            this.rebasing = rebasing;

            store = new TreeStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string), typeof(string));
            tree.Model = store;

            CellRendererPixbuf crp = new CellRendererPixbuf ();
            TreeViewColumn col = new TreeViewColumn ();
            col.PackStart (crp, false);
            col.AddAttribute (crp, "pixbuf", 1);
            CellRendererText crt = new CellRendererText ();
            col.PackStart (crt, true);
            col.AddAttribute (crt, "text", 2);
            tree.AppendColumn (col);

            tree.Selection.Changed += HandleTreeSelectionChanged;

            if (rebasing) {
                labelHeader.Text = GettextCatalog.GetString ("Select the branch to which to rebase:");
                checkStage.Label = GettextCatalog.GetString ("Stash/unstash local changes before/after rebasing");
            }

            checkStage.Active = true;

            Fill ();
        }
Example #5
0
        public static void ShowShelfManager(MercurialRepository repo)
        {
            ShelfManagerDialog dlg = new ShelfManagerDialog(repo);

            MessageService.RunCustomDialog(dlg);
            dlg.Destroy();
        }
        public MercurialConfigurationDialog(MercurialRepository repo)
        {
            this.Build ();
            this.repo = repo;
            this.HasSeparator = false;

            // Branches list

            storeBranches = new ListStore (typeof(Branch), typeof(string), typeof(string), typeof(string));
            listBranches.Model = storeBranches;
            listBranches.HeadersVisible = true;

            listBranches.AppendColumn (GettextCatalog.GetString ("Branch"), new CellRendererText (), "markup", 1);
            listBranches.AppendColumn (GettextCatalog.GetString ("Tracking"), new CellRendererText (), "text", 2);

            // Sources tree

            storeRemotes = new TreeStore (typeof(Branch), typeof(string), typeof(string), typeof(string), typeof(string));
            treeRemotes.Model = storeRemotes;
            treeRemotes.HeadersVisible = true;

            treeRemotes.AppendColumn ("Remote Source / Branch", new CellRendererText (), "markup", 1);
            treeRemotes.AppendColumn ("Url", new CellRendererText (), "text", 2);

            // Fill data

            FillBranches ();
            FillRemotes ();
        }
Example #7
0
        public MergeDialog(MercurialRepository repo, bool rebasing)
        {
            this.Build();

            this.repo     = repo;
            this.rebasing = rebasing;

            store      = new TreeStore(typeof(string), typeof(Gdk.Pixbuf), typeof(string), typeof(string));
            tree.Model = store;

            CellRendererPixbuf crp = new CellRendererPixbuf();
            TreeViewColumn     col = new TreeViewColumn();

            col.PackStart(crp, false);
            col.AddAttribute(crp, "pixbuf", 1);
            CellRendererText crt = new CellRendererText();

            col.PackStart(crt, true);
            col.AddAttribute(crt, "text", 2);
            tree.AppendColumn(col);

            tree.Selection.Changed += HandleTreeSelectionChanged;

            if (rebasing)
            {
                labelHeader.Text = GettextCatalog.GetString("Select the branch to which to rebase:");
                checkStage.Label = GettextCatalog.GetString("Stash/unstash local changes before/after rebasing");
            }

            checkStage.Active = true;

            Fill();
        }
Example #8
0
        protected void OnRebase()
        {
            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, true, true, false);
            try {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    MercurialTask worker = new MercurialTask();
                    worker.Description = string.Format("Rebasing on {0}", bsd.SelectedLocation);
                    worker.Operation   = delegate { repo.Rebase(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, worker.ProgressMonitor); };
                    worker.Start();
                }
            } finally {
                bsd.Destroy();
            }
        }        // OnRebase
Example #9
0
 internal void UnregisterRepo(MercurialRepository repo)
 {
     if (!repo.RootPath.IsNullOrEmpty)
     {
         repositories.Remove(repo.RootPath.CanonicalPath);
     }
 }
Example #10
0
        public override MercurialRevision[] GetOutgoing(MercurialRepository repo, string remote)
        {
            List <MercurialRevision> revisions = new List <MercurialRevision> ();

            if (string.IsNullOrEmpty(remote))
            {
                remote = "default";
            }

            string logText  = RunMercurialRepoCommand(repo.LocalBasePath, "commands.outgoing(repo.ui,repo,dest='{0}',style='xml')", remote);
            int    xmlIndex = logText.IndexOf("<?xml");

            if (0 > xmlIndex)
            {
                return(revisions.ToArray());
            }

            XmlDocument doc = new XmlDocument();

            try {
                doc.LoadXml(logText.Substring(xmlIndex));
            } catch (XmlException xe) {
                LoggingService.LogError("Error getting outgoing for " + remote, xe);
                return(revisions.ToArray());
            }

            foreach (XmlNode node in doc.SelectNodes("/log/logentry"))
            {
                revisions.Add(NodeToRevision(repo, node));
            }

            return(revisions.ToArray());
        }
Example #11
0
        public MercurialConfigurationDialog(MercurialRepository repo)
        {
            this.Build();
            this.repo         = repo;
            this.HasSeparator = false;

            // Branches list

            storeBranches               = new ListStore(typeof(Branch), typeof(string), typeof(string), typeof(string));
            listBranches.Model          = storeBranches;
            listBranches.HeadersVisible = true;

            listBranches.AppendColumn(GettextCatalog.GetString("Branch"), new CellRendererText(), "markup", 1);
            listBranches.AppendColumn(GettextCatalog.GetString("Tracking"), new CellRendererText(), "text", 2);

            // Sources tree

            storeRemotes               = new TreeStore(typeof(Branch), typeof(string), typeof(string), typeof(string), typeof(string));
            treeRemotes.Model          = storeRemotes;
            treeRemotes.HeadersVisible = true;

            treeRemotes.AppendColumn("Remote Source / Branch", new CellRendererText(), "markup", 1);
            treeRemotes.AppendColumn("Url", new CellRendererText(), "text", 2);

            // Fill data

            FillBranches();
            FillRemotes();
        }
Example #12
0
        public static void Push(MercurialRepository 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();
            }
        }
Example #13
0
        static MercurialRevision NodeToRevision(MercurialRepository repo, XmlNode node)
        {
            string changeset = node.Attributes["revision"].Value;
            string date      = node.SelectSingleNode("date").InnerText;
            string user      = node.SelectSingleNode("author").Attributes["email"].Value;
            string message   = node.SelectSingleNode("msg").InnerText;

            return(new MercurialRevision(repo, changeset, DateTime.Parse(date), user, message, new RevisionPath[] {}));
        }
Example #14
0
        public override MercurialRevision[] GetHistory(MercurialRepository repo, string localFile, MercurialRevision since)
        {
            string revisions = null;

            if (since != null && since.Rev != MercurialRevision.NONE)
            {
                revisions = since.Rev;
            }
            return(client.Log(revisions, NormalizePath(localFile)).Select(r => FromCommandRevision(repo, r)).ToArray());
        }
Example #15
0
        public override void OnNodeAdded(object dataObject)
        {
            IWorkspaceObject    ob  = (IWorkspaceObject)dataObject;
            MercurialRepository rep = VersionControlService.GetRepository(ob) as MercurialRepository;

            if (rep != null && !repos.ContainsKey(rep.RootPath.CanonicalPath))
            {
                repos [rep.RootPath] = ob;
            }
        }
Example #16
0
        protected void OnUncommit()
        {
            VersionControlItem  vcitem = GetItems()[0];
            MercurialRepository repo   = (MercurialRepository)vcitem.Repository;

            MercurialTask worker = new MercurialTask();

            worker.Description = string.Format("Uncommitting {0}", vcitem.Path);
            worker.Operation   = delegate { repo.Uncommit(vcitem.Path, worker.ProgressMonitor); };
            worker.Start();
        }        // OnUncommit
Example #17
0
        // public abstract RevisionPath[] GetRevisionChanges (MercurialRepository repo, MercurialRevision revision);
        public virtual RevisionPath[] GetRevisionChanges(MercurialRepository repo, MercurialRevision revision)
        {
            List <RevisionPath> paths = new List <RevisionPath> ();

            foreach (LocalStatus status in Status(repo.LocalBasePath, revision)
                     .Where(s => s.Status != ItemStatus.Unchanged && s.Status != ItemStatus.Unversioned))
            {
                paths.Add(new RevisionPath(Path.Combine(repo.LocalBasePath, status.Filename), ConvertAction(status.Status), status.Status.ToString()));
            }

            return(paths.ToArray());
        }
Example #18
0
        public EditBranchDialog(MercurialRepository repo, Branch branch, bool isNew)
        {
            this.Build();
            this.repo = repo;

            comboStore         = new ListStore(typeof(string), typeof(Gdk.Pixbuf), typeof(string));
            comboSources.Model = comboStore;
            CellRendererPixbuf crp = new CellRendererPixbuf();

            comboSources.PackStart(crp, false);
            comboSources.AddAttribute(crp, "pixbuf", 1);
            CellRendererText crt = new CellRendererText();

            comboSources.PackStart(crt, true);
            comboSources.AddAttribute(crt, "text", 2);

            if (branch != null)
            {
                if (!isNew)
                {
                    oldName = branch.Name;
                }
                currentTracking = branch.Tracking;
                entryName.Text  = branch.Name;
                if (currentTracking != null)
                {
                    checkTrack.Active = true;
                }
            }

            foreach (var b in repo.GetBranches())
            {
                AddValues(b.Name, ImageService.GetPixbuf("vc-git-branch", IconSize.Menu));
            }

            foreach (var t in repo.GetTags())
            {
                AddValues(t.Name, ImageService.GetPixbuf("vc-git-tag", IconSize.Menu));
            }

            foreach (var r in repo.GetRemotes())
            {
                foreach (string b in repo.GetRemoteBranches(r.Name))
                {
                    AddValues(r.Name + "/" + b, ImageService.GetPixbuf("md-web-search-icon", IconSize.Menu));
                }
            }

            UpdateStatus();
        }
Example #19
0
        public override void OnNodeRemoved(object dataObject)
        {
            IWorkspaceObject    ob  = (IWorkspaceObject)dataObject;
            MercurialRepository rep = VersionControlService.GetRepository(ob) as MercurialRepository;
            IWorkspaceObject    rob;

            if (rep != null && repos.TryGetValue(rep.RootPath.CanonicalPath, out rob))
            {
                if (ob == rob)
                {
                    repos.Remove(rep.RootPath.CanonicalPath);
                }
            }
        }
        public PushDialog(MercurialRepository repo)
        {
            this.Build ();
            this.repo = repo;
            HasSeparator = false;

            changeList.DiffLoader = DiffLoader;

            List<string> list = new List<string> (repo.GetRemotes ().Select (r => r.Name));
            foreach (string s in list)
                remoteCombo.AppendText (s);
            remoteCombo.Active = list.IndexOf (repo.GetCurrentRemote ());

            UpdateChangeSet ();
        }
Example #21
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 #22
0
        public static void ShowMergeDialog(MercurialRepository 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();
            }
        }
Example #23
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            IWorkspaceObject    ob  = (IWorkspaceObject)dataObject;
            MercurialRepository rep = VersionControlService.GetRepository(ob) as MercurialRepository;

            if (rep != null)
            {
                IWorkspaceObject rob;
                if (repos.TryGetValue(rep.RootPath.CanonicalPath, out rob))
                {
                    if (ob == rob)
                    {
                        label += " (" + rep.GetCurrentBranch() + ")";
                    }
                }
            }
        }
Example #24
0
        protected override void Update(CommandArrayInfo info)
        {
            MercurialRepository repo = Repository;

            if (repo != null)
            {
                string currentBranch = repo.GetCurrentBranch();
                foreach (var branch in repo.GetBranches())
                {
                    CommandInfo ci = info.Add(branch.Name, branch.Name);
                    if (branch.Name == currentBranch)
                    {
                        ci.Checked = true;
                    }
                }
            }
        }
Example #25
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
Example #26
0
        public PushDialog(MercurialRepository repo)
        {
            this.Build();
            this.repo    = repo;
            HasSeparator = false;

            changeList.DiffLoader = DiffLoader;

            List <string> list = new List <string> (repo.GetRemotes().Select(r => r.Name));

            foreach (string s in list)
            {
                remoteCombo.AppendText(s);
            }
            remoteCombo.Active = list.IndexOf(repo.GetCurrentRemote());

            UpdateChangeSet();
        }
Example #27
0
 public override Repository GetRepositoryReference(FilePath path, string id)
 {
     if (path.IsEmpty || path.ParentDirectory.IsEmpty || path.IsNull || path.ParentDirectory.IsNull)
     {
         return(null);
     }
     if (System.IO.Directory.Exists(path.Combine(".hg")))
     {
         MercurialRepository repo;
         if (!repositories.TryGetValue(path.CanonicalPath, out repo))
         {
             repositories [path.CanonicalPath] = repo = new MercurialRepository(path, null);
         }
         return(repo);
     }
     else
     {
         return(GetRepositoryReference(path.ParentDirectory, id));
     }
 }
Example #28
0
        protected void OnResolve()
        {
            List <FilePath>     files = null;
            MercurialRepository repo  = null;

            foreach (VersionControlItemList repolist in GetItems().SplitByRepository())
            {
                repo  = (MercurialRepository)repolist[0].Repository;
                files = new List <FilePath> (repolist.Count);
                foreach (VersionControlItem item in repolist)
                {
                    files.Add(new FilePath(item.Path));
                }

                MercurialTask worker = new MercurialTask();
                worker.Description = string.Format("Resolving {0}", files[0]);
                worker.Operation   = delegate { repo.Resolve(files.ToArray(), true, worker.ProgressMonitor); };
                worker.Start();
            }
        }        // OnResolve
Example #29
0
        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 #30
0
        public override MercurialRevision[] GetHistory(MercurialRepository repo, string localFile, MercurialRevision since)
        {
            localFile = NormalizePath(localFile);
            List <MercurialRevision> revisions = new List <MercurialRevision> ();
            string logText = RunMercurialRepoCommand(localFile, "commands.log(repo.ui,repo,os.path.realpath('{0}'),date=None,user=None{1},style='xml')", localFile, ",rev=None");

            XmlDocument doc = new XmlDocument();

            try {
                doc.LoadXml(logText);
            } catch (XmlException xe) {
                LoggingService.LogError("Error getting history for " + localFile, xe);
                return(revisions.ToArray());
            }

            foreach (XmlNode node in doc.SelectNodes("/log/logentry"))
            {
                revisions.Add(NodeToRevision(repo, node));
            }

            return(revisions.ToArray());
        }        // GetHistory
Example #31
0
        public static void SwitchToBranch(MercurialRepository repo, string branch)
        {
            MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true);

            try {
                IdeApp.Workbench.AutoReloadDocuments = true;
                IdeApp.Workbench.LockGui();
                System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        repo.SwitchToBranch(monitor, branch);
                    } catch (Exception ex) {
                        monitor.ReportError("Branch switch failed", ex);
                    } finally {
                        monitor.Dispose();
                    }
                });
                monitor.AsyncOperation.WaitForCompleted();
            } finally {
                IdeApp.Workbench.AutoReloadDocuments = false;
                IdeApp.Workbench.UnlockGui();
            }
        }
Example #32
0
        public override MercurialRevision[] GetHeads(MercurialRepository repo)
        {
            string localPath = NormalizePath(repo.LocalBasePath);
            string logText   = RunMercurialRepoCommand(localPath, "commands.heads(repo.ui,repo,style='xml')", localPath);
            List <MercurialRevision> revisions = new List <MercurialRevision> ();

            XmlDocument doc = new XmlDocument();

            try {
                doc.LoadXml(logText);
            } catch (XmlException xe) {
                LoggingService.LogError("Error getting heads for " + localPath, xe);
                return(revisions.ToArray());
            }

            foreach (XmlNode node in doc.SelectNodes("/log/logentry"))
            {
                revisions.Add(NodeToRevision(repo, node));
            }

            return(revisions.ToArray());
        }
Example #33
0
        protected void OnExport()
        {
            VersionControlItem  vcitem = GetItems()[0];
            MercurialRepository repo   = ((MercurialRepository)vcitem.Repository);

            FileChooserDialog fsd = new FileChooserDialog(GettextCatalog.GetString("Choose export location"),
                                                          null, FileChooserAction.Save, "Cancel", ResponseType.Cancel,
                                                          "Save", ResponseType.Accept);

            fsd.SetCurrentFolder(vcitem.Path.FullPath.ParentDirectory);

            try {
                if ((int)Gtk.ResponseType.Accept == fsd.Run() && !string.IsNullOrEmpty(fsd.Filename))
                {
                    MercurialTask worker = new MercurialTask();
                    worker.Description = string.Format("Exporting to {0}", fsd.Filename);
                    worker.Operation   = delegate { repo.Export(vcitem.Path, fsd.Filename, worker.ProgressMonitor); };
                    worker.Start();
                }
            } finally {
                fsd.Destroy();
            }
        }        // OnExport
        public ShelfManagerDialog(MercurialRepository repo)
        {
            throw new NotImplementedException ();
            /*
            this.Build ();
            stashes = repo.GetStashes ();

            store = new ListStore (typeof(Shelf), typeof(string), typeof(string));
            list.Model = store;

            list.AppendColumn (GettextCatalog.GetString ("Date/Time"), new CellRendererText (), "text", 1);
            list.AppendColumn (GettextCatalog.GetString ("Comment"), new CellRendererText (), "text", 2);
            Fill ();
            TreeIter it;
            if (store.GetIterFirst (out it))
                list.Selection.SelectIter (it);
            UpdateButtons ();

            list.Selection.Changed += delegate {
                UpdateButtons ();
            };
            */
        }
        public EditBranchDialog(MercurialRepository repo, Branch branch, bool isNew)
        {
            this.Build ();
            this.repo =  repo;

            comboStore = new ListStore (typeof(string), typeof(Gdk.Pixbuf), typeof (string));
            comboSources.Model = comboStore;
            CellRendererPixbuf crp = new CellRendererPixbuf ();
            comboSources.PackStart (crp, false);
            comboSources.AddAttribute (crp, "pixbuf", 1);
            CellRendererText crt = new CellRendererText ();
            comboSources.PackStart (crt, true);
            comboSources.AddAttribute (crt, "text", 2);

            if (branch != null) {
                if (!isNew)
                    oldName = branch.Name;
                currentTracking = branch.Tracking;
                entryName.Text = branch.Name;
                if (currentTracking != null)
                    checkTrack.Active = true;
            }

            foreach (var b in repo.GetBranches ()) {
                AddValues (b.Name, ImageService.GetPixbuf ("vc-git-branch", IconSize.Menu));
            }

            foreach (var t in repo.GetTags ())
                AddValues (t.Name, ImageService.GetPixbuf ("vc-git-tag", IconSize.Menu));

            foreach (var r in repo.GetRemotes ()) {
                foreach (string b in repo.GetRemoteBranches (r.Name))
                    AddValues (r.Name + "/" + b, ImageService.GetPixbuf ("md-web-search-icon", IconSize.Menu));
            }

            UpdateStatus ();
        }
        public static void Push(MercurialRepository 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 ();
            }
        }
 public static void ShowMergeDialog(MercurialRepository 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 ();
     }
 }
 public static void ShowConfigurationDialog(MercurialRepository repo)
 {
     var dlg = new MercurialConfigurationDialog (repo);
     MessageService.ShowCustomDialog (dlg);
 }
 public static void ShowShelfManager(MercurialRepository repo)
 {
     ShelfManagerDialog dlg = new ShelfManagerDialog (repo);
     MessageService.RunCustomDialog (dlg);
     dlg.Destroy ();
 }
 public static void SwitchToBranch(MercurialRepository repo, string branch)
 {
     MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor (true, false, false, true);
     try {
         IdeApp.Workbench.AutoReloadDocuments = true;
         IdeApp.Workbench.LockGui ();
         System.Threading.ThreadPool.QueueUserWorkItem (delegate {
             try {
                 repo.SwitchToBranch (monitor, branch);
             } catch (Exception ex) {
                 monitor.ReportError ("Branch switch failed", ex);
             } finally {
                 monitor.Dispose ();
             }
         });
         monitor.AsyncOperation.WaitForCompleted ();
     } finally {
         IdeApp.Workbench.AutoReloadDocuments = false;
         IdeApp.Workbench.UnlockGui ();
     }
 }
 internal void UnregisterRepo(MercurialRepository repo)
 {
     if (!repo.RootPath.IsNullOrEmpty)
         repositories.Remove (repo.RootPath.CanonicalPath);
 }
 public override Repository GetRepositoryReference(FilePath path, string id)
 {
     if (path.IsEmpty || path.ParentDirectory.IsEmpty || path.IsNull || path.ParentDirectory.IsNull)
         return null;
     if (System.IO.Directory.Exists (path.Combine (".hg"))) {
         MercurialRepository repo;
         if (!repositories.TryGetValue (path.CanonicalPath, out repo))
             repositories [path.CanonicalPath] = repo = new MercurialRepository (path, null);
         return repo;
     }
     else
         return GetRepositoryReference (path.ParentDirectory, id);
 }