Permalink
Browse files

add diff and diff_prev action for log kind.

  • Loading branch information...
1 parent f171c58 commit 7b4b559ca942f96f52b17524872d6ed880c93ed1 @hrsh7th committed Oct 5, 2012
Showing with 37 additions and 1 deletion.
  1. +36 −1 autoload/unite/kinds/vcs/log.vim
  2. +1 −0 autoload/unite/sources/vcs/log.vim
@@ -43,7 +43,42 @@ let s:kind.action_table.changeset = {
\ }
function! s:kind.action_table.changeset.func(candidates)
let candidate = type(a:candidates) == type([]) ? a:candidates[0] : a:candidates
- call unite#start_temporary([['vcs/changeset', fnamemodify(candidate.action__path, ':p:h'), candidate.action__revision]])
+ call unite#start_temporary([['vcs/changeset', candidate.action__path, candidate.action__revision]])
+endfunction
+
+let s:kind.action_table.diff = {
+ \ 'description': 'display candidates diff, if candidates path equals to source path.',
+ \ 'is_selectable': 0,
+ \ }
+function! s:kind.action_table.diff.func(candidates)
+ let candidate = type(a:candidates) == type([]) ? a:candidates[0] : a:candidates
+ if filereadable(candidate.source__path)
+ call vcs#diff_file_with_string(candidate.action__path, {
+ \ 'name': '[REMOTE] ' . candidate.action__path,
+ \ 'string': vcs#vcs('cat', [candidate.action__path, candidate.action__revision])
+ \ })
+ else
+ call unite#start_temporary([['vcs/changeset', candidate.action__path, candidate.action__revision]])
+ endif
+endfunction
+
+let s:kind.action_table.diff_prev = {
+ \ 'description': 'display candidates diff previous log, if candidates path equals to source path.',
+ \ 'is_selectable': 0,
+ \ }
+function! s:kind.action_table.diff_prev.func(candidates)
+ let candidate = type(a:candidates) == type([]) ? a:candidates[0] : a:candidates
+ if filereadable(candidate.source__path)
+ call vcs#diff_string_with_string({
+ \ 'name': '[REMOTE: ' . candidate.action__revision . '] ' . candidate.action__path,
+ \ 'string': vcs#vcs('cat', [candidate.action__path, candidate.action__revision])
+ \ }, {
+ \ 'name': '[REMOTE: ' . candidate.action__prev_revision . '] ' . candidate.action__path,
+ \ 'string': vcs#vcs('cat', [candidate.action__path, candidate.action__prev_revision])
+ \ })
+ else
+ call unite#start_temporary([['vcs/changeset', candidate.action__path, candidate.action__revision]])
+ endif
endfunction
let &cpo = s:save_cpo
@@ -32,6 +32,7 @@ function! s:source.gather_candidates(args, context)
let authorlen = max(map(copy(logs), "strlen(split(v:val.author, ' ')[0])"))
return map(logs, "{
\ 'word': s:padding(v:val.revision, revisionlen) . ' | '. s:padding(v:val.date, datelen) . ' | '. s:padding(v:val.author, authorlen) . ' | ' . v:val.message,
+ \ 'source__path': path,
\ 'action__path': v:val.path,
\ 'action__revision': v:val.revision,
\ 'action__prev_revision': v:val.prev_revision,

0 comments on commit 7b4b559

Please sign in to comment.