Esempio n. 1
0
        private void RefreshLoop()
        {
            try
            {
                while (!requestRefreshLoopStop)
                {
                    if (active && refreshLoopActive)
                    {
                        // make sure p4 data is initialized
                        if (P4Util.Instance.P4Initialized || InitializeP4Connection())
                        {
                            // refresh status
                            RefreshStatusDatabase();

                            lock (p4QueueLockToken)
                            {
                                // run p4 ops
                                if (p4OpQueue.Count > 0)
                                {
                                    P4QueueItem item = p4OpQueue[0];
                                    p4OpQueue.RemoveAt(0);
                                    GetStatus(item.level, "fstat -T " + fstatAttributes, item.path);
                                }
                            }
                        }
                    }
                }
            }
            catch (ThreadAbortException) { }
            catch (AppDomainUnloadedException) { }
            catch (Exception e)
            {
                DebugLog.ThrowException(e);
            }
            if (!requestRefreshLoopStop)
            {
                RefreshLoop();
            }
        }
Esempio n. 2
0
        public bool Status(IEnumerable <string> assets, StatusLevel statusLevel)
        {
            //D.Log(statusLevel.ToString());
            if (!active)
            {
                return(false);
            }
            if (statusLevel == StatusLevel.Previous)
            {
                statusLevel = StatusLevel.Local;
                foreach (var assetIt in assets)
                {
                    if (GetAssetStatus(assetIt).reflectionLevel == VCReflectionLevel.Repository && statusLevel == StatusLevel.Local)
                    {
                        statusLevel = StatusLevel.Remote;
                    }
                }
            }

            SetPending(assets);

            string diffRootToWorking = P4Util.Instance.Vars.workingDirectory.Replace("\\", Path.DirectorySeparatorChar.ToString()).Replace(rootPath, "");

            lock (p4QueueLockToken)
            {
                // add all assets to p4 queue (in reverse order since we're going to be inserting them at the beginning)
                string[] _assets = assets.ToArray();
                for (int i = _assets.Length - 1; i >= 0; i--)
                {
                    string a = _assets[i];
                    if (a.StartsWith("/"))
                    {
                        a = a.Substring(1);
                    }
                    if (Directory.Exists(rootPath + diffRootToWorking + "/" + a))
                    {
                        // only check files within the directory
                        a = a + "/*";
                    }
                    else
                    {
                        // let all scenes through so that the scene view GUI is updated as quickly as possible
                        if (!a.ToLower().EndsWith(".unity"))
                        {
                            // single file - make sure it's not already covered by a directory in the queue (or if it's a sibling of
                            // something already in there, remove that item and check the whole directory instead)
                            string      qItemPath        = "//" + P4Util.Instance.Vars.clientSpec + diffRootToWorking + "/" + a.Replace("//", "/");
                            int         lastIndexOfSlash = qItemPath.LastIndexOf("/");
                            P4QueueItem itemToRemove     = null;
                            bool        found            = false;
                            foreach (P4QueueItem item in p4OpQueue)
                            {
                                if (item.level == statusLevel)
                                {
                                    if (item.path.LastIndexOf("/") == lastIndexOfSlash)
                                    {
                                        // same leaf node
                                        if (item.path.Contains("*") || item.path.Contains("..."))
                                        {
                                            // already covered by a directory entry
                                            found = true;
                                            break;
                                        }
                                        else
                                        {
                                            // this is a sibling of the desired item, flag it for removal
                                            itemToRemove = item;

                                            // add the entire directory instead and continue (don't worry about duplicate adds, the
                                            // Distinct() call below will filter them out
                                            a = a.Substring(0, a.LastIndexOf("/") + 1) + "*";
                                            break;
                                        }
                                    }
                                }
                            }

                            // if we need to remove an item, do so here after we're done with the loop
                            if (itemToRemove != null)
                            {
                                p4OpQueue.Remove(itemToRemove);
                            }

                            // don't insert if it's already in the queue
                            if (found)
                            {
                                continue;
                            }
                        }
                    }
                    // this is a high-priority operation since specific assets are being asked for, put it at the front of the queue
                    p4OpQueue.Insert(0, new P4QueueItem(statusLevel, "//" + P4Util.Instance.Vars.clientSpec + diffRootToWorking + "/" + a.Replace("//", "/")));
                }
                p4OpQueue = new List <P4QueueItem>(p4OpQueue.Distinct(new P4QueueItemComparer()));
            }

            return(true);
        }