Ejemplo n.º 1
0
        internal static ObjectRepositoryAdd ComputeChanges_Added(IObjectRepository objectRepository, IObjectRepositorySerializer serializer, IRepository repository, PatchEntryChanges change, Func <string, string> relativeFileDataResolver)
        {
            // Only data file changes have to be taken into account
            // Changes made to the blobs will product a 'modified' change as well
            if (System.IO.Path.GetFileName(change.Path) != FileSystemStorage.DataFile)
            {
                return(null);
            }

            if (objectRepository.TryGetFromGitPath(change.Path) != null)
            {
                throw new NotImplementedException("Node already present in current state.");
            }
            var parentDataPath = change.Path.GetDataParentDataPath();

            if (objectRepository.TryGetFromGitPath(parentDataPath) == null)
            {
                throw new NotImplementedException("Node addition while parent has been deleted in head is not supported.");
            }

            var @new     = serializer.Deserialize(repository.Lookup <Blob>(change.Oid).GetContentStream(), relativeFileDataResolver);
            var parentId = change.Path.GetDataParentId(objectRepository);

            return(new ObjectRepositoryAdd(change.Path, @new, parentId));
        }
Ejemplo n.º 2
0
 private static IEnumerable <IMigration> GetCommitMigrations(IRepository repository, Commit previousCommit, Commit commit, IObjectRepositorySerializer serializer)
 {
     using (var changes = repository.Diff.Compare <TreeChanges>(previousCommit.Tree, commit.Tree))
     {
         foreach (var change in changes.Where(c => c.Path.StartsWith(FileSystemStorage.MigrationFolder, StringComparison.OrdinalIgnoreCase) && (c.Status == ChangeKind.Added || c.Status == ChangeKind.Modified)))
         {
             var blob = (Blob)commit[change.Path].Target;
             yield return((IMigration)serializer.Deserialize(blob.GetContentStream(),
                                                             relativePath => (commit[change.Path.GetSiblingFile(relativePath)]?.Target as Blob)?.GetContentText() ?? string.Empty));
         }
     }
 }
Ejemplo n.º 3
0
        internal static ObjectRepositoryDelete ComputeChanges_Deleted(IObjectRepositorySerializer serializer, IRepository repository, PatchEntryChanges change, Func <string, string> relativeFileDataResolver, Func <string, IList <TreeEntryChanges> > deletionConflictProvider = null)
        {
            // Only data file changes have to be taken into account
            // Changes made to the blobs will product a 'modified' change as well
            if (System.IO.Path.GetFileName(change.Path) != FileSystemStorage.DataFile)
            {
                return(null);
            }

            var conflicts = deletionConflictProvider?.Invoke(change.Path);

            if (conflicts?.Any() ?? false)
            {
                throw new NotImplementedException("Node deletion while children have been added or modified in head is not supported.");
            }

            var mergeBaseObject = serializer.Deserialize(repository.Lookup <Blob>(change.OldOid).GetContentStream(), relativeFileDataResolver);

            return(new ObjectRepositoryDelete(change.Path, mergeBaseObject.Id));
        }