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();
            }
        }
        protected override void Run()
        {
            var bsd = new BranchSelectionDialog(new List <string>(), string.Empty, Environment.GetFolderPath(Environment.SpecialFolder.Personal), true, false, false, false);

            try
            {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    string branchLocation = bsd.SelectedLocation,
                           branchName     = GetLastChunk(branchLocation),
                           localPath      = Path.Combine(bsd.LocalPath, (string.Empty == branchName) ? "branch" : branchName);
                    BazaarTask worker     = new BazaarTask();
                    worker.Description = string.Format("Branching from {0} to {1}", branchLocation, localPath);
                    worker.Operation   = delegate
                    {
                        DoBranch(branchLocation, localPath, worker.ProgressMonitor);
                    };
                    worker.Start();
                }
            }
            finally
            {
                bsd.Destroy();
            }
        }
        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();
            }
        }
        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();
        }
        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
        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();
            }
        }
        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();
            }
        }
Ejemplo n.º 8
0
 protected override void Run()
 {
     var bsd = new BranchSelectionDialog(new List<string>(), string.Empty, Environment.GetFolderPath(Environment.SpecialFolder.Personal), true, false, false, false);
     try
     {
         if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
         {
             string branchLocation = bsd.SelectedLocation,
             branchName = GetLastChunk(branchLocation),
             localPath = Path.Combine(bsd.LocalPath, (string.Empty == branchName) ? "branch" : branchName);
             BazaarTask worker = new BazaarTask();
             worker.Description = string.Format("Branching from {0} to {1}", branchLocation, localPath);
             worker.Operation = delegate
             {
                 DoBranch(branchLocation, localPath, worker.ProgressMonitor);
             };
             worker.Start();
         }
     }
     finally
     {
         bsd.Destroy();
     }
 }
        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();
        }
        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();
            }
        }
        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();
            }
        }
        protected void OnMerge()
        {
            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)))
            {
                var md = new MessageDialog(null, DialogFlags.Modal,
                             MessageType.Question, ButtonsType.YesNo,
                             GettextCatalog.GetString("You have uncommitted local changes. Merge 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, false, false);
            try
            {
                if ((int)Gtk.ResponseType.Ok == bsd.Run() && !string.IsNullOrEmpty(bsd.SelectedLocation))
                {
                    BazaarTask worker = new BazaarTask();
                    worker.Description = string.Format("Merging from {0}", bsd.SelectedLocation);
                    worker.Operation = delegate
                    {
                        repo.Merge(bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, true, worker.ProgressMonitor);
                    };
                    worker.Start();
                }
            }
            finally
            {
                bsd.Destroy();
            }
        }
        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 ();
            }
        }
        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();
            }
        }