Ejemplo n.º 1
0
def test_generate(mock_vim):
  eq_(graphlog.generate(
    False,
    0,
    1,
    2,
    False,
    Nodes() 
  ), [['o ', '[0] Original   ']])
Ejemplo n.º 2
0
def MundoRenderGraph(force=False):  # {{{
    """ Renders the undo graph if necessary, updating it to reflect changes in
        the target buffer's undo tree.

        Arguments
        ---------
        force : bool
            If True, the graph will always be rendered. If False, then the
            graph may not be rendered - when is already current for example.
    """
    if not _check_sanity():
        return

    util._goto_window_for_buffer('__Mundo__')

    first_visible_line = int(vim.eval("line('w0')"))
    last_visible_line = int(vim.eval("line('w$')"))

    verbose = vim.eval('g:mundo_verbose_graph') == "1"
    target = int(vim.eval('g:mundo_target_n'))

    if int(vim.eval('g:mundo_help')):
        header = (INLINE_HELP % target).splitlines()
    else:
        header = [(INLINE_HELP % target).splitlines()[0], '\n']

    show_inline_undo = int(vim.eval("g:mundo_inline_undo")) == 1
    mundo_last_visible_line = int(vim.eval("g:mundo_last_visible_line"))
    mundo_first_visible_line = int(vim.eval("g:mundo_first_visible_line"))

    if not force and not nodesData.is_outdated() and (
            not show_inline_undo or
        (mundo_first_visible_line == first_visible_line
         and mundo_last_visible_line == last_visible_line)):
        return

    result = graphlog.generate(verbose,
                               len(header) + 1, first_visible_line,
                               last_visible_line, show_inline_undo, nodesData)
    vim.command("let g:mundo_last_visible_line=%s" % last_visible_line)
    vim.command("let g:mundo_first_visible_line=%s" % first_visible_line)

    output = []
    # right align the dag and flip over the y axis:
    flip_dag = int(vim.eval("g:mundo_mirror_graph")) == 1
    dag_width = 1
    for line in result:
        if len(line[0]) > dag_width:
            dag_width = len(line[0])
    for line in result:
        if flip_dag:
            dag_line = (line[0][::-1]).replace("/", "\\")
            output.append("%*s %s" % (dag_width, dag_line, line[1]))
        else:
            output.append("%-*s %s" % (dag_width, line[0], line[1]))

    vim.command('call s:MundoOpenGraph()')
    vim.command('setlocal modifiable')
    lines = (header + output)
    lines = [line.rstrip('\n') for line in lines]
    vim.current.buffer[:] = lines
    vim.command('setlocal nomodifiable')

    i = 1
    for line in output:
        try:
            line.split('[')[0].index('@')
            i += 1
            break
        except ValueError:
            pass
        i += 1
    vim.command('%d' % (i + len(header) - 1))
Ejemplo n.º 3
0
def MundoRenderGraph(force=False):
    if not _check_sanity():
        return

    first_visible_line = int(vim.eval("line('w0')"))
    last_visible_line = int(vim.eval("line('w$')"))

    verbose = vim.eval("g:mundo_verbose_graph") == "1"
    target = (int(vim.eval("g:mundo_target_n")), vim.eval("g:mundo_map_move_older"), vim.eval("g:mundo_map_move_newer"))

    if int(vim.eval("g:mundo_help")):
        header = (INLINE_HELP % target).splitlines()
    else:
        header = [(INLINE_HELP % target).splitlines()[0], "\n"]

    show_inline_undo = int(vim.eval("g:mundo_inline_undo")) == 1
    mundo_last_visible_line = int(vim.eval("g:mundo_last_visible_line"))
    mundo_first_visible_line = int(vim.eval("g:mundo_first_visible_line"))

    if (
        not force
        and not nodesData.is_outdated()
        and (
            not show_inline_undo
            or not (mundo_first_visible_line == first_visible_line and mundo_last_visible_line == last_visible_line)
        )
    ):
        return

    result = graphlog.generate(
        verbose, len(header) + 1, first_visible_line, last_visible_line, show_inline_undo, nodesData
    )
    vim.command("let g:mundo_last_visible_line=%s" % last_visible_line)
    vim.command("let g:mundo_first_visible_line=%s" % first_visible_line)

    output = []
    # right align the dag and flip over the y axis:
    flip_dag = int(vim.eval("g:mundo_mirror_graph")) == 1
    dag_width = 1
    maxwidth = int(vim.eval("g:mundo_width"))
    for line in result:
        if len(line[0]) > dag_width:
            dag_width = len(line[0])
    for line in result:
        if flip_dag:
            dag_line = (line[0][::-1]).replace("/", "\\")
            output.append("%*s %s" % (dag_width, dag_line, line[1]))
        else:
            output.append("%-*s %s" % (dag_width, line[0], line[1]))

    vim.command("call s:MundoOpenGraph()")
    vim.command("setlocal modifiable")
    lines = header + output
    lines = [line.rstrip("\n") for line in lines]
    vim.current.buffer[:] = lines
    vim.command("setlocal nomodifiable")

    i = 1
    for line in output:
        try:
            line.split("[")[0].index("@")
            i += 1
            break
        except ValueError:
            pass
        i += 1
    vim.command("%d" % (i + len(header) - 1))
