public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
        {
            var diffReports = new List <IChangeReport>(1);

            // The only relevant change to report is the version number.
            var childData        = child.GetFileContents(repository);
            var splitData        = SplitData(childData);
            var childModelNumber = Int32.Parse(splitData[1]);

            if (parent == null)
            {
                diffReports.Add(new FieldWorksModelVersionAdditionChangeReport(child, childModelNumber));
            }
            else
            {
                var parentData = parent.GetFileContents(repository);
                splitData = SplitData(parentData);
                var parentModelNumber = Int32.Parse(splitData[1]);
                if (parentModelNumber != childModelNumber)
                {
                    diffReports.Add(new FieldWorksModelVersionUpdatedReport(parent, child, parentModelNumber, childModelNumber));
                }
                else
                {
                    throw new InvalidOperationException("The version number has downgraded");
                }
            }

            return(diffReports);
        }
Example #2
0
        //  private readonly XmlNode _deletedNode;

        public ErrorDeterminingChangeReport(FileInRevision parent, FileInRevision child, XmlNode parentNode, XmlNode childNode, Exception error)
            : base(parent, child)
        {
            _parentNode = parentNode;
            _childNode  = childNode;
            _error      = error;
        }
Example #3
0
 public XmlChangedRecordReport(FileInRevision parentFileInRevision, FileInRevision childFileInRevision, XmlNode parent, XmlNode child, string url)
     : base(parentFileInRevision, childFileInRevision)
 {
     _parent = parent;
     _child  = child;
     _url    = url;
 }
Example #4
0
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     return(Xml2WayDiffService.ReportDifferences(
                repository,
                parent,
                child,
                SharedConstants.Header,
                SharedConstants.WfiWordform, SharedConstants.GuidStr));
 }
Example #5
0
 /// <summary>
 /// Create instance of Xml2WayDiffer
 /// </summary>
 public static Xml2WayDiffer CreateFromFileInRevision(FileInRevision parent, FileInRevision child,
                                                      IMergeEventListener eventListener, HgRepository repository,
                                                      string firstElementMarker,
                                                      string startTag, string identfierAttribute)
 {
     return(new Xml2WayDiffer(repository, eventListener, parent, child,
                              firstElementMarker,
                              startTag, identfierAttribute));
 }
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     return(Xml2WayDiffService.ReportDifferences(
                repository,
                parent,
                child,
                null,
                SharedConstants.PhPhonData, SharedConstants.GuidStr));
 }
Example #7
0
 protected XmlAttributeChange(FileInRevision parent, FileInRevision child, XmlAttribute affectedAttribute, string url)
     : base(parent, child)
 {
     if (affectedAttribute == null)
     {
         throw new ArgumentNullException("affectedAttribute");
     }
     _affectedAttribute = affectedAttribute;
     _url = url;
 }
Example #8
0
        protected XmlTextChange(FileInRevision parent, FileInRevision child, XmlNode affectedNode, string url)
            : base(parent, child)
        {
            if (affectedNode.HasChildNodes && affectedNode.FirstChild.NodeType != XmlNodeType.Text)
            {
                throw new ArgumentException(AnnotationImages.kElementNotTextElement, "affectedNode");
            }

            _affectedNode = affectedNode;
            _url          = url;
        }
Example #9
0
        public IEnumerable <IChangeReport> DescribeInitialContents(FileInRevision fileInRevision, TempFile file)
        {
            var dom = new XmlDocument();

            dom.Load(file.Path);


            foreach (XmlNode e in dom.SafeSelectNodes("notes/annotation"))
            {
                yield return(new XmlAdditionChangeReport(fileInRevision, e));
            }
        }
Example #10
0
        public IEnumerable <IChangeReport> DescribeInitialContents(FileInRevision fileInRevision, TempFile file)
        {
            // Skip check, since DefaultChangeReport doesn't require it.
            //if (fileInRevision == null)
            //    throw new ArgumentNullException("fileInRevision");

            // Not used here, so don't fret if it is null.
            //if (file == null)
            //    throw new ArgumentNullException("file");

            return(new IChangeReport[] { new DefaultChangeReport(fileInRevision, "Added") });
        }
Example #11
0
 private Xml2WayDiffer(HgRepository repository, IMergeEventListener eventListener, FileInRevision parent, FileInRevision child,
                       string firstElementMarker,
                       string startTag, string identfierAttribute)
 {
     _diffingMode          = DiffingMode.FromFileInRevisions;
     _repository           = repository;
     _parentFileInRevision = parent;
     _childFileInRevision  = child;
     if (!string.IsNullOrEmpty(firstElementMarker))
     {
         _firstElementTag = firstElementMarker.Trim();
     }
     _startTag           = "<" + startTag.Trim();
     _identfierAttribute = identfierAttribute;
     _eventListener      = eventListener;
 }
Example #12
0
        public byte[] GetFileRevision(string repositoryName, string fileRelativePath, string revisionStr)
        {
            string       directory = Path.Combine(ChorusHubOptions.RootDirectory, repositoryName);
            HgRepository repo      = new HgRepository(directory, new NullProgress());
            Revision     revision  = repo.GetRevision(revisionStr);

            if (revision == null)
            {
                return(null);
            }

            FileInRevision file = repo.GetFilesInRevision(revision).FirstOrDefault(
                f => f.FullPath.Length > directory.Length + 1 && // Make path relative by removing directory and path separator character
                string.Equals(f.FullPath.Substring(directory.Length + 1), fileRelativePath, StringComparison.OrdinalIgnoreCase));

            return(file != null?file.GetFileContentsAsBytes(repo) : null);
        }
