-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvsmenu.vim
2241 lines (2082 loc) · 68.8 KB
/
cvsmenu.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" CVSmenu.vim : Vim menu for using CVS vim:tw=0
" Author : Thorsten Maerz <[email protected]> vim600:fdm=marker
" $Revision: 1.77 $
" $Date: 2001/11/12 23:48:44 $
" License : LGPL
"
" Tested with Vim 6.0
" Primary site : http://ezytools.sourceforge.net/
" Located in the "VimTools" section
" Thanks to Max Ischenko and Michael Sternberg
" for testing and useful tips
"
" TODO: Better support for additional params
" TODO: gettag()/getmodule()
"#############################################################################
" Settings
"#############################################################################
" global variables : may be set in ~/.vimrc {{{1
" this *may* interfere with :help (inhibits highlighting)
" disable autocheck, if this happens to you.
if ($CVSOPT == '')
let $CVSOPT='-z9'
endif
if ($CVSCMD == '')
let $CVSCMD='cvs'
endif
if !exists("g:CVSforcedirectory")
let g:CVSforcedirectory = 0 " 0:off 1:once 2:forever
endif
if !exists("g:CVSqueryrevision")
let g:CVSqueryrevision = 0 " 0:fast update 1:query for revisions
endif
if !exists("g:CVSdumpandclose")
let g:CVSdumpandclose = 2 " 0:new buffer 1:statusline 2:autoswitch
endif
if !exists("g:CVSsortoutput")
let g:CVSsortoutput = 1 " sort cvs output (group conflicts,updates,...)
endif
if !exists("g:CVScompressoutput")
let g:CVScompressoutput = 1 " show extended output only if error
endif
if !exists("g:CVSstatusline")
let g:CVSstatusline = 1 " Notification output to statusline
endif
if !exists("g:CVStitlebar")
let g:CVStitlebar = 1 " Notification output to titlebar
endif
if !exists("g:CVSofferrevision")
let g:CVSofferrevision = 1 " Offer current revision on queries
endif
if !exists("g:CVSsavediff")
let g:CVSsavediff = 1 " save settings when using :diff
endif
if !exists("g:CVSdontswitch")
let g:CVSdontswitch = 0 " dont switch to diffed file
endif
if !exists("g:CVSautocheck")
let g:CVSautocheck = 1 " do local status on every read file
endif
if !exists("g:CVSdefaultmsg")
let g:CVSdefaultmsg = '' " message to use for commands below
endif
if !exists("g:CVSusedefaultmsg")
let g:CVSusedefaultmsg = 'aj' " a:Add, i:Commit, j:Join in, p:Import
endif
if !exists("g:CVSfullstatus")
let g:CVSfullstatus = 0 " display all fields for fullstatus
endif
" problems with :help on console
if !(has("gui_running"))
let g:CVSautocheck = 0
endif
" script variables {{{1
if has('unix') " path separator
let s:sep='/'
else
let s:sep='\'
endif
let s:CVSentries='CVS'.s:sep.'Entries' " location of 'CVS/Entries' file
let s:cvsmenuhttp="http://cvs.sf.net/cgi-bin/viewcvs.cgi/~checkout~/ezytools/VimTools/"
let s:cvsmenucvs=":pserver:[email protected]:/cvsroot/ezytools"
let s:CVSupdatequeryonly = 0 " update -n (internal!)
let s:CVSorgtitle = &titlestring " backup of original title
let g:orgpath = getcwd()
let g:CVSleavediff = 0
let g:CVSdifforgbuf = 0
if exists("loaded_cvsmenu")
aunmenu CVS
endif
"-----------------------------------------------------------------------------
" Menu entries {{{1
"-----------------------------------------------------------------------------
" Space before each command to inhibit translation (no one wants a 'cvs Differenz':)
" <esc> in Keyword menus to avoid expansion
" use only TAB between menu item and command (used for MakeLeaderMapping)
amenu &CVS.\ In&fo :call CVSShowInfo()<cr>
amenu &CVS.\ Settin&gs.\ In&fo\ (buffer) :call CVSShowInfo(1)<cr>
amenu &CVS.\ Settin&gs.\ Show\ &mappings :call CVSShowMapping()<cr>
amenu &CVS.\ Settin&gs.-SEP1- :
amenu &CVS.\ Settin&gs.\ &Autocheck.&Enable :call CVSSetAutocheck(1)<cr>
amenu &CVS.\ Settin&gs.\ &Autocheck.&Disable :call CVSSetAutocheck(0)<cr>
amenu &CVS.\ Settin&gs.\ &Target.File\ in\ &buffer :call CVSSetForceDir(0)<cr>
amenu &CVS.\ Settin&gs.\ &Target.&Directory :call CVSSetForceDir(2)<cr>
amenu &CVS.\ Settin&gs.\ &Diff.Stay\ in\ &original :call CVSSetDontSwitch(1)<cr>
amenu &CVS.\ Settin&gs.\ &Diff.Switch\ to\ &diffed :call CVSSetDontSwitch(0)<cr>
amenu &CVS.\ Settin&gs.\ &Diff.-SEP1- :
amenu &CVS.\ Settin&gs.\ &Diff.&Autorestore\ prev\.\ mode :call CVSSetSaveDiff(1)<cr>
amenu &CVS.\ Settin&gs.\ &Diff.&No\ autorestore :call CVSSetSaveDiff(0)<cr>
amenu &CVS.\ Settin&gs.\ &Diff.-SEP2- :
amenu &CVS.\ Settin&gs.\ &Diff.Re&store\ pre-diff\ mode :call CVSRestoreDiffMode()<cr>
amenu &CVS.\ Settin&gs.\ Revision\ &queries.&Enable :call CVSSetQueryRevision(1)<cr>
amenu &CVS.\ Settin&gs.\ Revision\ &queries.&Disable :call CVSSetQueryRevision(0)<cr>
amenu &CVS.\ Settin&gs.\ Revision\ &queries.-SEP1- :
amenu &CVS.\ Settin&gs.\ Revision\ &queries.&Offer\ current\ rev :call CVSSetOfferRevision(1)<cr>
amenu &CVS.\ Settin&gs.\ Revision\ &queries.&Hide\ current\ rev :call CVSSetOfferRevision(0)<cr>
amenu &CVS.\ Settin&gs.\ &Output.N&otifcation.Enable\ &statusline :call CVSSetStatusline(1)<cr>
amenu &CVS.\ Settin&gs.\ &Output.N&otifcation.Disable\ status&line :call CVSSetStatusline(0)<cr>
amenu &CVS.\ Settin&gs.\ &Output.N&otifcation.-SEP1- :
amenu &CVS.\ Settin&gs.\ &Output.N&otifcation.Enable\ &titlebar :call CVSSetTitlebar(1)<cr>
amenu &CVS.\ Settin&gs.\ &Output.N&otifcation.Disable\ title&bar :call CVSSetTitlebar(0)<cr>
amenu &CVS.\ Settin&gs.\ &Output.-SEP1- :
amenu &CVS.\ Settin&gs.\ &Output.To\ new\ &buffer :call CVSSetDumpAndClose(0)<cr>
amenu &CVS.\ Settin&gs.\ &Output.&Notify\ only :call CVSSetDumpAndClose(1)<cr>
amenu &CVS.\ Settin&gs.\ &Output.&Autoswitch :call CVSSetDumpAndClose(2)<cr>
amenu &CVS.\ Settin&gs.\ &Output.-SEP2- :
amenu &CVS.\ Settin&gs.\ &Output.&Compressed :call CVSSetCompressOutput(1)<cr>
amenu &CVS.\ Settin&gs.\ &Output.&Full :call CVSSetCompressOutput(0)<cr>
amenu &CVS.\ Settin&gs.\ &Output.-SEP3- :
amenu &CVS.\ Settin&gs.\ &Output.&Sorted :call CVSSetSortOutput(1)<cr>
amenu &CVS.\ Settin&gs.\ &Output.&Unsorted :call CVSSetSortOutput(0)<cr>
amenu &CVS.\ Settin&gs.-SEP2- :
amenu &CVS.\ Settin&gs.\ &Install.&Install\ updates :call CVSInstallUpdates()<cr>
amenu &CVS.\ Settin&gs.\ &Install.&Download\ updates :call CVSDownloadUpdates()<cr>
amenu &CVS.\ Settin&gs.\ &Install.Install\ buffer\ as\ &help :call CVSInstallAsHelp()<cr>
amenu &CVS.\ Settin&gs.\ &Install.Install\ buffer\ as\ &plugin :call CVSInstallAsPlugin()<cr>
amenu &CVS.\ &Keyword.\ &Author a$Author<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Date a$Date<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Header a$Header<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Id a$Id<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Name a$Name<esc>a$<esc>
amenu &CVS.\ &Keyword.\ Loc&ker a$Locker<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Log a$Log<esc>a$<esc>
amenu &CVS.\ &Keyword.\ RCS&file a$RCSfile<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Revision a$Revision<esc>a$<esc>
amenu &CVS.\ &Keyword.\ &Source a$Source<esc>a$<esc>
amenu &CVS.\ &Keyword.\ S&tate a$State<esc>a$<esc>
amenu &CVS.\ Director&y.\ &Log :call CVSSetForceDir(1)<cr>:call CVSlog()<cr>
amenu &CVS.\ Director&y.\ &Status :call CVSSetForceDir(1)<cr>:call CVSstatus()<cr>
amenu &CVS.\ Director&y.\ S&hort\ status :call CVSSetForceDir(1)<cr>:call CVSshortstatus()<cr>
amenu &CVS.\ Director&y.\ Lo&cal\ status :call CVSSetForceDir(1)<cr>:call CVSLocalStatus()<cr>
amenu &CVS.\ Director&y.-SEP1- :
amenu &CVS.\ Director&y.\ &Query\ update :call CVSSetForceDir(1)<cr>:call CVSqueryupdate()<cr>
amenu &CVS.\ Director&y.\ &Update :call CVSSetForceDir(1)<cr>:call CVSupdate()<cr>
amenu &CVS.\ Director&y.-SEP2- :
amenu &CVS.\ Director&y.\ &Add :call CVSSetForceDir(1)<cr>:call CVSadd()<cr>
amenu &CVS.\ Director&y.\ Comm&it :call CVSSetForceDir(1)<cr>:call CVScommit()<cr>
amenu &CVS.\ Director&y.-SEP3- :
amenu &CVS.\ Director&y.\ Re&move\ from\ repositoy :call CVSSetForceDir(1)<cr>:call CVSremove()<cr>
amenu &CVS.\ E&xtra.\ &Create\ patchfile.\ &Context :call CVSdiffcontext()<cr>
amenu &CVS.\ E&xtra.\ &Create\ patchfile.\ &Standard :call CVSdiffstandard()<cr>
amenu &CVS.\ E&xtra.\ &Create\ patchfile.\ &Uni :call CVSdiffuni()<cr>
amenu &CVS.\ E&xtra.\ &Diff\ to\ revision :call CVSdifftorev()<cr>
amenu &CVS.\ E&xtra.\ &Log\ to\ revision :call CVSlogtorev()<cr>
amenu &CVS.\ E&xtra.-SEP1- :
amenu &CVS.\ E&xtra.\ Check&out\ revision :call CVScheckoutrevision()<cr>
amenu &CVS.\ E&xtra.\ &Update\ to\ revision :call CVSupdatetorev()<cr>
amenu &CVS.\ E&xtra.\ &Merge\ in\ revision :call CVSupdatemergerev()<cr>
amenu &CVS.\ E&xtra.\ Merge\ in\ revision\ di&ffs :call CVSupdatemergediff()<cr>
amenu &CVS.\ E&xtra.-SEP2- :
amenu &CVS.\ E&xtra.\ Comm&it\ to\ revision :call CVScommitrevision()<cr>
amenu &CVS.\ E&xtra.\ Im&port\ to\ revision :call CVSimportrevision()<cr>
amenu &CVS.\ E&xtra.\ &Join\ in\ to\ revision :call CVSjoininrevision()<cr>
amenu &CVS.\ E&xtra.-SEP3- :
amenu &CVS.\ E&xtra.\ CVS\ lin&ks :call CVSOpenLinks()<cr>
amenu &CVS.\ E&xtra.\ &Get\ file :call CVSGet()<cr>
amenu &CVS.\ E&xtra.\ Get\ file\ (pass&word) :call CVSGet('','','io')<cr>
amenu &CVS.-SEP1- :
amenu &CVS.\ Ad&min.\ Log&in :call CVSlogin()<cr>
amenu &CVS.\ Ad&min.\ Log&out :call CVSlogout()<cr>
amenu &CVS.\ D&elete.\ Re&move\ from\ repository :call CVSremove()<cr>
amenu &CVS.\ D&elete.\ Re&lease\ workdir :call CVSrelease()<cr>
amenu &CVS.\ &Tag.\ &Create\ tag :call CVStag()<cr>
amenu &CVS.\ &Tag.\ &Remove\ tag :call CVStagremove()<cr>
amenu &CVS.\ &Tag.\ Create\ &branch :call CVSbranch()<cr>
amenu &CVS.\ &Tag.-SEP1- :
amenu &CVS.\ &Tag.\ Cre&ate\ tag\ by\ module :call CVSrtag()<cr>
amenu &CVS.\ &Tag.\ Rem&ove\ tag\ by\ module :call CVSrtagremove()<cr>
amenu &CVS.\ &Tag.\ Create\ branc&h\ by\ module :call CVSrbranch()<cr>
amenu &CVS.\ &Watch/Edit.\ &Watchers :call CVSwatchwatchers()<cr>
amenu &CVS.\ &Watch/Edit.\ Watch\ &add :call CVSwatchadd()<cr>
amenu &CVS.\ &Watch/Edit.\ Watch\ &remove :call CVSwatchremove()<cr>
amenu &CVS.\ &Watch/Edit.\ Watch\ o&n :call CVSwatchon()<cr>
amenu &CVS.\ &Watch/Edit.\ Watch\ o&ff :call CVSwatchoff()<cr>
amenu &CVS.\ &Watch/Edit.-SEP1- :
amenu &CVS.\ &Watch/Edit.\ &Editors :call CVSwatcheditors()<cr>
amenu &CVS.\ &Watch/Edit.\ Edi&t :call CVSwatchedit()<cr>
amenu &CVS.\ &Watch/Edit.\ &Unedit :call CVSwatchunedit()<cr>
amenu &CVS.-SEP2- :
amenu &CVS.\ &Diff :call CVSdiff()<cr>
amenu &CVS.\ A&nnotate :call CVSannotate()<cr>
amenu &CVS.\ Histo&ry :call CVShistory()<cr>
amenu &CVS.\ &Log :call CVSlog()<cr>
amenu &CVS.\ &Status :call CVSstatus()<cr>
amenu &CVS.\ S&hort\ status :call CVSshortstatus()<cr>
amenu &CVS.\ Lo&cal\ status :call CVSLocalStatus()<cr>
amenu &CVS.-SEP3- :
amenu &CVS.\ Check&out :call CVScheckout()<cr>
amenu &CVS.\ &Query\ update :call CVSqueryupdate()<cr>
amenu &CVS.\ &Update :call CVSupdate()<cr>
amenu &CVS.\ Re&vert\ changes :call CVSrevertchanges()<cr>
amenu &CVS.-SEP4- :
amenu &CVS.\ &Add :call CVSadd()<cr>
amenu &CVS.\ Comm&it :call CVScommit()<cr>
amenu &CVS.\ Im&port :call CVSimport()<cr>
amenu &CVS.\ &Join\ in :call CVSjoinin()<cr>
" create key mappings from this script {{{1
" key mappings : <Leader> (mostly '\' ?), then same as menu hotkeys
" e.g. <ALT>ci = \ci = CVS.Commit
function! CVSMakeLeaderMapping()
let cvsmenu=expand("$VIM").s:sep.'plugin'.s:sep.'cvsmenu.vim'
silent! call CVSMappingFromMenu(cvsmenu,',')
unlet cvsmenu
endfunction
function! CVSMappingFromMenu(filename,...)
if !filereadable(a:filename)
return
endif
if a:0 == 0
let leader = '<Leader>'
else
let leader = a:1
endif
" create mappings from &-chars
new
exec 'read '.a:filename
" leave only amenu defs
exec 'g!/^\s*amenu/d'
" delete separators and blank lines
exec 'g/\.-SEP/d'
exec 'g/^$/d'
" count entries
let entries=line("$")
" extract menu entries, put in @m
exec '%s/^\s*amenu\s\([^'."\t".']*\).\+/\1/eg'
exec '%y m'
" extract mappings from '&'
exec '%s/&\(\w\)[^&]*/\l\1/eg'
" create cmd, delete to @k
exec '%s/^\(.*\)$/nmap '.leader.'\1 :em /eg'
exec '%d k'
" restore menu, delete '&'
normal "mP
exec '%s/&//eg'
" visual block inserts failed, when called from script (vim60at)
" append keymappings
normal G"kP
" merge keys/commands, execute
let curlin=0
while curlin < entries
let curlin = curlin + 1
call setline(curlin,getline(curlin + entries).getline(curlin).'<cr>')
exec getline(curlin)
endwhile
set nomodified
bwipeout
endfunction
"-----------------------------------------------------------------------------
" show cvs info {{{1
"-----------------------------------------------------------------------------
" Param : ToBuffer (bool)
function! CVSShowInfo(...)
if a:0 == 0
let tobuf = 0
else
let tobuf = a:1
endif
"exec 'cd '.expand('%:p:h')
call CVSChDir(expand('%:p:h'))
" show CVS info from directory
let cvsroot='CVS'.s:sep.'Root'
let cvsrepository='CVS'.s:sep.'Repository'
silent! exec 'split '.cvsroot
let root=getline(1)
bwipeout
silent! exec 'split '.cvsrepository
let repository=getline(1)
bwipeout
unlet cvsroot cvsrepository
" show settings
new
let zbak=@z
let @z = ''
\."\n\"CVSmenu $Revision: 1.77 $"
\."\n\"Current directory : ".expand('%:p:h')
\."\n\"Current Root : ".root
\."\n\"Current Repository : ".repository
\."\n\"\t\t\t\t set environment var to cvsroot"
\."\nlet $CVSROOT\t\t= \'" .$CVSROOT."\'"
\."\nlet $CVS_RSH\t\t= \'" .$CVS_RSH."\'" ."\t\" set environment var to rsh/ssh"
\."\nlet $CVSOPT\t\t= \'" .$CVSOPT."\'" ."\t\" set cvs options (see cvs --help-options)"
\."\nlet $CVSCMDOPT\t\t= \'" .$CVSCMDOPT."\'" ."\t\" set cvs command options"
\."\nlet $CVSCMD\t\t\= '" .$CVSCMD."\'" ."\t\" set cvs command"
\."\nlet g:CVSforcedirectory\t= " .g:CVSforcedirectory ."\t\" refer to directory instead of current file"
\."\nlet g:CVSqueryrevision\t= " .g:CVSqueryrevision ."\t\" Query for revisions (0:no 1:yes)"
\."\nlet g:CVSdumpandclose\t= " .g:CVSdumpandclose ."\t\" Output to: 0=buffer 1=notify 2=autoswitch"
\."\nlet g:CVSsortoutput\t= " .g:CVSsortoutput ."\t\" Toggle sorting output (0:no sorting)"
\."\nlet g:CVScompressoutput\t= " .g:CVScompressoutput ."\t\" Show extended output only if error"
\."\nlet g:CVStitlebar\t= " .g:CVStitlebar ."\t\" Notification on titlebar"
\."\nlet g:CVSstatusline\t= " .g:CVSstatusline ."\t\" Notification on statusline"
\."\nlet g:CVSautocheck\t= " .g:CVSautocheck ."\t\" Get local status when file is read"
\."\nlet g:CVSofferrevision\t= " .g:CVSofferrevision ."\t\" Offer current revision on queries"
\."\nlet g:CVSsavediff\t= " .g:CVSsavediff ."\t\" Save settings when using :diff"
\."\nlet g:CVSdontswitch\t= " .g:CVSdontswitch ."\t\" Dont switch to diffed file"
\."\nlet g:CVSdefaultmsg\t= \'" .g:CVSdefaultmsg."\'" ."\t\" message to use for commands below"
\."\nlet g:CVSusedefaultmsg\t= \'" .g:CVSusedefaultmsg."\'" ."\t\" a:Add, i:Commit, j:Join in, p:Import"
\."\nlet g:CVSfullstatus\t= " .g:CVSfullstatus ."\t\" display all fields for fullstatus"
\."\n\"----------------------------------------"
\."\n\" Change above values to your needs."
\."\n\" To execute a line, put the cursor on it and press <shift-cr> or doubleclick."
\."\n\" Site: http://ezytools.sf.net/VimTools"
normal "zP
let @z=zbak
normal dd
if tobuf == 0
silent! exec '5,$g/^"/d'
normal dddd
" dont dump this to titlebar
let titlebak = g:CVStitlebar
let g:CVStitlebar = 0
call CVSDumpAndClose()
let g:CVStitlebar = titlebak
unlet titlebak
else
map <buffer> q :bd!<cr>
map <buffer> <s-cr> :exec getline('.')<cr>:set nomod<cr>:echo getline('.')<cr>
map <buffer> <2-LeftMouse> <s-cr>
set syntax=vim
set nomodified
endif
call CVSRestoreDir()
unlet root repository tobuf
endfunction
"-----------------------------------------------------------------------------
" syntax, MakeRO/RW {{{1
"-----------------------------------------------------------------------------
function! CVSUpdateSyntax()
syn match cvsupdateMerge '^M .*$'
syn match cvsupdatePatch '^P .*$'
syn match cvsupdateConflict '^C .*$'
syn match cvsupdateDelete '^D .*$'
syn match cvsupdateUnknown '^? .*$'
syn match cvscheckoutUpdate '^U .*$'
syn match cvsimportNew '^N .*$'
syn match cvstagNew '^T .*$'
hi link cvstagNew Special
hi link cvsimportNew Special
hi link cvscheckoutUpdate Special
hi link cvsupdateMerge Special
hi link cvsupdatePatch Constant
hi link cvsupdateConflict WarningMsg
hi link cvsupdateDelete Statement
hi link cvsupdateUnknown Comment
syn match cvsstatusUpToDate '^File:\s.*\sStatus: Up-to-date$'
syn match cvsstatusLocal '^File:\s.*\sStatus: Locally.*$'
syn match cvsstatusNeed '^File:\s.*\sStatus: Need.*$'
syn match cvsstatusConflict '^File:\s.*\sStatus: File had conflict.*$'
syn match cvsstatusUnknown '^File:\s.*\sStatus: Unknown$'
hi link cvsstatusUpToDate Type
hi link cvsstatusLocal Constant
hi link cvsstatusNeed Identifier
hi link cvsstatusConflict Warningmsg
hi link cvsstatusUnknown Comment
syn match cvslocalstatusUnknown '^unknown:.*'
syn match cvslocalstatusUnchanged '^unchanged:.*'
syn match cvslocalstatusMissing '^missing:.*'
syn match cvslocalstatusModified '^modified:.*'
hi link cvslocalstatusUnknown Comment
hi link cvslocalstatusUnchanged Type
hi link cvslocalstatusMissing Identifier
hi link cvslocalstatusModified Constant
if !filereadable($VIM.s:sep.'syntax'.s:sep.'rcslog')
syn match cvslogRevision '^revision.*$'
syn match cvslogFile '^RCS file:.*'
syn match cvslogDate '^date: .*$'
hi link cvslogFile Type
hi link cvslogRevision Constant
hi link cvslogDate Identifier
endif
endfunction
function! CVSAddConflictSyntax()
syn region CVSConflictOrg start="^<<<<<<<" end="^====" contained
syn region CVSConflictNew start="===$" end="^>>>>>>>" contained
syn region CVSConflict start="^<<<<<<<" end=">>>>>>>.*" contains=CVSConflictOrg,CVSConflictNew keepend
" hi link CVSConflict Special
hi link CVSConflictOrg DiffChange
hi link CVSConflictNew DiffAdd
endfunction
function! CVSMakeRO()
set nomodified
set readonly
setlocal nomodifiable
endfunction
function! CVSMakeRW()
set noreadonly
setlocal modifiable
endfunction
" output window: open file under cursor by <doubleclick> or <shift-cr>
function! CVSUpdateMapping()
nmap <buffer> <2-LeftMouse> :call CVSFindFile()<cr>
nmap <buffer> <S-CR> :call CVSFindFile()<cr>
nmap <buffer> q :bd!<cr>
nmap <buffer> ? :call CVSShowMapping()<cr>
nmap <buffer> <Leader>a :call CVSFindFile()<cr>:call CVSadd()<cr>
nmap <buffer> <Leader>d :call CVSFindFile()<cr>:call CVSdiff()<cr>
nmap <buffer> <Leader>i :call CVSFindFile()<cr>:call CVScommit()<cr>
nmap <buffer> <Leader>u :call CVSFindFile()<cr>:call CVSupdate()<cr>
nmap <buffer> <Leader>s :call CVSFindFile()<cr>:call CVSstatus()<cr>
nmap <buffer> <Leader>h :call CVSFindFile()<cr>:call CVSshortstatus()<cr>
nmap <buffer> <Leader>c :call CVSFindFile()<cr>:call CVSlocalstatus()<cr>
nmap <buffer> <Leader>v :call CVSFindFile()<cr>:call CVSrevertchanges()<cr>
endfunction
function! CVSShowMapping()
echo 'Mappings in output buffer :'
echo '<2-LeftMouse> , <SHIFT-CR> : open file in new buffer'
echo 'q : close output buffer'
echo '? : close output buffer'
echo '<Leader>a : Show this help'
echo '<Leader>d : open file and CVSdiff'
echo '<Leader>i : open file and CVScommit'
echo '<Leader>u : open file and CVSupdate'
echo '<Leader>s : open file and CVSstatus'
echo '<Leader>h : open file and CVSshortstatus'
echo '<Leader>c : open file and CVSlocalstatus'
echo '<Leader>v : open file and CVSrevertchanges'
endfunction
function! CVSFindFile()
let curdir = getcwd()
exec 'cd '.g:workdir
normal 0W
exec 'cd '.curdir
unlet curdir
endfunction
"-----------------------------------------------------------------------------
" sort output {{{1
"-----------------------------------------------------------------------------
" move all lines matching "searchstr" to top
function! CVSMoveToTop(searchstr)
silent exec 'g/'.a:searchstr.'/m0'
endfunction
" only called by CVSShortStatus
function! CVSSortStatusOutput()
" allow changes
call CVSMakeRW()
call CVSMoveToTop('Status: Unknown$')
call CVSMoveToTop('Status: Needs Checkout$')
call CVSMoveToTop('Status: Needs Merge$')
call CVSMoveToTop('Status: Needs Patch$')
call CVSMoveToTop('Status: Locally Removed$')
call CVSMoveToTop('Status: Locally Added$')
call CVSMoveToTop('Status: Locally Modified$')
call CVSMoveToTop('Status: File had conflicts on merge$')
endfunction
" called by CVSDoCommand
function! CVSSortOutput()
" allow changes
call CVSMakeRW()
" localstatus
call CVSMoveToTop('^unknown:')
call CVSMoveToTop('^unchanged:')
call CVSMoveToTop('^missing:')
call CVSMoveToTop('^modified:')
" org cvs
call CVSMoveToTop('^? ') " unknown
call CVSMoveToTop('^T ') " tag
call CVSMoveToTop('^D ') " delete
call CVSMoveToTop('^N ') " new
call CVSMoveToTop('^U ') " update
call CVSMoveToTop('^M ') " merge
call CVSMoveToTop('^P ') " patch
call CVSMoveToTop('^C ') " conflict
endfunction
"-----------------------------------------------------------------------------
" status variables {{{1
"-----------------------------------------------------------------------------
function! CVSSaveOpts()
let s:CVSROOTbak = $CVSROOT
let s:CVS_RSHbak = $CVS_RSH
let s:CVSOPTbak = $CVSOPT
let s:CVSCMDOPTbak = $CVSCMDOPT
let s:CVSCMDbak = $CVSCMD
let s:CVSforcedirectorybak = g:CVSforcedirectory
let s:CVSqueryrevisionbak = g:CVSqueryrevision
let s:CVSdumpandclosebak = g:CVSdumpandclose
let g:CVSsortoutputbak = g:CVSsortoutput
let g:CVScompressoutputbak = g:CVScompressoutput
let g:CVStitlebarbak = g:CVStitlebar
let g:CVSstatuslinebak = g:CVSstatusline
let g:CVSautocheckbak = g:CVSautocheck
let g:CVSofferrevisionbak = g:CVSofferrevision
let g:CVSsavediffbak = g:CVSsavediff
let g:CVSdontswitchbak = g:CVSdontswitch
endfunction
function! CVSRestoreOpts()
let $CVSROOT = s:CVSROOTbak
let $CVS_RSH = s:CVS_RSHbak
let $CVSOPT = s:CVSOPTbak
let $CVSCMDOPT = s:CVSCMDOPTbak
let $CVSCMD = s:CVSCMDbak
let g:CVSforcedirectory = s:CVSforcedirectorybak
let g:CVSqueryrevision = s:CVSqueryrevisionbak
let g:CVSdumpandclose = s:CVSdumpandclosebak
let g:CVSsortoutput = g:CVSsortoutputbak
let g:CVScompressoutput = g:CVScompressoutputbak
let g:CVStitlebar = g:CVStitlebarbak
let g:CVSstatusline = g:CVSstatuslinebak
let g:CVSautocheck = g:CVSautocheckbak
let g:CVSofferrevision = g:CVSofferrevisionbak
let g:CVSsavediff = g:CVSsavediffbak
let g:CVSdontswitch = g:CVSdontswitchbak
unlet g:CVSsortoutputbak g:CVScompressoutputbak g:CVStitlebarbak
unlet g:CVSstatuslinebak g:CVSautocheckbak g:CVSofferrevisionbak
unlet g:CVSsavediffbak g:CVSdontswitchbak
unlet s:CVSROOTbak s:CVS_RSHbak s:CVSOPTbak s:CVSCMDOPTbak s:CVSCMDbak
unlet s:CVSforcedirectorybak s:CVSqueryrevisionbak s:CVSdumpandclosebak
endfunction
" set scope : file or directory, inform user
function! CVSSetForceDir(value)
let g:CVSforcedirectory=a:value
if g:CVSforcedirectory==1
echo 'CVS:Using current DIRECTORY once'
elseif g:CVSforcedirectory==2
echo 'CVS:Using current DIRECTORY'
else
echo 'CVS:Using current buffer'
endif
endfunction
" Set output to statusline, close output buffer
function! CVSSetDumpAndClose(value)
if a:value > 1
echo 'CVS:output to status(file) and buffer(dir)'
elseif a:value > 0
echo 'CVS:output to statusline'
else
echo 'CVS:output to buffer'
endif
let g:CVSdumpandclose = a:value
endfunction
" enable/disable revs/branchs queries
function! CVSSetQueryRevision(value)
if a:value > 0
echo 'CVS:Enabled revision queries'
else
echo 'CVS:Not asking for revisions'
endif
let g:CVSqueryrevision = a:value
endfunction
" Sort output (group conflicts,updates,...)
function! CVSSetSortOutput(value)
if a:value > 0
echo 'CVS:sorting output'
else
echo 'CVS:unsorted output'
endif
let g:CVSsortoutput = a:value
endfunction
" compress output to one line
function! CVSSetCompressOutput(value)
if a:value > 0
echo 'CVS:compressed output'
else
echo 'CVS:full output'
endif
let g:CVScompressoutput = a:value
endfunction
" output to statusline
function! CVSSetStatusline(value)
if a:value > 0
echo 'CVS:output to statusline'
else
echo 'CVS:no output to statusline'
endif
let g:CVSstatusline = a:value
endfunction
" output to titlebar
function! CVSSetTitlebar(value)
if a:value > 0
echo 'CVS:output to titlebar'
else
echo 'CVS:no output to titlebar'
endif
let g:CVStitlebar = a:value
endfunction
" show local status (autocheck)
function! CVSSetAutocheck(value)
if a:value > 0
echo 'CVS:autochecking each file'
else
echo 'CVS:autocheck disabled'
endif
let g:CVSautocheck = a:value
endfunction
" show current revision as default, when asking for it
function! CVSSetOfferRevision(value)
if a:value > 0
echo 'CVS:offering current revision'
else
echo 'CVS:not offering current revision'
endif
let g:CVSofferrevision = a:value
endfunction
" CVSDiff : activate original or checked-out
function! CVSSetDontSwitch(value)
if a:value > 0
echo 'CVS:switching to compared file'
else
echo 'CVS:stay in original when diffing'
endif
let g:CVSdontswitch = a:value
endfunction
" save settings when using :diff
function! CVSSetSaveDiff(value)
if a:value > 0
echo 'CVS:saving settings for :diff'
else
echo 'CVS:not saving settings for :diff'
endif
let g:CVSsavediff = a:value
endfunction
function! CVSChDir(path)
let g:orgpath = getcwd()
let g:workdir = expand("%:p:h")
exec 'cd '.a:path
endfunction
function! CVSRestoreDir()
if isdirectory(g:orgpath)
exec 'cd '.g:orgpath
endif
endfunction
"}}}
"#############################################################################
" CVS commands
"#############################################################################
"-----------------------------------------------------------------------------
" CVS call {{{1
"-----------------------------------------------------------------------------
" return > 0 if is win 95-me
function! CVSIsW9x()
return (has("win32") && (match($COMSPEC,"command\.com") > -1))
endfunction
function! CVSDoCommand(cmd,...)
" needs to be called from orgbuffer
let isfile = CVSUsesFile()
" change to buffers directory
"exec 'cd '.expand('%:p:h')
call CVSChDir(expand('%:p:h'))
" get file/directory to work on (if not given)
if a:0 < 1
if g:CVSforcedirectory>0
let filename=''
else
let filename=expand('%:p:t')
endif
else
let filename = a:1
endif
" problem with win98se : system() gives an error
" cannot open 'F:\WIN98\TEMP\VIo9134.TMP'
" piping the password also seems to fail (maybe caused by cvs.exe)
" Using 'exec' creates a confirm prompt - only use this s**t on w9x
if CVSIsW9x()
let tmp=tempname()
exec '!'.$CVSCMD.' '.$CVSOPT.' '.a:cmd.' '.$CVSCMDOPT.' '.filename.'>'.tmp
exec 'split '.tmp
let dummy=delete(tmp)
unlet tmp dummy
else
let regbak=@z
let @z=system($CVSCMD.' '.$CVSOPT.' '.a:cmd.' '.$CVSCMDOPT.' '.filename)
new
silent normal "zP
let @z=regbak
endif
call CVSProcessOutput(isfile, filename, a:cmd)
call CVSRestoreDir()
unlet filename
endfunction
" also jumped in by CVSLocalStatus
function! CVSProcessOutput(isfile,filename,cmd)
" delete leading and trainling blank lines
while (getline(1) == '') && (line("$")>1)
silent exec '0d'
endwhile
while (getline("$") == '') && (line("$")>1)
silent exec '$d'
endwhile
" group conflicts, updates, ....
if g:CVSsortoutput > 0
silent call CVSSortOutput()
endif
" compress output ?
if g:CVScompressoutput > 0
if (g:CVSdumpandclose > 0) && a:isfile
silent call CVSCompressOutput(a:cmd)
endif
endif
" move to top
normal gg
set nowrap
" reset single shot flag
if g:CVSforcedirectory==1
let g:CVSforcedirectory = 0
endif
call CVSMakeRO()
if (g:CVSdumpandclose == 1) || ((g:CVSdumpandclose == 2) && a:isfile)
call CVSDumpAndClose()
else
call CVSUpdateMapping()
call CVSUpdateSyntax()
endif
endfunction
" return: 1=file 0=dir
function! CVSUsesFile()
let filename=expand("%:p:t")
if ((g:CVSforcedirectory == 0) && (filename != ''))
\ || ((g:CVSforcedirectory > 0) && (filename == ''))
return 1
else
return 0
endif
unlet filename
endfunction
" compress output
function! CVSCompressOutput(cmd)
" commit
if match(a:cmd,"commit") > -1
let v:errmsg = ''
silent! exec '/^cvs \[commit aborted]:'
" only compress, if no error found
if v:errmsg != ''
silent! exec 'g!/^new revision:/d'
endif
" skip localstatus
elseif (match(a:cmd,"localstatus") > -1)
" status
elseif (match(a:cmd,"status") > -1)
silent! exec 'g/^=\+$/d'
silent! exec 'g/^$/d'
silent! exec '%s/.*Status: //'
silent! exec '%s/^\s\+Working revision:\s\+\([0-9.]*\).*/W:\1/'
silent! exec '%s/^\s\+Repository revision:\s\+\([0-9.]*\).*/R:\1/'
silent! exec '%s/^\s\+Sticky Tag:\s\+/T:/'
silent! exec '%s/^\s\+Sticky Date:\s\+/D:/'
silent! exec '%s/^\s\+Sticky Options:\s\+/O:/'
silent! normal ggJJJJJJ
endif
endfunction
"#############################################################################
" following commands read from STDIN. Call CVS directly
"#############################################################################
"-----------------------------------------------------------------------------
" CVS login / logout (password prompt) {{{1
"-----------------------------------------------------------------------------
function! CVSlogin(...)
if a:0 == 0
let pwpipe = ''
else
let pwpipe = 'echo '
if !has("unix")
if a:1 == ''
let pwpipe = pwpipe . '.'
endif
endif
let pwpipe = pwpipe . a:1 . '|'
endif
if has("unix")
" show password prompt
exec '!'.pwpipe.$CVSCMD.' '.$CVSOPT.' login '.$CVSCMDOPT
else
" shell is opened in win32 (dos?)
silent! exec '!'.pwpipe.$CVSCMD.' '.$CVSOPT.' login '.$CVSCMDOPT
endif
endfunction
function! CVSlogout()
silent! exec '!'.$CVSCMD.' '.$CVSOPT.' logout '.$CVSCMDOPT
endfunction
"-----------------------------------------------------------------------------
" CVS release (confirmation prompt) {{{1
"-----------------------------------------------------------------------------
function! CVSrelease()
let localtoo=input('Release:Also delete local file [y]:')
if (localtoo=='y') || (localtoo=='')
let localtoo='-d '
else
let localtoo=''
endif
let releasedir=expand('%:p:h')
"exec ':cd ..'
call CVSChDir(releasedir.s:sep.'..')
" confirmation prompt -> dont use CVSDoCommand
if has("unix")
" show confirmation prompt
exec '!'.$CVSCMD.' '.$CVSOPT.' release '.localtoo.releasedir.' '.$CVSCMDOPT
else
silent! exec '!'.$CVSCMD.' '.$CVSOPT.' release '.localtoo.releasedir.' '.$CVSCMDOPT
endif
call CVSRestoreDir()
unlet localtoo releasedir
endfunction
"#############################################################################
" from here : use CVSDoCommand wrapper
"#############################################################################
"-----------------------------------------------------------------------------
" CVS diff (diffsplit) {{{1
"-----------------------------------------------------------------------------
" parm : revision
function! CVSdiff(...)
if g:CVSsavediff > 0
call CVSDiffEnter()
endif
let orgcwd = getcwd()
exec 'cd '.expand('%:p:h')
let outputbak = g:CVSdumpandclose
let autocheckbak = g:CVSautocheck
let g:CVSautocheck = 0
let g:CVSdumpandclose = 0
let g:CVSautocheck = 0
let g:CVSdumpandclose = 0
let orgfiletype = &filetype
" query revision (if wanted)
if a:0 != ''
let rev = a:1
elseif g:CVSqueryrevision > 0
let rev=CVSInputRev('Revision (optional):')
else
let rev=''
endif
" tempname() would be deleted before diff (linux)!
" it is also better to show selected revision
let tmpnam=expand("%").'.'.rev.'_'.localtime().'.dif'
if rev!=''
let rev='-r '.rev.' '
endif
call CVSDoCommand('update -p '.rev)
redraw
" delete stderr ('checking out...')
call CVSStripHeader()
call CVSMakeRO()
" x! did not write before diffing (linux)!
exec "w! ".tmpnam
bwipeout
wincmd _
" jump to next diff (current buffer)
silent! nmap <unique> <buffer> <tab> ]c
silent! nmap <unique> <buffer> <s-tab> [c
redraw
exec 'vertical diffsplit '.tmpnam
let &filetype = orgfiletype
" jump to next diff (diffed buffer)
silent! nmap <unique> <buffer> <tab> ]c
silent! nmap <unique> <buffer> <s-tab> [c
silent! nmap <unique> <buffer> q :bwipeout<cr>
let dummy=delete(tmpnam)
if g:CVSdontswitch > 0
redraw
wincmd
endif
exec 'cd '.orgcwd
let g:CVSdumpandclose = outputbak
let g:CVSautocheck = autocheckbak
unlet outputbak autocheckbak
unlet tmpnam rev orgfiletype
endfunction
" diff to a specific revision
function! CVSdifftorev()
" Force revision input
let rev=CVSInputRev('Revision:')
if rev==''
echo "CVS diff to revision: aborted"
return
endif
call CVSdiff(rev)
unlet rev
endfunction
"-----------------------------------------------------------------------------
" CVS diff / patchfile {{{1
"-----------------------------------------------------------------------------
function! CVSgetdiff(parm)
call CVSSaveOpts()
let g:CVSdumpandclose = 0
let g:CVStitlebar = 1 " Notification output to titlebar
" query revision
let rev=CVSInputRev('Revision (optional):')
if rev!=''
let rev=' -r '.rev.' '
endif
call CVSDoCommand('diff '.a:parm.rev)
set syntax=diff
call CVSRestoreOpts()
unlet rev
endfunction
function! CVSdiffcontext()
call CVSgetdiff('-c')
endfunction
function! CVSdiffstandard()
call CVSgetdiff('')
endfunction
function! CVSdiffuni()
call CVSgetdiff('-u')
endfunction
"-----------------------------------------------------------------------------
" CVS annotate / log / status / history {{{1
"-----------------------------------------------------------------------------
function! CVSannotate()
call CVSDoCommand('annotate',expand('%:p:t'))
wincmd _
endfunction
function! CVSstatus()
call CVSDoCommand('status')
endfunction
function! CVShistory()
call CVSSaveOpts()
let g:CVSdumpandclose = 0
call CVSDoCommand('history')
call CVSRestoreOpts()
endfunction
function! CVSlog()
call CVSSaveOpts()
let g:CVSdumpandclose = 0
if g:CVSqueryrevision > 0
if g:CVSofferrevision > 0