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 SVNCommands() { vcc = new VCCFilteredAssets(this); StartRefreshLoop(); AppDomain.CurrentDomain.DomainUnload += Unload; AppDomain.CurrentDomain.ProcessExit += Unload; }
private static void OnVersionControlBackendChanged(IVersionControlCommands vcc) { if (VersionControlBackendChanged != null) { VersionControlBackendChanged(vcc); } }
public SVNCommands() { vcc = new VCCFilteredAssets(this); StartRefreshLoop(); AppDomain.CurrentDomain.DomainUnload += Unload; AppDomain.CurrentDomain.ProcessExit += Unload; }
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> AddDeletedInFolders(this IEnumerable<string> assetPaths, IVersionControlCommands vcc) { var deletedInFolders = assetPaths .SelectMany(d => vcc.GetFilteredAssets(status => (status.fileStatus == VCFileStatus.Deleted || status.fileStatus == VCFileStatus.Missing) && status.assetPath.StartsWith(new ComposedString(d)))) .Select(status => status.assetPath.Compose()) .ToArray(); return assetPaths.Concat(deletedInFolders).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); } } }
protected VCCDecorator(IVersionControlCommands vcc) { this.vcc = vcc; vcc.ProgressInformation += progress => { if (ProgressInformation != null) { ProgressInformation(progress); } }; vcc.StatusCompleted += () => { if (StatusCompleted != null) { StatusCompleted(); } }; }
private void OnVersionControlBackendChanged(IVersionControlCommands newVcc) { vcc?.Dispose(); vcc = newVcc; vcc.ProgressInformation += progress => { if (ProgressInformation != null) { OnNextUpdate.Do(() => ProgressInformation(progress)); } }; vcc.StatusCompleted += OnStatusCompleted; OnNextUpdate.Do(Start); EditorApplication.playModeStateChanged += OnPlaymodeStateChanged; }
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 void Init() { if (Directory.Exists(workingDirectoryForSVNTests)) { Directory.Delete(workingDirectoryForSVNTests, true); } Directory.CreateDirectory(workingDirectoryForSVNTests); vcc = new VCCFilteredAssets(new SVNCommands()); vcc.SetWorkingDirectory(workingDirectoryForSVNTests); Directory.SetCurrentDirectory(workingDirectoryForSVNTests); vcc.ProgressInformation += s => D.Log(s); vcc.Start(); vcc.SetUserCredentials("kjems", "dingo", true); vcc.Checkout(urlToEmptyRepo, workingDirectoryForSVNTests); }
public static bool CreateVersionControlCommands(VCSettings.EVersionControlBackend backend) { string workDirectory = Application.dataPath.Remove(Application.dataPath.LastIndexOf("/Assets", StringComparison.Ordinal)); bool noopSelected = backend == VCSettings.EVersionControlBackend.None; bool svnSelected = backend == VCSettings.EVersionControlBackend.Svn; /*P4_DISABLED bool p4Selected = backend == VCSettings.EVersionControlBackend.P4_Beta;*/ IVersionControlCommands uvc = null; bool success = false; if (svnSelected && CreateVersionControl <SVNCommands>(() => new SVNCommands(), workDirectory, out uvc)) { //D.Log(backend + " backend initialized successfully"); OnVersionControlBackendChanged(uvc); success = true; } /*P4_DISABLED * else if (p4Selected && CreateVersionControl<P4Commands>(() => new P4Commands(), workDirectory, out uvc)) * { * //D.Log(backend + " backend initialized successfully"); * OnVersionControlBackendChanged(uvc); * success = true; * }*/ else if (noopSelected) { //D.Log(backend + " backend initialized successfully"); OnVersionControlBackendChanged(GetDefaultImplementation()); success = true; } GoogleAnalytics.LogUserEvent("Backend", $"{backend.ToString()}_{(success ? "success" : "failed")}"); if (!success) { DebugLog.LogWarning(backend + " backend initialization failed!"); } return(success); }
public static void AddMoveMatches(ref List <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); } } assetPaths.AddRange(moveMatches.Distinct()); }
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> 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> InVersionedFolder(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Where(a => !a.InUnversionedParentFolder(vcc)).ToArray()); }
public static IEnumerable <string> AddDeletedInFolders(this IEnumerable <string> assetPaths, IVersionControlCommands vcc) { var deletedInFolders = assetPaths .SelectMany(d => vcc.GetFilteredAssets(status => (status.fileStatus == VCFileStatus.Deleted || status.fileStatus == VCFileStatus.Missing) && status.assetPath.StartsWith(new ComposedString(d)))) .Select(status => status.assetPath.Compose()) .ToArray(); return(assetPaths.Concat(deletedInFolders).ToArray()); }
public void Dispose() { vcc.Dispose(); vcc = null; }
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("\\", "/"))) .Distinct() .ToArray(); } } return(assets); }
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> 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> Deleted(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Deleted); }
private static IVersionControlCommands AddDecorators(IVersionControlCommands vcc) { return(new VCCAddMetaFiles(new VCCFilteredAssets(vcc))); }
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> OnChangeList(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).changelist != null); }
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> LocalModified(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets .Where(d => vcc.GetAssetStatus(d).ModifiedOrLocalEditAllowed()) .ToArray()); }
public static IEnumerable<string> InVersionedFolder(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => !a.InUnversionedParentFolder(vcc)).ToArray(); }
public static IEnumerable <string> LocalOnly(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets .Where(d => vcc.GetAssetStatus(d).localOnly) .ToArray()); }
public static bool InUnversionedParentFolder(this string asset, IVersionControlCommands vcc) { return ParentFolders(asset).Any(a => vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned); }
public VCCFilteredAssets(IVersionControlCommands vcc) : base(vcc) { }
public VCCAddMetaFiles(IVersionControlCommands vcc) : base(vcc) { }
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()); }
protected VCCDecorator(IVersionControlCommands vcc) { this.vcc = vcc; vcc.ProgressInformation += progress => { if (ProgressInformation != null) ProgressInformation(progress); }; vcc.StatusCompleted += () => { if (StatusCompleted != null) StatusCompleted(); }; }
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 void Init() { if (Directory.Exists(workingDirectoryForSVNTests)) { Directory.Delete(workingDirectoryForSVNTests, true); } Directory.CreateDirectory(workingDirectoryForSVNTests); vcc = new VCCFilteredAssets(new SVNCommands()); vcc.SetWorkingDirectory(workingDirectoryForSVNTests); Directory.SetCurrentDirectory(workingDirectoryForSVNTests); vcc.ProgressInformation += s => D.Log(s); vcc.Start(); vcc.SetUserCredentials("kjems", "dingo", true); vcc.Checkout(urlToEmptyRepo, workingDirectoryForSVNTests); }
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 void Dispose() { vcc.Dispose(); vcc = null; }
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> 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> 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> Versioned(this IEnumerable<string> assets, IVersionControlCommands vcc) { return assets.Where(a => vcc.GetAssetStatus(a).fileStatus != VCFileStatus.Unversioned && !a.InUnversionedParentFolder(vcc)); }
public static IEnumerable <string> AddedOrUnversionedParentFolders(this IEnumerable <string> assets, IVersionControlCommands vcc) { return(assets.Concat(assets.SelectMany(ParentFolders).Where(a => { Logging.D.Log("AddedOrUnversionedParentFolders: " + a + " - " + vcc.GetAssetStatus(a).fileStatus); bool bAddedOrUnversioned = vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Unversioned || vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Added; if (bAddedOrUnversioned) { return true; } //else if (vcc.GetAssetStatus(a).fileStatus == VCFileStatus.Normal) //Should not happen anymore (Direcotry exists fix) //{ // IEnumerable<string> parentsOfParent = ParentFolders(a); // foreach (string strParent in parentsOfParent) // { // if (vcc.GetAssetStatus(strParent).fileStatus == VCFileStatus.Unversioned || vcc.GetAssetStatus(strParent).fileStatus == VCFileStatus.Added) // return true; // } // return false; //} else { return false; } } )).Distinct().ToArray()); }
private static bool CreateVersionControl <T>(Func <T> factory, string workDirectory, out IVersionControlCommands uvc) where T : IVersionControlCommands { var watch = new System.Diagnostics.Stopwatch(); watch.Start(); uvc = null; bool valid = false; try { uvc = AddDecorators(factory()); uvc.SetWorkingDirectory(workDirectory); valid = uvc.HasValidLocalCopy(); } catch (Exception e) { DebugLog.ThrowException(e); } finally { if (!valid && uvc != null) { uvc.Dispose(); } } DebugLog.Log("CreateVersionControl took : " + watch.ElapsedMilliseconds + "ms"); return(valid); }
public VCCFilteredAssets(IVersionControlCommands vcc) : base(vcc) { }
public VCCAddMetaFiles(IVersionControlCommands vcc) : base(vcc) { }