Exemplo n.º 1
0
        protected override void OnCheckout(FilePath targetLocalPath, Revision rev, bool recurse, IProgressMonitor monitor)
        {
            Bazaar.StoreCredentials(Url);
            BazaarRevision brev = (null == rev) ? new BazaarRevision(this, BazaarRevision.HEAD) : (BazaarRevision)rev;

            Bazaar.Checkout(Url, targetLocalPath.FullPath, brev, recurse, monitor);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public abstract BazaarRevision[] GetHistory(BazaarRepository repo, string localFile, BazaarRevision since);
 public abstract void Merge(string mergeLocation, string localPath, bool remember, bool overwrite, BazaarRevision start, BazaarRevision end, IProgressMonitor monitor);
 public abstract string GetTextAtRevision(string path, BazaarRevision rev);
 public abstract void Revert(string localPath, bool recurse, IProgressMonitor monitor, BazaarRevision toRevision);
 public void Checkout(string url, string targetLocalPath, BazaarRevision rev, bool recurse, IProgressMonitor monitor)
 {
     Client.Checkout (url, targetLocalPath, rev, recurse, monitor);
 }
 public void Revert(string localPath, bool recurse, IProgressMonitor monitor, BazaarRevision toRevision)
 {
     Client.Revert (localPath, recurse, monitor, toRevision);
 }
 public string GetTextAtRevision(string path, BazaarRevision revision)
 {
     return Client.GetTextAtRevision (path, revision);
 }
Exemplo n.º 11
0
        public override System.Collections.Generic.IList<LocalStatus> Status(string path, BazaarRevision revision)
        {
            StringBuilder command = new StringBuilder();
            List<LocalStatus> statuses = new List<LocalStatus>();
            LocalStatus mystatus = null;
            string rev = string.Empty;
            bool modified = false;
            IntPtr tuple = IntPtr.Zero,
            listlen = IntPtr.Zero;

            path = NormalizePath(Path.GetFullPath(path).Replace("{", "{{").Replace("}", "}}"));// escape for string.format
            command.AppendFormat("tree,relpath = workingtree.WorkingTree.open_containing(path=ur\"{0}\")\n", path);

            if (null == revision || BazaarRevision.HEAD == revision.Rev || BazaarRevision.NONE == revision.Rev)
            {
                command.AppendFormat("rev = tree.basis_tree()\n");
                command.AppendFormat("totree = tree\n");
                rev = BazaarRevision.HEAD;
            }
            else
            {
                command.AppendFormat("revspec = revisionspec.RevisionSpec.from_string(spec=\"{0}\")\n", ((BazaarRevision)revision.GetPrevious()).Rev);
                command.AppendFormat("rev = tree.branch.repository.revision_tree(revision_id=revspec.in_history(branch=tree.branch).rev_id)\n");
                command.AppendFormat("revspec = revisionspec.RevisionSpec.from_string(spec=\"{0}\")\n", revision.Rev);
                command.AppendFormat("totree = tree.branch.repository.revision_tree(revision_id=revspec.in_history(branch=tree.branch).rev_id)\n");
                rev = revision.Rev;
            }
            command.AppendFormat("status = totree.changes_from(other=rev, specific_files=[relpath])\n");

            lock (lockme)
            {
                run(null, command.ToString());

                string[] types = new string[]{ "added", "removed", "modified", "unversioned" };
                string filename;

                foreach (string modtype in types)
                {
                    try
                    {
                        listlen = run(new List<string>{ "mylen" },
                            "mylist = status.{0}\nmylen = len(mylist)\n", modtype)[0];
                        int listlength = PyInt_AsLong(listlen);
                        for (int i = 0; i < listlength; ++i)
                        {
                            tuple = run(new List<string>{ "astatus" }, "astatus = tree.abspath(filename=mylist[{0}][0])", i)[0];
                            filename = StringFromPython(tuple);
                            if (Platform.IsWindows)
                            {
                                filename = filename.Replace("/", "\\");
                            }
                            LocalStatus status = new LocalStatus(rev, filename, longStatuses[modtype]);
                            if (path.Equals(filename, StringComparison.Ordinal))
                            {
                                mystatus = status;
                            }
                            if (filename.StartsWith(path, StringComparison.Ordinal))
                            {
                                modified = (!"unversioned".Equals(modtype, StringComparison.Ordinal));
                                statuses.Add(status);
                            }
                        }// get each file status
                    }
                    finally
                    {
                        Py_DecRef(listlen);
                    }
                }

                command = new StringBuilder();
                command.Append("myconflicts = \"\"\n");
                command.Append("for conflict in totree.conflicts():\n");
                command.Append("  myconflicts = myconflicts + totree.abspath (filename=conflict.path) + \"|\"\n");

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

                foreach (string conflict in conflicts.Split ('|'))
                {
                    if (!string.IsNullOrEmpty(conflict))
                    {
                        bool matched = false;
                        if (path.Equals(conflict, StringComparison.Ordinal))
                        {
                            if (null == mystatus)
                            {
                                statuses.Insert(0, mystatus = new LocalStatus(rev, path, ItemStatus.Conflicted));
                            }
                            else
                            {
                                mystatus.Status = ItemStatus.Conflicted;
                            }
                        }
                        else if (Path.GetFullPath(conflict).StartsWith(path, StringComparison.Ordinal))
                        {
                            foreach (LocalStatus status in statuses)
                            {
                                if (conflict.EndsWith(status.Filename, StringComparison.Ordinal))
                                {
                                    status.Status = ItemStatus.Conflicted;
                                    matched = true;
                                    break;
                                }
                            }// Check existing statuses
                            if (!matched)
                            {
                                statuses.Add(new LocalStatus(rev, conflict, ItemStatus.Conflicted));
                            }// Add new status if not found
                        }// Child file is conflicted
                    }// If conflict is valid path
                }// Check each conflict
            }// lock

            if (null == mystatus)
            {
                statuses.Insert(0, new LocalStatus("-1", path, modified ? ItemStatus.Modified : ItemStatus.Unchanged));
            }// path isn't in modified list

            return statuses;
        }
Exemplo n.º 12
0
 public abstract void Checkout(string url, string targetLocalPath, BazaarRevision rev, bool recurse, IProgressMonitor monitor);
Exemplo n.º 13
0
 public abstract DiffInfo[] Diff(string path, BazaarRevision fromRevision, BazaarRevision toRevision);
        }        // Diff

        public DiffInfo[] Diff(string path, BazaarRevision fromRevision, BazaarRevision toRevision)
        {
            return(Client.Diff(path, fromRevision, toRevision));
        }        // Diff
        }        // GetHistory

        public void Merge(string mergeLocation, string localPath, bool remember, bool overwrite, BazaarRevision start, BazaarRevision end, IProgressMonitor monitor)
        {
            Client.Merge(mergeLocation, localPath, remember, overwrite, start, end, monitor);
        }        // Merge
        }        // 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
        }        // Branch

        public string GetTextAtRevision(string path, BazaarRevision revision)
        {
            return(Client.GetTextAtRevision(path, revision));
        }        // GetTextAtRevision
        }        // Add

        public void Checkout(string url, string targetLocalPath, BazaarRevision rev, bool recurse, IProgressMonitor monitor)
        {
            Client.Checkout(url, targetLocalPath, rev, recurse, monitor);
        }        // Checkout
        }        // Status

        public void Revert(string localPath, bool recurse, IProgressMonitor monitor, BazaarRevision toRevision)
        {
            Client.Revert(localPath, recurse, monitor, toRevision);
        }        // Revert
