Is there a way to count/calculate the total size of a svn directory if you were to checkout a revision?
I have limited internet downloads so I need to know how big something is before I go and download it.
Thank you.
Is there a way to count/calculate the total size of a svn directory if you were to checkout a revision?
I have limited internet downloads so I need to know how big something is before I go and download it.
Thank you.
I needed the sizes on base project folder level. Here is my solution using powershell to generate the xml and a C# app to extract the summarized sizes for each base project folder.
PS C:\> svn list --xml --recursive https://svn.xy.com:4443/svn/Production/ >svn_extract.xml
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
namespace SvnProjectSizeFromXml
{
class Program
{
static void Main(string[] args)
{
//create svn repository xml file via powershell first:
//PS C:\> svn list --xml --recursive https://svn.xy.com:4443/svn/Production/ >svn_extract
//read file via streamreader, extract rootfolders and summarized size - export to csv
string fileName = @"C:\svn_extract.xml";
Dictionary<string, Int64> list = new Dictionary<string, Int64>();
string currentProject="";
Int64 currentSize=0;
using (System.IO.StreamReader sr = File.OpenText(fileName))
{
string s = String.Empty;
while ((s = sr.ReadLine()) != null)
{
if (s.Contains("<name>") || s.Contains("</lists>"))
{
if (s.Contains("</lists>"))
{
//end of file
list.Add(currentProject, currentSize);
break;
}
XmlDocument docNew = new XmlDocument();
docNew.LoadXml(s);
if (!docNew.InnerText.Contains("/") && !docNew.InnerText.Contains("."))
{
if (currentProject != docNew.InnerText && currentProject!= "")
{
//new project, store last one to list
list.Add(currentProject, currentSize);
Console.WriteLine(list.Count.ToString());
}
//new project, init
currentProject = docNew.InnerText;
currentSize = 0;
}
}
if (s.Contains("<size>"))
{
XmlDocument docNew = new XmlDocument();
docNew.LoadXml(s);
currentSize += Int64.Parse(docNew.InnerText);
}
}
String csv = String.Join(Environment.NewLine,list.Select(d => $"{d.Key};{d.Value};"));
System.IO.File.WriteAllText(@"C:\output.csv", csv);
}
}
}
}
Output as CSV: