当前位置: 首页>>代码示例>>C#>>正文


C# SvnClient.GetUriFromWorkingCopy方法代码示例

本文整理汇总了C#中SvnClient.GetUriFromWorkingCopy方法的典型用法代码示例。如果您正苦于以下问题:C# SvnClient.GetUriFromWorkingCopy方法的具体用法?C# SvnClient.GetUriFromWorkingCopy怎么用?C# SvnClient.GetUriFromWorkingCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SvnClient的用法示例。


在下文中一共展示了SvnClient.GetUriFromWorkingCopy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsWorkingCopy

 /// <summary>
 /// Check if the given path is a working copy or not
 /// </summary>
 /// <param name="path">local path to the respository</param>
 /// <returns></returns>
 public static bool IsWorkingCopy(string path)
 {
     using (var client = new SvnClient())
     {
         var uri = client.GetUriFromWorkingCopy(path);
         return uri != null;
     }
 }
开发者ID:sharat,项目名称:SvnChangeSetMaker,代码行数:13,代码来源:SvnChangeSet.cs

示例2: IsWorkingCopy

        private static bool IsWorkingCopy(String path)
        {
            if (String.IsNullOrEmpty(path))
                return false;

            using (SvnClient client = new SvnClient())
            {
                var uri = client.GetUriFromWorkingCopy(path);

                return uri != null;
            }
        }
开发者ID:crea-doo,项目名称:Subversion.Incrementor,代码行数:12,代码来源:SubversionIncrementor.cs

示例3: FileVersions_WalkKeywords

        public void FileVersions_WalkKeywords()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Empty);

            string wc = sbox.Wc;
            string file = Path.Combine(wc, "myFile.txt");
            string nl = Environment.NewLine;

            File.WriteAllText(file, "Line1 $Id: FileVersions.cs 2139 2012-05-19 10:21:53Z rhuijben $" + nl + "$HeadURL$" + nl + nl);

            Client.Add(file);
            Client.SetProperty(file, SvnPropertyNames.SvnKeywords, "Id\nHeadURL");
            Client.Commit(file);
            File.AppendAllText(file, "Line" + nl);
            Client.Commit(file);
            Client.SetProperty(file, SvnPropertyNames.SvnEolStyle, "native");
            Client.Commit(file);
            File.AppendAllText(file, "Line" + nl + "Line");
            Client.Commit(file);
            Client.SetProperty(file, SvnPropertyNames.SvnEolStyle, "CR");
            Client.Commit(file);

            string f2 = file + "2";
            Client.Copy(file, f2);
            SvnCommitArgs xa = new SvnCommitArgs();
            xa.LogProperties.Add("extra", "value");
            Client.Commit(wc, xa);
            Client.Update(wc);

            SvnFileVersionsArgs va;

            using (SvnClient c2 = new SvnClient())
            {
                Uri fileUri = c2.GetUriFromWorkingCopy(file);
                Uri f2Uri = c2.GetUriFromWorkingCopy(f2);

                for (int L = 0; L < 2; L++)
                {
                    va = new SvnFileVersionsArgs();
                    va.RetrieveProperties = true;
                    switch (L)
                    {
                        case 0:
                            va.Start = SvnRevision.Zero;
                            va.End = SvnRevision.Head;
                            break;
                        default:
                            break;
                    }

                    int i = 0;
                    Client.FileVersions(f2, va,
                        delegate(object sender, SvnFileVersionEventArgs e)
                        {
                            Assert.That(e.Revision, Is.EqualTo(i + 1L));
                            Assert.That(e.RepositoryRoot, Is.Not.Null);
                            Assert.That(e.Uri, Is.EqualTo(i == 5 ? f2Uri : fileUri));
                            Assert.That(e.Author, Is.EqualTo(Environment.UserName));
                            Assert.That(e.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 0, 10, 0, 0)));
                            Assert.That(e.RevisionProperties.Count, Is.GreaterThanOrEqualTo(3));

                            if (i == 5)
                            {
                                Assert.That(e.RevisionProperties.Contains("extra"), "Contains extra property");
                                //Assert.That(e.Properties.Contains(SvnPropertyNames.SvnMergeInfo), Is.True, "Contains merge info in revision 5");
                            }
                            else
                                Assert.That(e.Properties.Contains(SvnPropertyNames.SvnMergeInfo), Is.False, "No mergeinfo");

                            MemoryStream ms1 = new MemoryStream();
                            MemoryStream ms2 = new MemoryStream();

                            e.WriteTo(ms1);
                            c2.Write(new SvnUriTarget(e.Uri, e.Revision), ms2);

                            string s1 = Encoding.UTF8.GetString(ms1.ToArray());
                            string s2 = Encoding.UTF8.GetString(ms2.ToArray());

                            //Assert.That(ms1.Length, Is.EqualTo(ms2.Length), "Export lengths equal");
                            Assert.That(s1, Is.EqualTo(s2));
                            i++;
                        });

                    Assert.That(i, Is.EqualTo(6), "Found 6 versions");
                }
            }
        }