Exemplo n.º 20
0
 public abstract string GetTextAtRevision(string path, BazaarRevision rev);
 public DiffInfo[] Diff(string path, BazaarRevision fromRevision, BazaarRevision toRevision)
 {
     return Client.Diff (path, fromRevision, toRevision);
 }
Exemplo n.º 22
0
 public abstract void Merge(string mergeLocation, string localPath, bool remember, bool overwrite, BazaarRevision start, BazaarRevision end, IProgressMonitor monitor);
 public void Merge(string mergeLocation, string localPath, bool remember, bool overwrite, BazaarRevision start, BazaarRevision end, IProgressMonitor monitor)
 {
     Client.Merge (mergeLocation, localPath, remember, overwrite, start, end, monitor);
 }
Exemplo n.º 24
0
 public abstract void Revert(string localPath, bool recurse, IProgressMonitor monitor, BazaarRevision toRevision);
 public IList<LocalStatus> Status(string localPath, BazaarRevision revision)
 {
     return Client.Status (localPath, null);
 }
Exemplo n.º 26
0
 public abstract IList<LocalStatus> Status(string path, BazaarRevision revision);
 public abstract IList <LocalStatus> Status(string path, BazaarRevision revision);
Exemplo n.º 28
0
        public override void Checkout(string url, string targetLocalPath, BazaarRevision rev, bool recurse, MonoDevelop.Core.IProgressMonitor monitor)
        {
            if (null == monitor)
            {
                monitor = new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor();
            }
            string pyrev = "None";
            string realUrl = url;
            StringBuilder command = new StringBuilder();

            Match match = UrlRegex.Match(url);
            if (match.Success)
            {
                realUrl = UrlRegex.Replace(url, @"${protocol}://${host}$3${path}");
            }

            lock (lockme)
            {
                run(null, "b = branch.Branch.open_containing(url=ur\"{0}\")[0]\n", realUrl);
            }

            monitor.Log.WriteLine("Opened {0}", url);

            if (null != rev && BazaarRevision.HEAD != rev.Rev && BazaarRevision.NONE != rev.Rev)
            {
                command.AppendFormat("revspec = revisionspec.RevisionSpec.from_string(spec=\"{0}\")\n", rev.Rev);
                pyrev = "revspec.in_history(branch=b).rev_id";
            }
            command.AppendFormat("b.create_checkout(to_location=ur\"{1}\", revision_id={0})\n", pyrev, NormalizePath(targetLocalPath));

            lock (lockme)
            {
                run(null, command.ToString());
            }
            monitor.Log.WriteLine("Checkout to {0} completed", targetLocalPath);
        }
 public abstract void Checkout(string url, string targetLocalPath, BazaarRevision rev, bool recurse, IProgressMonitor monitor);
