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.
Using the below, you can determine the size of individual files.
svn list --verbose --recursive http://svn/repo/path
Maybe you can look around this command to find a way?
This is my modification to the answer. It reports how many files are below a certain directory in svn and the total size.
svn list -vR svn://svn/repo/subdir|awk {if ($3 !="") sum+=$3; i++} END {print "
total size= " sum/(1024*1024)" MB" "
number of files= " i/1000 " K"}
I ve tested the PowerShell solution and it just needs a small correction:
([xml](svn list --xml --recursive https://svn/repo/path)).lists.list.entry | measure-object -sum size
It some time to get the xml, but works very well.
Adopting from the above solutions, the following might be helpful
#------------------------- Show Repositories, Revisions and Individual Sizes -------------------- SuN --- 2011-11-14 -- { CSVN_DIR=/opt/csvn cd ${CSVN_DIR} REPO_PREFIX="${CSVN_DIR}/data/repositories" REPO_SUFFIX="db/current" for i in `ls ${REPO_PREFIX}/*/${REPO_SUFFIX} ` do if [ -f $i ] then FILENAME=`ls -l $i` REV_NO=`cat $i` REPONAME=`echo $i | awk { srch=" ${REPO_PREFIX} /"; idx = index($0,srch); xstr=substr($0,idx + length(srch)); idx = index(xstr, "/ ${REPO_SUFFIX} "); print substr(xstr,1,idx-1)} ` #REPONAME=sn_library ${CSVN_DIR}/bin/svn list --verbose --recursive https://vctl.ds.xxxxxx.in:9501/svn/${REPONAME} | awk BEGIN {repo=" ${REPONAME} "; rev=" ${REV_NO} ";} {print "Repository: " repo " Revision: " rev $0 } fi done #------------------------- Show Repositories, Revisions and Individual Sizes -------------------- SuN --- 2011-11-14 -- }
or
#------------------------- Show Versions of Repositories and Total Size -------------------- SuN --- 2011-11-14 -- { CSVN_DIR=/opt/csvn cd ${CSVN_DIR} REPO_PREFIX="${CSVN_DIR}/data/repositories" REPO_SUFFIX="db/current" for i in `ls ${REPO_PREFIX}/*/${REPO_SUFFIX} ` do if [ -f $i ] then FILENAME=`ls -l $i` REV_NO=`awk {print $1; exit} $i` REPONAME=`echo $i | awk { srch=" ${REPO_PREFIX} /"; idx = index($0,srch); xstr=substr($0,idx + length(srch)); idx = index(xstr, "/ ${REPO_SUFFIX} "); print substr(xstr,1,idx-1)} ` #REPONAME=sn_library COL_PREFIX="Repository: ${REPONAME} Revision No: ${REV_NO} ${FILENAME}" COL_PREFIX=`echo "${COL_PREFIX}" | awk {xstr = $0; gsub(" ","_",xstr); gsub(":","_",xstr); print xstr;} ` ${CSVN_DIR}/bin/svn list -vR https://vctl.ds.xxxxxx.in:9501/svn/${REPONAME} | awk BEGIN{xstr=" ${COL_PREFIX} "} {if ($3 !="") sum+=$3; i++} END {print xstr " Total size= " sum/1024/1024 " MB" " spread across " i " files/folders "} fi done #------------------------- Show Versions of Repositories and Total Size -------------------- SuN --- 2011-11-14 -- }
You can use the XML mode of the Subversion list command and sum over the file size.
On Linux/UNIX:
$ svn list --xml --recursive http://svn.example.org/module/trunk | awk -F [><]
/^ *<size>/ {s+=$3} END {printf("%.1f GiB
", s/1024/1024/1024)}
Note that the disk usage of an actual svn checkout is basically twice as much as computed above because in the checkout you have the files in the working directory and in the revision cache under the .svn
special directory/directories.
Alternatively, if you aren t overly concerned about RAM usage you use an XPath expression to compute the sum, e.g.:
$ printf %.1f GiB
$(svn list --xml --recursive
http://svn.example.org/module/trunk | xmlstarlet sel -t -v
sum(/lists/list/entry/size) div 1024 div 1024 div 1024 )
Or:
$ printf %.1f GiB
$(svn list --xml --recursive
http://svn.example.org/module/trunk | xmllint --xpath
sum(/lists/list/entry/size) div 1024 div 1024 div 1024 -)
Using such an XPath processor on a repository with many files may yield high memory usage because tools like xmllint (that uses libxml2) often construct the complete document tree in memory before starting to sum over the elements.
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:
I am developing a webpage in that the user can download their Resume for Edit. So I have a link to download the article. I use the following code for download. DataTable dt = user.getUserDetails(2); ...
I have recently added functionality for generating pdf reports to a web application. However the reports can be quite large and take some time to show the pdf download dialog. I want to show a spinner ...
I have a very interesting issue with only specific IE implementations. I have an ASPX page that is used to write files down to the user, as part of the process the page uses the following code to ...
I have a intranet site running PHP 5 that needs to list a folder containing only Excel files. Ideally the user needs to be able to input some search criteria (ie date) and the files would be filtered ...
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 ...
I have the code: #!/usr/bin/perl use strict; use WWW::Mechanize; my $url = http://divxsubtitles.net/page_subtitleinformation.php?ID=111292 ; my $m = WWW::Mechanize->new(autocheck => 1); $m-&...
I ve got a Scala program that downloads and parses html. I got the links to the image files form the html, Now I need to transfer those images to my hard drive. I m wondering what the best Scala ...
Im really stumped. Im using the wxHTTP class in wxWidgets to try and download two files. The first request succeeds but the second one fails when wxHTTP->GetInputStream is called. Between downloads, ...