开发者ID:riiiqpl,项目名称:sharpsvn,代码行数:88,代码来源:FileVersionsTests.cs

示例4: Main


//.........这里部分代码省略.........
                }
                if (namespaceName != null && className != null) GenerateCode(namespaceName, className, target.Hash, outputFilename);
                if (webVersionFile != null)
                {
                    using (var writer = new StreamWriter(webVersionFile))
                    {
                        writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        writer.WriteLine("<product>");
                        if (productName != null)
                        {
                            writer.WriteLine("  <name>{0}</name>", productName);
                        }
                        if (installer32 != null)
                        {
                            writer.WriteLine("  <x86>");
                            writer.WriteLine(GenerateWebVersionXml(installer32));
                            writer.WriteLine("  </x86>");
                        }
                        if (installer64 != null)
                        {
                            writer.WriteLine("  <x64>");
                            writer.WriteLine(GenerateWebVersionXml(installer64));
                            writer.WriteLine("  </x64>");
                        }
                        writer.WriteLine("</product>");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Usage();
                return -1;
            }
#if false
            try
            {
                string svnVersionString;
                using (var client = new SvnClient())
                {
                    if (string.IsNullOrEmpty(outputFilename)) outputFilename = assemblyVersionFile;
                    SvnInfoEventArgs svnInfo;
                    client.GetInfo(new SvnUriTarget(client.GetUriFromWorkingCopy(Path.GetDirectoryName(outputFilename))), out svnInfo);
                    svnVersionString = svnInfo.Revision.ToString(CultureInfo.InvariantCulture);
                }
                if (versionFile != null)
                {
                    var inputLines = File.ReadAllLines(versionFile);
                    foreach (var inputLine in inputLines)
                    {
                        var curLine = inputLine.Trim();
                        if (string.IsNullOrEmpty(curLine) || curLine.StartsWith("//")) continue;
                        var versionFields = curLine.Split('.');
                        switch (versionFields.Length)
                        {
                            case 4:
                            case 3:
                                int major, minor, build;
                                if (!int.TryParse(versionFields[0], out major) || !int.TryParse(versionFields[1], out minor) || !int.TryParse(versionFields[2], out build) || major < 0 || minor < 0 || build < 0) throw new FormatException(string.Format("Version file not in expected format. There should be only one line that does not begin with a comment mark ('//') and that line should contain a version number template in the form 1.2.3 where 1 is the Major version number of this application, 2 is the Minor version number and 3 is the Build number.  A fourth field, taken from the Subversion revision number of the output directory, will be appended to this and used for assembly and installer version numbers later in the build process."));
                                versionNumber = string.Format("{0}.{1}.{2}.{3}", versionFields[0], versionFields[1], versionFields[2], svnVersionString);
                                break;
                            default:
                                throw new FormatException(string.Format("Version file not in expected format. There should be only one line that does not begin with a comment mark ('//') and that line should contain a version number template in the form 1.2.3 where 1 is the Major version number of this application, 2 is the Minor version number and 3 is the Build number.  A fourth field, taken from the Subversion revision number of the output directory, will be appended to this and used for assembly and installer version numbers later in the build process."));
                        }
                    }
                }
                if (assemblyVersionFile != null)
                {
                    if (versionNumber == null) throw new ApplicationException("if -assemblyversion is specified, -version must also be specified");
                    using (var writer = new StreamWriter(assemblyVersionFile))
                    {
                        writer.WriteLine("using System.Reflection;");
                        writer.WriteLine();
                        writer.WriteLine("[assembly: AssemblyVersion(\"{0}\")]", versionNumber);
                        writer.WriteLine("[assembly: AssemblyFileVersion(\"{0}\")]", versionNumber);
                    }
                }

                if (wixVersionFile != null)
                {
                    if (versionNumber == null) throw new ApplicationException("if -wixversion is specified, -version must also be specified");
                    using (var writer = new StreamWriter(wixVersionFile))
                    {
                        writer.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        writer.WriteLine("<Include>");
                        writer.WriteLine("  <?define ProductFullVersion = \"{0}\" ?>", versionNumber);
                        writer.WriteLine("</Include>");
                    }
                }
                if (namespaceName != null && className != null) GenerateCode(namespaceName, className, svnVersionString, outputFilename);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Usage();
                return -1;
            }
#endif
            return 0;
        }
