示例#1
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);
        }
        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();
            }
        }
        }        // 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
示例#4
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);
        }
        }        // Update

        public bool IsVersioned(string localPath)
        {
            return((string.Empty != BazaarRepository.GetLocalBasePath(localPath)) && Client.IsVersioned(localPath));
        }