/// <summary>
        /// Get differences between the document's local file and his source control version.
        /// </summary>
        /// <returns>
        /// Collection that contains the result of comparing the document's local file with his source control version.
        /// <para/>Each element is a pair of key and value: the key is a line of text, the value is a type of difference.
        /// </returns>
        private DiffLinesCollection GetChangedLineNumbers()
        {
            Debug.Assert(_textDoc != null, "_textDoc is null.");
            Debug.Assert(_versionControl != null, "_versionControl is null.");

            var textSnapshot = _textView.TextSnapshot;

            Stream   sourceStream         = new MemoryStream();
            Encoding sourceStreamEncoding = _textDoc.Encoding;

            byte[] textBytes = sourceStreamEncoding.GetBytes(textSnapshot.GetText());
            sourceStream.Write(textBytes, 0, textBytes.Length);

            DiffSummary diffSummary;

            lock (_versionControlItemStreamLockObject)
            {
                diffSummary = GetDifference(
                    _versionControlItemStream,
                    Encoding.GetEncoding(_versionControlItem.Encoding),
                    sourceStream,
                    sourceStreamEncoding);
            }

            var dict = new DiffLinesCollection();

            for (int i = 0; i < diffSummary.Changes.Length; i++)
            {
                var diff = new DiffChange(diffSummary.Changes[i]);

                if (diff.ChangeType == DiffChangeType.Change)
                {
                    if (diff.OriginalLength >= diff.ModifiedLength)
                    {
                        int linesModified = diff.ModifiedLength;
                        if (linesModified == 0)
                        {
                            diff.ChangeType = DiffChangeType.Delete;
                            int linesDeleted = diff.OriginalLength - diff.ModifiedLength;
                            Debug.Assert(linesDeleted > 0, "linesDeleted must be greater than zero.");
                        }
                    }
                    else
                    {
                        int linesModified = diff.OriginalLength;
                        if (linesModified == 0)
                        {
                            diff.ChangeType = DiffChangeType.Insert;
                            int linesAdded = diff.ModifiedLength - diff.OriginalLength;
                            Debug.Assert(linesAdded > 0, "linesAdded must be greater than zero.");
                        }
                    }
                }

                if (diff.ChangeType != DiffChangeType.Delete)
                {
                    for (int k = diff.ModifiedStart; k <= diff.ModifiedEnd; k++)
                    {
                        AddLineToDiffLinesCollection(dict, textSnapshot, k, diff);
                    }
                }
                else
                {
                    AddLineToDiffLinesCollection(dict, textSnapshot, diff.ModifiedStart, diff);
                }
            }

            return(dict);
        }
        /// <summary>
        /// Get differences between the document's local file and his source control version.
        /// </summary>
        /// <returns>
        /// Collection that contains the result of comparing the document's local file with his source control version.
        /// <para/>Each element is a pair of key and value: the key is a line of text, the value is a type of difference.
        /// </returns>
        private DiffLinesCollection GetChangedLineNumbers()
        {
            Debug.Assert(_textDoc != null, "_textDoc is null.");
            Debug.Assert(_versionControl != null, "_versionControl is null.");

            var textSnapshot = _textView.TextSnapshot;

            Stream sourceStream = new MemoryStream();
            Encoding sourceStreamEncoding = _textDoc.Encoding;
            byte[] textBytes = sourceStreamEncoding.GetBytes(textSnapshot.GetText());
            sourceStream.Write(textBytes, 0, textBytes.Length);

            DiffSummary diffSummary;
            lock (_versionControlItemStreamLockObject)
            {
                diffSummary = GetDifference(
                    _versionControlItemStream,
                    Encoding.GetEncoding(_versionControlItem.Encoding),
                    sourceStream,
                    sourceStreamEncoding);
            }

            var dict = new DiffLinesCollection();
            for (int i = 0; i < diffSummary.Changes.Length; i++)
            {
                var diff = new DiffChange(diffSummary.Changes[i]);

                if (diff.ChangeType == DiffChangeType.Change)
                {
                    if (diff.OriginalLength >= diff.ModifiedLength)
                    {
                        int linesModified = diff.ModifiedLength;
                        if (linesModified == 0)
                        {
                            diff.ChangeType = DiffChangeType.Delete;
                            int linesDeleted = diff.OriginalLength - diff.ModifiedLength;
                            Debug.Assert(linesDeleted > 0, "linesDeleted must be greater than zero.");
                        }
                    }
                    else
                    {
                        int linesModified = diff.OriginalLength;
                        if (linesModified == 0)
                        {
                            diff.ChangeType = DiffChangeType.Insert;
                            int linesAdded = diff.ModifiedLength - diff.OriginalLength;
                            Debug.Assert(linesAdded > 0, "linesAdded must be greater than zero.");
                        }
                    }
                }

                if (diff.ChangeType != DiffChangeType.Delete)
                {
                    for (int k = diff.ModifiedStart; k <= diff.ModifiedEnd; k++)
                        AddLineToDiffLinesCollection(dict, textSnapshot, k, diff);
                }
                else
                {
                    AddLineToDiffLinesCollection(dict, textSnapshot, diff.ModifiedStart, diff);
                }
            }

            return dict;
        }