コード例 #1
0
        protected void OnBind()
        {
            VersionControlItem vcitem      = GetItems()[0];
            BazaarRepository   repo        = (BazaarRepository)vcitem.Repository;
            string             boundBranch = repo.GetBoundBranch(vcitem.Path);

            var bsd = new BranchSelectionDialog(new string[] { boundBranch }, boundBranch, vcitem.Path.FullPath, false, false, false, false);

            try
            {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    BazaarTask worker = new BazaarTask();
                    worker.Description = string.Format("Binding to {0}", bsd.SelectedLocation);
                    worker.Operation   = delegate
                    {
                        repo.Bind(bsd.SelectedLocation, vcitem.Path, worker.ProgressMonitor);
                    };
                    worker.Start();
                }
            }
            finally
            {
                bsd.Destroy();
            }
        }
コード例 #2
0
        protected override void OnRevertRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
        {
            if (IsModified(BazaarRepository.GetLocalBasePath(localPath)))
            {
                MessageDialog md = new MessageDialog(null, 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();
                }
            }

            BazaarRevision brev         = (BazaarRevision)revision;
            string         localPathStr = localPath.FullPath;

            Bazaar.Merge(localPathStr, localPathStr, false, true, brev, (BazaarRevision)(brev.GetPrevious()), monitor);
        }
コード例 #3
0
        protected void OnInit()
        {
            BazaarVersionControl bvc    = null;
            BazaarRepository     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 BazaarVersionControl)
                {
                    bvc = (BazaarVersionControl)vcs;
                }
            }

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

            bvc.Init(path);

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

            repo.Add(addFiles.ToArray(), false, null);
            solution.NeedsReload = true;
        }
コード例 #4
0
        protected void OnBzrPublish()
        {
            VersionControlItem vcitem = GetItems()[0];
            BazaarRepository   repo   = ((BazaarRepository)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(BazaarRepository.GetLocalBasePath(vcitem.Path.FullPath)))
            {
                MessageDialog md = new MessageDialog(null, 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

            var bsd = new BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, true, true, true);

            try
            {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    BazaarTask worker = new BazaarTask();
                    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();
            }
        }
コード例 #5
0
        protected void OnUncommit()
        {
            VersionControlItem vcitem = GetItems()[0];
            BazaarRepository   repo   = (BazaarRepository)vcitem.Repository;

            BazaarTask worker = new BazaarTask();

            worker.Description = string.Format("Uncommitting {0}", vcitem.Path);
            worker.Operation   = delegate
            {
                repo.Uncommit(vcitem.Path, worker.ProgressMonitor);
            };
            worker.Start();
        }
コード例 #6
0
        }        // ConvertStatus

        public override Repository GetRepositoryReference(FilePath path, string id)
        {
            // System.Console.WriteLine ("Requested repository reference for {0}", path);
            try {
                if (string.IsNullOrEmpty(BazaarRepository.GetLocalBasePath(path.FullPath)))
                {
                    return(null);
                }
                string url = Client.GetPathUrl(path.FullPath);
                // System.Console.WriteLine ("Got {0} for {1}", url, path);
                return(new BazaarRepository(this, url));
            } catch (Exception ex) {
                // No bzr
                LoggingService.LogError(ex.ToString());
                return(null);
            }
        }        // GetRepositoryReference
コード例 #7
0
        protected void OnResolve()
        {
            List <FilePath>  files = null;
            BazaarRepository repo  = null;

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

                BazaarTask worker = new BazaarTask();
                worker.Description = string.Format("Resolving {0}", files[0]);
                worker.Operation   = delegate
                {
                    repo.Resolve(files.ToArray(), true, worker.ProgressMonitor);
                };
                worker.Start();
            }
        }
