Provides a summarized output of a diff between two revisions
        (file, change type, file type)
167591
def diff_summary(self, old, new, rel_path=None):
        
        full_url_or_path = self.__url_or_path
        if rel_path is not None:
            full_url_or_path += '/' + rel_path
        result = self.run_command(
            'diff',
            ['--old', '{0}@{1}'.format(full_url_or_path, old),
             '--new', '{0}@{1}'.format(full_url_or_path, new),
             '--summarize', '--xml'],
            do_combine=True)
        root = xml.etree.ElementTree.fromstring(result)
        diff = []
        for element in root.findall('paths/path'):
            diff.append({
                'path': element.text,
                'item': element.attrib['item'],
                'kind': element.attrib['kind']})
        return diff
696253
def diff_missed_lines(self, filename):
        
        line_changed = []
        for line in self.file_source(filename):
            if line.status is not None:
                is_new = not line.status
                line_changed.append((line.number, is_new))
        return line_changed
71043
def changes_str(self):
        ''''''
        changes = ''
        for item in self._get_recursive_difference(type='intersect'):
            if item.diffs:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   # Next line should be tabulated even deeper,
                                   #  every change should be tabulated 1 deeper
                                   '\tidentified by {0} {1}:\n\t{2}\n'.format(
                                       self._key,
                                       item.past_dict[self._key],
                                       item.changes_str.replace('\n', '\n\t'))])
        for item in self._get_recursive_difference(type='removed'):
            if item.past_dict:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   '\tidentified by {0} {1}:'
                                   '\n\twill be removed\n'.format(self._key,
                                                                  item.past_dict[self._key])])
        for item in self._get_recursive_difference(type='added'):
            if item.current_dict:
                changes = ''.join([changes,
                                   # Tabulate comment deeper, show the key attribute and the value
                                   '\tidentified by {0} {1}:'
                                   '\n\twill be added\n'.format(self._key,
                                                                item.current_dict[self._key])])
        return changes
42917
def processed_file(self, new_text, filename, old_text=None, write=False,
                       encoding=None):
        
        self.files.append(filename)
        if old_text is None:
            old_text = self._read_python_source(filename)[0]
            if old_text is None:
                return
        equal = old_text == new_text
        self.print_output(old_text, new_text, filename, equal)
        if equal:
            self.log_debug("No changes to %s", filename)
            if not self.write_unchanged_files:
                return
        if write:
            self.write_file(new_text, filename, old_text, encoding)
        else:
            self.log_debug("Not writing changes to %s", filename)
1061439
def diff(old_html, new_html, cutoff=0.0, plaintext=False, pretty=False):
    
    if plaintext:
        old_dom = parse_text(old_html)
        new_dom = parse_text(new_html)
    else:
        old_dom = parse_minidom(old_html)
        new_dom = parse_minidom(new_html)

    # If the two documents are not similar enough, don't show the changes.
    if not check_text_similarity(old_dom, new_dom, cutoff):
        return '<h2>The differences from the previous version are too large to show concisely.</h2>'

    dom = dom_diff(old_dom, new_dom)

    # HTML-specific cleanup.
    if not plaintext:
        fix_lists(dom)
        fix_tables(dom)

    # Only return html for the document body contents.
    body_elements = dom.getElementsByTagName('body')
    if len(body_elements) == 1:
        dom = body_elements[0]

    return minidom_tostring(dom, pretty=pretty)
1225520
def diff(s1, s2):
    ''' '''
    delta = difflib.Differ().compare(s1.split(), s2.split())
    difflist = []
    fullline = ''
    for line in delta:
        if line[0] == '?':
            continue
        elif line[0] == ' ':
            fullline += line.strip() + ' '
        else:
            if fullline:
                difflist.append(fullline[:-1])
                fullline = ''
            difflist.append(line)
    if fullline:
        difflist.append(fullline[:-1])
    return [l[:] for l in '\n'.join(difflist).splitlines() if l]
