Beispiel #1
0
        /// <summary>
        /// Finds objects of the same name, but different hashes
        /// </summary>
        private static void FindModifieds(ChangelogBuilder changelog, string prefix, VDKeyedCollection byName,
                                          VDKeyedCollection otherByName)
        {
            var toRemove = new LinkedList <string>();

            foreach (var otherVD in otherByName)
            {
                //if (byName.ContainsKey(pair.Key))
                if (byName.Contains(otherVD.Filename))
                {
                    VersionData thisVD = byName[otherVD.Filename];
                    if (otherVD.Filetype == thisVD.Filetype)
                    {
                        string fpath = PrefixFilename(prefix, otherVD.Filename);
                        changelog.Modify(fpath, otherVD.Hash);
                        if (otherVD.Filetype == FileType.Directory)
                        {
                            var subchangelog = BuildChangelog(thisVD, otherVD, fpath);
                            changelog.Aggregate(subchangelog);
                        }
                        toRemove.AddLast(otherVD.Filename);
                    }
                }
            }
            foreach (string s in toRemove)
            {
                byName.Remove(s);
                otherByName.Remove(s);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Selects all files that were altered in some way (added, modified, removed, or renamed)
 /// </summary>
 /// <param name="thisVD"></param>
 /// <param name="otherVD"></param>
 /// <param name="byName"></param>
 /// <param name="byHash"></param>
 private static void AddAlteredFiles(VDKeyedCollection thisVD, VDKeyedCollection otherVD, VDKeyedCollection
                                     byName, Dictionary <string, LinkedList <string> > byHash)
 {
     foreach (var pair in thisVD)
     {
         string name     = pair.Filename;
         string hash     = pair.Hash;
         bool   contains = false;
         if (otherVD.Contains(name)) //if the file has not been altered
         {
             contains = true;
             if (hash == otherVD[name].Hash)
             {
                 continue;
             }
         }
         if (!byHash.ContainsKey(hash))
         {
             byHash[hash] = new LinkedList <string>();
         }
         if (contains) //prioritize renaming files with no counterpart
         {
             byHash[hash].AddLast(name);
         }
         else
         {
             byHash[hash].AddFirst(name);
         }
         byName.Add(pair);
     }
 }