コード例 #8
0
        protected void OnExport()
        {
            VersionControlItem vcitem = GetItems()[0];
            BazaarRepository   repo   = ((BazaarRepository)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))
                {
                    BazaarTask worker = new BazaarTask();
                    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
コード例 #9
0
        protected void OnPull()
        {
            VersionControlItem vcitem = GetItems()[0];
            BazaarRepository   repo   = ((BazaarRepository)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

            var bsd = new BranchSelectionDialog(branches.Keys, defaultBranch, localPath, false, true, true, false);

            try
            {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    BazaarTask worker = new BazaarTask();
                    worker.Description = string.Format("Pulling from {0}", bsd.SelectedLocation);
                    worker.Operation   = delegate
                    {
                        repo.Pull(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, worker.ProgressMonitor);
                    };
                    worker.Start();
                }
            }
            finally
            {
                bsd.Destroy();
            }
        }
コード例 #10
0
        protected override void OnRevertToRevision(FilePath localPath, Revision revision, IProgressMonitor monitor)
        {
            if (IsModified(BazaarRepository.GetLocalBasePath(localPath)))
            {
                MessageDialog md = new MessageDialog(null, 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();
                }
            }

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

            Bazaar.Revert(localPath.FullPath, true, monitor, brev);
        }
コード例 #11
0
        protected void OnInit()
        {
            BazaarVersionControl bvc = null;
            BazaarRepository 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 BazaarVersionControl)
                    bvc = (BazaarVersionControl)vcs;

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

            bvc.Init(path);

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

            repo.Add(addFiles.ToArray(), false, null);
            solution.NeedsReload = true;
        }
コード例 #12
0
        }        // GetTextAtRevision

        public Revision[] GetHistory(BazaarRepository repo, string localFile, Revision since)
        {
            BazaarRevision brev = (null == since)? new BazaarRevision(repo, BazaarRevision.FIRST): (BazaarRevision)since;

            return(Client.GetHistory(repo, localFile, brev));
        }        // GetHistory
コード例 #13
0
 public abstract BazaarRevision[] GetHistory(BazaarRepository repo, string localFile, BazaarRevision since);
コード例 #14
0
 public abstract BazaarRevision[] GetHistory(BazaarRepository repo, string localFile, BazaarRevision since);
コード例 #15
0
        public override BazaarRevision[] GetHistory(BazaarRepository repo, string localFile, BazaarRevision since)
        {
            localFile = NormalizePath(Path.GetFullPath(localFile));
            List<BazaarRevision> history = new List<BazaarRevision>();
            string basePath = BazaarRepository.GetLocalBasePath(localFile);

            string output = null;
            string revString = "None";

            if (null != since && BazaarRevision.FIRST != since.Rev && BazaarRevision.NONE != since.Rev)
            {
                revString = string.Format("'{0}..'", since.Rev);
            }

            StringBuilder command = new StringBuilder();
            command.AppendFormat("mycmd = builtins.cmd_log()\n");
            command.AppendFormat("mycmd.outf = StringIO.StringIO()\n");
            command.AppendFormat("try:\n");
            command.AppendFormat(string.Format("  mycmd.run(file_list=[ur'{0}'],revision={1},log_format=log.log_formatter_registry.get('line'),include_merges=True)\n",
                    localFile, revString));

            command.AppendFormat("  output = mycmd.outf.getvalue()\n");
            command.AppendFormat("finally:\n");
            command.AppendFormat("  mycmd.outf.close()\n");

            lock (lockme)
            {
                output = StringFromPython(run(new List<string>{ "output" }, command.ToString())[0]);
            }

            Match match = null;
            foreach (string line in output.Split (new char[]{'\r','\n'}, StringSplitOptions.RemoveEmptyEntries))
            {
                match = revisionRegex.Match(line);
                if (null != match && match.Success)
                {
                    DateTime date;
                    DateTime.TryParse(match.Groups["date"].Value, out date);
                    history.Add(new BazaarRevision(repo, match.Groups["revision"].Value, date,
                            match.Groups["committer"].Value, match.Groups["message"].Value,
                            new RevisionPath[]{ }));
                }
            }

            ThreadPool.QueueUserWorkItem(delegate
                {
                    foreach (BazaarRevision rev in history)
                    {
                        Thread.Sleep(0);
                        List<RevisionPath> paths = new List<RevisionPath>();
                        foreach (LocalStatus status in Status (basePath, rev))
                        {
                            paths.Add(new RevisionPath(status.Filename, ConvertAction(status.Status), status.Status.ToString()));
                        }
                        rev.ChangedFiles = paths.ToArray();
                    }
                });

            return history.ToArray();
        }
コード例 #16
0
        }        // Update

        public bool IsVersioned(string localPath)
        {
            return((string.Empty != BazaarRepository.GetLocalBasePath(localPath)) && Client.IsVersioned(localPath));
        }
コード例 #17
0
 public Revision[] GetHistory(BazaarRepository repo, string localFile, Revision since)
 {
     BazaarRevision brev = (null == since)? new BazaarRevision (repo, BazaarRevision.FIRST): (BazaarRevision)since;
     return Client.GetHistory (repo, localFile, brev);
 }