Thursday, December 10, 2009

sharpsvn getting list of locked files

public struct LockedFileMetaData
{
public string FilePath { get; set; }
public string LockOwner { get; set; }
}


public List GetListOfAllLockedFiles()
{
List lockedFiles = new List();
SvnTarget target = SvnTarget.FromUri(RepositoryUri);
System.Collections.ObjectModel.Collection ListEventArgs;
SvnListArgs args = new SvnListArgs();
args.RetrieveLocks = true;
_svnClient.GetList(target, args, out ListEventArgs); //lock doesn't get populated

if (ListEventArgs != null)
{
foreach (var fileStatus in ListEventArgs)
{
if (null != fileStatus.Lock)
{
lockedFiles.Add(new LockedFileMetaData() {
FilePath = fileStatus.Lock.FullPath,
LockOwner = fileStatus.Lock.Owner
});
}
}
}
return lockedFiles;
}

1 comment:

Mudassar said...

Hi,
nice article really helped out, thanks for that.
But i do have a question, wht if i just want to populate only the locked files.
As of now wht it does it populates list of all the files and then we filter out the locked ones, is there a way to get list of only locked files?
thanks in advance
Mudassar