public FieldCollection(IRevision <TIdentifier> revision, FieldDefinitionCollection <TIdentifier> fieldDefinitions) { _revision = revision; _fieldDefinitions = fieldDefinitions; InitialLoad(); }
public void MapRevision(NodeVersion source, IRevision <TypedEntity> destination, AbstractLookupHelper lookupHelper, AbstractMappingEngine masterMapper) { if (destination.Item == null) { var casted = destination as Revision <TypedEntity>; if (casted != null) { casted.Item = MapTypedEntityForRevision(source, lookupHelper, masterMapper); } } else { MapTypedEntityForRevision(source, destination.Item, lookupHelper, masterMapper); } var latestStatus = GetLatestNodeVersionStatus(source, lookupHelper, masterMapper); var utcStatusChanged = latestStatus == null ? DateTimeOffset.MinValue : latestStatus.Date; var statusType = latestStatus == null ? new RevisionStatusType("unknown", "Unknown / Not specified") : MapEntityStatusType(latestStatus.NodeVersionStatusType, lookupHelper, masterMapper); var metaData = new RevisionData() { Id = (HiveId)source.Id, StatusType = statusType, UtcCreated = source.NodeVersionStatuses.First().Date, UtcModified = utcStatusChanged, UtcStatusChanged = utcStatusChanged }; destination.Item.UtcModified = source.DateCreated; destination.Item.UtcStatusChanged = utcStatusChanged; destination.MetaData = metaData; }
public static void MapFromRevision(IRevision <TypedEntity> source, NodeVersion destination, AbstractLookupHelper lookupHelper, AbstractMappingEngine masterMapper) { var masterNode = destination; if (masterNode == null) { MapTypedEntityForRevision(source.Item, lookupHelper, masterMapper); } else { MapTypedEntityForRevision(source.Item, masterNode, lookupHelper, masterMapper); } // Overwrite the default status history that was created by MapVersion // since in this mapping method, we actually have real revision info // The MapVersion method, in lieu of any data about a revision, adds a status history of "Created", which we can remove var revisionData = source.MetaData; var rdbmsStatusHistory = CreateRdbmsStatusHistory(destination, revisionData, lookupHelper, masterMapper); var createdStatusHistory = destination.NodeVersionStatuses.FirstOrDefault(x => x.NodeVersionStatusType.Alias == FixedStatusTypes.Created.Alias); if (createdStatusHistory != null) { destination.NodeVersionStatuses.Remove(createdStatusHistory); } destination.NodeVersionStatuses.Add(rdbmsStatusHistory); }
public virtual void Publish(IRevision revision) { lock (padlock) { EnsureOpen(); if (currentRevision != null) { int compare = revision.CompareTo(currentRevision.Revision); if (compare == 0) { // same revision published again, ignore but release it revision.Release(); return; } if (compare < 0) { revision.Release(); throw new ArgumentException(string.Format("Cannot publish an older revision: rev={0} current={1}", revision, currentRevision), "revision"); } } RefCountedRevision oldRevision = currentRevision; currentRevision = new RefCountedRevision(revision); if (oldRevision != null) { oldRevision.DecRef(); } CheckExpiredSessions(); } }
public static NodeVersion MapFromRevision(IRevision <TypedEntity> source, AbstractLookupHelper lookupHelper, AbstractMappingEngine masterMapper) { var output = GetObjectReference(source.MetaData.Id, lookupHelper, () => new NodeVersion()); MapFromRevision(source, output, lookupHelper, masterMapper); return(output); }
private IUser GetTargetUser(List <UserDto> users, IRevision revision) { //UserDto mappedUser = users.FirstOrDefault( // u => u.RepositoryCredentials.Any( // c => string.Equals(c.Login, revision.Author, StringComparison.InvariantCultureIgnoreCase) && c.RepositoryType == this.source.Type)); UserDto mappedUser = users.FirstOrDefault( u => string.Equals(u.Email, revision.Author, StringComparison.InvariantCultureIgnoreCase)); if (mappedUser == null) { Logging.Log().Warning($"Missing {revision.Author} user. Using default {this.defaultPushUser.Email}."); this.syncLogger.Log(this.sync, $"Missing {revision.Author} user. Using default {this.defaultPushUser.Email}."); mappedUser = users.FirstOrDefault(u => u.Id == this.defaultPushUser.Id); if (mappedUser == null) { Logging.Log().Warning($"Default {this.defaultPushUser.Email} user does not have credentials matching revision author ({revision.Author})."); this.syncLogger.Log(this.sync, $"Default {this.defaultPushUser.Email} user does not have credentials matching revision author ({revision.Author})."); throw new InvalidOperationException($"Cannot find user with {this.source.Type} {revision.Author} credentials."); } } return(mappedUser.ToUser()); }
public MergingRevision(IRevision revisionAppliedTo, IList<IRevision> revisionsToMerge) { revisionAppliedTo.NextRevisionApplied = this; RevisionsToMerge = revisionsToMerge; PreviousRevisionAppliedTo = revisionAppliedTo; CheckForConflicts(); Id = Guid.NewGuid(); }
public static RevisionDto ToDto(this IRevision rev) { var dto = new RevisionDto { Id = rev.Id, Message = rev.Message, Author = rev.Author }; return(dto); }
public virtual int CompareTo(IRevision other) { //TODO: This breaks the contract and will fail if called with a different implementation // This is a flaw inherited from the original source... // It should at least provide a better description to the InvalidCastException IndexRevision or = (IndexRevision)other; return(commit.CompareTo(or.commit)); }
public void TestUpdateToLatest() { replicator.Publish(CreateRevision(1)); IRevision rev = CreateRevision(2); replicator.Publish(rev); SessionToken res = replicator.CheckForUpdate(null); assertNotNull(res); assertEquals(0, rev.CompareTo(res.Version)); }
public void GiveUpdate(IRevision revision) { var notification = new SubcriberNotification { patches = revision.BuildPatch(), id = revision.Id, revisionAppliedTo = revision.PreviousRevisionAppliedTo.Id, content = revision.GenerateEditedContent() }; if (SubscriberNotifiedOfUpdate != null) SubscriberNotifiedOfUpdate(this, notification); }
public void Checkout(IRevision revision) { IGitRevision gitRev = (IGitRevision)revision; var commit = gitRev.CommitObject; if (commit == null) { throw new InvalidOperationException($"Commit {revision.Id} not found."); } this.repo.Reset(ResetMode.Hard, commit); }
public AssemblyStatus(SourceControl.BuildServers.SourceController prj) { State = prj.BuildServer.GetState().ToString(); IRevision scmBS = prj.BuildServerRevision; IRevision scmPck = prj.PackageRevision; BuildServerRev = scmBS; PackageRev = scmPck; packagedDate = prj.Versions.LastPackagedDate; Loaded = prj.RuntimeLoaded; LoadedRevision = prj.RuntimeLoadedRevision; LoadedRemarks = prj.RuntimeLoadedRemark; }
private void CreateReflection(IRevision sourceRevision, IRevision targetRevision) { var reflection = new Reflection { DateTime = DateTime.Now, Mirror = this.sync.Mirror, Synchronization = this.sync, SourceRevision = sourceRevision, TargetRevision = targetRevision }; var dto = reflection.ToDto(); this.httpClient.Reflection.Add(dto); }
public Field(IRevision <TIdentifier> revision, IFieldDefinition <TIdentifier> fieldDefinition) { if (fieldDefinition == null) { throw new ArgumentNullException("fieldDefinition", "No field definition specified."); } if (revision == null) { throw new ArgumentNullException("revision", "No revision data specified"); } _revision = revision; _fieldDefinition = fieldDefinition; }
public virtual int CompareTo(IRevision other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (!(other is IndexAndTaxonomyRevision itr)) { throw new ArgumentException($"Cannot compare IndexAndTaxonomyRevision to a {other.GetType()}", nameof(other)); } int cmp = indexCommit.CompareTo(itr.indexCommit); return(cmp != 0 ? cmp : taxonomyCommit.CompareTo(itr.taxonomyCommit)); }
private IRevision UpdateRemote(IUser commiter, IRevision revision, string message) { string login = commiter.RepositoryCredentials.FirstOrDefault(c => c.RepositoryType == this.target.Type)?.Login; if (login == null) { throw new InvalidOperationException($"User {commiter.Name} does not have {this.target.Type} credentials."); } string password = this.retriever.GetPassword(commiter.Id, this.target.Type); this.target.StageAll(); var rev = this.target.UpdateRemoteWithCommit(message, login, password); return(rev); }
public virtual int CompareTo(IRevision other) { if (other == null) { throw new ArgumentNullException("other"); } IndexAndTaxonomyRevision itr = other as IndexAndTaxonomyRevision; if (itr == null) { throw new ArgumentException(string.Format("Cannot compare IndexAndTaxonomyRevision to a {0}", other.GetType()), "other"); } int cmp = indexCommit.CompareTo(itr.indexCommit); return(cmp != 0 ? cmp : taxonomyCommit.CompareTo(itr.taxonomyCommit)); }
public void TestPublishSameRevision() { IRevision rev = CreateRevision(1); replicator.Publish(rev); SessionToken res = replicator.CheckForUpdate(null); assertNotNull(res); assertEquals(rev.Version, res.Version); replicator.Release(res.Id); replicator.Publish(new IndexRevision(sourceWriter)); res = replicator.CheckForUpdate(res.Version); assertNull(res); // now make sure that publishing same revision doesn't leave revisions // "locked", i.e. that replicator releases revisions even when they are not // kept replicator.Publish(CreateRevision(2)); assertEquals(1, DirectoryReader.ListCommits(sourceDirectory).size()); }
public Revision(IRevision other) : this() { foreach (var gtkv in other.gts) { gts[gtkv.Key] = new HashSet <GT>(gtkv.Value); } foreach (var gttkv in other.gtts) { gtts[gttkv.Key] = new HashSet <GTT>(gttkv.Value); } foreach (var ga in other.assumedUGCs) { addAssumedUGC(ga); } foreach (var gaf in other.gafs) { addGAF(gaf); } }
partial void Attachments_SetCondition(ref IRevision instance, ref IAttachmentCollection setValue);
partial void Links_SetCondition(ref IRevision instance, ref ILinkCollection setValue);
partial void Index_SetCondition(ref IRevision instance, ref Int32 setValue);
private void NotifySubscribers(IRevision revision) { foreach (var subscriber in Subcribers) { subscriber.GiveUpdate(revision); } }
public void Checkout(IRevision revision) { long rev = long.Parse(revision.Id); this.Checkout(rev); }
public RevisionSaveResult(bool success, IRevision <T> item, params Exception[] errors) : base(success, item.Item, errors) { Revision = item; }
public BasicRevision(IRevision revision, List<Patch> revisionPatches ) : this(revision,revisionPatches, Guid.NewGuid()) { }
public HiveRevisionPreActionEventArgs(IRevision <IVersionableEntity> entity, AbstractScopedCache scopedCache) : base(scopedCache) { Entity = entity; }
/// <summary> /// Constructor with the given <paramref name="id"/> and <paramref name="revision"/>. /// </summary> /// <exception cref="IOException"></exception> public SessionToken(string id, IRevision revision) { Id = id; Version = revision.Version; SourceFiles = revision.SourceFiles; }
public RevisionSetItem(IRevision revision, bool canBeReleased) { this.revision = revision; this.CanBeReleased = revision.ReleaseStatus && canBeReleased; this.IsBlocked = revision.ReleaseStatus && !canBeReleased; }
public HiveRevisionPreActionEventArgs(IRevision<IVersionableEntity> entity, AbstractScopedCache scopedCache) : base(scopedCache) { Entity = entity; }
public RefCountedRevision(IRevision revision) { Revision = revision; }
partial void Fields_SetCondition(ref IRevision instance, ref IFieldCollection setValue);
/// <summary> /// Not supported. /// </summary> /// <exception cref="NotSupportedException">this replicator implementation does not support remote publishing of revisions</exception> public virtual void Publish(IRevision revision) { throw new NotSupportedException("this replicator implementation does not support remote publishing of revisions"); }
public void ResolveConflict(IRevision revision) { if(!RevisionsConflict || RevisionChosenForResolution != null) throw new InvalidOperationException("The revision is not currently in conflict, no resolution necessary"); RevisionChosenForResolution = revision; }
// ReSharper restore UnusedMember.Local public BasicRevision(IRevision revison, List<Patch> revisionPatches, Guid id) { PreviousRevisionAppliedTo = revison; Patches = revisionPatches; Id = id; }
public HiveRevisionPostActionEventArgs(IRevision<IVersionableEntity> entity, AbstractScopedCache scopedCache) { Entity = entity; ScopedCache = scopedCache; }
partial void GetTagLine_PostValidate(IRevision instance);
partial void GetTagLine_PreCondition(IRevision instance);
public void Edit(IRevision revision) { var appliedRevision = revision; var parentAlreadyHasNewChildRevision = revision.PreviousRevisionAppliedTo.NextRevisionApplied != null; var parentMerged = _revisionMap.ContainsKey(revision.PreviousRevisionAppliedTo.Id) && _revisionMap[revision.PreviousRevisionAppliedTo.Id].Item2 == RevisionStatus.Merged; if (parentAlreadyHasNewChildRevision) { var mergeParent = FindCommonAncestor(revision, CurrentRevision); appliedRevision = new MergingRevision(mergeParent, new List<IRevision> { revision, CurrentRevision }); var mergeRevision = (MergingRevision) appliedRevision; foreach (var mergedRevision in mergeRevision.RevisionsToMerge) { var tuple = Tuple.Create(mergedRevision, RevisionStatus.Merged); UpdateRevisionMap(tuple); mergedRevision.NextRevisionApplied = mergeRevision; } } else CurrentRevision.NextRevisionApplied = revision; UpdateRevisionMap(Tuple.Create(appliedRevision, RevisionStatus.Applied)); CurrentRevision = appliedRevision; NotifySubscribers(appliedRevision); }
private static IRevision FindCommonAncestor(IRevision revision1, IRevision revision2) { var revision1Parents = new List<IRevision>(); var revision2Parents = new List<IRevision>(); var revision1AncestorCurrentPtr = revision1; var revision2AncestorCurrentPtr = revision2; while (!revision1Parents.Intersect(revision2Parents).Any() && !( revision1AncestorCurrentPtr.PreviousRevisionAppliedTo == null && revision2AncestorCurrentPtr.PreviousRevisionAppliedTo == null)) { if (revision1AncestorCurrentPtr.PreviousRevisionAppliedTo != null) { revision1Parents.Add(revision1AncestorCurrentPtr.PreviousRevisionAppliedTo); revision1AncestorCurrentPtr = revision1AncestorCurrentPtr.PreviousRevisionAppliedTo; } if (revision2AncestorCurrentPtr.PreviousRevisionAppliedTo != null) { revision2Parents.Add(revision2AncestorCurrentPtr.PreviousRevisionAppliedTo); revision2AncestorCurrentPtr = revision2AncestorCurrentPtr.PreviousRevisionAppliedTo; } } return revision1Parents.Intersect(revision2Parents).Any() ? revision1Parents.Intersect(revision2Parents).Single() : null; }