Exemplo n.º 30
0
        public override DiffInfo[] Diff(string path, BazaarRevision fromRevision, BazaarRevision toRevision)
        {
            List<DiffInfo> results = new List<DiffInfo>();
            path = NormalizePath(Path.GetFullPath(path));
            StringBuilder command = new StringBuilder();

            command.AppendFormat("outfile = StringIO.StringIO()\n");
            command.AppendFormat("old_tree = None\n");
            command.AppendFormat("new_tree = None\n");
            command.AppendFormat("try:\n");
            command.AppendFormat("  old_tree,new_tree,old_branch,new_branch,specific_files,extra_trees = diff.get_trees_and_branches_to_diff(path_list=None, revision_specs=[revisionspec.RevisionSpec.from_string(ur\"{0}\"), revisionspec.RevisionSpec.from_string(ur\"{1}\")], old_url=ur\"{2}\", new_url=ur\"{2}\")\n",
                fromRevision, toRevision, path);
            command.AppendFormat("  mydiff = bzrlib.diff.DiffTree(old_tree=old_tree, new_tree=new_tree, to_file=outfile)\n");
            command.AppendFormat("  old_tree.lock_read()\n");
            command.AppendFormat("  new_tree.lock_read()\n");
            command.AppendFormat("  mydiff.show_diff(specific_files=specific_files, extra_trees=extra_trees)\n");
            command.AppendFormat("  output = outfile.getvalue()\n");
            command.AppendFormat("finally:\n");
            command.AppendFormat("  outfile.close()\n");
            command.AppendFormat("  if(old_tree): old_tree.unlock()\n");
            command.AppendFormat("  if(new_tree): new_tree.unlock()\n");

            lock (lockme)
            {
                string output = StringFromPython(run(new List<string>{ "output" }, command.ToString())[0]);
                results.Add(new DiffInfo(Path.GetDirectoryName(path), Path.GetFileName(path),
                        output.Replace("\r\n", Environment.NewLine)));
            }

            return results.ToArray();
        }
 public abstract BazaarRevision[] GetHistory(BazaarRepository repo, string localFile, BazaarRevision since);
Exemplo n.º 32
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();
        }
 public abstract DiffInfo[] Diff(string path, BazaarRevision fromRevision, BazaarRevision toRevision);
