Example #1
0
        private static CommitSelectionExpression RelativeCommitSelection(
            this CommitSelectionExpression parentExp,
            string revision,
            Func <CommitSelectionExpression, int, CommitSelectionExpression> numberFilter,
            Func <CommitSelectionExpression, BranchMask, CommitSelectionExpression> branchFilter)
        {
            if (revision == null)
            {
                return(parentExp);
            }

            var revisionData = (
                from c in parentExp.Queryable <Commit>().Where(x => x.Revision == revision)
                join b in parentExp.Queryable <Branch>() on c.BranchId equals b.Id
                select new
            {
                Number = c.Number,
                Branch = b,
            }).SingleOrDefault();

            if (revisionData == null)
            {
                return(parentExp.Reselect(c => c.Take(0)));
            }

            return(parentExp
                   .Reselect(s => numberFilter(s, revisionData.Number))
                   .Reselect(s => branchFilter(s, revisionData.Branch.Mask)));
        }
Example #2
0
 public static CommitSelectionExpression FromRevision(
     this CommitSelectionExpression parentExp, string revision)
 {
     return(RelativeCommitSelection(
                parentExp,
                revision,
                (s, number) => s.FromNumber(number),
                (s, mask) => s.OnBranchForward(mask)));
 }
Example #3
0
 public static CommitSelectionExpression ByAuthors(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.Reselect(s =>
                               from c in s
                               join a in parentExp.Selection <Author>() on c.AuthorId equals a.Id
                               select c
                               ));
 }
Example #4
0
 public static CommitSelectionExpression TillRevision(
     this CommitSelectionExpression parentExp, string revision)
 {
     return(RelativeCommitSelection(
                parentExp,
                revision,
                (s, number) => s.TillNumber(number),
                (s, mask) => s.OnBranchBack(mask)));
 }
Example #5
0
 public static CommitSelectionExpression HasAttribute(
     this CommitSelectionExpression parentExp, string attributeType)
 {
     return(parentExp.Reselect(s =>
                               (from c in s
                                join ca in parentExp.Queryable <CommitAttribute>()
                                .Where(x => x.Type == attributeType) on c.Number equals ca.CommitNumber
                                select c).Distinct()
                               ));
 }
Example #6
0
 public static CommitSelectionExpression ContainModifications(this CommitSelectionExpression parentExp)
 {
     return(parentExp.Reselect(s =>
                               (
                                   from c in s
                                   join m in parentExp.Selection <Modification>() on c.Number equals m.CommitNumber
                                   select c
                               ).Distinct()
                               ));
 }
Example #7
0
 public static CommitSelectionExpression AreRefactorings(this CommitSelectionExpression parentExp)
 {
     return(parentExp.Reselect(s => s.Where(commit =>
                                            (from c in s
                                             join m in parentExp.Queryable <Modification>() on c.Number equals m.CommitNumber
                                             join cb in parentExp.Queryable <CodeBlock>() on m.Id equals cb.ModificationId
                                             where cb.TargetCodeBlock == null || cb.Size < 0
                                             group cb.Size by c.Number)
                                            .Where(x => x.Sum() <= 0).Select(x => x.Key).Contains(commit.Number))));
 }
Example #8
0
 public static CommitSelectionExpression NotByAuthors(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.Reselect(s =>
                               from c in s
                               join a in parentExp.Selection <Author>() on c.AuthorId equals a.Id into agroup
                               from author in agroup.DefaultIfEmpty()
                               where author == null
                               select c
                               ));
 }
Example #9
0
 public static CommitSelectionExpression TouchFiles(this CommitSelectionExpression parentExp)
 {
     return(parentExp.Reselect(s =>
                               (
                                   from c in s
                                   join m in parentExp.Queryable <Modification>() on c.Number equals m.CommitNumber
                                   join f in parentExp.Selection <CodeFile>() on m.FileId equals f.Id
                                   select c
                               ).Distinct()
                               ));
 }
Example #10
0
        public static CommitSelectionExpression FromTag(
            this CommitSelectionExpression parentExp, string tag)
        {
            var commitWithTag = parentExp.Fixed().WithTags(tag).SingleOrDefault();

            if (commitWithTag == null)
            {
                return(parentExp.Reselect(c => c.Take(0)));
            }

            return(parentExp.FromRevision(commitWithTag.Revision));
        }
Example #11
0
 public static CommitSelectionExpression HasNotAttribute(
     this CommitSelectionExpression parentExp, string attributeType)
 {
     return(parentExp.Reselect(s =>
                               from c in s
                               join ca in parentExp.Queryable <CommitAttribute>()
                               .Where(x => x.Type == attributeType) on c.Number equals ca.CommitNumber into caGroup
                               from caNullable in caGroup.DefaultIfEmpty()
                               where caNullable == null
                               select c
                               ));
 }
Example #12
0
 public static CommitSelectionExpression WithTags(
     this CommitSelectionExpression parentExp, params string[] tags)
 {
     return(parentExp.Reselect(s =>
                               (from c in s
                                join ca in parentExp.Selection <CommitAttribute>() on c.Number equals ca.CommitNumber
                                where
                                ca.Type == CommitAttribute.TAG &&
                                tags.Contains(ca.Data)
                                select c).Distinct()
                               ));
 }
Example #13
0
 public static CommitSelectionExpression OnBranchForward(
     this CommitSelectionExpression parentExp, BranchMask mask)
 {
     return(parentExp.Reselect(s =>
                               from c in s
                               join br in parentExp.Queryable <Branch>() on c.BranchId equals br.Id
                               let branch_bit_pos = mask.Data.Length + mask.Offset - 1 - br.Mask.Offset
                                                    where
                                                    (branch_bit_pos < 0)
                                                    ||
                                                    (branch_bit_pos < br.Mask.Data.Length && br.Mask.Data.Substring(branch_bit_pos, 1) == "1")
                                                    select c));
 }
Example #14
0
 public static CommitSelectionExpression AreNotSplits(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.HasNotAttribute(CommitAttribute.SPLIT));
 }
Example #15
0
 public static CommitSelectionExpression AreTagged(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.HasAttribute(CommitAttribute.TAG));
 }
Example #16
0
 public static CommitSelectionExpression AreMerges(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.HasAttribute(CommitAttribute.MERGE));
 }
Example #17
0
 public static CommitSelectionExpression AreBugFixes(
     this CommitSelectionExpression parentExp)
 {
     return(parentExp.HasAttribute(CommitAttribute.FIX));
 }