public static IEnumerable<string> AddMoveMatches(this IEnumerable<string> assetPaths, IVersionControlCommands vcc) { List<string> moveMatches = new List<string>(); var allDeleted = vcc.GetFilteredAssets(status => status.fileStatus == VCFileStatus.Deleted); var allAdded = vcc.GetFilteredAssets(status => status.fileStatus == VCFileStatus.Added); var commitDeleted = assetPaths.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Deleted); var commitAdded = assetPaths.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Added); foreach (var deleted in allDeleted) { var deletedPath = deleted.assetPath.Compose(); if (commitAdded.Count(added => added.EndsWith(Path.GetFileName(deletedPath))) > 0) { moveMatches.Add(deletedPath); } if (commitAdded.Count(added => added.StartsWith(Path.GetDirectoryName(deletedPath)) && Path.GetExtension(deletedPath) == Path.GetExtension(added)) > 0) { moveMatches.Add(deletedPath); } } foreach (var added in allAdded) { var addedPath = added.assetPath.Compose(); if (commitDeleted.Count(deleted => deleted.EndsWith(Path.GetFileName(addedPath))) > 0) { moveMatches.Add(addedPath); } if (commitDeleted.Count(deleted => deleted.StartsWith(Path.GetDirectoryName(addedPath)) && Path.GetExtension(addedPath) == Path.GetExtension(deleted)) > 0) { moveMatches.Add(addedPath); } } return assetPaths.Concat(moveMatches).ToArray(); }
public static bool InIgnoredParentFolder(this string asset, IVersionControlCommands vcc) { return(ParentFolders(asset).Any(a => { return vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Ignored; })); }
public static IEnumerable <string> RemoveFilesUnderUnversionedFolders(this IEnumerable <string> assets, IVersionControlCommands vcc) { var folders = assets.Where(a => Directory.Exists(a) && vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned); assets = assets.Where(a => !folders.Any(f => a.StartsWith(f) && a != f)); return(assets.ToArray()); }
public static IEnumerable <string> AddFolders(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets .Select(a => Path.GetDirectoryName(a)) .Where(d => vcc.GetAssetStatus(d).fileStatus != VCFileStatus.Normal) .Concat(assets) .Distinct() .ToArray()); }
public static IEnumerable<string> AddFolders(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets .Select(a => Path.GetDirectoryName(a)) .Where(d => vcc.GetAssetStatus(d).fileStatus != VCFileStatus.Normal) .Concat(assets) .Distinct() .ToArray(); }
public static void AddFolders(ref List <string> assets, IVersionControlCommands vcc) { for (int i = assets.Count - 1; i >= 0; i--) { string directory = GetDirectoryNameForwardSlash(assets[i]); if (!assets.Contains(directory) && vcc.GetAssetStatus(directory).fileStatus != VCFileStatus.Normal) { assets.Add(directory); } } }
static void RunMemoryTestComplex() { var assets = vcc.GetFilteredAssets(status => { VersionControlStatus metaStatus = status; if (!status.assetPath.EndsWith(meta)) { metaStatus = vcc.GetAssetStatus(status.assetPath + meta); } return(status.fileStatus != VCFileStatus.Normal || metaStatus.fileStatus != VCFileStatus.Normal); }); //Logging(assets.Select(s => s.assetPath.Compose()).Aggregate((a, b) => a + "\n" + b)); //Logging("Memory Used Simple: " + GC.GetTotalMemory(true)); }
public static IEnumerable <string> AddMoveMatches(this IEnumerable <string> assetPaths, IVersionControlCommands vcc) { List <string> moveMatches = new List <string>(); //moveMatches.AddRange(assetPaths.Select(vcc.GetAssetStatus).Where(status => !ComposedString.IsNullOrEmpty(status.movedFrom)).Select(status => status.movedFrom.Compose())); //UnityEngine.Debug.Log(moveMatches.Count > 0 ? moveMatches.AggregateString() : "Empty move match"); var allDeleted = vcc.GetFilteredAssets(status => status.fileStatus == VCFileStatus.Deleted); var allAdded = vcc.GetFilteredAssets(status => status.fileStatus == VCFileStatus.Added); var commitDeleted = assetPaths.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Deleted); var commitAdded = assetPaths.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Added); foreach (var deleted in allDeleted) { var deletedPath = deleted.assetPath.Compose(); if (commitAdded.Count(added => added.EndsWith(Path.GetFileName(deletedPath))) > 0) { moveMatches.Add(deletedPath); } if (commitAdded.Count(added => added.StartsWith(GetDirectoryNameForwardSlash(deletedPath)) && Path.GetExtension(deletedPath) == Path.GetExtension(added)) > 0) { moveMatches.Add(deletedPath); } } foreach (var added in allAdded) { var addedPath = added.assetPath.Compose(); if (commitDeleted.Count(deleted => deleted.EndsWith(Path.GetFileName(addedPath))) > 0) { moveMatches.Add(addedPath); } if (commitDeleted.Count(deleted => deleted.StartsWith(GetDirectoryNameForwardSlash(addedPath)) && Path.GetExtension(addedPath) == Path.GetExtension(deleted)) > 0) { moveMatches.Add(addedPath); } } return(assetPaths.Concat(moveMatches.Distinct()).ToArray()); }
public static IEnumerable<string> AddFilesInFolders(this IEnumerable<string> assets, IVersionControlCommands vcc, bool versionedFoldersOnly = false) { foreach (var assetIt in new List<string>(assets)) { if (Directory.Exists(assetIt) && (!versionedFoldersOnly || vcc.GetAssetStatus(assetIt).fileStatus != VCFileStatus.Unversioned)) { assets = assets .Concat(Directory.GetFiles(assetIt, "*", SearchOption.AllDirectories) .Where(a => File.Exists(a) && !a.Contains("/.") && !a.Contains("\\.") && (File.GetAttributes(a) & FileAttributes.Hidden) == 0) .Select(s => s.Replace("\\", "/"))) .ToArray(); } } return assets; }
public static IEnumerable <string> AddFilesInFolders(this IEnumerable <string> assets, IVersionControlCommands vcc, bool versionedFoldersOnly = false) { foreach (var assetIt in new List <string>(assets)) { if (Directory.Exists(assetIt) && (!versionedFoldersOnly || vcc.GetAssetStatus(assetIt).fileStatus != VCFileStatus.Unversioned)) { assets = assets .Concat(Directory.GetFiles(assetIt, "*", SearchOption.AllDirectories) .Where(a => File.Exists(a) && !a.Contains("/.") && !a.Contains("\\.") && (File.GetAttributes(a) & FileAttributes.Hidden) == 0) .Select(s => s.Replace("\\", "/"))) .ToArray(); } } return(assets); }
public static IEnumerable <string> LocalOnly(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets .Where(d => vcc.GetAssetStatus(d).localOnly) .ToArray()); }
public static IEnumerable <string> LocalModified(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets .Where(d => vcc.GetAssetStatus(d).ModifiedOrLocalEditAllowed()) .ToArray()); }
public static IEnumerable <string> AddedOrUnversionedParentFolders(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Concat(assets.SelectMany(ParentFolders).Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned || vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Added)).Distinct().ToArray()); }
public static IEnumerable<string> RemoveFilesUnderUnversionedFolders(this IEnumerable<string> assets, IVersionControlCommands vcc) { var folders = assets.Where(a => Directory.Exists(a) && vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned); assets = assets.Where(a => !folders.Any(f => a.StartsWith(f) && a != f)); return assets.ToArray(); }
public static IEnumerable <string> OnChangeList(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Where(a => vcc.GetAssetStatus(a).changelist != null)); }
public static IEnumerable<string> Locked(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).lockStatus == VCLockStatus.LockedHere); }
public static IEnumerable <string> Locked(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Where(a => vcc.GetAssetStatus(a).lockStatus == VCLockStatus.LockedHere)); }
public static IEnumerable<string> NotLocked(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).fileStatus != VCFileStatus.Unversioned && vcc.GetAssetStatus(a).lockStatus == VCLockStatus.NoLock); }
public static IEnumerable<string> AddedOrUnversionedParentFolders(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Concat(assets.SelectMany(ParentFolders).Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned || vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Added)).Distinct().ToArray(); }
public static IEnumerable<string> Versioned(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).fileStatus != VCFileStatus.Unversioned && !a.InUnversionedParentFolder(vcc)); }
public VersionControlStatus GetAssetStatus(string assetPath) { return(vcc.GetAssetStatus(new ComposedString(assetPath))); }
public static IEnumerable <string> Versioned(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Where(a => vcc.GetAssetStatus(a).fileStatus != VCFileStatus.Unversioned && !a.InUnversionedParentFolder(vcc))); }
public static bool InUnversionedParentFolder(this string asset, IVersionControlCommands vcc) { return ParentFolders(asset).Any(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned); }
public static IEnumerable <string> Conflicted(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Conflicted)); }
public static IEnumerable<string> OnChangeList(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).changelist != null); }
public static IEnumerable <string> NotLocked(this IEnumerable <string> assets, IVersionControlCommands vcc) { return (assets.Where(a => vcc.GetAssetStatus(a).fileStatus != VCFileStatus.Unversioned && vcc.GetAssetStatus(a).lockStatus == VCLockStatus.NoLock)); }
public static IEnumerable<string> Deleted(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Deleted); }
public virtual VersionControlStatus GetAssetStatus(string assetPath) { return(vcc.GetAssetStatus(assetPath)); }
public void AddAndRemoveFile() { const string fileA = "fileA.txt"; var fs = File.Create(workingDirectoryForSVNTests + "\\" + fileA, 10); fs.Close(); vcc.Status(StatusLevel.Local, DetailLevel.Normal); var status = vcc.GetAssetStatus(fileA); Assert.IsTrue(status.assetPath.Compose() == fileA, "AssetPath mismatch: " + status.assetPath.Compose() + "!=" + fileA); Assert.IsTrue(status.fileStatus == VCFileStatus.Unversioned, "Unversioned"); vcc.Add(new[] { fileA }); vcc.Status(StatusLevel.Local, DetailLevel.Normal); status = vcc.GetAssetStatus(fileA); Assert.IsTrue(status.fileStatus == VCFileStatus.Added, "Added"); vcc.Commit(new[] { fileA }, "AddFile Test 1/2"); vcc.Status(StatusLevel.Local, DetailLevel.Normal); status = vcc.GetAssetStatus(fileA); Assert.IsTrue(status.fileStatus == VCFileStatus.Normal, "Normal"); var basePath = vcc.GetBasePath(fileA); Assert.That(File.Exists(basePath), Is.True, "Base path exist: " + basePath); vcc.Delete(new[] { fileA }, OperationMode.Normal); vcc.Status(StatusLevel.Local, DetailLevel.Normal); status = vcc.GetAssetStatus(fileA); Assert.IsTrue(status.fileStatus == VCFileStatus.Deleted, "Deleted"); vcc.Commit(new[] { fileA }, "AddFile Test 2/2"); vcc.Status(StatusLevel.Local, DetailLevel.Normal); status = vcc.GetAssetStatus(fileA); Assert.That(status.Reflected, Is.False, "fileA is not present in repo"); Assert.IsTrue(!File.Exists(workingDirectoryForSVNTests + "\\" + fileA), "File removed again"); }