Example #13
0
        internal static Dictionary <string, byte[]> GetDataFromRevision(FileInRevision revision, HgRepository repository)
        {
            var doc  = XDocument.Parse(revision.GetFileContents(repository));
            var data = doc.Root.Elements("layout")
                       .ToDictionary(layoutElement =>
                                     layoutElement.Attribute("class").Value + layoutElement.Attribute("type").Value + layoutElement.Attribute("name").Value,
                                     layoutElement => SharedConstants.Utf8.GetBytes(layoutElement.ToString()));

            var layoutTypeElement = doc.Root.Element("layoutType");

            if (layoutTypeElement != null)
            {
                data.Add("layoutType", SharedConstants.Utf8.GetBytes(doc.Root.Element("layoutType").ToString()));
            }

            return(data);
        }
Example #14
0
        public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");                 // Parent seems not be optional in Chorus usage.
            }
            if (child == null)
            {
                throw new ArgumentNullException("child");
            }
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            var extension = FileWriterService.GetExtensionFromPathname(child.FullPath);

            return(GetHandlerfromExtension(extension).Find2WayDifferences(parent, child, repository));
        }
Example #15
0
        /// <summary>
        /// Report the differences between two versions of files in the repository.
        /// </summary>
        /// <returns>Zero or more change reports.</returns>
        public static IEnumerable <IChangeReport> ReportDifferences(HgRepository repository,
                                                                    FileInRevision parent, FileInRevision child,
                                                                    string firstElementMarker,
                                                                    string recordMarker, string identfierAttribute)
        {
            var changeAndConflictAccumulator = new ChangeAndConflictAccumulator();
            // Pulls the files out of the repository so we can read them.
            var differ = Xml2WayDiffer.CreateFromFileInRevision(
                parent,
                child,
                changeAndConflictAccumulator,
                repository,
                firstElementMarker,
                recordMarker,
                identfierAttribute);

            differ.ReportDifferencesToListener();

            return(changeAndConflictAccumulator.Changes);
        }
Example #16
0
 public DefaultChangeReport(FileInRevision parent, FileInRevision child, string label)
     : base(parent, child)
 {
     _label = label;
 }
Example #17
0
 public DefaultChangeReport(FileInRevision initial, string label)
     : base(null, initial)
 {
     _label = label;
 }
Example #18
0
 public XmlAttributeChangedReport(FileInRevision parentFileInRevision, FileInRevision childFileInRevision, XmlAttribute editedAttribute)
     : this(parentFileInRevision, childFileInRevision, editedAttribute, string.Empty)
 {
 }
Example #19
0
 public XmlAttributeChangedReport(FileInRevision parentFileInRevision, FileInRevision childFileInRevision, XmlAttribute editedAttribute, string url)
     : base(parentFileInRevision, childFileInRevision, editedAttribute, url)
 {
 }
Example #20
0
 public XmlAttributeDeletedReport(FileInRevision fileInRevision, XmlAttribute ancestorAttribute, string url)
     : base(null, fileInRevision, ancestorAttribute, url)
 {
 }
Example #21
0
 public XmlAttributeBothMadeSameChangeReport(FileInRevision fileInRevision, XmlAttribute editedChilAttribute, string url)
     : base(null, fileInRevision, editedChilAttribute, url)
 {
 }
Example #22
0
 public XmlAttributeBothAddedReport(FileInRevision fileInRevision, XmlAttribute addedChildAttribute, string url)
     : base(null, fileInRevision, addedChildAttribute, url)
 {
 }
Example #23
0
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     return(new IChangeReport[] { new DefaultChangeReport(parent, child, "Edited") });
 }
Example #24
0
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     throw new ApplicationException(string.Format("Chorus could not find a handler to diff files like '{0}'", child.FullPath));
 }
Example #25
0
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     //this is never called because we said we don't do diffs yet; review is handled some other way
     throw new NotImplementedException();
 }
Example #26
0
 public XmlChangedRecordReport(FileInRevision parentFileInRevision, FileInRevision childFileInRevision, XmlNode parent, XmlNode child)
     : this(parentFileInRevision, childFileInRevision, parent, child, string.Empty)
 {
     _parent = parent;
     _child  = child;
 }
Example #27
0
 public IEnumerable <IChangeReport> DescribeInitialContents(FileInRevision fileInRevision, TempFile file)
 {
     //this is never called because we said we don't present diffs; review is handled some other way
     throw new NotImplementedException();
 }
Example #28
0
 public IEnumerable <IChangeReport> Find2WayDifferences(FileInRevision parent, FileInRevision child, HgRepository repository)
 {
     yield return(new TextEditChangeReport(parent, child, parent.GetFileContents(repository), child.GetFileContents(repository)));
 }
Example #29
0
 public IEnumerable <IChangeReport> DescribeInitialContents(FileInRevision fileInRevision, TempFile file)
 {
     return(new IChangeReport[] { new DefaultChangeReport(fileInRevision, "Added") });
 }
Example #30
0
 protected ChangeReport(FileInRevision parent, FileInRevision child)
 {
     ChildFileInRevision  = child;
     ParentFileInRevision = parent;
 }