Ejemplo n.º 4
0
def GundoRenderGraph(force=False):
    if not _check_sanity():
        return

    first_visible_line = int(vim.eval("line('w0')"))
    last_visible_line = int(vim.eval("line('w$')"))

    verbose = vim.eval('g:mundo_verbose_graph') == "1"
    target = (int(vim.eval('g:mundo_target_n')),
              vim.eval('g:mundo_map_move_older'),
              vim.eval('g:mundo_map_move_newer'))

    if int(vim.eval('g:mundo_help')):
        header = (INLINE_HELP % target).splitlines()
    else:
        header = [(INLINE_HELP % target).splitlines()[0], '\n']

    show_inline_undo = int(vim.eval("g:mundo_inline_undo")) == 1
    gundo_last_visible_line = int(vim.eval("g:mundo_last_visible_line"))
    gundo_first_visible_line = int(vim.eval("g:mundo_first_visible_line"))

    if not force and not nodesData.is_outdated() and (
            not show_inline_undo
            or not (gundo_first_visible_line == first_visible_line
                    and gundo_last_visible_line == last_visible_line)):
        return

    result = graphlog.generate(verbose,
                               len(header) + 1, first_visible_line,
                               last_visible_line, show_inline_undo, nodesData)
    vim.command("let g:mundo_last_visible_line=%s" % last_visible_line)
    vim.command("let g:mundo_first_visible_line=%s" % first_visible_line)

    output = []
    # right align the dag and flip over the y axis:
    flip_dag = int(vim.eval("g:mundo_mirror_graph")) == 1
    dag_width = 1
    maxwidth = int(vim.eval("g:mundo_width"))
    for line in result:
        if len(line[0]) > dag_width:
            dag_width = len(line[0])
    for line in result:
        if flip_dag:
            dag_line = (line[0][::-1]).replace("/", "\\")
            output.append("%*s %s" % (dag_width, dag_line, line[1]))
        else:
            output.append("%-*s %s" % (dag_width, line[0], line[1]))

    vim.command('call s:GundoOpenGraph()')
    vim.command('setlocal modifiable')
    lines = (header + output)
    lines = [line.rstrip('\n') for line in lines]
    vim.current.buffer[:] = lines
    vim.command('setlocal nomodifiable')

    i = 1
    for line in output:
        try:
            line.split('[')[0].index('@')
            i += 1
            break
        except ValueError:
            pass
        i += 1
    vim.command('%d' % (i + len(header) - 1))
