private static void AddItemToDatabase(string[] fstatLines, int rootDirLength, string rootUnixDir, ref StatusDatabase statusDatabase)
 {
     if (fstatLines.Length > 0)
     {
         P4FStatData fileData = new P4FStatData();
         fileData.ReadFromLines(fstatLines);
         string unixPath = fileData.clientFile.Replace("\\", "/");
         if (unixPath.Length > rootDirLength)
         {
             string assetPath = unixPath.Remove(0, rootDirLength + 1);
             if (unixPath.Contains(rootUnixDir))
             {
                 var status = PopulateFromFstatData(fileData);
                 status.assetPath = assetPath;
                 statusDatabase[new ComposedString(assetPath)] = status;
             }
         }
     }
 }
 private static void AddItemToDatabase(string[] fstatLines, int rootDirLength, string rootUnixDir, ref StatusDatabase statusDatabase)
 {
     if (fstatLines.Length > 0)
     {
         P4FStatData fileData = new P4FStatData();
         fileData.ReadFromLines(fstatLines);
         string unixPath = fileData.clientFile.Replace("\\", "/");
         if (unixPath.Length > rootDirLength)
         {
             string assetPath = unixPath.Remove(0, rootDirLength + 1);
             if (unixPath.Contains(rootUnixDir))
             {
                 var status = PopulateFromFstatData(fileData);
                 status.assetPath = assetPath;
                 statusDatabase[new ComposedString(assetPath)] = status;
             }
         }
     }
 }
        private static VersionControlStatus PopulateFromFstatData(P4FStatData fileData)
        {
            var versionControlStatus = new VersionControlStatus();

            versionControlStatus.remoteStatus         = fileData.haveRev == fileData.headRev ? VCRemoteFileStatus.None : VCRemoteFileStatus.Modified;
            versionControlStatus.lastModifiedRevision = fileData.headRev == -1 ? 1 : fileData.headRev;
            versionControlStatus.revision             = fileData.haveRev == -1 ? 1 : fileData.haveRev;
            versionControlStatus.repositoryStatus     = VCRepositoryStatus.NotLocked; // this is only regarding the local copy
            versionControlStatus.user = "";                                           // supposed to be the last person who checked the file in - don't have that info in p4 fstat
            // we could do another p4 call, but that would not be performant for most cases
            versionControlStatus.changelist = fileData.change;

            if (fileData.otherLock)
            {
                versionControlStatus.lockStatus = VCLockStatus.LockedOther;
                versionControlStatus.owner      = fileData.otherOwner;
            }
            else if (fileData.ourLock)
            {
                versionControlStatus.lockStatus       = VCLockStatus.LockedHere;
                versionControlStatus.repositoryStatus = VCRepositoryStatus.Locked;
                versionControlStatus.owner            = fileData.actionOwner;
            }
            else
            {
                versionControlStatus.lockStatus = VCLockStatus.NoLock;
            }

            if (!String.IsNullOrEmpty(fileData.action))
            {
                switch (fileData.action)
                {
                case "add":
                    versionControlStatus.fileStatus = VCFileStatus.Added;
                    versionControlStatus.owner      = fileData.actionOwner;
                    break;

                case "edit":
                    // if we have it checked out and this is a "+l" type file, it must be locked
                    if (fileData.type.IndexOf("+l") != -1)
                    {
                        versionControlStatus.lockStatus       = VCLockStatus.LockedHere;
                        versionControlStatus.repositoryStatus = VCRepositoryStatus.Locked;
                    }
                    else if (versionControlStatus.lockStatus == VCLockStatus.NoLock)
                    {
                        versionControlStatus.allowLocalEdit = true;
                    }
                    versionControlStatus.owner = fileData.actionOwner;
                    break;

                case "delete":
                    versionControlStatus.fileStatus = VCFileStatus.Deleted;
                    versionControlStatus.owner      = fileData.actionOwner;
                    break;

                default:
                    D.LogError(String.Format("Unexpected action type: {0} for file {1} - status may be incorrect.", fileData.action, fileData.clientFile));
                    break;
                }
            }

            versionControlStatus.treeConflictStatus = VCTreeConflictStatus.Normal;

            //			if (wcStatus.Attributes["tree-conflicted"] != null) versionControlStatus.treeConflictStatus = (wcStatus.Attributes["tree-conflicted"].InnerText == "true") ? VCTreeConflictStatus.TreeConflict : VCTreeConflictStatus.Normal;


            return(versionControlStatus);
        }
        private static VersionControlStatus PopulateFromFstatData(P4FStatData fileData)
        {
            var versionControlStatus = new VersionControlStatus();

            versionControlStatus.remoteStatus = fileData.haveRev == fileData.headRev ? VCRemoteFileStatus.None : VCRemoteFileStatus.Modified;
            versionControlStatus.lastModifiedRevision = fileData.headRev == -1 ? 1 : fileData.headRev;
            versionControlStatus.revision = fileData.haveRev == -1 ? 1 : fileData.haveRev;
            versionControlStatus.repositoryStatus = VCRepositoryStatus.NotLocked;	// this is only regarding the local copy
            versionControlStatus.user = "";	// supposed to be the last person who checked the file in - don't have that info in p4 fstat
            // we could do another p4 call, but that would not be performant for most cases
            versionControlStatus.changelist = fileData.change;

            if (fileData.otherLock)
            {
                versionControlStatus.lockStatus = VCLockStatus.LockedOther;
                versionControlStatus.owner = fileData.otherOwner;
            }
            else if (fileData.ourLock)
            {
                versionControlStatus.lockStatus = VCLockStatus.LockedHere;
                versionControlStatus.repositoryStatus = VCRepositoryStatus.Locked;
                versionControlStatus.owner = fileData.actionOwner;
            }
            else
            {
                versionControlStatus.lockStatus = VCLockStatus.NoLock;
            }

            if (!String.IsNullOrEmpty(fileData.action))
            {
                switch (fileData.action)
                {
                    case "add":
                        versionControlStatus.fileStatus = VCFileStatus.Added;
                        versionControlStatus.owner = fileData.actionOwner;
                        break;
                    case "edit":
                        // if we have it checked out and this is a "+l" type file, it must be locked
                        if (fileData.type.IndexOf("+l") != -1)
                        {
                            versionControlStatus.lockStatus = VCLockStatus.LockedHere;
                            versionControlStatus.repositoryStatus = VCRepositoryStatus.Locked;
                        }
                        else if (versionControlStatus.lockStatus == VCLockStatus.NoLock)
                        {
                            versionControlStatus.allowLocalEdit = true;
                        }
                        versionControlStatus.owner = fileData.actionOwner;
                        break;
                    case "delete":
                        versionControlStatus.fileStatus = VCFileStatus.Deleted;
                        versionControlStatus.owner = fileData.actionOwner;
                        break;
                    default:
                        D.LogError(String.Format("Unexpected action type: {0} for file {1} - status may be incorrect.", fileData.action, fileData.clientFile));
                        break;
                }
            }

            versionControlStatus.treeConflictStatus = VCTreeConflictStatus.Normal;

            //			if (wcStatus.Attributes["tree-conflicted"] != null) versionControlStatus.treeConflictStatus = (wcStatus.Attributes["tree-conflicted"].InnerText == "true") ? VCTreeConflictStatus.TreeConflict : VCTreeConflictStatus.Normal;

            return versionControlStatus;
        }