开发者ID:AuditoryBiophysicsLab,项目名称:ESME-Workbench,代码行数:101,代码来源:Program.cs

示例5: ValidateWorkingCopy

 public static bool ValidateWorkingCopy(string repositoryPath)
 {
     using (var client = new SvnClient())
     {
         try
         {
             return client.GetUriFromWorkingCopy(repositoryPath) != null;
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
开发者ID:mathewng,项目名称:vss2svn,代码行数:14,代码来源:SvnWrapper.cs

示例6: VssLabel

        public void VssLabel(string name, string taggerName, string taggerEmail, string comment, DateTime localTime, string taggedPath)
        {
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);

                var codeBasePath = useSvnStandardDirStructure ? this.trunkPath : workingCopyPath;
                var relativePath = taggedPath.StartsWith(codeBasePath) ? taggedPath.Substring(codeBasePath.Length) : null;
                if (relativePath == null || client.GetUriFromWorkingCopy(taggedPath) == null)
                    throw new ArgumentException(string.Format("invalid path {0}", taggedPath));

                var fullLabelPath = Path.Combine(labelPath, name + relativePath);

                Uri repositoryRootUri = client.GetUriFromWorkingCopy(workingCopyPath);

                var codeBaseUri = client.GetUriFromWorkingCopy(codeBasePath);
                var labelBaseUri = client.GetUriFromWorkingCopy(labelPath);

                var relativeSourceUri = new Uri(taggedPath.Substring(workingCopyPath.Length), UriKind.Relative);
                relativeSourceUri = repositoryRootUri.MakeRelativeUri(new Uri(repositoryRootUri, relativeSourceUri));

                var relativeLabelUri = new Uri(fullLabelPath.Substring(workingCopyPath.Length), UriKind.Relative);
                relativeLabelUri = repositoryRootUri.MakeRelativeUri(new Uri(repositoryRootUri, relativeLabelUri));

                var sourceUri = client.GetUriFromWorkingCopy(taggedPath);
                var labelUri = new Uri(labelBaseUri, name + "/" + sourceUri.ToString().Substring(codeBaseUri.ToString().Length));

                var fullLabelPathExists = client.GetUriFromWorkingCopy(fullLabelPath) != null;

                // check intermediate parents
                var intermediateParentNames = labelUri.ToString().Substring(labelBaseUri.ToString().Length).Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Reverse().Skip(1).Reverse();
                var intermediateParentRelativeUriToCreate = new List<string>();
                {
                    var intermediatePath = labelPath;
                    var intermediateUriPath = repositoryRootUri.MakeRelativeUri(labelBaseUri).ToString();
                    foreach (var parent in intermediateParentNames)
                    {
                        intermediatePath = Path.Combine(intermediatePath, parent);
                        intermediateUriPath += parent + "/";
                        if (client.GetUriFromWorkingCopy(intermediatePath) == null)
                            intermediateParentRelativeUriToCreate.Add(intermediateUriPath.Substring(0, intermediateUriPath.Length - 1));
                    }
                }

                // perform svn copy or svn delete + svn copy if necessary
                var result = true;
                var svnCommitResult = (SvnCommitResult)null;

                client.RepositoryOperation(repositoryRootUri, new SvnRepositoryOperationArgs { LogMessage = comment }, delegate (SvnMultiCommandClient muccClient)
                {
                    // if label path already exists, delete first
                    if (fullLabelPathExists)
                        result &= muccClient.Delete(Uri.UnescapeDataString(relativeLabelUri.ToString()));

                    // create intermediate parents if necessary
                    foreach (var parentRelativeUri in intermediateParentRelativeUriToCreate)
                        result &= muccClient.CreateDirectory(Uri.UnescapeDataString(parentRelativeUri));

                    result &= muccClient.Copy(Uri.UnescapeDataString(relativeSourceUri.ToString()), Uri.UnescapeDataString(relativeLabelUri.ToString()));

                }, out svnCommitResult);

                if (result)
                {
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, taggerName);
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));
                }

                result &= client.Update(workingCopyPath, new SvnUpdateArgs { AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false });

            }
        }
