Example #1
0
 /// <summary>Write an ObjectId and LF to the temporary file.</summary>
 /// <remarks>Write an ObjectId and LF to the temporary file.</remarks>
 /// <param name="id">
 /// the id to store in the file. The id will be written in hex,
 /// followed by a sole LF.
 /// </param>
 /// <exception cref="System.IO.IOException">
 /// the temporary file could not be written. The lock is released
 /// before throwing the underlying IO exception to the caller.
 /// </exception>
 /// <exception cref="Sharpen.RuntimeException">
 /// the temporary file could not be written. The lock is released
 /// before throwing the underlying exception to the caller.
 /// </exception>
 public virtual void Write(ObjectId id)
 {
     byte[] buf = new byte[Constants.OBJECT_ID_STRING_LENGTH + 1];
     id.CopyTo(buf, 0);
     buf[Constants.OBJECT_ID_STRING_LENGTH] = (byte)('\n');
     Write(buf);
 }
        /// <summary>Overwrite (or create) a loose ref in the remote repository.</summary>
        /// <remarks>
        /// Overwrite (or create) a loose ref in the remote repository.
        /// <p>
        /// This method creates any missing parent directories, if necessary.
        /// </remarks>
        /// <param name="name">
        /// name of the ref within the ref space, for example
        /// <code>refs/heads/pu</code>.
        /// </param>
        /// <param name="value">new value to store in this ref. Must not be null.</param>
        /// <exception cref="System.IO.IOException">
        /// writing is not supported, or attempting to write the file
        /// failed, possibly due to permissions or remote disk full, etc.
        /// </exception>
        internal virtual void WriteRef(string name, ObjectId value)
        {
            ByteArrayOutputStream b;

            b = new ByteArrayOutputStream(Constants.OBJECT_ID_STRING_LENGTH + 1);
            value.CopyTo(b);
            b.Write('\n');
            WriteFile(ROOT_DIR + name, b.ToByteArray());
        }
        public void writeRef(string name, ObjectId value)
        {
            MemoryStream m = new MemoryStream(Constants.OBJECT_ID_LENGTH * 2 + 1);
            BinaryWriter b = new BinaryWriter(m);

            value.CopyTo(b);
            b.Write('\n');
            b.Flush();

            writeFile(ROOT_DIR + name, m.ToArray());
        }
        /// <summary>
        /// Overwrite (or create) a loose ref in the remote repository.
        /// <para/>
        /// This method creates any missing parent directories, if necessary.
        /// </summary>
        /// <param name="name">
        /// name of the ref within the ref space, for example
        /// <code>refs/heads/pu</code>.
        /// </param>
        /// <param name="value">new value to store in this ref. Must not be null.</param>
        public void writeRef(string name, ObjectId value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            using (var m = new MemoryStream(Constants.OBJECT_ID_STRING_LENGTH + 1))
                using (var b = new BinaryWriter(m))
                {
                    value.CopyTo(b);
                    b.Write('\n');
                    b.Flush();

                    writeFile(ROOT_DIR + name, m.ToArray());
                }
        }
        /// <summary>
        /// Overwrite (or create) a loose ref in the remote repository.
        /// <para/>
        /// This method creates any missing parent directories, if necessary. 
        /// </summary>
        /// <param name="name">
        /// name of the ref within the ref space, for example
        /// <code>refs/heads/pu</code>.
        /// </param>
        /// <param name="value">new value to store in this ref. Must not be null.</param>
        public void writeRef(string name, ObjectId value)
        {
            if (value == null)
                throw new ArgumentNullException("value");

            using (var m = new MemoryStream(Constants.OBJECT_ID_STRING_LENGTH + 1))
            using (var b = new BinaryWriter(m))
            {
                value.CopyTo(b);
                b.Write('\n');
                b.Flush();

                writeFile(ROOT_DIR + name, m.ToArray());
            }
        }
        public void writeRef(string name, ObjectId value)
        {
            MemoryStream m = new MemoryStream(Constants.OBJECT_ID_LENGTH * 2 + 1);
            BinaryWriter b = new BinaryWriter(m);
            value.CopyTo(b);
            b.Write('\n');
            b.Flush();

            writeFile(ROOT_DIR + name, m.ToArray());
        }
Example #7
0
 private void format(StringBuilder m, char[] idtmp, ObjectId id, string name)
 {
     m.Length = 0;
     id.CopyTo(idtmp, m);
     m.Append(' ');
     m.Append(name);
 }