104469
def diff(*args):
    """"""
    parser = argparse.ArgumentParser(prog="%s %s" % (__package__, diff.__name__), description=diff.__doc__)
    parser.add_argument('FILENAME', help="file(s) to show changes in", nargs="*", default=['.'])
    parser.add_argument('-U', '--unified', type=int, dest="NUM", default=3, action="store", help="number of lines of context to show")
    args = parser.parse_args(args)

    config = FragmentsConfig()

    for s, curr_path in _iterate_over_files(args.FILENAME, config, statuses='MAD'):
        key = os.path.relpath(curr_path, config.root)
        if key not in config['files']:
            yield "Could not diff '%s', it is not being followed" % os.path.relpath(curr_path)
            continue

        if s in 'MAD':
            repo_lines = []
            curr_lines = []
            if s in 'MA':
                with _smart_open(curr_path, 'r') as curr_file:
                    curr_lines = curr_file.readlines()
            if s in 'MD':
                repo_path = os.path.join(config.directory, config['files'][key])
                with _smart_open(repo_path, 'r') as repo_file:
                    repo_lines = repo_file.readlines()
            weave = Weave()
            weave.add_revision(1, repo_lines, [])
            weave.add_revision(2, curr_lines, [])
            for l in _full_diff(weave.merge(1, 2), key, context_lines=args.NUM):
                yield l
227910
def mkchange(text0,text1,version,mtime):
  ""
  return Change(version,mtime,ucrc(text1),diff.word_diff(text0,text1))
222737
def _get_changed_diff(self, blueprint, schema):
        
        table = schema.list_table_details(
            self.get_table_prefix() + blueprint.get_table()
        )

        return Comparator().diff_table(
            table, self._get_table_with_column_changes(blueprint, table)
        )
850317
def changes(ctx, check, dry_run):
    """"""
    if not dry_run and check not in get_valid_checks():
        abort('Check `{}` is not an Agent-based Integration'.format(check))

    # get the name of the current release tag
    cur_version = get_version_string(check)
    target_tag = get_release_tag_string(check, cur_version)

    # get the diff from HEAD
    diff_lines = get_commits_since(check, target_tag)

    # for each PR get the title, we'll use it to populate the changelog
    pr_numbers = parse_pr_numbers(diff_lines)
    if not dry_run:
        echo_info('Found {} PRs merged since tag: {}'.format(len(pr_numbers), target_tag))

    user_config = ctx.obj
    if dry_run:
        changelog_types = []

        for pr_num in pr_numbers:
            try:
                payload = get_pr(pr_num, user_config)
            except Exception as e:
                echo_failure('Unable to fetch info for PR #{}: {}'.format(pr_num, e))
                continue

            current_changelog_types = get_changelog_types(payload)
            if not current_changelog_types:
                abort('No valid changelog labels found attached to PR #{}, please add one!'.format(pr_num))
            elif len(current_changelog_types) > 1:
                abort('Multiple changelog labels found attached to PR #{}, please only use one!'.format(pr_num))

            current_changelog_type = current_changelog_types[0]
            if current_changelog_type != 'no-changelog':
                changelog_types.append(current_changelog_type)

        return cur_version, changelog_types
    else:
        for pr_num in pr_numbers:
            try:
                payload = get_pr(pr_num, user_config)
            except Exception as e:
                echo_failure('Unable to fetch info for PR #{}: {}'.format(pr_num, e))
                continue

            changelog_types = get_changelog_types(payload)

            echo_success(payload.get('title'))
            echo_info(' * Url: {}'.format(payload.get('html_url')))

            echo_info(' * Changelog status: ', nl=False)
            if not changelog_types:
                echo_warning('WARNING! No changelog labels attached.\n')
            elif len(changelog_types) > 1:
                echo_warning('WARNING! Too many changelog labels attached: {}\n'.format(', '.join(changelog_types)))
            else:
                echo_success('{}\n'.format(changelog_types[0]))
822156
def diff_text2(self, diffs):
    
    text = []
    for (op, data) in diffs:
      if op != self.DIFF_DELETE:
        text.append(data)
    return "".join(text)