开发者ID:mathewng,项目名称:vss2svn,代码行数:72,代码来源:SvnWrapper.cs

示例7: Tag

        public void Tag(string name, string taggerName, string taggerEmail, string comment, DateTime localTime, string taggedPath)
        {
            /*
            TempFile commentFile;

            var args = "tag";
            AddComment(comment, ref args, out commentFile);

            // tag names are not quoted because they cannot contain whitespace or quotes
            args += " -- " + name;

            using (commentFile)
            {
                var startInfo = GetStartInfo(args);
                startInfo.EnvironmentVariables["GIT_COMMITTER_NAME"] = taggerName;
                startInfo.EnvironmentVariables["GIT_COMMITTER_EMAIL"] = taggerEmail;
                startInfo.EnvironmentVariables["GIT_COMMITTER_DATE"] = GetUtcTimeString(localTime);

                ExecuteUnless(startInfo, null);
            }
            */
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                var svnCopyArgs = new SvnCopyArgs { LogMessage = comment, CreateParents = true, AlwaysCopyAsChild = false };

                var workingCopyUri = client.GetUriFromWorkingCopy(workingCopyPath);
                var tagsUri = client.GetUriFromWorkingCopy(tagPath);
                var sourceUri = useSvnStandardDirStructure ? client.GetUriFromWorkingCopy(trunkPath) : workingCopyUri;
                var tagUri = new Uri(useSvnStandardDirStructure ? tagsUri : workingCopyUri, name);

                var svnCommitResult = (SvnCommitResult)null;
                var result = client.RemoteCopy(sourceUri, tagUri, svnCopyArgs, out svnCommitResult);
                if (result)
                {
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, taggerName);
                    result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));
                }
                result &= client.Update(workingCopyPath, new SvnUpdateArgs { AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false });
            }
        }
开发者ID:mathewng,项目名称:vss2svn,代码行数:41,代码来源:SvnWrapper.cs

