Exemplo n.º 1
0
        public static VcsDataMapper ConstructDataMapper(
            IDataStore data,
            IVcsData vcsData,
            MappingSettings settings)
        {
            VcsDataMapper dataMapper = new VcsDataMapper(data, vcsData, settings);

            dataMapper.RegisterMapper(new CommitMapper(vcsData));
            dataMapper.RegisterMapper(new TagMapper(vcsData));
            var bugFixDetector = new BugFixDetectorBasedOnLogMessage();

            if (settings.FixMessageKeyWords != null)
            {
                bugFixDetector.KeyWords = settings.FixMessageKeyWords.Split(' ');
            }
            if (settings.FixMessageStopWords != null)
            {
                bugFixDetector.StopWords = settings.FixMessageStopWords.Split(' ');
            }
            dataMapper.RegisterMapper(new BugFixMapper(vcsData, bugFixDetector));
            dataMapper.RegisterMapper(new CommitAttributeMapper(vcsData));
            dataMapper.RegisterMapper(new AuthorMapper(vcsData));
            dataMapper.RegisterMapper(new BranchMapper(vcsData));
            dataMapper.RegisterMapper(new CodeFileMapper(vcsData)
            {
                FastMergeProcessing = settings.FastMergeProcessing
            });
            dataMapper.RegisterMapper(new ModificationMapper(vcsData));
            dataMapper.RegisterMapper(new BlamePreLoader(vcsData), true);
            dataMapper.RegisterMapper(new CodeBlockMapper(vcsData));

            return(dataMapper);
        }
Exemplo n.º 2
0
        static VcsDataMapper ConstructDataMapper(
            IDataStore data, IVcsData vcsData, VcsDataMapper.MappingSettings settings)
        {
            var dataMapper = VcsDataMapper.ConstructDataMapper(
                data,
                vcsData,
                settings);

            dataMapper.OnMapRevision += revision =>
            {
                Console.WriteLine("mapping of revision {0}", revision);
            };
            dataMapper.OnTruncateRevision += revision =>
            {
                Console.WriteLine("truncating of revision {0}", revision);
            };
            dataMapper.OnCheckRevision += revision =>
            {
                Console.WriteLine("checking of revision {0}", revision);
            };
            dataMapper.OnError += message =>
            {
                Console.WriteLine(message);
            };
            return(dataMapper);
        }
Exemplo n.º 3
0
 public VcsDataMapper(
     IDataStore data,
     IVcsData vcsData,
     MappingSettings settings)
 {
     this.data     = data;
     this.vcsData  = vcsData;
     this.settings = settings;
 }
Exemplo n.º 4
0
        static void BlameDiff(IVcsData vcsData)
        {
            var r0 = "41f93a2c903a45167b26c2dc93d45ffa9a9bbd49";
            var r1 = "c2f3bf071ee90b01f2d629921bb04c4f798f02fa";

            var file = "/test-delta.c";

            var blame0 = vcsData.Blame(r0, file);
            var blame1 = vcsData.Blame(r1, file);
            var diff01 = blame0.Diff(blame1);

            Console.WriteLine();
        }
Exemplo n.º 5
0
        static void FileHistory(IDataStore data, IVcsData vcsData, string path)
        {
            using (var s = data.OpenSession())
            {
                var modifications =
                    (from f in s.GetReadOnly <CodeFile>()
                     join m in s.GetReadOnly <Modification>() on f.Id equals m.FileId
                     join c in s.GetReadOnly <Commit>() on m.CommitNumber equals c.Number
                     join cb in s.GetReadOnly <CodeBlock>() on m.Id equals cb.ModificationId
                     where f.Path == path
                     group cb by new { m.Action, c.Revision, c.Number, c.Date } into modCode
                     select new
                {
                    Action = modCode.Key.Action,
                    Revision = modCode.Key.Revision,
                    Number = modCode.Key.Number,
                    Date = modCode.Key.Date,
                    Added = modCode.Sum(
                        x => x.TargetCodeBlockId == null ? x.Size : 0),
                    Removed = modCode.Sum(
                        x => x.Size < 0 ? x.Size : 0),
                    Compensated = modCode.Sum(
                        x => (x.TargetCodeBlockId != null && x.Size > 0) ? x.Size : 0),
                }).ToArray();

                Console.WriteLine(path);

                foreach (var m in modifications.OrderByDescending(x => x.Number))
                {
                    var linesCount = (m.Action == TouchedFileAction.REMOVED)
                                                ? 0
                                                : vcsData.Blame(m.Revision, path).Values.Sum();
                    Console.WriteLine(string.Format("{0} ({1}) {2} {3} +{4} -{5} +{6} loc: {7}",
                                                    m.Revision,
                                                    m.Number,
                                                    m.Date.ToShortDateString(),
                                                    m.Action,
                                                    m.Added,
                                                    Math.Abs(m.Removed),
                                                    m.Compensated,
                                                    linesCount));
                }
            }
        }
Exemplo n.º 6
0
 public BlamePreLoader(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 7
0
 public CommitMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 8
0
 public BaseMapperTest()
 {
     vcsData = Substitute.For <IVcsData>();
 }
Exemplo n.º 9
0
 public CommitAttributeMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 10
0
 public Mapper(IVcsData vcsData)
 {
     this.vcsData = vcsData;
 }
Exemplo n.º 11
0
 public CodeFileMapper(IVcsData vcsData)
     : base(vcsData)
 {
     FastMergeProcessing = false;
 }
Exemplo n.º 12
0
 public ModificationMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 13
0
        static void GetLog(IVcsData vcsData)
        {
            var r0 = "6c9de40fbcd0dbc62bffce68a82d170d62bb0df0";

            var log = vcsData.Log(r0);
        }
Exemplo n.º 14
0
 public VcsDataCachedTest()
 {
     innerData = Substitute.For <IVcsData>();
     cache     = new VcsDataCached(innerData);
 }
Exemplo n.º 15
0
 public BugFixMapper(IVcsData vcsData, IBugFixDetector bugFixDetector)
     : base(vcsData)
 {
     this.bugFixDetector = bugFixDetector;
 }
Exemplo n.º 16
0
 public AuthorMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 17
0
 public TagMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 18
0
 public BranchMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }
Exemplo n.º 19
0
 public CodeBlockMapper(IVcsData vcsData)
     : base(vcsData)
 {
 }