本文整理汇总了C#中SvnClient.Write方法的典型用法代码示例。如果您正苦于以下问题:C# SvnClient.Write方法的具体用法?C# SvnClient.Write怎么用?C# SvnClient.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SvnClient
的用法示例。
在下文中一共展示了SvnClient.Write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFileVersion
private static byte[] ReadFileVersion(SvnClient svnClient, string uriString, long revision)
{
using (var versionStream = new MemoryStream())
{
var versionTarget = new SvnUriTarget(uriString, revision);
svnClient.Write(versionTarget, versionStream);
return versionStream.ToArray();
}
}
示例2: RepositoryOperation_SetupRepository
public void RepositoryOperation_SetupRepository()
{
SvnSandBox sbox = new SvnSandBox(this);
Uri uri = sbox.CreateRepository(SandBoxRepository.Empty);
SvnCommitResult cr;
SvnRepositoryOperationArgs oa = new SvnRepositoryOperationArgs();
oa.LogMessage = "Everything in one revision";
using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, oa))
{
mucc.CreateDirectory("trunk");
mucc.CreateDirectory("branches");
mucc.CreateDirectory("tags");
mucc.CreateDirectory("trunk/src");
mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
mucc.SetProperty("", "svn:global-ignores", "bin obj");
mucc.CreateFile("trunk/README", new MemoryStream(Encoding.UTF8.GetBytes("Welcome to this project")));
mucc.SetProperty("trunk/README", "svn:eol-style", "native");
Assert.That(mucc.Commit(out cr)); // Commit r1
Assert.That(cr, Is.Not.Null);
}
using (SvnClient svn = new SvnClient())
{
Collection<SvnListEventArgs> members;
svn.GetList(uri, out members);
Assert.That(members, Is.Not.Empty);
MemoryStream ms = new MemoryStream();
SvnPropertyCollection props;
svn.Write(new Uri(uri, "trunk/README"), ms, out props);
Assert.That(props, Is.Not.Empty);
Assert.That(Encoding.UTF8.GetString(ms.ToArray()), Is.EqualTo("Welcome to this project"));
Assert.That(props.Contains("svn:eol-style"));
Collection<SvnLogEventArgs> la;
SvnLogArgs ll = new SvnLogArgs();
ll.Start = 1;
svn.GetLog(uri, ll, out la);
Assert.That(la, Is.Not.Empty);
Assert.That(la[0].LogMessage, Is.EqualTo("Everything in one revision"));
}
}
示例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");
}
}
}
示例4: Main
static void Main(string[] args)
{
if (args.Length != 1)
throw new InvalidOperationException("Specify directory at the command line");
var lines = new List<Line>();
using (var client = new SvnClient())
{
Collection<SvnListEventArgs> list;
var listArgs = new SvnListArgs { Depth = SvnDepth.Infinity };
client.GetList(new SvnUriTarget(args[0]), listArgs, out list);
foreach (var item in list)
{
string hashString = null;
long length = 0;
if (item.Entry.NodeKind == SvnNodeKind.File)
{
using (var stream = new MemoryStream())
{
client.Write(item.Uri, stream);
length = stream.Length;
stream.Position = 0;
using (var sha = new SHA1Managed())
{
var hash = sha.ComputeHash(stream);
hashString = BitConverter.ToString(hash).Replace("-", "").ToLower();
}
}
}
lines.Add(new Line(
item.Path,
item.Entry.Revision,
length,
item.Entry.Author,
item.Entry.Time,
hashString
));
}
}
lines.Sort((a, b) => String.Compare(a.Path, b.Path, StringComparison.InvariantCultureIgnoreCase));
using (var target = new StreamWriter("out.txt"))
{
target.WriteLine("Path\tRevision\tLength\tAuthor\tTime\tHash");
foreach (var line in lines)
{
target.WriteLine(
new StringBuilder()
.Append(line.Path)
.Append('\t')
.Append(line.Revision)
.Append('\t')
.Append(line.Length)
.Append('\t')
.Append(line.Author)
.Append('\t')
.Append(line.Time.ToString("yyyy-MM-dd hh:mm:ss"))
.Append('\t')
.Append(line.Hash)
.ToString()
);
}
}
}
示例5: getFile
/// <summary>
/// Get the revision of a specified file and write to the path specified
/// </summary>
/// <param name="fileWorkingCopyPath">local path for the file to get the specfied version</param>
/// <param name="filePathToWrite">Path to write the new file</param>
/// <param name="bWorkingCopy">Simply copy from source to destination. Or else get the base version from SVN</param>
void getFile(string fileWorkingCopyPath, string filePathToWrite, bool bWorkingCopy)
{
SvnChangeSetHelper.createDirForFile(filePathToWrite);
if (bWorkingCopy) // Copy the file the the destination. This is used for old files typically.
File.Copy(fileWorkingCopyPath, filePathToWrite);
else
{
using (SvnClient c = new SvnClient())
{
using (Stream to = File.Create(filePathToWrite))
{
c.Write(new SvnPathTarget(fileWorkingCopyPath, SvnRevision.Base), to);
}
}
}
}