Esempio n. 1
0
        /// <exception cref="System.IO.IOException"></exception>
        private Tree BuildTree(Dictionary <string, string> headEntries)
        {
            Tree tree = new Tree(db);

            if (headEntries == null)
            {
                return(tree);
            }
            FileTreeEntry  fileEntry;
            Tree           parent;
            ObjectInserter oi = db.NewObjectInserter();

            try
            {
                foreach (KeyValuePair <string, string> e in headEntries.EntrySet())
                {
                    fileEntry = tree.AddFile(e.Key);
                    fileEntry.SetId(GenSha1(e.Value));
                    parent = fileEntry.GetParent();
                    while (parent != null)
                    {
                        parent.SetId(oi.Insert(Constants.OBJ_TREE, parent.Format()));
                        parent = parent.GetParent();
                    }
                }
                oi.Flush();
            }
            finally
            {
                oi.Release();
            }
            return(tree);
        }
Esempio n. 2
0
        /// <exception cref="System.IO.IOException"></exception>
        private void Commit(string commitMsg, PersonIdent author, PersonIdent committer)
        {
            NGit.CommitBuilder commit = new NGit.CommitBuilder();
            commit.Author    = author;
            commit.Committer = committer;
            commit.Message   = commitMsg;
            ObjectInserter inserter = db.NewObjectInserter();
            ObjectId       id;

            try
            {
                commit.TreeId = inserter.Insert(new TreeFormatter());
                id            = inserter.Insert(commit);
                inserter.Flush();
            }
            finally
            {
                inserter.Release();
            }
            int       nl = commitMsg.IndexOf('\n');
            RefUpdate ru = db.UpdateRef(Constants.HEAD);

            ru.SetNewObjectId(id);
            ru.SetRefLogMessage("commit : " + ((nl == -1) ? commitMsg : Sharpen.Runtime.Substring
                                                   (commitMsg, 0, nl)), false);
            ru.ForceUpdate();
        }
Esempio n. 3
0
		public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
		}
Esempio n. 4
0
 public virtual void Release()
 {
     if (inserter != null)
     {
         inserter.Release();
         inserter = null;
     }
 }
        /// <exception cref="System.IO.FileNotFoundException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        internal static DirCacheEditor.PathEdit Add(Repository db, FilePath workdir, string
                                                    path)
        {
            ObjectInserter inserter = db.NewObjectInserter();
            FilePath       f        = new FilePath(workdir, path);
            ObjectId       id       = inserter.Insert(Constants.OBJ_BLOB, IOUtil.ReadFully(f));

            return(new _PathEdit_81(f, id, path));
        }
Esempio n. 6
0
		public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
			merger = new DefaultNoteMerger();
			noteOn = tr.Blob("a");
			baseNote = NewNote("data");
		}
Esempio n. 7
0
        /// <summary>Insert this tree and obtain its ObjectId.</summary>
        /// <remarks>Insert this tree and obtain its ObjectId.</remarks>
        /// <param name="ins">the inserter to store the tree.</param>
        /// <returns>computed ObjectId of the tree</returns>
        /// <exception cref="System.IO.IOException">the tree could not be stored.</exception>
        public virtual ObjectId InsertTo(ObjectInserter ins)
        {
            if (buf != null)
            {
                return(ins.Insert(Constants.OBJ_TREE, buf, 0, ptr));
            }
            long len = overflowBuffer.Length();

            return(ins.Insert(Constants.OBJ_TREE, len, overflowBuffer.OpenInputStream()));
        }
