Mercurial > vim
comparison plugins/hghelp/hghelp.vim @ 15:7edd5f6fe136
This is another test of commiting with the message this time
| author | Luka Sitas <lsitas@avatarasoftware.com> |
|---|---|
| date | Tue, 02 Dec 2025 12:13:02 -0500 |
| parents | 6ee7fce1cba8 |
| children | 412c33afd395 |
comparison
equal
deleted
inserted
replaced
| 14:6ee7fce1cba8 | 15:7edd5f6fe136 |
|---|---|
| 67 " Open a new tab for this commit UI | 67 " Open a new tab for this commit UI |
| 68 tabnew | 68 tabnew |
| 69 " Top window for file selection | 69 " Top window for file selection |
| 70 enew | 70 enew |
| 71 let b:hgcommit_type = 'filelist' | 71 let b:hgcommit_type = 'filelist' |
| 72 call setline(1, s:FormatHgStatusLines(l:lines)) | 72 call setline(1, l:lines) |
| 73 setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile | 73 setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile |
| 74 setlocal nomodifiable | 74 setlocal nomodifiable |
| 75 setlocal cursorline | 75 setlocal cursorline |
| 76 nnoremap <silent> <buffer> <CR> :call <SID>ToggleHgFileSelection()<CR> | 76 nnoremap <silent> <buffer> <CR> :call <SID>ToggleHgFileSelection()<CR> |
| 77 nnoremap <silent> <buffer> <leader>aa :call <SID>ToggleHgSelectAll()<CR> | 77 nnoremap <silent> <buffer> <leader>aa :call <SID>ToggleHgSelectAll()<CR> |
| 83 let b:hgcommit_type = 'message' | 83 let b:hgcommit_type = 'message' |
| 84 setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile | 84 setlocal buftype=acwrite bufhidden=wipe nobuflisted noswapfile |
| 85 " Optional: initial comment | 85 " Optional: initial comment |
| 86 call setline(1, ['# Enter commit message above. Lines starting with # are ignored.']) | 86 call setline(1, ['# Enter commit message above. Lines starting with # are ignored.']) |
| 87 " Map to commit | 87 " Map to commit |
| 88 nnoremap <silent> <buffer> <leader>cc :call <SID>DoHgCommit()<CR> | 88 nnoremap <silent> <buffer> <leader>c :call <SID>DoHgCommit()<CR> |
| 89 | 89 |
| 90 " Go back to top window to start there | 90 " Go back to top window to start there |
| 91 wincmd k | 91 wincmd k |
| 92 endfunction | 92 endfunction |
| 93 | 93 |
| 189 endfor | 189 endfor |
| 190 " Go back to original window (optional; this simple version just leaves you where you end) | 190 " Go back to original window (optional; this simple version just leaves you where you end) |
| 191 return l:files | 191 return l:files |
| 192 endfunction | 192 endfunction |
| 193 | 193 |
| 194 function! s:GetHgCommitMessage() abort | |
| 195 let l:msg_lines = [] | |
| 196 for l:w in range(1, winnr('$')) | |
| 197 execute l:w . 'wincmd w' | |
| 198 if get(b:, 'hgcommit_type', '') ==# 'message' | |
| 199 " Get commit message lines, ignoring leading '#' lines | |
| 200 let l:all_lines = getline(1, '$') | |
| 201 let l:msg_lines = [] | |
| 202 for l:L in l:all_lines | |
| 203 if l:L =~# '^#' | |
| 204 continue | |
| 205 endif | |
| 206 call add(l:msg_lines, l:L) | |
| 207 endfor | |
| 208 endif | |
| 209 endfor | |
| 210 return l:msg_lines | |
| 211 endfunction | |
| 194 | 212 |
| 195 function! s:DoHgCommit() abort | 213 function! s:DoHgCommit() abort |
| 196 if get(b:, 'hgcommit_type', '') !=# 'message' | 214 if get(b:, 'hgcommit_type', '') !=# 'message' |
| 197 return | 215 return |
| 198 endif | 216 endif |
| 204 echom "No files selected for commit." | 222 echom "No files selected for commit." |
| 205 echohl None | 223 echohl None |
| 206 return | 224 return |
| 207 endif | 225 endif |
| 208 | 226 |
| 209 " Get commit message lines, ignoring leading '#' lines | 227 |
| 210 let l:all_lines = getline(1, '$') | 228 let l:msg_lines = s:GetHgCommitMessage() |
| 211 let l:msg_lines = [] | |
| 212 for l:L in l:all_lines | |
| 213 if l:L =~# '^#' | |
| 214 continue | |
| 215 endif | |
| 216 call add(l:msg_lines, l:L) | |
| 217 endfor | |
| 218 | |
| 219 let l:msg = join(l:msg_lines, "\n") | 229 let l:msg = join(l:msg_lines, "\n") |
| 220 if empty(l:msg) | 230 if empty(l:msg) |
| 221 echohl ErrorMsg | 231 echohl ErrorMsg |
| 222 echom "Commit message is empty." | 232 echom "Commit message is empty." |
| 223 echohl None | 233 echohl None |
