Exemple #1
0
        public override string ToString()
        {
            StringBuilder r = new StringBuilder();

            r.Append("Tag");
            r.Append("={\n");
            r.Append("object ");
            r.Append(@object != null ? @object.Name : "NOT_SET");
            r.Append("\n");
            r.Append("type ");
            r.Append(@object != null ? Constants.TypeString(type) : "NOT_SET");
            r.Append("\n");
            r.Append("tag ");
            r.Append(tag != null ? tag : "NOT_SET");
            r.Append("\n");
            if (tagger != null)
            {
                r.Append("tagger ");
                r.Append(tagger);
                r.Append("\n");
            }
            r.Append("\n");
            r.Append(message != null ? message : string.Empty);
            r.Append("}");
            return(r.ToString());
        }
Exemple #2
0
        public override string ToString()
        {
            byte[] raw            = ToByteArray();
            CanonicalTreeParser p = new CanonicalTreeParser();

            p.Reset(raw);
            StringBuilder r = new StringBuilder();

            r.Append("Tree={");
            if (!p.Eof)
            {
                r.Append('\n');
                try
                {
                    new ObjectChecker().CheckTree(raw);
                }
                catch (CorruptObjectException error)
                {
                    r.Append("*** ERROR: ").Append(error.Message).Append("\n");
                    r.Append('\n');
                }
            }
            while (!p.Eof)
            {
                FileMode mode = p.EntryFileMode;
                r.Append(mode);
                r.Append(' ');
                r.Append(Constants.TypeString(mode.GetObjectType()));
                r.Append(' ');
                r.Append(p.EntryObjectId.Name);
                r.Append(' ');
                r.Append(p.EntryPathString);
                r.Append('\n');
                p.Next();
            }
            r.Append("}");
            return(r.ToString());
        }
Exemple #3
0
        /// <summary>Format this builder's state as an annotated tag object.</summary>
        /// <remarks>Format this builder's state as an annotated tag object.</remarks>
        /// <returns>
        /// this object in the canonical annotated tag format, suitable for
        /// storage in a repository.
        /// </returns>
        public virtual byte[] Build()
        {
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            OutputStreamWriter    w  = new OutputStreamWriter(os, Constants.CHARSET);

            try
            {
                w.Write("object ");
                GetObjectId().CopyTo(w);
                w.Write('\n');
                w.Write("type ");
                w.Write(Constants.TypeString(GetObjectType()));
                w.Write("\n");
                w.Write("tag ");
                w.Write(GetTag());
                w.Write("\n");
                if (GetTagger() != null)
                {
                    w.Write("tagger ");
                    w.Write(GetTagger().ToExternalString());
                    w.Write('\n');
                }
                w.Write('\n');
                if (GetMessage() != null)
                {
                    w.Write(GetMessage());
                }
                w.Close();
            }
            catch (IOException err)
            {
                // This should never occur, the only way to get it above is
                // for the ByteArrayOutputStream to throw, but it doesn't.
                //
                throw new RuntimeException(err);
            }
            return(os.ToByteArray());
        }