VSS record representing a project/file revision.
Inheritance: VssRecord
Exemple #1
0
 internal VssRevision(VssItem item, RevisionRecord revision, CommentRecord comment)
 {
     this.item = item;
     this.action = CreateAction(revision, item);
     this.revision = revision;
     this.comment = comment;
 }
Exemple #2
0
        private static RevisionRecord CreateRevisionRecord(
            RecordHeader recordHeader, BufferReader recordReader)
        {
            if (recordHeader.Signature != RevisionRecord.SIGNATURE)
            {
                return(null);
            }

            RevisionRecord record;
            var            action = RevisionRecord.PeekAction(recordReader);

            switch (action)
            {
            case Action.Label:
                record = new RevisionRecord();
                break;

            case Action.DestroyProject:
            case Action.DestroyFile:
                record = new DestroyRevisionRecord();
                break;

            case Action.RenameProject:
            case Action.RenameFile:
                record = new RenameRevisionRecord();
                break;

            case Action.MoveFrom:
            case Action.MoveTo:
                record = new MoveRevisionRecord();
                break;

            case Action.ShareFile:
                record = new ShareRevisionRecord();
                break;

            case Action.BranchFile:
            case Action.CreateBranch:
                record = new BranchRevisionRecord();
                break;

            case Action.EditFile:
                record = new EditRevisionRecord();
                break;

            case Action.ArchiveProject:
            case Action.RestoreProject:
            case Action.RestoreFile:
                record = new ArchiveRevisionRecord();
                break;

            case Action.CreateProject:
            case Action.AddProject:
            case Action.AddFile:
            case Action.DeleteProject:
            case Action.DeleteFile:
            case Action.RecoverProject:
            case Action.RecoverFile:
            case Action.CreateFile:
            default:
                record = new CommonRevisionRecord();
                break;
            }
            return(record);
        }
Exemple #3
0
 protected override VssRevision CreateRevision(RevisionRecord revision, CommentRecord comment)
 {
     return new VssFileRevision(this, revision, comment);
 }
 internal VssProjectRevision(VssItem item, RevisionRecord revision, CommentRecord comment)
     : base(item, revision, comment)
 {
 }
Exemple #5
0
 public RevisionRecord GetNextRevision(RevisionRecord revision)
 {
     reader.Offset = revision.Header.Offset + revision.Header.Length + RecordHeader.LENGTH;
     return(GetNextRecord <RevisionRecord>(CreateRevisionRecord, true));
 }
Exemple #6
0
 public RevisionRecord GetNextRevision(RevisionRecord revision)
 {
     reader.Offset = revision.Header.Offset + revision.Header.Length + RecordHeader.LENGTH;
     return GetNextRecord<RevisionRecord>(CreateRevisionRecord, true);
 }
Exemple #7
0
        private static RevisionRecord CreateRevisionRecord(
            RecordHeader recordHeader, BufferReader recordReader)
        {
            if (recordHeader.Signature != RevisionRecord.SIGNATURE)
            {
                return null;
            }

            RevisionRecord record;
            var action = RevisionRecord.PeekAction(recordReader);
            switch (action)
            {
                case Action.Label:
                    record = new RevisionRecord();
                    break;
                case Action.DestroyProject:
                case Action.DestroyFile:
                    record = new DestroyRevisionRecord();
                    break;
                case Action.RenameProject:
                case Action.RenameFile:
                    record = new RenameRevisionRecord();
                    break;
                case Action.MoveFrom:
                case Action.MoveTo:
                    record = new MoveRevisionRecord();
                    break;
                case Action.ShareFile:
                    record = new ShareRevisionRecord();
                    break;
                case Action.BranchFile:
                case Action.CreateBranch:
                    record = new BranchRevisionRecord();
                    break;
                case Action.EditFile:
                    record = new EditRevisionRecord();
                    break;
                case Action.ArchiveProject:
                case Action.RestoreProject:
                    record = new ArchiveRevisionRecord();
                    break;
                case Action.CreateProject:
                case Action.AddProject:
                case Action.AddFile:
                case Action.DeleteProject:
                case Action.DeleteFile:
                case Action.RecoverProject:
                case Action.RecoverFile:
                case Action.CreateFile:
                default:
                    record = new CommonRevisionRecord();
                    break;
            }
            return record;
        }
