private static void DumpLogFile(string filename) { try { var itemFile = new ItemFile(filename, Encoding.Default); itemFile.Header.Header.Dump(Console.Out); itemFile.Header.Dump(Console.Out); var record = itemFile.GetNextRecord(true); while (record != null) { record.Header.Dump(Console.Out); record.Dump(Console.Out); var revision = record as RevisionRecord; if (revision != null) { if (itemFile.Header.ItemType == ItemType.Project) { projectActions.Add(revision.Action); } else { fileActions.Add(revision.Action); } } record = itemFile.GetNextRecord(true); } } catch (Exception e) { Console.WriteLine("ERROR: {0}", e.Message); } }
public Stream GetContents() { Stream dataFile = new FileStream(item.DataPath, FileMode.Open, FileAccess.Read, FileShare.Read); var itemFile = item.ItemFile; var lastRev = itemFile.GetLastRevision(); if (lastRev != null) { IEnumerable<DeltaOperation> deltaOps = null; while (lastRev != null && lastRev.Revision > this.Version) { var branchRev = lastRev as BranchRevisionRecord; if (branchRev != null) { var branchRevId = branchRev.Revision; var itemPath = item.Database.GetDataPath(branchRev.BranchFile); itemFile = new ItemFile(itemPath, item.Database.Encoding); lastRev = itemFile.GetLastRevision(); while (lastRev != null && lastRev.Revision >= branchRevId) { lastRev = itemFile.GetPreviousRevision(lastRev); } } else { var editRev = lastRev as EditRevisionRecord; if (editRev != null) { var delta = itemFile.GetPreviousDelta(editRev); if (delta != null) { var curDeltaOps = delta.Operations; deltaOps = (deltaOps == null) ? curDeltaOps : DeltaUtil.Merge(deltaOps, curDeltaOps); } } lastRev = itemFile.GetPreviousRevision(lastRev); } } if (deltaOps != null) { dataFile = new DeltaStream(dataFile, deltaOps); } } return dataFile; }
public VssItem GetItemPhysical(string physicalName) { physicalName = physicalName.ToUpper(); if (physicalName == RootProjectFile) { return rootProject; } var physicalPath = GetDataPath(physicalName); var itemFile = new ItemFile(physicalPath, encoding); var isProject = (itemFile.Header.ItemType == ItemType.Project); var logicalName = GetFullName(itemFile.Header.Name); var itemName = new VssItemName(logicalName, physicalName, isProject); VssItem item; if (isProject) { var parentFile = ((ProjectHeaderRecord)itemFile.Header).ParentFile; var parent = (VssProject)GetItemPhysical(parentFile); var logicalPath = BuildPath(parent, logicalName); item = new VssProject(this, itemName, physicalPath, logicalPath); } else { item = new VssFile(this, itemName, physicalPath); } item.ItemFile = itemFile; return item; }