Esempio n. 1
0
        // ------------------------------------------------------------------------
        /// Add a root directory and query the status of the contining files
        /// by a QueryRootStatus call.
        // ------------------------------------------------------------------------
        public bool AddRootDirectory(string directory)
        {
            if (directory == string.Empty)
            {
                return(false);
            }

            string root = HG.FindRootDirectory(directory);

            if (root != string.Empty && !_rootDirMap.ContainsKey(root))
            {
                _rootDirMap[root] = new RootInfo()
                {
                    _Branch = HG.GetCurrentBranchName(root)
                };

                if (!_directoryWatcherMap.ContainsDirectory(root))
                {
                    _directoryWatcherMap.WatchDirectory(root);
                }

                Dictionary <string, char> fileStatusDictionary;
                if (HG.QueryRootStatus(root, out fileStatusDictionary))
                {
                    _fileStatusDictionary.Add(fileStatusDictionary);
                }
            }

            return(true);
        }
Esempio n. 2
0
        // ------------------------------------------------------------------------
        // update given root files status.
        // ------------------------------------------------------------------------
        public void UpdateFileStatus(string root)
        {
            Dictionary <string, char> fileStatusDictionary;

            if (HG.QueryRootStatus(root, out fileStatusDictionary))
            {
                _fileStatusDictionary.Add(fileStatusDictionary);
            }
        }
Esempio n. 3
0
        // ------------------------------------------------------------------------
        // rebuild the entire _fileStatusDictionary map
        // this includes all files in all watched directories
        // ------------------------------------------------------------------------
        void RebuildStatusCache()
        {
            // remove all status entries
            _fileStatusDictionary.Clear();

            _bRebuildStatusCacheRequired = false;

            SkipDirstate(true);

            HGFileStatusInfoDictionary newFileStatusDictionary = new HGFileStatusInfoDictionary();

            foreach (var directoryWatcher in _directoryWatcherMap.WatcherList)
            {
                // reset the watcher map
                directoryWatcher.Value.PopDirtyFilesMap();
            }

            List <string> rootDirList = null;

            lock (_rootDirMap)
            {
                rootDirList = new List <string>(_rootDirMap.Keys);
            }

            // sort dirs by lenght to query from root top to down root
            rootDirList.Sort((a, b) => ((a.Length == b.Length) ? 0 : ((a.Length > b.Length) ? 1 : -1)));
            foreach (string rootDirectory in rootDirList)
            {
                if (rootDirectory != string.Empty)
                {
                    _rootDirMap[rootDirectory]._Branch = HG.GetCurrentBranchName(rootDirectory);

                    Dictionary <string, char> fileStatusDictionary;
                    if (HG.QueryRootStatus(rootDirectory, out fileStatusDictionary))
                    {
                        Trace.WriteLine("RebuildStatusCache - number of files: " + fileStatusDictionary.Count.ToString());
                        newFileStatusDictionary.Add(fileStatusDictionary);
                    }
                }
            }

            lock (_fileStatusDictionary)
            {
                _fileStatusDictionary = newFileStatusDictionary;
            }

            SkipDirstate(false);
        }