コード例 #1
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);
		}
コード例 #2
0
ファイル: CanonicalTreeParser.cs プロジェクト: sharwell/ngit
 /// <summary>Reset this parser to walk through the given tree.</summary>
 /// <remarks>Reset this parser to walk through the given tree.</remarks>
 /// <param name="reader">reader to use during repository access.</param>
 /// <param name="id">
 /// identity of the tree being parsed; used only in exception
 /// messages if data corruption is found.
 /// </param>
 /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository.
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
 /// the object supplied as an argument is not actually a tree and
 /// cannot be parsed as though it were a tree.
 /// </exception>
 /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
 /// 	</exception>
 public virtual void Reset(ObjectReader reader, AnyObjectId id)
 {
     Reset(reader.Open(id, Constants.OBJ_TREE).GetCachedBytes());
 }
コード例 #3
0
ファイル: DirCacheCheckout.cs プロジェクト: stinos/ngit
        /// <summary>
        /// Updates the file in the working tree with content and mode from an entry
        /// in the index.
        /// </summary>
        /// <remarks>
        /// Updates the file in the working tree with content and mode from an entry
        /// in the index. The new content is first written to a new temporary file in
        /// the same directory as the real file. Then that new file is renamed to the
        /// final filename.
        /// <p>
        /// TODO: this method works directly on File IO, we may need another
        /// abstraction (like WorkingTreeIterator). This way we could tell e.g.
        /// Eclipse that Files in the workspace got changed
        /// </p>
        /// </remarks>
        /// <param name="repo"></param>
        /// <param name="f">
        /// the file to be modified. The parent directory for this file
        /// has to exist already
        /// </param>
        /// <param name="entry">the entry containing new mode and content</param>
        /// <param name="or">object reader to use for checkout</param>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public static void CheckoutEntry(Repository repo, FilePath f, DirCacheEntry entry
			, ObjectReader or)
        {
            ObjectLoader ol = or.Open(entry.GetObjectId());
            FilePath parentDir = f.GetParentFile();
            FilePath tmpFile = FilePath.CreateTempFile("._" + f.GetName(), null, parentDir);
            WorkingTreeOptions opt = repo.GetConfig().Get(WorkingTreeOptions.KEY);
            FileOutputStream rawChannel = new FileOutputStream(tmpFile);
            OutputStream channel;
            if (opt.GetAutoCRLF() == CoreConfig.AutoCRLF.TRUE)
            {
                channel = new AutoCRLFOutputStream(rawChannel);
            }
            else
            {
                channel = rawChannel;
            }
            try
            {
                ol.CopyTo(channel);
            }
            finally
            {
                channel.Close();
            }
            FS fs = repo.FileSystem;
            if (opt.IsFileMode() && fs.SupportsExecute())
            {
                if (FileMode.EXECUTABLE_FILE.Equals(entry.RawMode))
                {
                    if (!fs.CanExecute(tmpFile))
                    {
                        fs.SetExecute(tmpFile, true);
                    }
                }
                else
                {
                    if (fs.CanExecute(tmpFile))
                    {
                        fs.SetExecute(tmpFile, false);
                    }
                }
            }
            if (!tmpFile.RenameTo(f))
            {
                // tried to rename which failed. Let' delete the target file and try
                // again
                FileUtils.Delete(f);
                if (!tmpFile.RenameTo(f))
                {
                    throw new IOException(MessageFormat.Format(JGitText.Get().couldNotWriteFile, tmpFile
                        .GetPath(), f.GetPath()));
                }
            }
            entry.LastModified = f.LastModified();
            if (opt.GetAutoCRLF() != CoreConfig.AutoCRLF.FALSE)
            {
                entry.SetLength(f.Length());
            }
            else
            {
                // AutoCRLF wants on-disk-size
                entry.SetLength((int)ol.GetSize());
            }
        }
コード例 #4
0
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		private static byte[] Read(ObjectReader or, AnyObjectId blobId)
		{
			ObjectLoader loader = or.Open(blobId, Constants.OBJ_BLOB);
			return loader.GetCachedBytes(int.MaxValue);
		}
コード例 #5
0
ファイル: Candidate.cs プロジェクト: LunarLanding/ngit
		/// <exception cref="System.IO.IOException"></exception>
		internal virtual void LoadText(ObjectReader reader)
		{
			ObjectLoader ldr = reader.Open(sourceBlob, Constants.OBJ_BLOB);
			sourceText = new RawText(ldr.GetCachedBytes(int.MaxValue));
		}
コード例 #6
0
        /// <exception cref="System.IO.IOException"></exception>
        internal virtual void LoadText(ObjectReader reader)
        {
            ObjectLoader ldr = reader.Open(sourceBlob, Constants.OBJ_BLOB);

            sourceText = new RawText(ldr.GetCachedBytes(int.MaxValue));
        }
コード例 #7
0
 /// <summary>Reset this parser to walk through the given tree.</summary>
 /// <remarks>Reset this parser to walk through the given tree.</remarks>
 /// <param name="reader">reader to use during repository access.</param>
 /// <param name="id">
 /// identity of the tree being parsed; used only in exception
 /// messages if data corruption is found.
 /// </param>
 /// <exception cref="NGit.Errors.MissingObjectException">the object supplied is not available from the repository.
 ///     </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
 /// the object supplied as an argument is not actually a tree and
 /// cannot be parsed as though it were a tree.
 /// </exception>
 /// <exception cref="System.IO.IOException">a loose object or pack file could not be read.
 ///     </exception>
 public virtual void Reset(ObjectReader reader, AnyObjectId id)
 {
     Reset(reader.Open(id, Constants.OBJ_TREE).GetCachedBytes());
 }
コード例 #8
0
 /// <exception cref="System.IO.IOException"></exception>
 public override ObjectLoader Open(string path, ObjectId id)
 {
     return(reader.Open(id, Constants.OBJ_BLOB));
 }