Esempio n. 8
0
        /// <exception cref="System.IO.IOException"></exception>
        private ObjectId InsertTree(Tree tree)
        {
            ObjectInserter oi = db.NewObjectInserter();

            try
            {
                ObjectId id = oi.Insert(Constants.OBJ_TREE, tree.Format());
                oi.Flush();
                return(id);
            }
            finally
            {
                oi.Release();
            }
        }
            /// <summary>
            /// Update this index entry with stat and SHA-1 information if it looks
            /// like the file has been modified in the workdir.
            /// </summary>
            /// <remarks>
            /// Update this index entry with stat and SHA-1 information if it looks
            /// like the file has been modified in the workdir.
            /// </remarks>
            /// <param name="f">file in work dir</param>
            /// <returns>true if a change occurred</returns>
            /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
            public virtual bool Update(FilePath f)
            {
                long lm       = f.LastModified() * 1000000L;
                bool modified = this.mtime != lm;

                this.mtime = lm;
                if (this.size != f.Length())
                {
                    modified = true;
                }
                if (this._enclosing.Config_filemode())
                {
                    if (this._enclosing.File_canExecute(f) != FileMode.EXECUTABLE_FILE.Equals(this.mode
                                                                                              ))
                    {
                        this.mode = FileMode.EXECUTABLE_FILE.GetBits();
                        modified  = true;
                    }
                }
                if (modified)
                {
                    this.size = (int)f.Length();
                    ObjectInserter oi = this._enclosing.db.NewObjectInserter();
                    try
                    {
                        InputStream @in = new FileInputStream(f);
                        try
                        {
                            ObjectId newsha1 = oi.Insert(Constants.OBJ_BLOB, f.Length(), @in);
                            oi.Flush();
                            if (!newsha1.Equals(this.sha1))
                            {
                                modified = true;
                            }
                            this.sha1 = newsha1;
                        }
                        finally
                        {
                            @in.Close();
                        }
                    }
                    finally
                    {
                        oi.Release();
                    }
                }
                return(modified);
            }
Esempio n. 10
0
        /// <summary>Compute the ObjectId for this tree</summary>
        /// <param name="ins"></param>
        /// <returns>ObjectId for this tree</returns>
        public virtual ObjectId ComputeId(ObjectInserter ins)
        {
            if (buf != null)
            {
                return(ins.IdFor(Constants.OBJ_TREE, buf, 0, ptr));
            }
            long len = overflowBuffer.Length();

            try
            {
                return(ins.IdFor(Constants.OBJ_TREE, len, overflowBuffer.OpenInputStream()));
            }
            catch (IOException e)
            {
                // this should never happen
                throw new RuntimeException(e);
            }
        }
Esempio n. 11
0
 /// <exception cref="System.IO.IOException"></exception>
 private void BuildIndex(Dictionary <string, string> indexEntries)
 {
     dirCache = new DirCache(db.GetIndexFile(), db.FileSystem);
     if (indexEntries != null)
     {
         NUnit.Framework.Assert.IsTrue(dirCache.Lock());
         DirCacheEditor editor = dirCache.Editor();
         foreach (KeyValuePair <string, string> e in indexEntries.EntrySet())
         {
             WriteTrashFile(e.Key, e.Value);
             ObjectInserter inserter = db.NewObjectInserter();
             ObjectId       id       = inserter.Insert(Constants.OBJ_BLOB, Constants.Encode(e.Value));
             editor.Add(new DirCacheEditor.DeletePath(e.Key));
             editor.Add(new _PathEdit_287(id, e.Key));
         }
         NUnit.Framework.Assert.IsTrue(editor.Commit());
     }
 }
            /// <exception cref="System.IO.IOException"></exception>
            internal Entry(GitIndex _enclosing, byte[] key, FilePath f, int stage, byte[] newContent
                           )
            {
                this._enclosing = _enclosing;
                this.ctime      = f.LastModified() * 1000000L;
                this.mtime      = this.ctime;
                // we use same here
                this.dev = -1;
                this.ino = -1;
                if (this._enclosing.Config_filemode() && this._enclosing.File_canExecute(f))
                {
                    this.mode = FileMode.EXECUTABLE_FILE.GetBits();
                }
                else
                {
                    this.mode = FileMode.REGULAR_FILE.GetBits();
                }
                this.uid  = -1;
                this.gid  = -1;
                this.size = newContent.Length;
                ObjectInserter inserter = this._enclosing.db.NewObjectInserter();

                try
                {
                    InputStream @in = new FileInputStream(f);
                    try
                    {
                        this.sha1 = inserter.Insert(Constants.OBJ_BLOB, newContent);
                    }
                    finally
                    {
                        @in.Close();
                    }
                    inserter.Flush();
                }
                finally
                {
                    inserter.Release();
                }
                this.name  = key;
                this.flags = (short)((stage << 12) | this.name.Length);
                // TODO: fix flags
                this.stages = (1 >> this.GetStage());
            }
Esempio n. 13
0
        internal virtual ObjectId GenSha1(string data)
        {
            ObjectInserter w = db.NewObjectInserter();

            try
            {
                ObjectId id = w.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString(data
                                                                                             ));
                w.Flush();
                return(id);
            }
            catch (IOException e)
            {
                NUnit.Framework.Assert.Fail(e.ToString());
            }
            finally
            {
                w.Release();
            }
            return(null);
        }
