private static void AppendOneRecord(ObjectId oldId, ObjectId newId, PersonIdent ident, String msg, Repository db, String refName) { ident = ident == null ? new PersonIdent(db) : new PersonIdent(ident); var r = new StringBuilder(); r.Append(ObjectId.ToString(oldId)); r.Append(' '); r.Append(ObjectId.ToString(newId)); r.Append(' '); r.Append(ident.ToExternalString()); r.Append('\t'); r.Append(msg); r.Append('\n'); byte[] rec = Constants.encode(r.ToString()); var logdir = new DirectoryInfo(db.Directory + "/" + Constants.LOGS); var reflog = new DirectoryInfo(logdir + "/" + refName); var refdir = reflog.Parent; if (refdir != null) { refdir.Create(); if (!refdir.Exists) { throw new IOException("Cannot create directory " + refdir); } } using (var @out = new FileStream(reflog.FullName, System.IO.FileMode.OpenOrCreate, FileAccess.Write)) { try { @out.Write(rec, 0, rec.Length); } finally { @out.Close(); } } }
private static string BuildReflogString(Repository repo, ObjectId oldCommit, ObjectId commit, string message) { PersonIdent me = new PersonIdent(repo); string initial = ""; if (oldCommit == null) { oldCommit = ObjectId.ZeroId; initial = " (initial)"; } string s = oldCommit.ToString() + " " + commit.ToString() + " " + me.ToExternalString() + "\t" + message + initial; return s; }
private static void AppendOneRecord(ObjectId oldId, ObjectId newId, PersonIdent ident, string msg, Repository db, string refName) { ident = ident == null ? new PersonIdent(db) : new PersonIdent(ident); var r = new StringBuilder(); r.Append(ObjectId.ToString(oldId)); r.Append(' '); r.Append(ObjectId.ToString(newId)); r.Append(' '); r.Append(ident.ToExternalString()); r.Append('\t'); r.Append(msg); r.Append('\n'); byte[] rec = Constants.encode(r.ToString()); var logdir = new DirectoryInfo(Path.Combine(db.Directory.FullName, Constants.LOGS)); var reflog = new DirectoryInfo(Path.Combine(logdir.FullName, refName)); var refdir = reflog.Parent; if (!refdir.Exists && !refdir.Mkdirs()) { throw new IOException("Cannot create directory " + refdir); } using (var @out = new FileStream(reflog.FullName, System.IO.FileMode.Append, FileAccess.Write)) { @out.Write(rec, 0, rec.Length); } }