private static StatusDatabase ParseStatusResult(XmlDocument xmlDoc) { if (!xmlDoc.HasChildNodes) { return(null); } var statusDatabase = new StatusDatabase(); XmlNodeList entries = xmlDoc.GetElementsByTagName("entry"); foreach (XmlNode entryIt in entries) { ComposedString assetPath = new ComposedString((entryIt.Attributes["path"].InnerText.Replace('\\', '/')).Trim()); var status = ParseXMLNode(entryIt); status.assetPath = assetPath; statusDatabase[assetPath] = status; } XmlNodeList changelists = xmlDoc.GetElementsByTagName("changelist"); foreach (XmlNode changelistIt in changelists) { string changelist = changelistIt.Attributes["name"].InnerText; foreach (XmlNode entryIt in changelistIt.ChildNodes) { ComposedString assetPath = new ComposedString((entryIt.Attributes["path"].InnerText.Replace('\\', '/')).Trim()); if (statusDatabase.ContainsKey(assetPath)) { statusDatabase[assetPath].changelist = changelist; if (changelist == SVNCommands.localEditChangeList) { statusDatabase[assetPath].allowLocalEdit = true; } } } } foreach (var assetPathIt in new List <ComposedString>(statusDatabase.Keys)) { string assetPathStr = assetPathIt.Compose(); if (Directory.Exists(assetPathStr)) { var status = statusDatabase[assetPathIt]; if (status.fileStatus == VCFileStatus.Unversioned) { foreach (var unversionedIt in GetFilesInFolder(assetPathStr)) { var fileStatus = new VersionControlStatus { assetPath = unversionedIt, fileStatus = VCFileStatus.Unversioned, }; statusDatabase[unversionedIt] = fileStatus; } } } } return(statusDatabase); }
public VersionControlStatus GetAssetStatus(ComposedString assetPath) { lock (statusDatabaseLockToken) { return(statusDatabase[assetPath]); } }
public static bool HaveAssetControl(VersionControlStatus assetStatus) { return(!VCCommands.Active || HaveVCLock(assetStatus) || assetStatus.fileStatus == VCFileStatus.Added || assetStatus.fileStatus == VCFileStatus.Unversioned || assetStatus.fileStatus == VCFileStatus.Ignored || ComposedString.IsNullOrEmpty(assetStatus.assetPath) || assetStatus.LocalEditAllowed()); }
private static bool IsOpenForEdit(string assetPath, out string message) { if (VCCommands.Active && VCSettings.LockAssets) { var ap = new ComposedString(assetPath).TrimEnd(VCCAddMetaFiles.meta); if (!VCUtility.IsMergableAsset(ap) && ap.StartsWith("Assets/")) { var status = VCCommands.Instance.GetAssetStatus(ap); message = AssetStatusUtils.GetStatusText(status); return(VCUtility.HaveAssetControl(status)); } } message = ""; return(true); }
private void SetPending(IEnumerable <string> assets) { lock (statusDatabaseLockToken) { foreach (var assetIt in assets) { if (GetAssetStatus(assetIt).reflectionLevel != VCReflectionLevel.Pending) { ComposedString asset = new ComposedString(assetIt); var status = statusDatabase[asset]; status.reflectionLevel = VCReflectionLevel.Pending; statusDatabase[asset] = status; } } //D.Log("Set Pending : " + assets.Aggregate((a, b) => a + ", " + b)); } }
private bool BaseFilter(VersionControlStatus vcStatus) { using (PushStateUtility.Profiler("CommitWindow::BaseFilter")) { var metaStatus = vcStatus.MetaStatus(); bool interresting = (vcStatus.fileStatus != VCFileStatus.None && (vcStatus.fileStatus != VCFileStatus.Normal || (metaStatus != null && metaStatus.fileStatus != VCFileStatus.Normal))) || vcStatus.lockStatus == VCLockStatus.LockedHere; if (!interresting) { return(false); } ComposedString key = vcStatus.assetPath.TrimEnd(VCCAddMetaFiles.meta); return(assetPaths.Contains(key) || depedencyAssetPaths.Contains(key)); } }
public static string GetLockStatusMessage(VersionControlStatus assetStatus) { string lockMessage = assetStatus.lockStatus.ToString(); if (assetStatus.lockStatus == VCLockStatus.LockedOther) { lockMessage = Terminology.getlock + " by: " + assetStatus.owner; } if (assetStatus.lockStatus == VCLockStatus.LockedHere) { lockMessage = Terminology.getlock + " Here: " + assetStatus.owner; } if (assetStatus.lockStatus == VCLockStatus.NoLock) { if (ComposedString.IsNullOrEmpty(assetStatus.assetPath)) { lockMessage = "Not saved"; } else if (assetStatus.fileStatus == VCFileStatus.Added) { lockMessage = "Added"; } else if (assetStatus.fileStatus == VCFileStatus.Replaced) { lockMessage = "Replaced"; } else { lockMessage = VCUtility.ManagedByRepository(assetStatus) ? "Not " + Terminology.getlock : "Not on Version Control"; } } if (assetStatus.LocalEditAllowed()) { lockMessage = Terminology.allowLocalEdit; if ((assetStatus.lockStatus == VCLockStatus.LockedOther)) { lockMessage += " (" + Terminology.getlock + " By: " + assetStatus.owner + " )"; } } if (assetStatus.fileStatus == VCFileStatus.Modified) { lockMessage += "*"; } return(lockMessage); }
public void TestComposeAndDecompose() { ComposedString cstr2 = new ComposedString(str2); ComposedString cstr3 = new ComposedString(str3); ComposedString cstr4 = new ComposedString(str4); ComposedString cstr5 = new ComposedString(str5); var cstr3meta = cstr3 + meta; Assert.AreEqual(str1, cstr1.Compose(), "compose/decompose mismatch"); Assert.AreEqual(str5, cstr5.Compose(), "compose/decompose mismatch with Unicode characters"); Assert.AreEqual(cstr2, cstr3, "equal ComposedString"); Assert.AreEqual(str3meta, cstr3meta.Compose(), "using operator + with string"); Assert.True(cstr3meta.EndsWith(meta), "Endwith and implicit string conversion"); Assert.False(cstr3meta.EndsWith(empty), "Endwith empty"); Assert.False(cstr3meta.EndsWith(metaDot), "Endwith metaDot"); Assert.True(cstr4.EndsWith("@run.fbx"), "Endwith @run.fbx"); Assert.AreEqual(cstr3, cstr3meta.TrimEnd(meta), "Trim End"); Assert.AreEqual(cstr3meta, cstr3 + meta, "Trim End does not modify original"); }
public static bool IsMergableAsset(ComposedString assetPath) { return(mergablePostfix.Any(assetPath.EndsWith)); }
public bool GetStatus(StatusLevel statusLevel, string fstatArgs, string path) { //D.Log( "Processing " + path ); string arguments = "status -aedf \"" + path + "\""; CommandLineOutput statusCommandLineOutput = null; if (statusLevel == StatusLevel.Local) { using (var p4StatusTask = P4Util.Instance.CreateP4CommandLine(arguments)) { statusCommandLineOutput = P4Util.Instance.ExecuteOperation(p4StatusTask); } } arguments = fstatArgs + " \"" + path + "\""; CommandLineOutput fstatCommandLineOutput = null; using (var p4FstatTask = P4Util.Instance.CreateP4CommandLine(arguments)) { fstatCommandLineOutput = P4Util.Instance.ExecuteOperation(p4FstatTask); } if (statusCommandLineOutput == null || statusCommandLineOutput.Failed || string.IsNullOrEmpty(statusCommandLineOutput.OutputStr) || !active) { return(false); } if (fstatCommandLineOutput == null || fstatCommandLineOutput.Failed || string.IsNullOrEmpty(fstatCommandLineOutput.OutputStr) || !active) { return(false); } try { var statusDB = statusCommandLineOutput != null?P4StatusParser.P4ParseStatus(statusCommandLineOutput.OutputStr, P4Util.Instance.Vars.userName) : null; var fstatDB = P4StatusParser.P4ParseFstat(fstatCommandLineOutput.OutputStr, P4Util.Instance.Vars.workingDirectory); lock (statusDatabaseLockToken) { if (statusDB != null) { foreach (var statusIt in statusDB) { var status = statusIt.Value; status.reflectionLevel = statusLevel == StatusLevel.Remote ? VCReflectionLevel.Repository : VCReflectionLevel.Local; statusDatabase[new ComposedString(statusIt.Key.Compose().Replace(P4Util.Instance.Vars.workingDirectory + "/", ""))] = status; } } foreach (var statusIt in fstatDB) { VersionControlStatus status = null; ComposedString aPath = new ComposedString(statusIt.Key.Compose().Replace(P4Util.Instance.Vars.workingDirectory + "/", "")); statusDatabase.TryGetValue(aPath, out status); if (status == null || status.reflectionLevel == VCReflectionLevel.Pending) { // no previous status or previous status is pending, so set it here status = statusIt.Value; } else { // probably got this status from the "status -a -e -d" command, merge it with whatever we got back from fstat if (status.fileStatus == VCFileStatus.Modified && statusIt.Value.remoteStatus == VCRemoteFileStatus.Modified) { // we have modified locally and file is out of date with server - mark as a conflict (might not be, but at // least this will raise a flag with the user to make sure they get up to date before going any further) status.fileStatus = VCFileStatus.Conflicted; status.treeConflictStatus = VCTreeConflictStatus.TreeConflict; } } status.reflectionLevel = statusLevel == StatusLevel.Remote ? VCReflectionLevel.Repository : VCReflectionLevel.Local; statusDatabase[aPath] = status; } } lock (requestQueueLockToken) { if (statusDB != null) { foreach (var assetIt in statusDB.Keys) { if (statusLevel == StatusLevel.Remote) { remoteRequestQueue.Remove(assetIt.Compose()); } localRequestQueue.Remove(assetIt.Compose()); } } foreach (var assetIt in fstatDB.Keys) { if (statusLevel == StatusLevel.Remote) { remoteRequestQueue.Remove(assetIt.Compose()); } localRequestQueue.Remove(assetIt.Compose()); } } OnStatusCompleted(); } catch (Exception e) { DebugLog.ThrowException(e); return(false); } return(true); }
public virtual VersionControlStatus GetAssetStatus(ComposedString assetPath) { return(defaultStatus); }
public VersionControlStatus GetAssetStatus(ComposedString assetPath) { return statusDatabase[assetPath]; }
// This is a performance critical function private bool BaseFilter(VersionControlStatus vcStatus) { if (!vcStatus.Reflected) { return(false); } bool assetCriteria = vcStatus.fileStatus != VCFileStatus.None && (vcStatus.ModifiedOrLocalEditAllowed() || vcStatus.fileStatus != VCFileStatus.Normal || !ComposedString.IsNullOrEmpty(vcStatus.changelist)) && vcStatus.fileStatus != VCFileStatus.Ignored; if (assetCriteria) { return(true); } bool property = vcStatus.property == VCProperty.Modified || vcStatus.property == VCProperty.Conflicted; if (property) { return(true); } bool localLock = vcStatus.lockStatus == VCLockStatus.LockedHere; if (localLock) { return(true); } var metaStatus = vcStatus.MetaStatus(); bool metaCriteria = metaStatus.fileStatus != VCFileStatus.Normal && (metaStatus.fileStatus != VCFileStatus.None || !ComposedString.IsNullOrEmpty(metaStatus.changelist)) && metaStatus.fileStatus != VCFileStatus.Ignored; if (metaCriteria) { return(true); } return(false); }
public static bool IsDiffableAsset(ComposedString assetPath) { return(mergablePostfix.Any(assetPath.EndsWith) || requiresTextConversionPostfix.Any(assetPath.EndsWith)); }
public static ValidActions GetValidActions(string assetPath, Object instance = null) { using (sceneviewUpdateMarker.Auto()) { if (!VCCommands.Active || string.IsNullOrEmpty(assetPath)) { return(noAction); } var assetStatus = VCCommands.Instance.GetAssetStatus(assetPath); bool isPrefab = instance != null && PrefabHelper.IsPrefab(instance); bool isPrefabParent = isPrefab && PrefabHelper.IsPrefabParent(instance); bool isFolder = AssetDatabase.IsValidFolder(assetPath); bool diffableAsset = MergeHandler.IsDiffableAsset(assetPath); bool mergableAsset = MergeHandler.IsMergableAsset(assetPath); bool modifiedDiffableAsset = diffableAsset && assetStatus.fileStatus != VCFileStatus.Normal; bool modifiedMeta = assetStatus.MetaStatus().fileStatus != VCFileStatus.Normal; bool lockedMeta = assetStatus.MetaStatus().lockStatus == VCLockStatus.LockedHere; bool modified = assetStatus.fileStatus == VCFileStatus.Modified; bool localOnly = assetStatus.localOnly; bool deleted = assetStatus.fileStatus == VCFileStatus.Deleted; bool added = assetStatus.fileStatus == VCFileStatus.Added; bool unversioned = assetStatus.fileStatus == VCFileStatus.Unversioned; bool ignored = assetStatus.fileStatus == VCFileStatus.Ignored; bool replaced = assetStatus.fileStatus == VCFileStatus.Replaced; bool lockedByOther = assetStatus.lockStatus == VCLockStatus.LockedOther; bool managedByRep = VCUtility.ManagedByRepository(assetStatus); bool haveControl = VCUtility.HaveAssetControl(assetStatus); bool haveLock = VCUtility.HaveVCLock(assetStatus); bool allowLocalEdit = assetStatus.LocalEditAllowed(); bool pending = assetStatus.reflectionLevel == VCReflectionLevel.Pending; bool mergeinfo = assetStatus.property == VCProperty.Modified; bool conflicted = assetStatus.fileStatus == VCFileStatus.Conflicted; bool hasChangeSet = !ComposedString.IsNullOrEmpty(assetStatus.changelist); bool showAdd = !pending && !ignored && unversioned; bool showOpen = !pending && !showAdd && !added && !haveLock && !deleted && !isFolder && !mergableAsset && ((!lockedByOther && !localOnly) || allowLocalEdit); bool showDiff = !pending && !ignored && !deleted && modifiedDiffableAsset && managedByRep; bool showCommit = !pending && !ignored && !allowLocalEdit && !localOnly && (haveLock || added || deleted || modifiedDiffableAsset || modifiedMeta || mergeinfo); bool showRevert = !pending && !ignored && !unversioned && (haveControl || modified || added || deleted || replaced || modifiedDiffableAsset || modifiedMeta || lockedMeta || mergeinfo); bool showDelete = !pending && !ignored && !deleted && !lockedByOther; bool showOpenLocal = !pending && !ignored && !deleted && !isFolder && !allowLocalEdit && !unversioned && !added && !haveLock && !mergableAsset && !localOnly; bool showUnlock = !pending && !ignored && !allowLocalEdit && haveLock; bool showUpdate = !pending && !ignored && !added && managedByRep && instance != null; bool showUseTheirs = !pending && !ignored && conflicted; bool showUseMine = !pending && !ignored && conflicted; bool showMerge = !pending && !ignored && conflicted && mergableAsset; bool showAddChangeList = !pending && !ignored && !unversioned; bool showRemoveChangeList = !pending && !ignored && hasChangeSet; ValidActions validActions = 0; if (showAdd) { validActions |= ValidActions.Add; } if (showOpen) { validActions |= ValidActions.Open; } if (showDiff) { validActions |= ValidActions.Diff; } if (showCommit) { validActions |= ValidActions.Commit; } if (showRevert) { validActions |= ValidActions.Revert; } if (showDelete) { validActions |= ValidActions.Delete; } if (showOpenLocal) { validActions |= ValidActions.OpenLocal; } if (showUnlock) { validActions |= ValidActions.Unlock; } if (showUpdate) { validActions |= ValidActions.Update; } if (showUseTheirs) { validActions |= ValidActions.UseTheirs; } if (showUseMine) { validActions |= ValidActions.UseMine; } if (showMerge) { validActions |= ValidActions.Merge; } if (showAddChangeList) { validActions |= ValidActions.AddChangeList; } if (showRemoveChangeList) { validActions |= ValidActions.RemoveChangeList; } return(validActions); } }
public static bool IsBinaryAsset(ComposedString assetPath) { return(requiresTextConversionPostfix.Any(assetPath.EndsWith)); }
public static bool IsDiffableAsset(ComposedString assetPath) { return(true); }
public virtual VersionControlStatus GetAssetStatus(ComposedString assetPath) { return(vcc.GetAssetStatus(assetPath)); }
public static bool ManagedByRepository(VersionControlStatus assetStatus) { return(assetStatus.fileStatus != VCFileStatus.Unversioned && !ComposedString.IsNullOrEmpty(assetStatus.assetPath) && !Application.isPlaying); }
private static VersionControlStatus ParseXMLNode(XmlNode entryIt, ComposedString assetPath) { var versionControlStatus = new VersionControlStatus(); XmlElement reposStatus = entryIt["repos-status"]; if (reposStatus != null) { if (reposStatus.Attributes["item"] != null && reposStatus.Attributes["item"].InnerText != "normal") { versionControlStatus.remoteStatus = VCRemoteFileStatus.Modified; } XmlElement lockStatus = reposStatus["lock"]; if (lockStatus != null) { if (lockStatus["owner"] != null) { versionControlStatus.owner = lockStatus["owner"].InnerText; } versionControlStatus.lockStatus = VCLockStatus.LockedOther; } } XmlElement wcStatus = entryIt["wc-status"]; if (wcStatus != null) { if (wcStatus.Attributes["item"] == null || !SVNToVersionControlStatusMap.fileStatusMap.TryGetValue(wcStatus.Attributes["item"].InnerText, out versionControlStatus.fileStatus)) { DebugLog.Log("SVN: Unknown file status: " + wcStatus.Attributes["item"].InnerText); } if (wcStatus.Attributes["props"] == null || !SVNToVersionControlStatusMap.propertyMap.TryGetValue(wcStatus.Attributes["props"].InnerText, out versionControlStatus.property)) { DebugLog.Log("SVN: Unknown property: " + wcStatus.Attributes["props"].InnerText); } if (wcStatus.Attributes["revision"] != null) { versionControlStatus.revision = Int32.Parse(wcStatus.Attributes["revision"].InnerText); } if (wcStatus.Attributes["wc-locked"] != null && wcStatus.Attributes["wc-locked"].InnerText == "true") { versionControlStatus.repositoryStatus = VCRepositoryStatus.Locked; } if (wcStatus.Attributes["tree-conflicted"] != null) { versionControlStatus.treeConflictStatus = (wcStatus.Attributes["tree-conflicted"].InnerText == "true") ? VCTreeConflictStatus.TreeConflict : VCTreeConflictStatus.Normal; } /*if (wcStatus.Attributes["moved-from"] != null) * { * var movedFrom = new ComposedString(wcStatus.Attributes["moved-from"].InnerText.Replace('\\', '/').Trim()); * if (movedFrom.StartsWith(dot)) * { * var lastIndex = assetPath.FindLastIndex(slash); * if (lastIndex != -1) * { * versionControlStatus.movedFrom = assetPath.GetSubset(0, lastIndex + 1) + movedFrom; * } * } * else * { * versionControlStatus.movedFrom = movedFrom; * } * Debug.Log($"Moved From {movedFrom} => {assetPath} : {versionControlStatus.movedFrom}"); * }*/ XmlElement commit = wcStatus["commit"]; if (commit != null) { if (commit.Attributes["revision"] != null) { versionControlStatus.lastModifiedRevision = Int32.Parse(commit.Attributes["revision"].InnerText); } if (commit["author"] != null) { versionControlStatus.user = commit["author"].InnerText; } } XmlElement lockStatus = wcStatus["lock"]; if (lockStatus != null) { if (lockStatus["owner"] != null) { versionControlStatus.owner = lockStatus["owner"].InnerText; } if (lockStatus["token"] != null) { versionControlStatus.lockToken = lockStatus["token"].InnerText; } versionControlStatus.lockStatus = VCLockStatus.LockedHere; } } return(versionControlStatus); }
public virtual VersionControlStatus GetAssetStatus(ComposedString assetPath) { return defaultStatus; }