Esempio n. 14
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual Note Merge(Note @base, Note ours, Note theirs, ObjectReader reader
			, ObjectInserter inserter)
        {
            if (ours == null)
            {
                return theirs;
            }
            if (theirs == null)
            {
                return ours;
            }
            if (ours.GetData().Equals(theirs.GetData()))
            {
                return ours;
            }
            ObjectLoader lo = reader.Open(ours.GetData());
            ObjectLoader lt = reader.Open(theirs.GetData());
            UnionInputStream union = new UnionInputStream(lo.OpenStream(), lt.OpenStream());
            ObjectId noteData = inserter.Insert(Constants.OBJ_BLOB, lo.GetSize() + lt.GetSize
                (), union);
            return new Note(ours, noteData);
        }
Esempio n. 15
0
        /// <summary>Resets the index to represent exactly some filesystem content.</summary>
        /// <remarks>
        /// Resets the index to represent exactly some filesystem content. E.g. the
        /// following call will replace the index with the working tree content:
        /// <p>
        /// <code>resetIndex(new FileSystemIterator(db))</code>
        /// <p>
        /// This method can be used by testcases which first prepare a new commit
        /// somewhere in the filesystem (e.g. in the working-tree) and then want to
        /// have an index which matches their prepared content.
        /// </remarks>
        /// <param name="treeItr">
        /// a
        /// <see cref="NGit.Treewalk.FileTreeIterator">NGit.Treewalk.FileTreeIterator</see>
        /// which determines which files should
        /// go into the new index
        /// </param>
        /// <exception cref="System.IO.FileNotFoundException">System.IO.FileNotFoundException
        ///     </exception>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        protected internal virtual void ResetIndex(FileTreeIterator treeItr)
        {
            ObjectInserter  inserter = db.NewObjectInserter();
            DirCacheBuilder builder  = db.LockDirCache().Builder();
            DirCacheEntry   dce;

            while (!treeItr.Eof)
            {
                long len = treeItr.GetEntryLength();
                dce              = new DirCacheEntry(treeItr.EntryPathString);
                dce.FileMode     = treeItr.EntryFileMode;
                dce.LastModified = treeItr.GetEntryLastModified();
                dce.SetLength((int)len);
                FileInputStream @in = new FileInputStream(treeItr.GetEntryFile());
                dce.SetObjectId(inserter.Insert(Constants.OBJ_BLOB, len, @in));
                @in.Close();
                builder.Add(dce);
                treeItr.Next(1);
            }
            builder.Commit();
            inserter.Flush();
            inserter.Release();
        }
            /// <summary>
            /// Update this index entry with stat and SHA-1 information if it looks
            /// like the file has been modified in the workdir.
            /// </summary>
            /// <remarks>
            /// Update this index entry with stat and SHA-1 information if it looks
            /// like the file has been modified in the workdir.
            /// </remarks>
            /// <param name="f">file in work dir</param>
            /// <param name="newContent">the new content of the file</param>
            /// <returns>true if a change occurred</returns>
            /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
            public virtual bool Update(FilePath f, byte[] newContent)
            {
                bool modified = false;

                this.size = newContent.Length;
                ObjectInserter oi = this._enclosing.db.NewObjectInserter();

                try
                {
                    ObjectId newsha1 = oi.Insert(Constants.OBJ_BLOB, newContent);
                    oi.Flush();
                    if (!newsha1.Equals(this.sha1))
                    {
                        modified = true;
                    }
                    this.sha1 = newsha1;
                }
                finally
                {
                    oi.Release();
                }
                return(modified);
            }
        /// <summary>Construct and write tree out of index.</summary>
        /// <remarks>Construct and write tree out of index.</remarks>
        /// <returns>SHA-1 of the constructed tree</returns>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public virtual ObjectId WriteTree()
        {
            CheckWriteOk();
            ObjectInserter inserter = db.NewObjectInserter();

            try
            {
                Tree         current = new Tree(db);
                Stack <Tree> trees   = new Stack <Tree>();
                trees.Push(current);
                string[] prevName = new string[0];
                foreach (GitIndex.Entry e in entries.Values)
                {
                    if (e.GetStage() != 0)
                    {
                        continue;
                    }
                    string[] newName = SplitDirPath(e.GetName());
                    int      c       = LongestCommonPath(prevName, newName);
                    while (c < trees.Count - 1)
                    {
                        current.SetId(inserter.Insert(Constants.OBJ_TREE, current.Format()));
                        trees.Pop();
                        current = trees.IsEmpty() ? null : (Tree)trees.Peek();
                    }
                    while (trees.Count < newName.Length)
                    {
                        if (!current.ExistsTree(newName[trees.Count - 1]))
                        {
                            current = new Tree(current, Constants.Encode(newName[trees.Count - 1]));
                            current.GetParent().AddEntry(current);
                            trees.Push(current);
                        }
                        else
                        {
                            current = (Tree)current.FindTreeMember(newName[trees.Count - 1]);
                            trees.Push(current);
                        }
                    }
                    FileTreeEntry ne = new FileTreeEntry(current, e.sha1, Constants.Encode(newName[newName
                                                                                                   .Length - 1]), (e.mode & FileMode.EXECUTABLE_FILE.GetBits()) == FileMode.EXECUTABLE_FILE
                                                         .GetBits());
                    current.AddEntry(ne);
                }
                while (!trees.IsEmpty())
                {
                    current.SetId(inserter.Insert(Constants.OBJ_TREE, current.Format()));
                    trees.Pop();
                    if (!trees.IsEmpty())
                    {
                        current = trees.Peek();
                    }
                }
                inserter.Flush();
                return(current.GetId());
            }
            finally
            {
                inserter.Release();
            }
        }
