Example #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);
            }
        }
Example #2
0
 /// <summary>
 /// Finds objects of the same hash but different names
 /// </summary>
 private static void FindRenames(ChangelogBuilder changelog, string prefix, VDKeyedCollection byName,
                                 VDKeyedCollection otherByName, Dictionary <string, LinkedList <string> > byHash,
                                 Dictionary <string, LinkedList <string> > otherByHash)
 {
     foreach (var pair in byHash)
     {
         if (otherByHash.ContainsKey(pair.Key))
         {
             var thisll  = pair.Value;
             var otherll = otherByHash[pair.Key];
             while (thisll.Count > 0 && otherll.Count > 0)
             {
                 string thisfile  = thisll.First.Value;
                 string otherfile = otherll.First.Value;
                 byName.Remove(thisfile);
                 otherByName.Remove(otherfile);
                 string thisfpath  = PrefixFilename(prefix, thisfile);
                 string otherfpath = PrefixFilename(prefix, otherfile);
                 changelog.Rename(thisfpath, otherfpath);
                 thisll.RemoveFirst();
                 otherll.RemoveFirst();
             }
         }
     }
 }