changeset 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 (current diff) e2757acfd9b1 (diff)
children c04855b6f318
files plugin/lawrencium.vim
diffstat 2 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/doc/lawrencium.txt	Fri Feb 19 15:39:56 2016 -0800
+++ b/doc/lawrencium.txt	Fri Feb 19 15:50:34 2016 -0800
@@ -474,6 +474,9 @@
 :Hgannotatediffsum      Show a diff summary (similar to |:Hgdiffsum|) for the
                         revision mentioned under the cursor.
                         Mapped to |<CR>|.
+:Hgannotatelog          Show the complete commit for the revision mentioned
+                        under the cursor.
+                        Mapped to <Leader><CR>.
 
 
 
--- a/plugin/lawrencium.vim	Fri Feb 19 15:39:56 2016 -0800
+++ b/plugin/lawrencium.vim	Fri Feb 19 15:50:34 2016 -0800
@@ -713,6 +713,17 @@
     setlocal filetype=hglog
 endfunction
 
+function! s:read_lawrencium_logpatch(repo, path_parts, full_path) abort
+    let l:log_cmd = 'log --patch --verbose --rev ' . a:path_parts['value']
+
+    if a:path_parts['path'] == ''
+        call a:repo.ReadCommandOutput(l:log_cmd)
+    else
+        call a:repo.ReadCommandOutput(l:log_cmd, a:full_path)
+    endif
+    setlocal filetype=diff
+endfunction
+
 " Diff revisions (`hg diff`)
 function! s:read_lawrencium_diff(repo, path_parts, full_path) abort
     let l:diffargs = []
@@ -776,6 +787,7 @@
 let s:lawrencium_file_readers = {
             \'rev': function('s:read_lawrencium_rev'),
             \'log': function('s:read_lawrencium_log'),
+            \'logpatch': function('s:read_lawrencium_logpatch'),
             \'diff': function('s:read_lawrencium_diff'),
             \'status': function('s:read_lawrencium_status'),
             \'annotate': function('s:read_lawrencium_annotate'),
@@ -2024,8 +2036,10 @@
 
     " Add some other nice commands and mappings.
     command! -buffer Hgannotatediffsum :call s:HgAnnotate_DiffSummary()
+    command! -buffer Hgannotatelog     :call s:HgAnnotate_DiffSummary(1)
     if g:lawrencium_define_mappings
         nnoremap <buffer> <silent> <cr> :Hgannotatediffsum<cr>
+        nnoremap <buffer> <silent> <leader><cr> :Hgannotatelog<cr>
     endif
 
     " Clean up when the annotate buffer is deleted.
@@ -2039,15 +2053,20 @@
     endif
 endfunction
 
-function! s:HgAnnotate_DiffSummary() abort
+function! s:HgAnnotate_DiffSummary(...) abort
     " Get the path for the diff of the revision specified under the cursor.
     let l:line = getline('.')
     let l:rev_hash = matchstr(l:line, '\v[a-f0-9]{12}')
+    let l:log = (a:0 > 0 ? a:1 : 0)
 
     " Get the Lawrencium path for the diff, and the buffer object for the
     " annotation.
     let l:repo = s:hg_repo()
-    let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'diff', l:rev_hash)
+    if l:log
+      let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'logpatch', l:rev_hash)
+    else
+      let l:path = l:repo.GetLawrenciumPath(b:lawrencium_annotated_path, 'diff', l:rev_hash)
+    endif
     let l:annotate_buffer = s:buffer_obj()
 
     " Find a window already displaying diffs for this annotation.