Esempio n. 18
0
		/// <param name="local"></param>
		/// <param name="inCore"></param>
		protected internal ResolveMerger(Repository local, bool inCore) : base(local)
		{
			DiffAlgorithm.SupportedAlgorithm diffAlg = local.GetConfig().GetEnum(ConfigConstants
				.CONFIG_DIFF_SECTION, null, ConfigConstants.CONFIG_KEY_ALGORITHM, DiffAlgorithm.SupportedAlgorithm
				.HISTOGRAM);
			mergeAlgorithm = new MergeAlgorithm(DiffAlgorithm.GetAlgorithm(diffAlg));
			commitNames = new string[] { "BASE", "OURS", "THEIRS" };
			oi = GetObjectInserter();
			this.inCore = inCore;
			if (inCore)
			{
				dircache = DirCache.NewInCore();
			}
		}
Esempio n. 19
0
		/// <summary>Write this note map as a tree.</summary>
		/// <remarks>Write this note map as a tree.</remarks>
		/// <param name="inserter">
		/// inserter to use when writing trees to the object database.
		/// Caller is responsible for flushing the inserter before trying
		/// to read the objects, or exposing them through a reference.
		/// </param>
		/// <returns>the top level tree.</returns>
		/// <exception cref="System.IO.IOException">a tree could not be written.</exception>
		public virtual ObjectId WriteTree(ObjectInserter inserter)
		{
			return root.WriteTree(inserter);
		}
Esempio n. 20
0
 /// <exception cref="System.IO.IOException"></exception>
 private PackParser Index(byte[] raw)
 {
     if (inserter == null)
     {
         inserter = repo.NewObjectInserter();
     }
     return inserter.NewPackParser(new ByteArrayInputStream(raw));
 }
Esempio n. 21
0
		/// <summary>Compute the ObjectId for this tree</summary>
		/// <param name="ins"></param>
		/// <returns>ObjectId for this tree</returns>
		public virtual ObjectId ComputeId(ObjectInserter ins)
		{
			if (buf != null)
			{
				return ins.IdFor(Constants.OBJ_TREE, buf, 0, ptr);
			}
			long len = overflowBuffer.Length();
			try
			{
				return ins.IdFor(Constants.OBJ_TREE, len, overflowBuffer.OpenInputStream());
			}
			catch (IOException e)
			{
				// this should never happen
				throw new RuntimeException(e);
			}
		}
Esempio n. 22
0
		/// <summary>Set the inserter this merger will use to create objects.</summary>
		/// <remarks>
		/// Set the inserter this merger will use to create objects.
		/// <p>
		/// If an inserter was already set on this instance (such as by a prior set,
		/// or a prior call to
		/// <see cref="GetObjectInserter()">GetObjectInserter()</see>
		/// ), the prior inserter will
		/// be released first.
		/// </remarks>
		/// <param name="oi">
		/// the inserter instance to use. Must be associated with the
		/// repository instance returned by
		/// <see cref="GetRepository()">GetRepository()</see>
		/// .
		/// </param>
		public virtual void SetObjectInserter(ObjectInserter oi)
		{
			if (inserter != null)
			{
				inserter.Release();
			}
			inserter = oi;
		}
