comparison plugin/lawrencium.vim @ 130:7ad578b151c1

Merge pull request #8 from GitHub.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 19 Feb 2016 15:50:34 -0800
parents 96e4423e729e 098222a17b1f
children c04855b6f318
comparison
equal deleted inserted replaced
127:96e4423e729e 130:7ad578b151c1
711 call a:repo.ReadCommandOutput(l:log_cmd, '--style', s:log_style_file, a:full_path) 711 call a:repo.ReadCommandOutput(l:log_cmd, '--style', s:log_style_file, a:full_path)
712 endif 712 endif
713 setlocal filetype=hglog 713 setlocal filetype=hglog
714 endfunction 714 endfunction
715 715
716 function! s:read_lawrencium_logpatch(repo, path_parts, full_path) abort
717 let l:log_cmd = 'log --patch --verbose --rev ' . a:path_parts['value']
718
719 if a:path_parts['path'] == ''
720 call a:repo.ReadCommandOutput(l:log_cmd)
721 else
722 call a:repo.ReadCommandOutput(l:log_cmd, a:full_path)
723 endif
724 setlocal filetype=diff
725 endfunction
726
716 " Diff revisions (`hg diff`) 727 " Diff revisions (`hg diff`)
717 function! s:read_lawrencium_diff(repo, path_parts, full_path) abort 728 function! s:read_lawrencium_diff(repo, path_parts, full_path) abort
718 let l:diffargs = [] 729 let l:diffargs = []
719 let l:commaidx = stridx(a:path_parts['value'], ',') 730 let l:commaidx = stridx(a:path_parts['value'], ',')
720 if l:commaidx > 0 731 if l:commaidx > 0
774 785
775 " Generic read 786 " Generic read
776 let s:lawrencium_file_readers = { 787 let s:lawrencium_file_readers = {
777 \'rev': function('s:read_lawrencium_rev'), 788 \'rev': function('s:read_lawrencium_rev'),
778 \'log': function('s:read_lawrencium_log'), 789 \'log': function('s:read_lawrencium_log'),
790 \'logpatch': function('s:read_lawrencium_logpatch'),
779 \'diff': function('s:read_lawrencium_diff'), 791 \'diff': function('s:read_lawrencium_diff'),
780 \'status': function('s:read_lawrencium_status'), 792 \'status': function('s:read_lawrencium_status'),
781 \'annotate': function('s:read_lawrencium_annotate'), 793 \'annotate': function('s:read_lawrencium_annotate'),
782 \'qseries': function('s:read_lawrencium_qseries') 794 \'qseries': function('s:read_lawrencium_qseries')
783 \} 795 \}
2022 let b:lawrencium_annotated_bufnr = l:bufnr 2034 let b:lawrencium_annotated_bufnr = l:bufnr
2023 call s:DefineMainCommands() 2035 call s:DefineMainCommands()
2024 2036
2025 " Add some other nice commands and mappings. 2037 " Add some other nice commands and mappings.
2026 command! -buffer Hgannotatediffsum :call s:HgAnnotate_DiffSummary() 2038 command! -buffer Hgannotatediffsum :call s:HgAnnotate_DiffSummary()
2039 command! -buffer Hgannotatelog :call s:HgAnnotate_DiffSummary(1)
2027 if g:lawrencium_define_mappings 2040 if g:lawrencium_define_mappings
2028 nnoremap <buffer> <silent> <cr> :Hgannotatediffsum<cr> 2041 nnoremap <buffer> <silent> <cr> :Hgannotatediffsum<cr>
2042 nnoremap <buffer> <silent> <leader><cr> :Hgannotatelog<cr>
2029 endif 2043 endif
2030 2044
2031 " Clean up when the annotate buffer is deleted. 2045 " Clean up when the annotate buffer is deleted.
2032 let l:bufobj = s:buffer_obj() 2046 let l:bufobj = s:buffer_obj()
2033 call l:bufobj.OnDelete('call s:HgAnnotate_Delete(' . l:bufobj.nr . ')') 2047 call l:bufobj.OnDelete('call s:HgAnnotate_Delete(' . l:bufobj.nr . ')')
2037 if g:lawrencium_auto_close_buffers 2051 if g:lawrencium_auto_close_buffers
2038 call s:delete_dependency_buffers('lawrencium_diff_for', a:bufnr) 2052 call s:delete_dependency_buffers('lawrencium_diff_for', a:bufnr)
2039 endif 2053 endif
2040 endfunction 2054 endfunction
2041 2055
2042 function! s:HgAnnotate_DiffSummary() abort 2056 function! s:HgAnnotate_DiffSummary(...) abort
2043 " Get the path for the diff of the revision specified under the cursor. 2057 " Get the path for the diff of the revision specified under the cursor.
2044 let l:line = getline('.') 2058 let l:line = getline('.')
2045 let l:rev_hash = matchstr(l:line, '\v[a-f0-9]{12}') 2059 let l:rev_hash = matchstr(l:line, '\v[a-f0-9]{12}')
2060 let l:log = (a:0 > 0 ? a:1 : 0)
2046 2061
2047 " Get the Lawrencium path for the diff, and the buffer object for the 2062 " Get the Lawrencium path for the diff, and the buffer object for the
2048 " annotation. 2063 " annotation.
2049 let l:repo = s:hg_repo() 2064 let l:repo = s:hg_repo()
2050 let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'diff', l:rev_hash) 2065 if l:log
2066 let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'logpatch', l:rev_hash)
2067 else
2068 let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'diff', l:rev_hash)
2069 endif
2051 let l:annotate_buffer = s:buffer_obj() 2070 let l:annotate_buffer = s:buffer_obj()
2052 2071
2053 " Find a window already displaying diffs for this annotation. 2072 " Find a window already displaying diffs for this annotation.
2054 let l:diff_winnr = s:find_buffer_window('lawrencium_diff_for', l:annotate_buffer.nr) 2073 let l:diff_winnr = s:find_buffer_window('lawrencium_diff_for', l:annotate_buffer.nr)
2055 if l:diff_winnr == -1 2074 if l:diff_winnr == -1