Exemple #1
0
        private async Task LoadRevisions(string path)
        {
            Revisions = new List <Revision>();
            SvnTarget target;

            if (path.Contains("://"))
            {
                target = new SvnUriTarget(path);
            }
            else
            {
                target = new SvnPathTarget(path);
            }
            var svnFileVersionsArgs = new SvnFileVersionsArgs {
                Start = SvnRevision.Zero, End = SvnRevision.Head
            };

            svnClient.FileVersions(target, svnFileVersionsArgs, (sender, args) =>
            {
                var revision = new Revision
                {
                    Author       = args.Author,
                    Message      = args.LogMessage,
                    RevisionId   = args.Revision.ToString(CultureInfo.InvariantCulture),
                    RevisionTime = args.Time,
                };

                using (TextReader reader = new StreamReader(args.GetContentStream()))
                {
                    revision.Content = reader.ReadToEnd();
                }

                Revisions.Insert(0, revision); // Put them in newest-to-oldest order
            });
        }
Exemple #2
0
    static void Main(string[] args)
    {
        Uri uri = null;

        if (args.Length < 2 ||
            !Uri.TryCreate(args[0], UriKind.Absolute, out uri))
        {
            Console.Error.WriteLine("Usage: SvnDumpFileToRepository URL PATH");
        }
        using (SvnRepositoryClient repos = new SvnRepositoryClient())
        {
            repos.CreateRepository(args[1]);
        }
        Uri reposUri = SvnTools.LocalPathToUri(args[1], true);

        using (SvnClient client = new SvnClient())
            using (SvnClient client2 = new SvnClient())
            {
                SvnUI.Bind(client, new SvnUIBindArgs());
                string fileName = SvnTools.GetFileName(uri);
                bool   create   = true;
                client.FileVersions(uri,
                                    delegate(object sender, SvnFileVersionEventArgs e)
                {
                    Console.Write("Copying {0} in r{1}", fileName, e.Revision);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        e.WriteTo(ms);     // Write full text to memory stream
                        ms.Position = 0;
                        // And now use 'svnmucc' to update repository
                        client2.RepositoryOperation(reposUri,
                                                    new SvnRepositoryOperationArgs {
                            LogMessage = e.LogMessage
                        },
                                                    delegate(SvnMultiCommandClient mucc)
                        {
                            if (create)
                            {
                                mucc.CreateFile(fileName, ms);
                                create = false;
                            }
                            else
                            {
                                mucc.UpdateFile(fileName, ms);
                            }
                        });
                    }
                });
            }
    }
        public void  GetFile()
        {
            using (SvnClient client = new SvnClient())
            {
                Uri       fileUri = new Uri(@"svn://technix01/directory/trunk/Dev/WebSite/Studio/Courses/Items/Modules/Edit.ascx.cs");
                SvnTarget target  = SvnTarget.FromUri(fileUri);

                client.FileVersions(target,
                                    new SvnFileVersionsArgs()
                {
                    Start = new SvnRevision(30078),
                    //Start = new SvnRevision(30078),
                    //End = new SvnRevision(30078),
                    RetrieveContents = true,
                },
                                    versionHandler);
            }
        }