Esempio n. 23
0
		/// <returns>
		/// an object writer to create objects in
		/// <see cref="GetRepository()">GetRepository()</see>
		/// .
		/// </returns>
		public virtual ObjectInserter GetObjectInserter()
		{
			if (inserter == null)
			{
				inserter = GetRepository().NewObjectInserter();
			}
			return inserter;
		}
		/// <exception cref="System.IO.IOException"></exception>
		private void OpenPack(TemporaryBuffer.Heap buf)
		{
			if (inserter == null)
			{
				inserter = src.NewObjectInserter();
			}
			byte[] raw = buf.ToByteArray();
			PackParser p = inserter.NewPackParser(new ByteArrayInputStream(raw));
			p.SetAllowThin(true);
			p.Parse(PM);
		}
Esempio n. 25
0
        /// <exception cref="System.IO.IOException"></exception>
        private DirCacheEntry AddEntryToBuilder(string path, FilePath file, ObjectInserter
			 newObjectInserter, DirCacheBuilder builder, int stage)
        {
            FileInputStream inputStream = new FileInputStream(file);
            ObjectId id = newObjectInserter.Insert(Constants.OBJ_BLOB, file.Length(), inputStream
                );
            inputStream.Close();
            DirCacheEntry entry = new DirCacheEntry(path, stage);
            entry.SetObjectId(id);
            entry.FileMode = FileMode.REGULAR_FILE;
            entry.LastModified = file.LastModified();
            entry.SetLength((int)file.Length());
            builder.Add(entry);
            return entry;
        }
Esempio n. 26
0
		/// <summary>Construct a WriteTree for a given directory</summary>
		/// <param name="sourceDirectory"></param>
		/// <param name="db"></param>
		public WriteTree(FilePath sourceDirectory, Repository db) : base(sourceDirectory)
		{
			inserter = db.NewObjectInserter();
		}
Esempio n. 27
0
		internal WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
		{
			NGit.Transport.Transport wt = (NGit.Transport.Transport)t;
			local = wt.local;
			objCheck = wt.IsCheckFetchedObjects() ? new ObjectChecker() : null;
			inserter = local.NewObjectInserter();
			reader = local.NewObjectReader();
			remotes = new AList<WalkRemoteObjectDatabase>();
			remotes.AddItem(w);
			unfetchedPacks = new List<WalkFetchConnection.RemotePack>();
			packsConsidered = new HashSet<string>();
			noPacksYet = new List<WalkRemoteObjectDatabase>();
			noPacksYet.AddItem(w);
			noAlternatesYet = new List<WalkRemoteObjectDatabase>();
			noAlternatesYet.AddItem(w);
			fetchErrors = new Dictionary<ObjectId, IList<Exception>>();
			packLocks = new AList<PackLock>(4);
			revWalk = new RevWalk(reader);
			revWalk.SetRetainBody(false);
			treeWalk = new TreeWalk(reader);
			COMPLETE = revWalk.NewFlag("COMPLETE");
			IN_WORK_QUEUE = revWalk.NewFlag("IN_WORK_QUEUE");
			LOCALLY_SEEN = revWalk.NewFlag("LOCALLY_SEEN");
			localCommitQueue = new DateRevQueue();
			workQueue = new List<ObjectId>();
		}
Esempio n. 28
0
		/// <summary>Insert this tree and obtain its ObjectId.</summary>
		/// <remarks>Insert this tree and obtain its ObjectId.</remarks>
		/// <param name="ins">the inserter to store the tree.</param>
		/// <returns>computed ObjectId of the tree</returns>
		/// <exception cref="System.IO.IOException">the tree could not be stored.</exception>
		public virtual ObjectId InsertTo(ObjectInserter ins)
		{
			if (buf != null)
			{
				return ins.Insert(Constants.OBJ_TREE, buf, 0, ptr);
			}
			long len = overflowBuffer.Length();
			return ins.Insert(Constants.OBJ_TREE, len, overflowBuffer.OpenInputStream());
		}