示例8: Commit

        public bool Commit(string authorName, string authorEmail, string comment, DateTime localTime)
        {
            /*
            TempFile commentFile;

            var args = "commit";
            AddComment(comment, ref args, out commentFile);

            using (commentFile)
            {
                var startInfo = GetStartInfo(args);
                startInfo.EnvironmentVariables["GIT_AUTHOR_NAME"] = authorName;
                startInfo.EnvironmentVariables["GIT_AUTHOR_EMAIL"] = authorEmail;
                startInfo.EnvironmentVariables["GIT_AUTHOR_DATE"] = GetUtcTimeString(localTime);

                // also setting the committer is supposedly useful for converting to Mercurial
                startInfo.EnvironmentVariables["GIT_COMMITTER_NAME"] = authorName;
                startInfo.EnvironmentVariables["GIT_COMMITTER_EMAIL"] = authorEmail;
                startInfo.EnvironmentVariables["GIT_COMMITTER_DATE"] = GetUtcTimeString(localTime);

                // ignore empty commits, since they are non-trivial to detect
                // (e.g. when renaming a directory)
                return ExecuteUnless(startInfo, "nothing to commit");
            }
            */
            if (string.IsNullOrEmpty(authorName))
            {
                return false;
            }
            using (var client = new SvnClient())
            {
                SvnUI.Bind(client, parentWindow);
                var svnCommitArgs = new SvnCommitArgs { LogMessage = comment };

                var svnCommitResult = (SvnCommitResult)null;
                var result = client.Commit(useSvnStandardDirStructure ? trunkPath : workingCopyPath, svnCommitArgs, out svnCommitResult);
                // commit without files results in result=true and svnCommitResult=null
                if (svnCommitResult != null)
                {
                    if (result)
                    {

                        var workingCopyUri = client.GetUriFromWorkingCopy(useSvnStandardDirStructure ? trunkPath : workingCopyPath);

                        result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, authorName);
                        result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime));

                        result &= client.Update(workingCopyPath, new SvnUpdateArgs { AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false });
                    }
                    else
                    {
                        MessageBox.Show(string.Format("{0} Error Code: {1}{2}", svnCommitResult.PostCommitError, "", Environment.NewLine), "SVN Commit Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                return result;
            }
            return false;
        }
开发者ID:mathewng,项目名称:vss2svn,代码行数:58,代码来源:SvnWrapper.cs

示例9: doSvnUpdate

        /// <summary>
        /// While the server isn't up to date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void doSvnUpdate(object sender, DoWorkEventArgs e)
        {
            client = new SvnClient();
            client.Notify += onSvnNotify;
            client.Authentication.Clear();
            client.Authentication.DefaultCredentials = null;

            System.Console.Out.WriteLine(client.GetUriFromWorkingCopy(System.IO.Directory.GetCurrentDirectory()));

            Uri rep = client.GetUriFromWorkingCopy(System.IO.Directory.GetCurrentDirectory());
            Uri rel = new Uri("http://subversion.assembla.com/svn/skyrimonlineupdate/");

            if (rep == null || rep != rel)
            {
                SvnDelete.findSvnDirectories(System.IO.Directory.GetCurrentDirectory());
                exploreDirectory(rel);

                download.Maximum = iCount;
                updating = true;

                SvnCheckOutArgs args = new SvnCheckOutArgs();
                args.AllowObstructions = true;

                if (client.CheckOut(rel, System.IO.Directory.GetCurrentDirectory(), args, out mResult))
                {
                    updated = true;
                }

            }
            else
            {
                downloadprogress.Text = "Building update list, please be patient...";

                updating = true;
                SvnStatusArgs sa = new SvnStatusArgs();
                sa.RetrieveRemoteStatus = true;

                Collection<SvnStatusEventArgs> r;
                client.GetStatus(System.IO.Directory.GetCurrentDirectory(), sa, out r);

                foreach (SvnStatusEventArgs i in r)
                {
                    client.Revert(i.FullPath);

                    if (i.IsRemoteUpdated)
                        iCount++;
                }

                download.Maximum = iCount;
                SvnUpdateArgs args = new SvnUpdateArgs();
                args.AllowObstructions = true;

                if (client.Update(System.IO.Directory.GetCurrentDirectory(), args))
                {
                    updated = true;
                }
                else
                {
                    Application.Exit();
                }
            }
        }
开发者ID:commodoremartin,项目名称:SkyrimOnline,代码行数:67,代码来源:Panel.cs


注:本文中的SvnClient.GetUriFromWorkingCopy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。