Ejemplo n.º 5
0
def MundoRenderGraph(force=False):
    if not _check_sanity():
        return

    first_visible_line = int(vim.eval("line('w0')"))
    last_visible_line = int(vim.eval("line('w$')"))

    verbose = vim.eval('g:mundo_verbose_graph') == "1"
    target = (int(vim.eval('g:mundo_target_n')),
                vim.eval('g:mundo_map_move_older'),
                vim.eval('g:mundo_map_move_newer'))

    if int(vim.eval('g:mundo_help')):
        header = (INLINE_HELP % target).splitlines()
    else:
        header = []

    show_inline_undo = int(vim.eval("g:mundo_inline_undo")) == 1
    mundo_last_visible_line = int(vim.eval("g:mundo_last_visible_line"))
    mundo_first_visible_line = int(vim.eval("g:mundo_first_visible_line"))

    if not force and not nodesData.is_outdated() and (
                not show_inline_undo or 
                (
                    mundo_first_visible_line == first_visible_line and
                    mundo_last_visible_line == last_visible_line
                )
            ):
        return

    result = graphlog.generate(
            verbose,
            len(header)+1,
            first_visible_line,
            last_visible_line,
            show_inline_undo,
            nodesData
    )
    vim.command("let g:mundo_last_visible_line=%s"%last_visible_line)
    vim.command("let g:mundo_first_visible_line=%s"%first_visible_line)

    output = []
    # right align the dag and flip over the y axis:
    flip_dag = int(vim.eval("g:mundo_mirror_graph")) == 1
    dag_width = 1
    for line in result:
        if len(line[0]) > dag_width:
            dag_width = len(line[0])
    for line in result:
        if flip_dag:
            dag_line = (line[0][::-1]).replace("/","\\")
            output.append("%*s %s"% (dag_width,dag_line,line[1]))
        else:
            output.append("%-*s %s"% (dag_width,line[0],line[1]))

    vim.command('call s:MundoOpenGraph()')
    vim.command('setlocal modifiable')
    lines = (header + output)
    lines = [line.rstrip('\n') for line in lines]
    vim.current.buffer[:] = lines
    vim.command('setlocal nomodifiable')

    i = next(iter(i for i, line in enumerate(output, 2) if
                  '@' in line.split('[')[0] or
                  '$' in line.split('[')[0]), len(output))
    vim.command('%d' % (i+len(header)-1))
Ejemplo n.º 6
0
def MundoRenderGraph(force=False):# {{{
    """ Renders the undo graph if necessary, updating it to reflect changes in
        the target buffer's undo tree.

        Arguments
        ---------
        force : bool
            If True, the graph will always be rendered. If False, then the
            graph may not be rendered - when is already current for example.
    """
    if not _check_sanity():
        return

    util._goto_window_for_buffer('__Mundo__')

    first_visible_line = int(vim.eval("line('w0')"))
    last_visible_line = int(vim.eval("line('w$')"))

    verbose = vim.eval('g:mundo_verbose_graph') == "1"
    target = int(vim.eval('g:mundo_target_n'))

    if int(vim.eval('g:mundo_help')):
        header = (INLINE_HELP % target).splitlines()
    else:
        header = [(INLINE_HELP % target).splitlines()[0], '\n']

    show_inline_undo = int(vim.eval("g:mundo_inline_undo")) == 1
    mundo_last_visible_line = int(vim.eval("g:mundo_last_visible_line"))
    mundo_first_visible_line = int(vim.eval("g:mundo_first_visible_line"))

    if not force and not nodesData.is_outdated() and (
                not show_inline_undo or
                (
                    mundo_first_visible_line == first_visible_line and
                    mundo_last_visible_line == last_visible_line
                )
            ):
        return

    result = graphlog.generate(
            verbose,
            len(header)+1,
            first_visible_line,
            last_visible_line,
            show_inline_undo,
            nodesData
    )
    vim.command("let g:mundo_last_visible_line=%s"%last_visible_line)
    vim.command("let g:mundo_first_visible_line=%s"%first_visible_line)

    output = []
    # right align the dag and flip over the y axis:
    flip_dag = int(vim.eval("g:mundo_mirror_graph")) == 1
    dag_width = 1
    for line in result:
        if len(line[0]) > dag_width:
            dag_width = len(line[0])
    for line in result:
        if flip_dag:
            dag_line = (line[0][::-1]).replace("/","\\")
            output.append("%*s %s"% (dag_width,dag_line,line[1]))
        else:
            output.append("%-*s %s"% (dag_width,line[0],line[1]))

    vim.command('call s:MundoOpenGraph()')
    vim.command('setlocal modifiable')
    lines = (header + output)
    lines = [line.rstrip('\n') for line in lines]
    vim.current.buffer[:] = lines
    vim.command('setlocal nomodifiable')

    i = 1
    for line in output:
        try:
            line.split('[')[0].index('@')
            i += 1
            break
        except ValueError:
            pass
        i += 1
    vim.command('%d' % (i+len(header)-1))
Ejemplo n.º 7
0
def test_generate(mock_vim):
    eq_(graphlog.generate(False, 0, 1, 2, False, Nodes()),
        [['o ', '[0] Original   ']])