/// <summary> /// 两个版本之间的不同 /// </summary> /// <param name="from"></param> /// <param name="to"></param> private void deff(string from, string to) { using (SvnClient client = new SvnClient()) { SvnPathTarget path1 = new SvnPathTarget(WORKSPACE, SvnRevision.One); SvnUriTarget path2 = new SvnUriTarget(WORKSPACE, SvnRevision.Head); Collection <SvnDiffSummaryEventArgs> diffEvents = new Collection <SvnDiffSummaryEventArgs>(); client.GetDiffSummary(path1, path2, out diffEvents); foreach (var item in diffEvents) { Console.WriteLine(item.Path + " " + item.NodeKind + " " + item.DiffKind); } } }
public XmlDocument getSVNDifferFiles() { //获取最大的版本号 this.getLastVersion(); // diff xml XmlDocument newDoc = new XmlDocument(); XmlDeclaration xmldecl = newDoc.CreateXmlDeclaration("1.0", "UTF-8", null); newDoc.AppendChild(xmldecl); XmlElement newRoot = newDoc.CreateElement("files"); newDoc.AppendChild(newRoot); newRoot.SetAttribute("version", PackageSubVM.Instance.Version); long fileSizes = 0; int index = 0; string[] szFilter = PackageSubVM.Instance.Filter.Split(new char[1] { ':' }); SvnClient svnClient = new SvnClient(); //List<SvnDiffSummaryEventArgs> list; System.Collections.ObjectModel.Collection <SvnDiffSummaryEventArgs> list; svnClient.GetDiffSummary(new SvnUriTarget(PackageSubVM.Instance.SVNPath, Int32.Parse(PackageSubVM.Instance.BeginVersion)), new SvnUriTarget(PackageSubVM.Instance.SVNPath, Int32.Parse(PackageSubVM.Instance.EndVersion)), out list); foreach (SvnDiffSummaryEventArgs item in list) { if (szFilter.Contains(Path.GetExtension(item.Path)) || szFilter.Contains(Path.GetFileName(item.Path))) { continue; } string fullFileName = szResourceOutPath + "\\" + item.Path; if (item.NodeKind == SvnNodeKind.Directory) { if (Directory.Exists(fullFileName) == false) { DirectoryInfo info = Directory.CreateDirectory(fullFileName); } continue; } string outPath = Path.GetDirectoryName(fullFileName); if (Directory.Exists(outPath) == false) { DirectoryInfo info = Directory.CreateDirectory(outPath); } try { SvnClient exportSVN = new SvnClient(); SvnExportArgs ex = new SvnExportArgs(); ex.Overwrite = true; long size = 0; if (item.DiffKind != SvnDiffKind.Deleted) { exportSVN.Export(new SvnUriTarget(item.ToUri, Int32.Parse(PackageSubVM.Instance.EndVersion)), fullFileName, ex); index = index + 1; this.createXmlNode(newDoc, newRoot, item.Path, this.createFileMD5(fullFileName, out size), "1", index); fileSizes += size; } else { this.createXmlNode(newDoc, newRoot, item.Path, "this is a delete file.", "0", index); } } catch (Exception ee) { MessageBox.Show(ee.Message); Console.WriteLine(ee.Message); } } newRoot.SetAttribute("lastVersion", szLastVersion); newRoot.SetAttribute("size", fileSizes.ToString()); return(newDoc); }
public XmlDocument getSVNDifferFiles() { //获取最大的版本号 this.getLastVersion(); // diff xml XmlDocument newDoc = new XmlDocument(); XmlDeclaration xmldecl = newDoc.CreateXmlDeclaration("1.0", "UTF-8", null); newDoc.AppendChild(xmldecl); XmlElement newRoot = newDoc.CreateElement("files"); newDoc.AppendChild(newRoot); newRoot.SetAttribute("version", PackageSubVM.Instance.Version); long fileSizes = 0; int index = 0; string[] szFilter = PackageSubVM.Instance.Filter.Split(new char[1] { ':' }); SvnClient svnClient = new SvnClient(); //List<SvnDiffSummaryEventArgs> list; System.Collections.ObjectModel.Collection<SvnDiffSummaryEventArgs> list; svnClient.GetDiffSummary(new SvnUriTarget(PackageSubVM.Instance.SVNPath, Int32.Parse(PackageSubVM.Instance.BeginVersion)), new SvnUriTarget(PackageSubVM.Instance.SVNPath, Int32.Parse(PackageSubVM.Instance.EndVersion)), out list); foreach (SvnDiffSummaryEventArgs item in list) { if (szFilter.Contains(Path.GetExtension(item.Path)) || szFilter.Contains(Path.GetFileName(item.Path))) { continue; } string fullFileName = szResourceOutPath + "\\" + item.Path; if (item.NodeKind == SvnNodeKind.Directory) { if (Directory.Exists(fullFileName) == false) { DirectoryInfo info = Directory.CreateDirectory(fullFileName); } continue; } string outPath = Path.GetDirectoryName(fullFileName); if (Directory.Exists(outPath) == false) { DirectoryInfo info = Directory.CreateDirectory(outPath); } try { SvnClient exportSVN = new SvnClient(); SvnExportArgs ex = new SvnExportArgs(); ex.Overwrite = true; long size = 0; if (item.DiffKind != SvnDiffKind.Deleted) { exportSVN.Export(new SvnUriTarget(item.ToUri, Int32.Parse(PackageSubVM.Instance.EndVersion)), fullFileName, ex); index = index + 1; this.createXmlNode(newDoc, newRoot, item.Path, this.createFileMD5(fullFileName, out size), "1", index); fileSizes += size; } else { this.createXmlNode(newDoc, newRoot, item.Path, "this is a delete file.", "0", index); } } catch (Exception ee) { MessageBox.Show(ee.Message); Console.WriteLine(ee.Message); } } newRoot.SetAttribute("lastVersion", szLastVersion); newRoot.SetAttribute("size", fileSizes.ToString()); return newDoc; }