示例#1
0
 public bool Equals(SVNStatusData other)
 {
     return(Status == other.Status &&
            PropertyStatus == other.PropertyStatus &&
            TreeConflictStatus == other.TreeConflictStatus &&
            LockStatus == other.LockStatus &&
            RemoteStatus == other.RemoteStatus
            );
 }
示例#2
0
        private void AddModifiedFolders(SVNStatusData statusData)
        {
            var status = statusData.Status;

            if (status == VCFileStatus.Unversioned || status == VCFileStatus.Ignored || status == VCFileStatus.Normal)
            {
                return;
            }

            if (statusData.IsConflicted)
            {
                statusData.Status = VCFileStatus.Conflicted;
            }
            else if (status != VCFileStatus.Modified)
            {
                statusData.Status = VCFileStatus.Modified;
            }

            // Folders don't have locks.
            statusData.LockStatus = VCLockStatus.NoLock;

            statusData.Path = Path.GetDirectoryName(statusData.Path);

            while (!string.IsNullOrEmpty(statusData.Path))
            {
                // "Packages" folder doesn't have valid guid. "Assets" do have a special guid.
                if (statusData.Path == "Packages")
                {
                    break;
                }

                var guid = AssetDatabase.AssetPathToGUID(statusData.Path);

                // Folder may be deleted.
                if (string.IsNullOrWhiteSpace(guid))
                {
                    return;
                }

                // Added folders should not be shown as modified.
                if (GetKnownStatusData(guid).Status == VCFileStatus.Added)
                {
                    return;
                }

                bool moveToNext = SetStatusData(guid, statusData, false, false);

                // If already exists, upper folders should be added as well.
                if (!moveToNext)
                {
                    return;
                }

                statusData.Path = Path.GetDirectoryName(statusData.Path);
            }
        }
示例#3
0
 public bool Equals(SVNStatusData other)
 {
     return(Status == other.Status &&
            PropertiesStatus == other.PropertiesStatus &&
            TreeConflictStatus == other.TreeConflictStatus &&
            SwitchedExternalStatus == other.SwitchedExternalStatus &&
            LockStatus == other.LockStatus &&
            RemoteStatus == other.RemoteStatus
            );
 }
        private bool SetStatusData(string guid, SVNStatusData statusData, bool skipPriorityCheck)
        {
            if (string.IsNullOrEmpty(guid))
            {
                Debug.LogError($"SVN: Trying to add empty guid for \"{statusData.Path}\" with status {statusData.Status}");
                return(false);
            }

            foreach (var bind in StatusDatas)
            {
                if (bind.Guid.Equals(guid, StringComparison.Ordinal))
                {
                    if (bind.Data.Equals(statusData))
                    {
                        return(false);
                    }

                    // This is needed because the status of the meta might differ. In that case take the stronger status.
                    if (!skipPriorityCheck)
                    {
                        if (m_StatusPriority[bind.Data.Status] > m_StatusPriority[statusData.Status])
                        {
                            // Merge any other data.
                            if (bind.Data.LockStatus == VCLockStatus.NoLock)
                            {
                                bind.Data.LockStatus = statusData.LockStatus;
                            }
                            if (bind.Data.RemoteStatus == VCRemoteFileStatus.None)
                            {
                                bind.Data.RemoteStatus = statusData.RemoteStatus;
                            }

                            return(false);
                        }
                    }

                    bind.Data = statusData;
                    return(true);
                }
            }

            StatusDatas.Add(new GuidStatusDataBind()
            {
                Guid = guid, Data = statusData
            });
            return(true);
        }
