async Task TestCreateTag(CommitID cmid) { var db = getDataContext(); ICommitRepository cmrepo = new CommitRepository(db); ITagRepository tgrepo = new TagRepository(db); Console.WriteLine("Get commit by tag 'v1.0'"); var cm = await cmrepo.GetCommitByTagName("v1.0"); if (cm != null) { Console.WriteLine("v1.0 was {0}", cm.Item2.ID); #if false Console.WriteLine("Deleting Tag by ID {0}", cm.Item1.ID); await tgrepo.DeleteTag(cm.Item1.ID).Wait(); #else Console.WriteLine("Deleting Tag by name 'v1.0'"); await tgrepo.DeleteTagByName("v1.0"); #endif } Tag tg = new Tag.Builder("v1.0", cmid, "James Dunne <*****@*****.**>", DateTimeOffset.Now, "Tagged for version 1.0"); await tgrepo.PersistTag(tg); var tgByName = await cmrepo.GetCommitByTagName("v1.0"); Debug.Assert(tgByName.Item2.ID == cmid); Console.WriteLine("Completed."); }
public StringBuilder WriteTo(StringBuilder sb) { if (Parents != null && Parents.Length > 0) { // Sort parent CommitIDs in order: CommitID[] parents = new CommitID[Parents.Length]; for (int i = 0; i < parents.Length; ++i) parents[i] = Parents[i]; Array.Sort(parents, new CommitID.Comparer()); for (int i = 0; i < parents.Length; ++i) { sb.AppendFormat("parent {0}\n", parents[i]); } } sb.AppendFormat("tree {0}\n", TreeID); sb.AppendFormat("committer {0}\n", Committer); // NOTE: date parsing will result in an inexact DateTimeOffset from what was created with, but it // is close enough because the SHA-1 hash is calculated using the DateTimeOffset.ToString(), so // only the ToString() representations of the DateTimeOffsets need to match. sb.AppendFormat("date {0}\n\n", DateCommitted.ToString()); sb.AppendFormat(Message ?? String.Empty); return sb; }
private async Task <Errorable <Commit[]> > getCommitsRecursively(CommitID id, int depthLevel, int depthMaximum) { // Get the current commit: var eroot = await getCommit(id).ConfigureAwait(continueOnCapturedContext: false); if (eroot.HasErrors) { return(eroot.Errors); } var root = eroot.Value; var rootArr = new Commit[1] { root }; // We have no parents: if (root.Parents.Length == 0) { return(rootArr); } // This is the last depth level: if (depthLevel >= depthMaximum) { return(rootArr); } // Recurse up the commit parents: Task <Errorable <Commit[]> >[] tasks = new Task <Errorable <Commit[]> > [root.Parents.Length]; for (int i = 0; i < root.Parents.Length; ++i) { tasks[i] = getCommitsRecursively(root.Parents[i], depthLevel + 1, depthMaximum); } // Await all the tree retrievals: var allCommits = await Task.WhenAll(tasks).ConfigureAwait(continueOnCapturedContext: false); // Roll up all the errors: ErrorContainer errors = ( from ecms in allCommits where ecms.HasErrors select ecms.Errors ).Aggregate(new ErrorContainer(), (acc, err) => acc + err); if (errors.HasAny) { return(errors); } // Flatten out the tree arrays: var flattened = from ecms in allCommits from cm in ecms.Value select cm; // Return the final array: return(rootArr.Concat(flattened).ToArray(allCommits.Sum(ca => ca.Value.Length) + 1)); }
internal FileInfo getPathByID(CommitID id) { DirectoryInfo objDir = getObjectsDirectory(); string idStr = id.ToString(); string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2), idStr.Substring(2)); return(new FileInfo(path)); }
internal static Errorable <Tuple <Tag, Commit> > retrieve(ConsistencyError errorIfNotExist, SqlCommand cmd, SqlDataReader dr) { // If no result, return null: if (!dr.Read()) { return(errorIfNotExist); } TagID tgid = (TagID)dr.GetSqlBinary(0).Value; Tag.Builder tgb = new Tag.Builder( pName: (TagName)dr.GetSqlString(1).Value, pCommitID: (CommitID)dr.GetSqlBinary(2).Value, pTagger: dr.GetSqlString(3).Value, pDateTagged: dr.GetDateTimeOffset(4), pMessage: dr.GetSqlString(5).Value ); Tag tg = tgb; if (tg.ID != tgid) { return(new ComputedTagIDMismatchError(tg.ID, tgid)); } const int offs = 6; CommitID id = (CommitID)dr.GetSqlBinary(0 + offs).Value; Commit.Builder cmb = new Commit.Builder( pParents: new System.Collections.Generic.List <CommitID>(2), pTreeID: (TreeID)dr.GetSqlBinary(1 + offs).Value, pCommitter: dr.GetSqlString(2 + offs).Value, pDateCommitted: dr.GetDateTimeOffset(3 + offs), pMessage: dr.GetSqlString(4 + offs).Value ); // Read the parent commit ids from the second result: if (dr.NextResult()) { while (dr.Read()) { cmb.Parents.Add((CommitID)dr.GetSqlBinary(0).Value); } cmb.Parents.Sort(new CommitID.Comparer()); } Commit cm = cmb; if (cm.ID != id) { return(new ComputedCommitIDMismatchError(cm.ID, id)); } return(new Tuple <Tag, Commit>(tg, cm)); }
public Task <Errorable <CommitID> > ResolvePartialID(CommitID.Partial id) { FileInfo[] fis = system.getPathsByPartialID(id); if (fis.Length == 1) { return(Task.FromResult(CommitID.TryParse(id.ToString().Substring(0, 2) + fis[0].Name))); } if (fis.Length == 0) { return(Task.FromResult((Errorable <CommitID>) new CommitIDPartialNoResolutionError(id))); } return(Task.FromResult((Errorable <CommitID>) new CommitIDPartialAmbiguousResolutionError(id, fis.SelectAsArray(f => CommitID.TryParse(id.ToString().Substring(0, 2) + f.Name).Value)))); }
public Builder( CommitID pID , TreeID pTreeID , string pCommitter , DateTimeOffset pDateCommitted , string pMessage ) { this.ID = pID; this.TreeID = pTreeID; this.Committer = pCommitter; this.DateCommitted = pDateCommitted; this.Message = pMessage; }
public async Task <Errorable <CommitTree> > GetCommitTree(CommitID id, int depth = 10) { var eall = await getCommitsRecursively(id, 1, depth).ConfigureAwait(continueOnCapturedContext: false); if (eall.HasErrors) { return(eall.Errors); } var all = eall.Value; // Return them (all[0] is the root): return(new CommitTree(all[0].ID, new ImmutableContainer <CommitID, ICommit>(cm => cm.ID, all))); }
private void deleteCommit(CommitID id) { FileInfo fi = system.getPathByID(id); lock (FileSystem.SystemLock) { if (!fi.Exists) { return; } fi.Delete(); } }
async Task Create3DeepCommit() { // Create a 3-depth commit tree up from HEAD: for (int i = 0; i < 3; ++i) { TreeID rootid = await TestPersistTree(); TestRetrieveTreeRecursively(rootid).Wait(); CommitID cmid = await TestCreateCommit(rootid, i); TestCreateTag(cmid).Wait(); } }
private CommitTreeResponse toJSON(CommitID id, ImmutableContainer<CommitID, ICommit> commits) { ICommit cm; if (!commits.TryGetValue(id, out cm)) return null; return new CommitTreeResponse() { id = cm.ID.ToString(), treeid = cm.TreeID.ToString(), committer = cm.Committer.ToString(), date_committed = JSONTranslateExtensions.FromDate(cm.DateCommitted), parents_retrieved = cm.IsComplete, message = cm.Message, parents = cm.Parents.SelectAsArray(cmid => toJSON(cmid, commits)) }; }
static void RecursivePrint(CommitID cmID, ImmutableContainer <CommitID, ICommit> commits, int depth = 1) { ICommit cm = commits[cmID]; if (cm.IsComplete) { Console.WriteLine("{0}c {1}: ({2})", new string(' ', (depth - 1) * 2), cm.ID.ToString(firstLength: 7), String.Join(",", cm.Parents.Select(id => id.ToString(firstLength: 7)))); foreach (CommitID parentID in cm.Parents) { RecursivePrint(parentID, commits, depth + 1); } } else { Console.WriteLine("{0}p {1}: ?", new string(' ', (depth - 1) * 2), cm.ID.ToString(firstLength: 7)); } }
public Errorable <Tuple <Ref, Commit> > retrieve(SqlCommand cmd, SqlDataReader dr) { // If no result, return null: if (!dr.Read()) { return(new RefNameDoesNotExistError(this._refName)); } Ref.Builder rfb = new Ref.Builder( pName: (RefName)dr.GetSqlString(0).Value, pCommitID: (CommitID)dr.GetSqlBinary(1).Value ); Ref rf = rfb; const int offs = 2; CommitID id = (CommitID)dr.GetSqlBinary(0 + offs).Value; Commit.Builder cmb = new Commit.Builder( pParents: new System.Collections.Generic.List <CommitID>(2), pTreeID: (TreeID)dr.GetSqlBinary(1 + offs).Value, pCommitter: dr.GetSqlString(2 + offs).Value, pDateCommitted: dr.GetDateTimeOffset(3 + offs), pMessage: dr.GetSqlString(4 + offs).Value ); // Read the parent commit ids from the second result: if (dr.NextResult()) { while (dr.Read()) { cmb.Parents.Add((CommitID)dr.GetSqlBinary(0).Value); } cmb.Parents.Sort(new CommitID.Comparer()); } Commit cm = cmb; if (cm.ID != id) { return(new ComputedCommitIDMismatchError(cm.ID, id)); } return(new Tuple <Ref, Commit>(rf, cm)); }
private async Task <Errorable <Ref> > getRefByName(RefName refName) { FileInfo fiTracker = system.getRefPathByRefName(refName); if (!fiTracker.Exists) { return(new RefNameDoesNotExistError(refName)); } byte[] buf; int nr = 0; using (var fs = new FileStream(fiTracker.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true)) { // TODO: implement an async buffered Stream: buf = new byte[16384]; nr = await fs.ReadAsync(buf, 0, 16384).ConfigureAwait(continueOnCapturedContext: false); if (nr >= 16384) { // My, what a large tag you have! throw new NotSupportedException(); } } // Parse the CommitID: using (var ms = new MemoryStream(buf, 0, nr, false)) using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line = sr.ReadLine(); if (line == null) { return(new RefNameDoesNotExistError(refName)); } var ecid = CommitID.TryParse(line); if (ecid.HasErrors) { return(ecid.Errors); } return((Ref) new Ref.Builder(refName, ecid.Value)); } }
private Errorable <Commit> retrieve(SqlCommand cmd, SqlDataReader dr) { // If no result, return null: if (!dr.Read()) { return(new CommitIDRecordDoesNotExistError(this._id)); } CommitID id = (CommitID)dr.GetSqlBinary(0).Value; Commit.Builder b = new Commit.Builder( pParents: new System.Collections.Generic.List <CommitID>(10), pTreeID: (TreeID)dr.GetSqlBinary(1).Value, pCommitter: dr.GetSqlString(2).Value, pDateCommitted: dr.GetDateTimeOffset(3), pMessage: dr.GetSqlString(4).Value ); // Read the parent commit ids from the second result: if (dr.NextResult()) { while (dr.Read()) { b.Parents.Add((CommitID)dr.GetSqlBinary(0).Value); } b.Parents.Sort(new CommitID.Comparer()); } Commit cm = b; if (cm.ID != id) { throw new ComputedCommitIDMismatchError(cm.ID, id); } return(cm); }
public async Task <Errorable <CommitID> > DeleteCommit(CommitID id) { await Task.Run(() => deleteCommit(id)).ConfigureAwait(continueOnCapturedContext: false); return(id); }
internal FileInfo[] getPathsByPartialID(CommitID.Partial partial) { DirectoryInfo objDir = getObjectsDirectory(); string idStr = partial.ToString(); string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2)); var di = new DirectoryInfo(path); if (!di.Exists) return new FileInfo[0]; return di.GetFiles(idStr.Substring(2) + "*"); }
public ComputedCommitIDMismatchError(CommitID computedID, CommitID expectedID) : base("Computed CommitID {0} does not match expected CommitID {1}", computedID, expectedID) { }
internal void RemoveFossils(int memberIndex, CommitID threshold, bool includeThreshold) { members[memberIndex].RemoveFossils(threshold, includeThreshold); }
public Builder(Ref imm) { this.Name = imm.Name; this.CommitID = imm.CommitID; }
public CommitIDRecordDoesNotExistError(CommitID commitID) : base("A commit with CommitID {0} does not exist", commitID) { }
private async Task<Errorable<Commit>> getCommit(CommitID id) { FileInfo fi = system.getPathByID(id); if (!fi.Exists) return null; byte[] buf; int nr = 0; using (var fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true)) { // TODO: implement an async buffered Stream: buf = new byte[16384]; nr = await fs.ReadAsync(buf, 0, 16384).ConfigureAwait(continueOnCapturedContext: false); if (nr >= 16384) { // My, what a large commit you have! throw new NotSupportedException(); } } Commit.Builder cb = new Commit.Builder() { Parents = new List<CommitID>() }; // Parse the Commit: using (var ms = new MemoryStream(buf, 0, nr, false)) using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line; // Read the list of parent CommitIDs: while ((line = sr.ReadLine()) != null) { if (!line.StartsWith("parent ")) break; string parent_commitid = line.Substring("parent ".Length); var ecid = CommitID.TryParse(parent_commitid); if (ecid.HasErrors) return ecid.Errors; cb.Parents.Add(ecid.Value); } // Set TreeID: if (line == null || !line.StartsWith("tree ")) return new CommitParseExpectedTreeError(); var etrid = TreeID.TryParse(line.Substring("tree ".Length)); if (etrid.HasErrors) return etrid.Errors; cb.TreeID = etrid.Value; // Set Committer: line = sr.ReadLine(); if (line == null || !line.StartsWith("committer ")) return new CommitParseExpectedCommitterError(); cb.Committer = line.Substring("committer ".Length); // Set DateCommitted: line = sr.ReadLine(); if (line == null || !line.StartsWith("date ")) return new CommitParseExpectedDateError(); // NOTE: date parsing will result in an inexact DateTimeOffset from what was created with, but it // is close enough because the SHA-1 hash is calculated using the DateTimeOffset.ToString(), so // only the ToString() representations of the DateTimeOffsets need to match. DateTimeOffset tmpDate; if (!DateTimeOffset.TryParse(line.Substring("date ".Length), out tmpDate)) return new CommitParseBadDateFormatError(); cb.DateCommitted = tmpDate; // Skip empty line: line = sr.ReadLine(); if (line == null || line.Length != 0) return new CommitParseExpectedBlankLineError(); // Set Message: cb.Message = sr.ReadToEnd(); } // Create the immutable Commit from the Builder: Commit cm = cb; // Validate the computed CommitID: if (cm.ID != id) return new ComputedCommitIDMismatchError(cm.ID, id); return cm; }
public Builder( TagName pName ,CommitID pCommitID ,string pTagger ,DateTimeOffset pDateTagged ,string pMessage ) { this.Name = pName; this.CommitID = pCommitID; this.Tagger = pTagger; this.DateTagged = pDateTagged; this.Message = pMessage; }
internal FileInfo getPathByID(CommitID id) { DirectoryInfo objDir = getObjectsDirectory(); string idStr = id.ToString(); string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2), idStr.Substring(2)); return new FileInfo(path); }
public Task <Errorable <CommitTree> > GetCommitTree(CommitID id, int depth = 10) { return(db.ExecuteListQueryAsync(new QueryCommitsRecursively(id, depth))); }
public CommitIDPartialNoResolutionError(CommitID.Partial id) : base("Partial CommitID {0} does not resolve to a CommitID", id) { }
public CommitRecordAlreadyExistsError(CommitID id) : base("A commit with CommitID {0} already exists", id) { }
public CommitIDPartialAmbiguousResolutionError(CommitID.Partial id, params CommitID[] ids) : base("Partial CommitID {0} resolves to multiple CommitID", id, ids) { }
public Task<Errorable<CommitID>> ResolvePartialID(CommitID.Partial id) { FileInfo[] fis = system.getPathsByPartialID(id); if (fis.Length == 1) return Task.FromResult(CommitID.TryParse(id.ToString().Substring(0, 2) + fis[0].Name)); if (fis.Length == 0) return Task.FromResult((Errorable<CommitID>)new CommitIDPartialNoResolutionError(id)); return Task.FromResult((Errorable<CommitID>)new CommitIDPartialAmbiguousResolutionError(id, fis.SelectAsArray(f => CommitID.TryParse(id.ToString().Substring(0, 2) + f.Name).Value))); }
public Task <Errorable <Commit> > GetCommit(CommitID id) { return(db.ExecuteSingleQueryAsync(new QueryCommit(id))); }
public Builder( CommitID pID ,TreeID pTreeID ,string pCommitter ,DateTimeOffset pDateCommitted ,string pMessage ) { this.ID = pID; this.TreeID = pTreeID; this.Committer = pCommitter; this.DateCommitted = pDateCommitted; this.Message = pMessage; }
public Task <Errorable <CommitID> > DeleteCommit(CommitID id) { return(db.ExecuteNonQueryAsync(new DestroyCommit(id))); }
public Ref(Builder b) { this.Name = b.Name; this.CommitID = b.CommitID; }
public Task<Errorable<CommitID>> DeleteCommit(CommitID id) { return db.ExecuteNonQueryAsync(new DestroyCommit(id)); }
public Builder( RefName pName ,CommitID pCommitID ) { this.Name = pName; this.CommitID = pCommitID; }
public Task<Errorable<CommitTree>> GetCommitTree(CommitID id, int depth = 10) { return db.ExecuteListQueryAsync(new QueryCommitsRecursively(id, depth)); }
private async Task <Errorable <Commit> > getCommit(CommitID id) { FileInfo fi = system.getPathByID(id); if (!fi.Exists) { return(null); } byte[] buf; int nr = 0; using (var fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true)) { // TODO: implement an async buffered Stream: buf = new byte[16384]; nr = await fs.ReadAsync(buf, 0, 16384).ConfigureAwait(continueOnCapturedContext: false); if (nr >= 16384) { // My, what a large commit you have! throw new NotSupportedException(); } } Commit.Builder cb = new Commit.Builder() { Parents = new List <CommitID>() }; // Parse the Commit: using (var ms = new MemoryStream(buf, 0, nr, false)) using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line; // Read the list of parent CommitIDs: while ((line = sr.ReadLine()) != null) { if (!line.StartsWith("parent ")) { break; } string parent_commitid = line.Substring("parent ".Length); var ecid = CommitID.TryParse(parent_commitid); if (ecid.HasErrors) { return(ecid.Errors); } cb.Parents.Add(ecid.Value); } // Set TreeID: if (line == null || !line.StartsWith("tree ")) { return(new CommitParseExpectedTreeError()); } var etrid = TreeID.TryParse(line.Substring("tree ".Length)); if (etrid.HasErrors) { return(etrid.Errors); } cb.TreeID = etrid.Value; // Set Committer: line = sr.ReadLine(); if (line == null || !line.StartsWith("committer ")) { return(new CommitParseExpectedCommitterError()); } cb.Committer = line.Substring("committer ".Length); // Set DateCommitted: line = sr.ReadLine(); if (line == null || !line.StartsWith("date ")) { return(new CommitParseExpectedDateError()); } // NOTE: date parsing will result in an inexact DateTimeOffset from what was created with, but it // is close enough because the SHA-1 hash is calculated using the DateTimeOffset.ToString(), so // only the ToString() representations of the DateTimeOffsets need to match. DateTimeOffset tmpDate; if (!DateTimeOffset.TryParse(line.Substring("date ".Length), out tmpDate)) { return(new CommitParseBadDateFormatError()); } cb.DateCommitted = tmpDate; // Skip empty line: line = sr.ReadLine(); if (line == null || line.Length != 0) { return(new CommitParseExpectedBlankLineError()); } // Set Message: cb.Message = sr.ReadToEnd(); } // Create the immutable Commit from the Builder: Commit cm = cb; // Validate the computed CommitID: if (cm.ID != id) { return(new ComputedCommitIDMismatchError(cm.ID, id)); } return(cm); }
public Task <Errorable <Commit> > GetCommit(CommitID id) { return(getCommit(id)); }
public async Task<Errorable<CommitID>> DeleteCommit(CommitID id) { await Task.Run(() => deleteCommit(id)).ConfigureAwait(continueOnCapturedContext: false); return id; }
public void Commit(Node hub, CommitID commitID) { TestAttachment attach = (TestAttachment)hub.Attachment; attach.Received.Enqueue(Index); }
public Task<Errorable<Commit>> GetCommit(CommitID id) { return getCommit(id); }
public QueryCommit(CommitID id) { this._id = id; }
private async Task<Errorable<Commit[]>> getCommitsRecursively(CommitID id, int depthLevel, int depthMaximum) { // Get the current commit: var eroot = await getCommit(id).ConfigureAwait(continueOnCapturedContext: false); if (eroot.HasErrors) return eroot.Errors; var root = eroot.Value; var rootArr = new Commit[1] { root }; // We have no parents: if (root.Parents.Length == 0) return rootArr; // This is the last depth level: if (depthLevel >= depthMaximum) return rootArr; // Recurse up the commit parents: Task<Errorable<Commit[]>>[] tasks = new Task<Errorable<Commit[]>>[root.Parents.Length]; for (int i = 0; i < root.Parents.Length; ++i) { tasks[i] = getCommitsRecursively(root.Parents[i], depthLevel + 1, depthMaximum); } // Await all the tree retrievals: var allCommits = await Task.WhenAll(tasks).ConfigureAwait(continueOnCapturedContext: false); // Roll up all the errors: ErrorContainer errors = ( from ecms in allCommits where ecms.HasErrors select ecms.Errors ).Aggregate(new ErrorContainer(), (acc, err) => acc + err); if (errors.HasAny) return errors; // Flatten out the tree arrays: var flattened = from ecms in allCommits from cm in ecms.Value select cm; // Return the final array: return rootArr.Concat(flattened).ToArray(allCommits.Sum(ca => ca.Value.Length) + 1); }
public async Task<Errorable<CommitTree>> GetCommitTree(CommitID id, int depth = 10) { var eall = await getCommitsRecursively(id, 1, depth).ConfigureAwait(continueOnCapturedContext: false); if (eall.HasErrors) return eall.Errors; var all = eall.Value; // Return them (all[0] is the root): return new CommitTree(all[0].ID, new ImmutableContainer<CommitID, ICommit>(cm => cm.ID, all)); }
private async Task <Errorable <Tag> > getTag(TagID id) { FileInfo fi = system.getPathByID(id); if (!fi.Exists) { return(new TagIDRecordDoesNotExistError(id)); } byte[] buf; int nr = 0; using (var fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true)) { // TODO: implement an async buffered Stream: buf = new byte[16384]; nr = await fs.ReadAsync(buf, 0, 16384).ConfigureAwait(continueOnCapturedContext: false); if (nr >= 16384) { // My, what a large tag you have! throw new NotSupportedException(); } } Tag.Builder tb = new Tag.Builder(); // Parse the Tag: using (var ms = new MemoryStream(buf, 0, nr, false)) using (var sr = new StreamReader(ms, Encoding.UTF8)) { string line = sr.ReadLine(); // Set CommitID: if (line == null || !line.StartsWith("commit ")) { return(new TagParseExpectedCommitError()); } var ecid = CommitID.TryParse(line.Substring("commit ".Length)); if (ecid.HasErrors) { return(ecid.Errors); } tb.CommitID = ecid.Value; // Set Name: line = sr.ReadLine(); if (line == null || !line.StartsWith("name ")) { return(new TagParseExpectedNameError()); } tb.Name = (TagName)line.Substring("name ".Length); // Set Tagger: line = sr.ReadLine(); if (line == null || !line.StartsWith("tagger ")) { return(new TagParseExpectedTaggerError()); } tb.Tagger = line.Substring("tagger ".Length); // Set DateTagged: line = sr.ReadLine(); if (line == null || !line.StartsWith("date ")) { return(new TagParseExpectedDateError()); } // NOTE: date parsing will result in an inexact DateTimeOffset from what was created with, but it // is close enough because the SHA-1 hash is calculated using the DateTimeOffset.ToString(), so // only the ToString() representations of the DateTimeOffsets need to match. DateTimeOffset tmpDate; if (!DateTimeOffset.TryParse(line.Substring("date ".Length), out tmpDate)) { return(new TagParseBadDateFormatError()); } tb.DateTagged = tmpDate; // Skip empty line: line = sr.ReadLine(); if (line == null || line.Length != 0) { return(new TagParseExpectedBlankLineError()); } // Set Message: tb.Message = sr.ReadToEnd(); } // Create the immutable Tag from the Builder: Tag tg = tb; // Validate the computed TagID: if (tg.ID != id) { return(new ComputedTagIDMismatchError(tg.ID, id)); } return(tg); }
public Task<Errorable<Commit>> GetCommit(CommitID id) { return db.ExecuteSingleQueryAsync(new QueryCommit(id)); }
public QueryCommitsRecursively(CommitID id, int depth = 10) { this._id = id; this._depth = depth; }
public async Task<Errorable<CommitID>> ResolvePartialID(CommitID.Partial id) { var resolvedIDs = await db.ExecuteListQueryAsync(new ResolvePartialCommitID(id)); if (resolvedIDs.Length == 1) return resolvedIDs[0]; if (resolvedIDs.Length == 0) return new CommitIDPartialNoResolutionError(id); return new CommitIDPartialAmbiguousResolutionError(id, resolvedIDs); }
private void deleteCommit(CommitID id) { FileInfo fi = system.getPathByID(id); lock (FileSystem.SystemLock) { if (!fi.Exists) return; fi.Delete(); } }