Show differences between committed and uncommitted versions, limited to FILENAME(s) if specified.

def diff(*args):
    """Show differences between committed and uncommitted versions, limited to FILENAME(s) if specified."""
    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