示例#5
0
        private bool SetStatusData(string guid, SVNStatusData statusData, bool skipPriorityCheck, bool isMeta)
        {
            if (string.IsNullOrEmpty(guid))
            {
                Debug.LogError($"SVN: Trying to add empty guid for \"{statusData.Path}\" with status {statusData.Status}");
                return(false);
            }

            foreach (var bind in m_Data)
            {
                if (bind.Key.Equals(guid, StringComparison.Ordinal))
                {
                    if (!isMeta && bind.AssetStatusData.Equals(statusData))
                    {
                        return(false);
                    }

                    if (isMeta && bind.MetaStatusData.Equals(statusData))
                    {
                        return(false);
                    }

                    if (!isMeta)
                    {
                        bind.AssetStatusData = statusData;
                    }
                    else
                    {
                        bind.MetaStatusData = statusData;
                    }

                    // This is needed because the status of the meta might differ. In that case take the stronger status.
                    if (!skipPriorityCheck)
                    {
                        if (m_StatusPriority[bind.MergedStatusData.Status] > m_StatusPriority[statusData.Status])
                        {
                            // Merge any other data.
                            if (bind.MergedStatusData.PropertiesStatus == VCPropertiesStatus.Normal)
                            {
                                bind.MergedStatusData.PropertiesStatus = statusData.PropertiesStatus;
                            }
                            if (bind.MergedStatusData.TreeConflictStatus == VCTreeConflictStatus.Normal)
                            {
                                bind.MergedStatusData.TreeConflictStatus = statusData.TreeConflictStatus;
                            }
                            if (bind.MergedStatusData.SwitchedExternalStatus == VCSwitchedExternal.Normal)
                            {
                                bind.MergedStatusData.SwitchedExternalStatus = statusData.SwitchedExternalStatus;
                            }
                            if (bind.MergedStatusData.LockStatus == VCLockStatus.NoLock)
                            {
                                bind.MergedStatusData.LockStatus  = statusData.LockStatus;
                                bind.MergedStatusData.LockDetails = statusData.LockDetails;
                            }
                            if (bind.MergedStatusData.RemoteStatus == VCRemoteFileStatus.None)
                            {
                                bind.MergedStatusData.RemoteStatus = statusData.RemoteStatus;
                            }

                            return(false);
                        }
                    }

                    bind.MergedStatusData = statusData;
                    if (isMeta)
                    {
                        bind.MergedStatusData.Path = statusData.Path.Substring(0, statusData.Path.LastIndexOf(".meta"));
                    }
                    return(true);
                }
            }

            m_Data.Add(new GuidStatusDatasBind()
            {
                Key = guid,
                MergedStatusData = statusData,

                AssetStatusData = isMeta ? new SVNStatusData() : statusData,
                MetaStatusData  = isMeta ? statusData : new SVNStatusData(),
            });

            if (isMeta)
            {
                m_Data.Last().MergedStatusData.Path = statusData.Path.Substring(0, statusData.Path.LastIndexOf(".meta"));
            }

            return(true);
        }
示例#6
0
		private static IEnumerable<SVNStatusData> ExtractStatuses(string output, SVNStatusDataOptions options)
		{
			using (var sr = new StringReader(output)) {
				string line;
				while ((line = sr.ReadLine()) != null) {

					var lineLen = line.Length;

					// Last status was deleted / added+, so this is telling us where it moved to / from. Skip it.
					if (lineLen > 8 && line[8] == '>')
						continue;

					// Tree conflict "local dir edit, incoming dir delete or move upon switch / update" or similar.
					if (lineLen > 6 && line[6] == '>')
						continue;

					// If there are any conflicts, the report will have two additional lines like this:
					// Summary of conflicts:
					// Text conflicts: 1
					if (line.StartsWith("Summary", StringComparison.Ordinal))
						break;

					// If -u is used, additional line is added at the end:
					// Status against revision:     14
					if (line.StartsWith("Status", StringComparison.Ordinal))
						break;

					// All externals append separate sections with their statuses:
					// Performing status on external item at '...':
					if (line.StartsWith("Performing status", StringComparison.Ordinal))
						continue;

					// If user has files in the "ignore-on-commit" list, this is added at the end plus empty line:
					// ---Changelist 'ignore-on-commit': ...
					if (string.IsNullOrEmpty(line))
						continue;
					if (line.StartsWith("---", StringComparison.Ordinal))
						break;

					// Rules are described in "svn help status".
					var statusData = new SVNStatusData();
					statusData.Status = m_FileStatusMap[line[0]];
					statusData.PropertyStatus = m_PropertyStatusMap[line[1]];
					statusData.LockStatus = m_LockStatusMap[line[5]];
					statusData.TreeConflictStatus = m_ConflictStatusMap[line[6]];
					statusData.LockDetails = LockDetails.Empty;

					// 7 columns statuses + space;
					int pathStart = 7 + 1;

					if (!options.Offline) {
						// + remote status + revision
						pathStart += 13;
						statusData.RemoteStatus = m_RemoteStatusMap[line[8]];
					}

					statusData.Path = line.Substring(pathStart);

					// NOTE: If you pass absolute path to svn, the output will be with absolute path -> always pass relative path and we'll be good.
					// If path is not relative, make it.
					//if (!statusData.Path.StartsWith("Assets", StringComparison.Ordinal)) {
					//	// Length+1 to skip '/'
					//	statusData.Path = statusData.Path.Remove(0, ProjectRoot.Length + 1);
					//}

					if (IsHiddenPath(statusData.Path))
						continue;


					if (!options.Offline && options.FetchLockOwner) {
						if (statusData.LockStatus != VCLockStatus.NoLock && statusData.LockStatus != VCLockStatus.BrokenLock) {
							statusData.LockDetails = FetchLockDetails(statusData.Path, options.Timeout, options.RaiseError);
						}
					}

					yield return statusData;
				}
			}
		}