Exemplo n.º 34
0
        public override string GetTextAtRevision(string path, BazaarRevision rev)
        {
            StringBuilder command = new StringBuilder();
            IntPtr text = IntPtr.Zero;
            command.AppendFormat("revspec = revisionspec.RevisionSpec.from_string(spec=\"{0}\")\n", rev.Rev);
            command.AppendFormat("b,relpath = branch.Branch.open_containing(url=ur\"{0}\")\n", NormalizePath(path));
            command.AppendFormat("rev_tree = b.repository.revision_tree(revision_id=revspec.in_history(branch=b).rev_id)\n");
            command.AppendFormat("rev_tree.lock_read()\n");
            command.AppendFormat("try:\n");
            command.AppendFormat("  diff = rev_tree.get_file_text(file_id=rev_tree.path2id(path=relpath))\n");
            command.AppendFormat("finally:\n");
            command.AppendFormat("  rev_tree.unlock()\n");

            lock (lockme)
            {
                text = run(new List<string>{ "diff" }, command.ToString())[0];
                return StringFromPython(text);
            }// lock
        }
Exemplo n.º 35
0
        // List
        public override void Merge(string mergeLocation, string localPath, bool remember, bool overwrite, BazaarRevision start, BazaarRevision end, MonoDevelop.Core.IProgressMonitor monitor)
        {
            localPath = NormalizePath(Path.GetFullPath(localPath));
            if (null == monitor)
            {
                monitor = new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor();
            }

            string revisionSpec = string.Empty;
            string output = string.Empty;

            if (null != start && BazaarRevision.FIRST != start.Rev && BazaarRevision.NONE != start.Rev)
            {
                string endrev = "-1";
                if (null != end && BazaarRevision.HEAD != end.Rev && BazaarRevision.NONE != end.Rev)
                {
                    endrev = end.Rev;
                }
                revisionSpec = string.Format("'{0}..{1}'", start.Rev, endrev);
            }
            else if (null != end && BazaarRevision.HEAD != end.Rev && BazaarRevision.NONE != end.Rev)
            {
                revisionSpec = string.Format("'1..{0}'", end.Rev);
            }// build revisionspec string

            StringBuilder command = new StringBuilder();
            command.AppendFormat("mycmd = builtins.cmd_merge()\n");
            command.AppendFormat("mycmd.outf = StringIO.StringIO()\n");
            command.AppendFormat("try:\n");
            command.AppendFormat(string.Format("  mycmd.run(location=ur'{0}',revision={1},force={4},remember={2},directory=ur'{3}')\n",
                    mergeLocation, string.IsNullOrEmpty(revisionSpec) ? "None" : revisionSpec,
                    remember ? "True" : "False", localPath, overwrite ? "True" : "False"));

            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]);
            }

            monitor.Log.WriteLine(output);

            monitor.Log.WriteLine("Merged to {0}", localPath);
        }
Exemplo n.º 36
0
        public override void Revert(string localPath, bool recurse, MonoDevelop.Core.IProgressMonitor monitor, BazaarRevision toRevision)
        {
            localPath = NormalizePath(Path.GetFullPath(localPath));

            StringBuilder command = new StringBuilder();
            command.AppendFormat("tree = workingtree.WorkingTree.open_containing(path=ur\"{0}\")[0]\n", localPath);
            if (null == toRevision || BazaarRevision.HEAD == toRevision.Rev || BazaarRevision.NONE == toRevision.Rev)
            {
                command.AppendFormat("rev = None\n");
            }
            else
            {
                command.AppendFormat("revspec = revisionspec.RevisionSpec.from_string(spec=\"{0}\")\n", toRevision.Rev);
                command.AppendFormat("b,relpath = branch.Branch.open_containing(url=ur\"{0}\")\n", localPath);
                command.AppendFormat("rev = b.repository.revision_tree(revision_id=revspec.in_history(branch=b).rev_id)\n");
            }
            command.AppendFormat("tree.lock_tree_write()\n");
            command.AppendFormat("try:\n  tree.revert(filenames=[tree.relpath(ur\"{0}\")], old_tree=rev)\n", localPath);
            command.AppendFormat("finally:\n  tree.unlock()\n");
            lock (lockme)
            {
                run(null, command.ToString());
            }
        }
Exemplo n.º 37
0
        protected override string OnGetTextAtRevision(FilePath repositoryPath, Revision revision)
        {
            BazaarRevision brev = (null == revision) ? new BazaarRevision(this, BazaarRevision.HEAD) : (BazaarRevision)revision;

            return(Bazaar.GetTextAtRevision(repositoryPath.FullPath, brev));
        }
 public IList <LocalStatus> Status(string localPath, BazaarRevision revision)
 {
     return(Client.Status(localPath, null));
 }        // Status