1094296
def changes(since, out_file, eager):
    """"""
    root = get_root()
    history_data = defaultdict(lambda: {'lines': deque(), 'releasers': set()})

    with chdir(root):
        result = run_command(
            (
                'git log "--pretty=format:%H %s" --date-order --date=iso8601 '
                '--since="{}T00:00:00" */CHANGELOG.md'.format(since)
            ),
            capture=True,
            check=True,
        )

        for result_line in result.stdout.splitlines():
            commit_hash, commit_subject = result_line.split(' ', 1)

            if not eager and 'release' not in commit_subject.lower():
                continue

            result = run_command(
                'git show "--pretty=format:%an%n" -U0 {} */CHANGELOG.md'.format(commit_hash), capture=True, check=True
            )

            # Example:
            #
            # <AUTHOR NAME>
            # diff --git a/<INTEGRATION NAME 1>/CHANGELOG.md b/<INTEGRATION NAME 1>/CHANGELOG.md
            # index 89b5a3441..9534019a9 100644
            # --- a/<INTEGRATION NAME 1>/CHANGELOG.md
            # +++ b/<INTEGRATION NAME 1>/CHANGELOG.md
            # @@ -2,0 +3,5 @@
            # +## <RELEASE VERSION> / <RELEASE DATE>
            # +
            # +* <ENTRY>
            # +* <ENTRY>
            # +
            # diff --git a/<INTEGRATION NAME 2>/CHANGELOG.md b/<INTEGRATION NAME 2>/CHANGELOG.md
            # index 89b5a3441..9534019a9 100644
            # --- a/<INTEGRATION NAME 2>/CHANGELOG.md
            # +++ b/<INTEGRATION NAME 2>/CHANGELOG.md
            # @@ -2,0 +3,4 @@
            # +## <RELEASE VERSION> / <RELEASE DATE>
            # +
            # +* <ENTRY>
            # +
            lines = deque(result.stdout.splitlines())
            author_name = lines.popleft().strip()

            patches = []
            for line in lines:
                if line:
                    # New patch
                    if line.startswith('diff --git'):
                        patches.append([])
                    patches[-1].append(line)

            for patch in patches:
                integration = patch[0].split('/')[-2].strip()
                history_data[integration]['releasers'].add(author_name)

                additions = deque()
                for line in reversed(patch):
                    if line.startswith('+'):
                        line = line[1:]
                        # Demote releases to h3
                        if line.startswith('##'):
                            line = '#{}'.format(line)
                        additions.append(line)
                    elif line.startswith('@@'):
                        break

                # Get rid of the header for new integrations
                if additions[-1].startswith('# '):
                    additions.pop()

                # Get rid of blank lines to ensure consistency
                while not additions[0].strip():
                    additions.popleft()
                while not additions[-1].strip():
                    additions.pop()

                history_data[integration]['lines'].appendleft('')
                history_data[integration]['lines'].extendleft(additions)

    output_lines = ['# Changes since {}'.format(since), '']

    for integration, history in sorted(iteritems(history_data)):
        display_name = load_manifest(integration).get('display_name', integration)
        output_lines.append('## {}'.format(display_name))
        output_lines.append('released by: {}'.format(', '.join(sorted(history['releasers']))))

        output_lines.append('')
        output_lines.extend(history['lines'])

    output = '\n'.join(output_lines)

    if out_file:
        write_file(out_file, output)
    else:
        echo_info(output)
1002025
def _nested_changes(changes):
    '''
    
    '''
    ret = '\n'
    ret += salt.output.out_format(
            changes,
            'nested',
            __opts__,
            nested_indent=14)
    return ret
383690
def diff(file_, imports):
    """"""
    modules_not_imported = compare_modules(file_, imports)

    logging.info("The following modules are in {} but do not seem to be imported: "
                 "{}".format(file_, ", ".join(x for x in modules_not_imported)))
1360339
def _get_diff(self):
        """"""
        diff = []
        self._create_sot_file()
        diff_out = self._send_command(
            "show diff rollback-patch file {} file {}".format(
                "sot_file", self.candidate_cfg
            ),
            raw_text=True,
        )
        try:
            diff_out = (
                diff_out.split("Generating Rollback Patch")[1]
                .replace("Rollback Patch is Empty", "")
                .strip()
            )
            for line in diff_out.splitlines():
                if line:
                    if line[0].strip() != "!" and line[0].strip() != ".":
                        diff.append(line.rstrip(" "))
        except (AttributeError, KeyError):
            raise ReplaceConfigException(
                "Could not calculate diff. It's possible the given file doesn't exist."
            )
        return "\n".join(diff)
135856
public static <T> void dump(Iterable<Difference<T>> diffs) {
		for(Difference<T> diff: diffs) {
			System.out.println(diff);
		}
	}
885376
def _get_diff(self):
        """"""
        diff = []
        self._create_sot_file()
        command = ('show diff rollback-patch file {0} file {1}'.format(
                   'sot_file', self.replace_file.split('/')[-1]))
        diff_out = self.device.send_command(command)
        try:
            diff_out = diff_out.split(
                '#Generating Rollback Patch')[1].replace(
                    'Rollback Patch is Empty', '').strip()
            for line in diff_out.splitlines():
                if line:
                    if line[0].strip() != '!' and line[0].strip() != '.':
                        diff.append(line.rstrip(' '))
        except (AttributeError, KeyError):
            raise ReplaceConfigException(
                'Could not calculate diff. It\'s possible the given file doesn\'t exist.')
        return '\n'.join(diff)