Mercurial > vim-lawrencium
comparison plugin/lawrencium.vim @ 52:cd0b1cea326c
Use Lawrencium files for displaying revisions in an `Hgdiff`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 10 Nov 2012 18:45:44 -0800 |
parents | 671f5e18b515 |
children | b7caa6693c39 |
comparison
equal
deleted
inserted
replaced
51:671f5e18b515 | 52:cd0b1cea326c |
---|---|
703 execute 'edit ' . fnameescape(l:path) | 703 execute 'edit ' . fnameescape(l:path) |
704 endif | 704 endif |
705 " Make it part of the diff group. | 705 " Make it part of the diff group. |
706 call s:HgDiff_DiffThis() | 706 call s:HgDiff_DiffThis() |
707 else | 707 else |
708 let l:temp_file = tempname() | 708 let l:rev_path = l:repo.GetLawrenciumPath(l:path, 'rev', l:rev1) |
709 call l:repo.RunCommand('cat', '-r', '"'.l:rev1.'"', '-o', '"'.l:temp_file.'"', '"'.l:path.'"') | 709 execute 'edit ' . fnameescape(l:rev_path) |
710 execute 'edit ' . fnameescape(l:temp_file) | |
711 " Make it part of the diff group. | 710 " Make it part of the diff group. |
712 call s:HgDiff_DiffThis() | 711 call s:HgDiff_DiffThis() |
713 " Remember the repo it belongs to. | |
714 let b:mercurial_dir = l:repo.root_dir | |
715 " Make sure it's deleted when we move away from it. | |
716 setlocal bufhidden=delete | |
717 " Make commands available. | |
718 call s:DefineMainCommands() | |
719 endif | 712 endif |
720 | 713 |
721 " Get the second file and open it too. | 714 " Get the second file and open it too. |
722 let l:diffsplit = 'diffsplit' | 715 let l:diffsplit = 'diffsplit' |
723 if a:vertical | 716 if a:vertical |
724 let l:diffsplit = 'vertical diffsplit' | 717 let l:diffsplit = 'vertical diffsplit' |
725 endif | 718 endif |
726 if l:rev2 == '' | 719 if l:rev2 == '' |
727 execute l:diffsplit . ' ' . fnameescape(l:path) | 720 execute l:diffsplit . ' ' . fnameescape(l:path) |
728 else | 721 else |
729 let l:temp_file = tempname() | 722 let l:rev_path = l:repo.GetLawrenciumPath(l:path, 'rev', l:rev1) |
730 call l:repo.RunCommand('cat', '-r', '"'.l:rev2.'"', '-o', '"'.l:temp_file.'"', '"'.l:path.'"') | 723 execute l:diffsplit . ' ' . fnameescape(l:rev_path) |
731 execute l:diffsplit . ' ' . fnameescape(l:temp_file) | |
732 " Remember the repo it belongs to. | |
733 let b:mercurial_dir = l:repo.root_dir | |
734 " Make sure it's deleted when we move away from it. | |
735 setlocal bufhidden=delete | |
736 " Make commands available. | |
737 call s:DefineMainCommands() | |
738 endif | 724 endif |
739 endfunction | 725 endfunction |
740 | 726 |
741 function! s:HgDiff_DiffThis() abort | 727 function! s:HgDiff_DiffThis() abort |
742 " Store some commands to run when we exit diff mode. | 728 " Store some commands to run when we exit diff mode. |
1155 call l:repo.ReadCommandOutput('diff', l:comps['path']) | 1141 call l:repo.ReadCommandOutput('diff', l:comps['path']) |
1156 endif | 1142 endif |
1157 setlocal filetype=diff | 1143 setlocal filetype=diff |
1158 endif | 1144 endif |
1159 | 1145 |
1146 " Setup the new buffer. | |
1160 setlocal readonly | 1147 setlocal readonly |
1161 setlocal nomodified | 1148 setlocal nomodified |
1162 setlocal bufhidden=delete | 1149 setlocal bufhidden=delete |
1163 setlocal buftype=nofile | 1150 setlocal buftype=nofile |
1151 | |
1152 " Remember the repo it belongs to and make | |
1153 " the Lawrencium commands available. | |
1154 let b:mercurial_dir = l:repo.root_dir | |
1155 call s:DefineMainCommands() | |
1156 | |
1164 return '' | 1157 return '' |
1165 endfunction | 1158 endfunction |
1166 | 1159 |
1167 augroup lawrencium_files | 1160 augroup lawrencium_files |
1168 autocmd! | 1161 autocmd! |