Esempio n. 29
0
		/// <summary>Attach a note to an object.</summary>
		/// <remarks>
		/// Attach a note to an object.
		/// If no note exists, a new note is stored. If a note already exists for the
		/// given object, it is replaced (or removed).
		/// </remarks>
		/// <param name="noteOn">
		/// the object to attach the note to. This same ObjectId can later
		/// be used as an argument to
		/// <see cref="Get(NGit.AnyObjectId)">Get(NGit.AnyObjectId)</see>
		/// or
		/// <see cref="GetCachedBytes(NGit.AnyObjectId, int)">GetCachedBytes(NGit.AnyObjectId, int)
		/// 	</see>
		/// to read back the
		/// <code>noteData</code>
		/// .
		/// </param>
		/// <param name="noteData">
		/// text to store in the note. The text will be UTF-8 encoded when
		/// stored in the repository. If null the note will be deleted, if
		/// the empty string a note with the empty string will be stored.
		/// </param>
		/// <param name="ins">
		/// inserter to write the encoded
		/// <code>noteData</code>
		/// out as a blob.
		/// The caller must ensure the inserter is flushed before the
		/// updated note map is made available for reading.
		/// </param>
		/// <exception cref="System.IO.IOException">the note data could not be stored in the repository.
		/// 	</exception>
		public virtual void Set(AnyObjectId noteOn, string noteData, ObjectInserter ins)
		{
			ObjectId dataId;
			if (noteData != null)
			{
				byte[] dataUTF8 = Constants.Encode(noteData);
				dataId = ins.Insert(Constants.OBJ_BLOB, dataUTF8);
			}
			else
			{
				dataId = null;
			}
			Set(noteOn, dataId);
		}
Esempio n. 30
0
		/// <exception cref="System.IO.IOException"></exception>
		internal abstract ObjectId WriteTree(ObjectInserter inserter);
Esempio n. 31
0
		/// <exception cref="System.Exception"></exception>
		private ObjectId Commit(ObjectInserter odi, DirCache treeB, ObjectId[] parentIds)
		{
			NGit.CommitBuilder c = new NGit.CommitBuilder();
			c.TreeId = treeB.WriteTree(odi);
			c.Author = new PersonIdent("A U Thor", "a.u.thor", 1L, 0);
			c.Committer = c.Author;
			c.SetParentIds(parentIds);
			c.Message = "Tree " + c.TreeId.Name;
			ObjectId id = odi.Insert(c);
			odi.Flush();
			return id;
		}
Esempio n. 32
0
		/// <summary>
		/// Constructs a NoteMapMerger with custom
		/// <see cref="NoteMerger">NoteMerger</see>
		/// and custom
		/// <see cref="NGit.Merge.MergeStrategy">NGit.Merge.MergeStrategy</see>
		/// .
		/// </summary>
		/// <param name="db">Git repository</param>
		/// <param name="noteMerger">note merger for merging conflicting changes on a note</param>
		/// <param name="nonNotesMergeStrategy">merge strategy for merging non-note entries</param>
		public NoteMapMerger(Repository db, NoteMerger noteMerger, MergeStrategy nonNotesMergeStrategy
			)
		{
			this.db = db;
			this.reader = db.NewObjectReader();
			this.inserter = db.NewObjectInserter();
			this.noteMerger = noteMerger;
			this.nonNotesMergeStrategy = nonNotesMergeStrategy;
			this.objectIdPrefix = new MutableObjectId();
		}
Esempio n. 33
0
 /// <exception cref="System.IO.IOException"></exception>
 private PackParser Index(InputStream @in)
 {
     if (inserter == null)
     {
         inserter = db.NewObjectInserter();
     }
     return inserter.NewPackParser(@in);
 }
Esempio n. 34
0
		public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
			noRoot = NoteMap.NewMap(null, reader);
			empty = NoteMap.NewEmptyMap();
			noteAId = tr.Blob("a");
			noteAContent = "noteAContent";
			noteABlob = tr.Blob(noteAContent);
			sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create();
			tr.ParseBody(sampleTree_a);
			map_a = NoteMap.Read(reader, sampleTree_a);
			noteBId = tr.Blob("b");
			noteBContent = "noteBContent";
			noteBBlob = tr.Blob(noteBContent);
			sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob
				).Create();
			tr.ParseBody(sampleTree_a_b);
			map_a_b = NoteMap.Read(reader, sampleTree_a_b);
		}