public static CodeBlockMappingExpression RemoveCode(this IModificationMappingExpression exp) { var file = exp.CurrentEntity <CodeFile>(); var currentCommitBranch = exp.CurrentEntity <Branch>(); var commitsOnBranch = exp.SelectionDSL().Commits() .OnBranchBack(currentCommitBranch.Mask); return(DoWithRemainingCode( exp, commitsOnBranch, file.Id, RemoveCodeBlock)); }
public static CodeBlockMappingExpression UpdateCode( this IModificationMappingExpression exp, Func <IModificationMappingExpression, string, double, CodeBlockMappingExpression> codeToExp) { var file = exp.CurrentEntity <CodeFile>(); var currentCommitBranch = exp.CurrentEntity <Branch>(); var commitsOnBranch = exp.SelectionDSL().Commits() .OnBranchBack(currentCommitBranch.Mask); return(DoWithRemainingCode( exp, commitsOnBranch, file.Id, codeToExp)); }
public static CodeBlockMappingExpression DeleteCode(this IModificationMappingExpression exp) { CodeBlockMappingExpression lastCodeBlockExp = null; foreach (var codeByAddedCode in ( from cb in exp.Queryable <CodeBlock>() join m in exp.Queryable <Modification>() on cb.ModificationID equals m.ID join f in exp.Queryable <ProjectFile>() on m.FileID equals f.ID let addedCodeID = cb.Size < 0 ? cb.TargetCodeBlockID : cb.ID where f.ID == exp.CurrentEntity <ProjectFile>().ID group cb.Size by addedCodeID ) ) { double currentCodeSize = codeByAddedCode.Sum(); if (currentCodeSize != 0) { if (lastCodeBlockExp == null) { lastCodeBlockExp = exp.Code(-currentCodeSize); } else { lastCodeBlockExp = lastCodeBlockExp.Code(-currentCodeSize); } lastCodeBlockExp.ForCodeAddedInitiallyInRevision( RevisionCodeBlockWasInitiallyAddedIn(exp, codeByAddedCode.Key ?? 0) ); } } return(lastCodeBlockExp); }
public static CodeBlockMappingExpression CopyCode(this IModificationMappingExpression exp) { var modification = exp.CurrentEntity <Modification>(); var sourceCommit = ( from c in exp.GetReadOnly <Commit>().Where(x => x.Number == modification.SourceCommit.Number) join b in exp.GetReadOnly <Branch>() on c.BranchId equals b.Id select new { c.Number, b.Mask }).Single(); var commitsOnBranch = exp.SelectionDSL().Commits() .OnBranchBack(sourceCommit.Mask) .Where(x => x.Number <= sourceCommit.Number); return(DoWithRemainingCode( exp, commitsOnBranch, modification.SourceFile.Id, CopyCodeBlock)); }