Exemple #8
0
 public RevisionRecord GetPreviousRevision(RevisionRecord revision)
 {
     if (revision.PrevRevOffset > 0)
     {
         return GetRecord<RevisionRecord>(CreateRevisionRecord, false, revision.PrevRevOffset);
     }
     return null;
 }
Exemple #9
0
 private static VssAction CreateAction(RevisionRecord revision, VssItem item)
 {
     var db = item.Database;
     switch (revision.Action)
     {
         case Hpdi.VssPhysicalLib.Action.Label:
             {
                 return new VssLabelAction(revision.Label);
             }
         case Hpdi.VssPhysicalLib.Action.DestroyProject:
         case Hpdi.VssPhysicalLib.Action.DestroyFile:
             {
                 var destroy = (DestroyRevisionRecord)revision;
                 return new VssDestroyAction(db.GetItemName(destroy.Name, destroy.Physical));
             }
         case Hpdi.VssPhysicalLib.Action.RenameProject:
         case Hpdi.VssPhysicalLib.Action.RenameFile:
             {
                 var rename = (RenameRevisionRecord)revision;
                 return new VssRenameAction(db.GetItemName(rename.Name, rename.Physical),
                     db.GetFullName(rename.OldName));
             }
         case Hpdi.VssPhysicalLib.Action.MoveFrom:
             {
                 var moveFrom = (MoveRevisionRecord)revision;
                 return new VssMoveFromAction(db.GetItemName(moveFrom.Name, moveFrom.Physical),
                     moveFrom.ProjectPath);
             }
         case Hpdi.VssPhysicalLib.Action.MoveTo:
             {
                 var moveTo = (MoveRevisionRecord)revision;
                 return new VssMoveToAction(db.GetItemName(moveTo.Name, moveTo.Physical),
                     moveTo.ProjectPath);
             }
         case Hpdi.VssPhysicalLib.Action.ShareFile:
             {
                 var share = (ShareRevisionRecord)revision;
                 return new VssShareAction(db.GetItemName(share.Name, share.Physical),
                     share.ProjectPath);
             }
         case Hpdi.VssPhysicalLib.Action.BranchFile:
         case Hpdi.VssPhysicalLib.Action.CreateBranch:
             {
                 var branch = (BranchRevisionRecord)revision;
                 var name = db.GetFullName(branch.Name);
                 return new VssBranchAction(
                     new VssItemName(name, branch.Physical, branch.Name.IsProject),
                     new VssItemName(name, branch.BranchFile, branch.Name.IsProject));
             }
         case Hpdi.VssPhysicalLib.Action.EditFile:
             {
                 return new VssEditAction(item.PhysicalName);
             }
         case Hpdi.VssPhysicalLib.Action.CreateProject:
         case Hpdi.VssPhysicalLib.Action.CreateFile:
             {
                 var create = (CommonRevisionRecord)revision;
                 return new VssCreateAction(db.GetItemName(create.Name, create.Physical));
             }
         case Hpdi.VssPhysicalLib.Action.AddProject:
         case Hpdi.VssPhysicalLib.Action.AddFile:
             {
                 var add = (CommonRevisionRecord)revision;
                 return new VssAddAction(db.GetItemName(add.Name, add.Physical));
             }
         case Hpdi.VssPhysicalLib.Action.DeleteProject:
         case Hpdi.VssPhysicalLib.Action.DeleteFile:
             {
                 var delete = (CommonRevisionRecord)revision;
                 return new VssDeleteAction(db.GetItemName(delete.Name, delete.Physical));
             }
         case Hpdi.VssPhysicalLib.Action.RecoverProject:
         case Hpdi.VssPhysicalLib.Action.RecoverFile:
             {
                 var recover = (CommonRevisionRecord)revision;
                 return new VssRecoverAction(db.GetItemName(recover.Name, recover.Physical));
             }
         case Hpdi.VssPhysicalLib.Action.ArchiveProject:
             {
                 var archive = (ArchiveRevisionRecord)revision;
                 return new VssArchiveAction(db.GetItemName(archive.Name, archive.Physical),
                     archive.ArchivePath);
             }
         case Hpdi.VssPhysicalLib.Action.RestoreProject:
             {
                 var archive = (ArchiveRevisionRecord)revision;
                 return new VssRestoreAction(db.GetItemName(archive.Name, archive.Physical),
                     archive.ArchivePath);
             }
         default:
             throw new RecordException("Unknown revision action: " + revision.Action);
     }
 }