Show More
@@ -1,33 +1,33 b'' | |||||
1 |
* |
|
1 | *hgcommand.txt* HGCommand | |
2 |
|
2 | |||
3 | For instructions on installing this file, type |
|
3 | For instructions on installing this file, type | |
4 | :help add-local-help |
|
4 | :help add-local-help | |
5 | inside Vim. |
|
5 | inside Vim. | |
6 |
|
6 | |||
7 | Author: Bob Hiestand <bob.hiestand@gmail.com> |
|
7 | Author: Mathieu Clabaut <mathieu.clabaut@gmail.com> | |
8 | Credits: Benji Fisher's excellent MatchIt documentation |
|
8 | Credits: Bob Hiestand <bob.hiestand@gmail.com> | |
9 |
|
9 | |||
10 | ============================================================================== |
|
10 | ============================================================================== | |
11 |
1. Contents * |
|
11 | 1. Contents *hgcommand-contents* | |
12 |
|
12 | |||
13 |
Installation : | |
|
13 | Installation : |hgcommand-install| | |
14 |
|
|
14 | HGCommand Intro : |hgcommand| | |
15 |
|
|
15 | HGCommand Manual : |hgcommand-manual| | |
16 |
Customization : | |
|
16 | Customization : |hgcommand-customize| | |
17 |
SSH "integration" : | |
|
17 | SSH "integration" : |hgcommand-ssh| | |
18 |
Bugs : | |
|
18 | Bugs : |hgcommand-bugs| | |
19 |
|
19 | |||
20 | ============================================================================== |
|
20 | ============================================================================== | |
21 |
|
21 | |||
22 |
2. |
|
22 | 2. HGCommand Installation *hgcommand-install* | |
23 |
|
23 | |||
24 |
The |
|
24 | The HGCommand plugin comprises two files, hgcommand.vim and hgcommand.txt | |
25 |
(this file). In order to install the plugin, place the |
|
25 | (this file). In order to install the plugin, place the hgcommand.vim file | |
26 | into a plugin' directory in your runtime path (please see |add-global-plugin| |
|
26 | into a plugin' directory in your runtime path (please see |add-global-plugin| | |
27 | and |'runtimepath'|. |
|
27 | and |'runtimepath'|. | |
28 |
|
28 | |||
29 |
|
|
29 | HGCommand may be customized by setting variables, creating maps, and | |
30 |
specifying event handlers. Please see | |
|
30 | specifying event handlers. Please see |hgcommand-customize| for more | |
31 | details. |
|
31 | details. | |
32 |
|
32 | |||
33 | This help file can be included in the VIM help system by copying it into a |
|
33 | This help file can be included in the VIM help system by copying it into a | |
@@ -37,90 +37,82 b' command, specifying the full path of the' | |||||
37 |
|
37 | |||
38 | ============================================================================== |
|
38 | ============================================================================== | |
39 |
|
39 | |||
40 |
3. |
|
40 | 3. HGCommand Intro *hgcommand* | |
41 |
* |
|
41 | *hgcommand-intro* | |
42 |
|
42 | |||
43 |
The |
|
43 | The HGCommand plugin provides global ex commands for manipulating | |
44 |
|
|
44 | HG-controlled source files. In general, each command operates on the current | |
45 |
buffer and accomplishes a separate |
|
45 | buffer and accomplishes a separate hg function, such as update, commit, log, | |
46 |
and others (please see | |
|
46 | and others (please see |hgcommand-commands| for a list of all available | |
47 | commands). The results of each operation are displayed in a scratch buffer. |
|
47 | commands). The results of each operation are displayed in a scratch buffer. | |
48 | Several buffer variables are defined for those scratch buffers (please see |
|
48 | Several buffer variables are defined for those scratch buffers (please see | |
49 |
| |
|
49 | |hgcommand-buffer-variables|). | |
50 |
|
50 | |||
51 | The notion of "current file" means either the current buffer, or, in the case |
|
51 | The notion of "current file" means either the current buffer, or, in the case | |
52 | of a directory buffer, the file on the current line within the buffer. |
|
52 | of a directory buffer, the file on the current line within the buffer. | |
53 |
|
53 | |||
54 |
For convenience, any |
|
54 | For convenience, any HGCommand invoked on a HGCommand scratch buffer acts as | |
55 | though it was invoked on the original file and splits the screen so that the |
|
55 | though it was invoked on the original file and splits the screen so that the | |
56 | output appears in a new window. |
|
56 | output appears in a new window. | |
57 |
|
57 | |||
58 | Many of the commands accept revisions as arguments. By default, most operate |
|
58 | Many of the commands accept revisions as arguments. By default, most operate | |
59 | on the most recent revision on the current branch if no revision is specified |
|
59 | on the most recent revision on the current branch if no revision is specified | |
60 |
(though see | |
|
60 | (though see |HGCommandInteractive| to prompt instead). | |
61 |
|
61 | |||
62 |
Each |
|
62 | Each HGCommand is mapped to a key sequence starting with the <Leader> | |
63 | keystroke. The default mappings may be overridden by supplying different |
|
63 | keystroke. The default mappings may be overridden by supplying different | |
64 | mappings before the plugin is loaded, such as in the vimrc, in the standard |
|
64 | mappings before the plugin is loaded, such as in the vimrc, in the standard | |
65 | fashion for plugin mappings. For examples, please see |
|
65 | fashion for plugin mappings. For examples, please see | |
66 |
| |
|
66 | |hgcommand-mappings-override|. | |
67 |
|
67 | |||
68 |
The |
|
68 | The HGCommand plugin may be configured in several ways. For more details, | |
69 |
please see | |
|
69 | please see |hgcommand-customize|. | |
70 |
|
70 | |||
71 | ============================================================================== |
|
71 | ============================================================================== | |
72 |
|
72 | |||
73 |
4. |
|
73 | 4. HGCommand Manual *hgcommand-manual* | |
74 |
|
74 | |||
75 |
4.1 |
|
75 | 4.1 HGCommand commands *hgcommand-commands* | |
76 |
|
76 | |||
77 |
|
|
77 | HGCommand defines the following commands: | |
78 |
|
78 | |||
79 |
|: |
|
79 | |:HGAdd| | |
80 |
|: |
|
80 | |:HGAnnotate| | |
81 |
|: |
|
81 | |:HGCommit| | |
82 |
|: |
|
82 | |:HGDiff| | |
83 | |:CVSEdit| |
|
83 | |:HGGotoOriginal| | |
84 | |:CVSEditors| |
|
84 | |:HGLog| | |
85 | |:CVSGotoOriginal| |
|
85 | |:HGRevert| | |
86 | |:CVSLog| |
|
86 | |:HGReview| | |
87 | |:CVSRevert| |
|
87 | |:HGStatus| | |
88 | |:CVSReview| |
|
88 | |:HGUnedit| | |
89 | |:CVSStatus| |
|
89 | |:HGUpdate| | |
90 | |:CVSUnedit| |
|
90 | |:HGVimDiff| | |
91 | |:CVSUpdate| |
|
|||
92 | |:CVSVimDiff| |
|
|||
93 | |:CVSWatch| |
|
|||
94 | |:CVSWatchAdd| |
|
|||
95 | |:CVSWatchOn| |
|
|||
96 | |:CVSWatchOff| |
|
|||
97 | |:CVSWatchRemove| |
|
|||
98 | |:CVSWatchers| |
|
|||
99 |
|
91 | |||
100 |
: |
|
92 | :HGAdd *:HGAdd* | |
101 |
|
93 | |||
102 |
This command performs " |
|
94 | This command performs "hg add" on the current file. Please note, this does | |
103 | not commit the newly-added file. |
|
95 | not commit the newly-added file. | |
104 |
|
96 | |||
105 |
: |
|
97 | :HGAnnotate *:HGAnnotate* | |
106 |
|
98 | |||
107 |
This command performs " |
|
99 | This command performs "hg annotate" on the current file. If an argument is | |
108 | given, the argument is used as a revision number to display. If not given an |
|
100 | given, the argument is used as a revision number to display. If not given an | |
109 | argument, it uses the most recent version of the file on the current branch. |
|
101 | argument, it uses the most recent version of the file on the current branch. | |
110 |
Additionally, if the current buffer is a |
|
102 | Additionally, if the current buffer is a HGAnnotate buffer already, the | |
111 | version number on the current line is used. |
|
103 | version number on the current line is used. | |
112 |
|
104 | |||
113 |
If the | |
|
105 | If the |HGCommandAnnotateParent| variable is set to a non-zero value, the | |
114 | version previous to the one on the current line is used instead. This allows |
|
106 | version previous to the one on the current line is used instead. This allows | |
115 | one to navigate back to examine the previous version of a line. |
|
107 | one to navigate back to examine the previous version of a line. | |
116 |
|
108 | |||
117 |
The filetype of the |
|
109 | The filetype of the HGCommand scratch buffer is set to 'HGAnnotate', to take | |
118 | advantage of the bundled syntax file. |
|
110 | advantage of the bundled syntax file. | |
119 |
|
111 | |||
120 |
|
112 | |||
121 |
: |
|
113 | :HGCommit[!] *:HGCommit* | |
122 |
|
114 | |||
123 |
If called with arguments, this performs " |
|
115 | If called with arguments, this performs "hg commit" using the arguments as | |
124 | the log message. |
|
116 | the log message. | |
125 |
|
117 | |||
126 | If '!' is used with no arguments, an empty log message is committed. |
|
118 | If '!' is used with no arguments, an empty log message is committed. | |
@@ -131,79 +123,74 b' automatically closed and the file is com' | |||||
131 | log message. The commit can be abandoned if the log message buffer is deleted |
|
123 | log message. The commit can be abandoned if the log message buffer is deleted | |
132 | or wiped before being written. |
|
124 | or wiped before being written. | |
133 |
|
125 | |||
134 |
Alternatively, the mapping that is used to invoke : |
|
126 | Alternatively, the mapping that is used to invoke :HGCommit (by default | |
135 |
<Leader> |
|
127 | <Leader>hgc) can be used in the log message buffer to immediately commit. | |
136 | is useful if the |CVSCommandCommitOnWrite| variable is set to 0 to disable the |
|
128 | This | |
|
129 | is useful if the |HGCommandCommitOnWrite| variable is set to 0 to disable the | |||
137 | normal commit-on-write behavior. |
|
130 | normal commit-on-write behavior. | |
138 |
|
131 | |||
139 |
: |
|
132 | :HGDiff *:HGDiff* | |
140 |
|
133 | |||
141 |
With no arguments, this performs " |
|
134 | With no arguments, this performs "hg diff" on the current file against the | |
142 | current repository version. |
|
135 | current repository version. | |
143 |
|
136 | |||
144 |
With one argument, " |
|
137 | With one argument, "hg diff" is performed on the current file against the | |
145 | specified revision. |
|
138 | specified revision. | |
146 |
|
139 | |||
147 |
With two arguments, |
|
140 | With two arguments, hg diff is performed between the specified | |
148 | revisions of the current file. |
|
141 | revisions of the current file. | |
149 |
|
142 | |||
150 |
This command uses the ' |
|
143 | This command uses the 'HGCommandDiffOpt' variable to specify diff options. | |
151 | If that variable does not exist, then 'wbBc' is assumed. If you wish to have |
|
144 | If that variable does not exist, then 'wbBc' is assumed. If you wish to have | |
152 | no options, then set it to the empty string. |
|
145 | no options, then set it to the empty string. | |
153 |
|
146 | |||
154 | :CVSEdit *:CVSEdit* |
|
|||
155 |
|
||||
156 | This command performs "cvs edit" on the current file. Yes, the output buffer |
|
|||
157 | in this case is almost completely useless. |
|
|||
158 |
|
147 | |||
159 | :CVSEditors *:CVSEditors* |
|
148 | This command performs "hg edit" on the current file. | |
160 |
|
149 | |||
161 | This command performs "cvs edit" on the current file. |
|
150 | :HGGotoOriginal *:HGGotoOriginal* | |
162 |
|
||||
163 | :CVSGotoOriginal *:CVSGotoOriginal* |
|
|||
164 |
|
151 | |||
165 | This command returns the current window to the source buffer, if the current |
|
152 | This command returns the current window to the source buffer, if the current | |
166 |
buffer is a |
|
153 | buffer is a HG command output buffer. | |
167 |
|
154 | |||
168 |
: |
|
155 | :HGGotoOriginal! | |
169 |
|
156 | |||
170 |
Like ": |
|
157 | Like ":HGGotoOriginal" but also executes :bufwipeout on all HG command | |
171 | output buffers for the source buffer. |
|
158 | output buffers for the source buffer. | |
172 |
|
159 | |||
173 |
: |
|
160 | :HGLog *:HGLog* | |
174 |
|
161 | |||
175 |
Performs " |
|
162 | Performs "hg log" on the current file. | |
176 |
|
163 | |||
177 | If an argument is given, it is passed as an argument to the "-r" option of |
|
164 | If an argument is given, it is passed as an argument to the "-r" option of | |
178 |
" |
|
165 | "hg log". | |
179 |
|
166 | |||
180 |
: |
|
167 | :HGRevert *:HGRevert* | |
181 |
|
168 | |||
182 | Replaces the current file with the most recent version from the repository in |
|
169 | Replaces the current file with the most recent version from the repository in | |
183 | order to wipe out any undesired changes. |
|
170 | order to wipe out any undesired changes. | |
184 |
|
171 | |||
185 |
: |
|
172 | :HGReview *:HGReview* | |
186 |
|
173 | |||
187 | Retrieves a particular version of the current file. If no argument is given, |
|
174 | Retrieves a particular version of the current file. If no argument is given, | |
188 | the most recent version of the file on the current branch is retrieved. |
|
175 | the most recent version of the file on the current branch is retrieved. | |
189 | Otherwise, the specified version is retrieved. |
|
176 | Otherwise, the specified version is retrieved. | |
190 |
|
177 | |||
191 |
: |
|
178 | :HGStatus *:HGStatus* | |
192 |
|
179 | |||
193 |
Performs " |
|
180 | Performs "hg status" on the current file. | |
194 |
|
181 | |||
195 |
: |
|
182 | :HGUnedit *:HGUnedit* | |
196 |
|
183 | |||
197 |
Performs " |
|
184 | Performs "hg unedit" on the current file. Again, yes, the output buffer here | |
198 | is basically useless. |
|
185 | is basically useless. | |
199 |
|
186 | |||
200 |
: |
|
187 | :HGUpdate *:HGUpdate* | |
201 |
|
188 | |||
202 |
Performs " |
|
189 | Performs "hg update" on the current file. This intentionally does not | |
203 | automatically reload the current buffer, though vim should prompt the user to |
|
190 | automatically reload the current buffer, though vim should prompt the user to | |
204 | do so if the underlying file is altered by this command. |
|
191 | do so if the underlying file is altered by this command. | |
205 |
|
192 | |||
206 |
: |
|
193 | :HGVimDiff *:HGVimDiff* | |
207 |
|
194 | |||
208 | With no arguments, this prompts the user for a revision and then uses vimdiff |
|
195 | With no arguments, this prompts the user for a revision and then uses vimdiff | |
209 | to display the differences between the current file and the specified |
|
196 | to display the differences between the current file and the specified | |
@@ -226,97 +213,66 b' Using the 2-argument form of the command' | |||||
226 | versions. Additionally, invoking the command on a different file will close |
|
213 | versions. Additionally, invoking the command on a different file will close | |
227 | the previous vimdiff buffers. |
|
214 | the previous vimdiff buffers. | |
228 |
|
215 | |||
229 | :CVSWatch *:CVSWatch* |
|
|||
230 |
|
216 | |||
231 | This command takes an argument which must be one of [on|off|add|remove]. The |
|
217 | 4.2 Mappings *hgcommand-mappings* | |
232 | command performs "cvs watch" with the given argument on the current file. |
|
|||
233 |
|
||||
234 | :CVSWatchAdd *:CVSWatchAdd* |
|
|||
235 |
|
||||
236 | This command is an alias for ":CVSWatch add" |
|
|||
237 |
|
||||
238 | :CVSWatchOn *:CVSWatchOn* |
|
|||
239 |
|
||||
240 | This command is an alias for ":CVSWatch on" |
|
|||
241 |
|
||||
242 | :CVSWatchOff *:CVSWatchOff* |
|
|||
243 |
|
||||
244 | This command is an alias for ":CVSWatch off" |
|
|||
245 |
|
||||
246 | :CVSWatchRemove *:CVSWatchRemove* |
|
|||
247 |
|
||||
248 | This command is an alias for ":CVSWatch remove" |
|
|||
249 |
|
||||
250 | :CVSWatchers *:CVSWatchers* |
|
|||
251 |
|
||||
252 | This command performs "cvs watchers" on the current file. |
|
|||
253 |
|
||||
254 | 4.2 Mappings *cvscommand-mappings* |
|
|||
255 |
|
218 | |||
256 | By default, a mapping is defined for each command. These mappings execute the |
|
219 | By default, a mapping is defined for each command. These mappings execute the | |
257 | default (no-argument) form of each command. |
|
220 | default (no-argument) form of each command. | |
258 |
|
221 | |||
259 |
<Leader> |
|
222 | <Leader>hga HGAdd | |
260 |
<Leader> |
|
223 | <Leader>hgn HGAnnotate | |
261 |
<Leader> |
|
224 | <Leader>hgc HGCommit | |
262 |
<Leader> |
|
225 | <Leader>hgd HGDiff | |
263 | <Leader>ce CVSEdit |
|
226 | <Leader>hgg HGGotoOriginal | |
264 | <Leader>ci CVSEditors |
|
227 | <Leader>hgG HGGotoOriginal! | |
265 |
<Leader> |
|
228 | <Leader>hgl HGLog | |
266 | <Leader>cG CVSGotoOriginal! |
|
229 | <Leader>hgr HGReview | |
267 | <Leader>cl CVSLog |
|
230 | <Leader>hgs HGStatus | |
268 | <Leader>cr CVSReview |
|
231 | <Leader>hgt HGUnedit | |
269 | <Leader>cs CVSStatus |
|
232 | <Leader>hgu HGUpdate | |
270 | <Leader>ct CVSUnedit |
|
233 | <Leader>hgv HGVimDiff | |
271 | <Leader>cu CVSUpdate |
|
|||
272 | <Leader>cv CVSVimDiff |
|
|||
273 | <Leader>cwv CVSWatchers |
|
|||
274 | <Leader>cwa CVSWatchAdd |
|
|||
275 | <Leader>cwn CVSWatchOn |
|
|||
276 | <Leader>cwf CVSWatchOff |
|
|||
277 | <Leader>cwf CVSWatchRemove |
|
|||
278 |
|
234 | |||
279 |
* |
|
235 | *hgcommand-mappings-override* | |
280 |
|
236 | |||
281 | The default mappings can be overriden by user-provided instead by mapping to |
|
237 | The default mappings can be overriden by user-provided instead by mapping to | |
282 | <Plug>CommandName. This is especially useful when these mappings collide with |
|
238 | <Plug>CommandName. This is especially useful when these mappings collide with | |
283 | other existing mappings (vim will warn of this during plugin initialization, |
|
239 | other existing mappings (vim will warn of this during plugin initialization, | |
284 | but will not clobber the existing mappings). |
|
240 | but will not clobber the existing mappings). | |
285 |
|
241 | |||
286 |
For instance, to override the default mapping for : |
|
242 | For instance, to override the default mapping for :HGAdd to set it to '\add', | |
287 | add the following to the vimrc: |
|
243 | add the following to the vimrc: | |
288 |
|
244 | |||
289 |
nmap \add <Plug> |
|
245 | nmap \add <Plug>HGAdd | |
290 |
|
246 | |||
291 |
4.3 Automatic buffer variables * |
|
247 | 4.3 Automatic buffer variables *hgcommand-buffer-variables* | |
292 |
|
248 | |||
293 |
Several buffer variables are defined in each |
|
249 | Several buffer variables are defined in each HGCommand result buffer. These | |
294 | may be useful for additional customization in callbacks defined in the event |
|
250 | may be useful for additional customization in callbacks defined in the event | |
295 |
handlers (please see | |
|
251 | handlers (please see |hgcommand-events|). | |
296 |
|
252 | |||
297 | The following variables are automatically defined: |
|
253 | The following variables are automatically defined: | |
298 |
|
254 | |||
299 |
b: |
|
255 | b:hgOrigBuffNR *b:hgOrigBuffNR* | |
300 |
|
256 | |||
301 | This variable is set to the buffer number of the source file. |
|
257 | This variable is set to the buffer number of the source file. | |
302 |
|
258 | |||
303 |
b: |
|
259 | b:hgcmd *b:hgcmd* | |
304 |
|
260 | |||
305 |
This variable is set to the name of the |
|
261 | This variable is set to the name of the hg command that created the result | |
306 | buffer. |
|
262 | buffer. | |
307 | ============================================================================== |
|
263 | ============================================================================== | |
308 |
|
264 | |||
309 |
5. Configuration and customization * |
|
265 | 5. Configuration and customization *hgcommand-customize* | |
310 |
* |
|
266 | *hgcommand-config* | |
311 |
|
267 | |||
312 |
The |
|
268 | The HGCommand plugin can be configured in two ways: by setting configuration | |
313 |
variables (see | |
|
269 | variables (see |hgcommand-options|) or by defining HGCommand event handlers | |
314 |
(see | |
|
270 | (see |hgcommand-events|). Additionally, the HGCommand plugin provides | |
315 |
several option for naming the |
|
271 | several option for naming the HG result buffers (see |hgcommand-naming|) and | |
316 |
supported a customized status line (see | |
|
272 | supported a customized status line (see |hgcommand-statusline| and | |
317 |
| |
|
273 | |hgcommand-buffer-management|). | |
318 |
|
274 | |||
319 |
5.1 |
|
275 | 5.1 HGCommand configuration variables *hgcommand-options* | |
320 |
|
276 | |||
321 | Several variables affect the plugin's behavior. These variables are checked |
|
277 | Several variables affect the plugin's behavior. These variables are checked | |
322 | at time of execution, and may be defined at the window, buffer, or global |
|
278 | at time of execution, and may be defined at the window, buffer, or global | |
@@ -325,181 +281,181 b' level and are checked in that order of p' | |||||
325 |
|
281 | |||
326 | The following variables are available: |
|
282 | The following variables are available: | |
327 |
|
283 | |||
328 |
| |
|
284 | |HGCommandAnnotateParent| | |
329 |
| |
|
285 | |HGCommandCommitOnWrite| | |
330 |
| |
|
286 | |HGCommandHGExec| | |
331 |
| |
|
287 | |HGCommandDeleteOnHide| | |
332 |
| |
|
288 | |HGCommandDiffOpt| | |
333 |
| |
|
289 | |HGCommandDiffSplit| | |
334 |
| |
|
290 | |HGCommandEdit| | |
335 |
| |
|
291 | |HGCommandEnableBufferSetup| | |
336 |
| |
|
292 | |HGCommandInteractive| | |
337 |
| |
|
293 | |HGCommandNameMarker| | |
338 |
| |
|
294 | |HGCommandNameResultBuffers| | |
339 |
| |
|
295 | |HGCommandSplit| | |
340 |
|
296 | |||
341 |
|
|
297 | HGCommandAnnotateParent *HGCommandAnnotateParent* | |
342 |
|
298 | |||
343 | This variable, if set to a non-zero value, causes the zero-argument form of |
|
299 | This variable, if set to a non-zero value, causes the zero-argument form of | |
344 |
|
|
300 | HGAnnotate when invoked on a HGAnnotate buffer to go to the version previous | |
345 | to that displayed on the current line. If not set, it defaults to 0. |
|
301 | to that displayed on the current line. If not set, it defaults to 0. | |
346 |
|
302 | |||
347 |
|
|
303 | HGCommandCommitOnWrite *HGCommandCommitOnWrite* | |
348 |
|
304 | |||
349 |
This variable, if set to a non-zero value, causes the pending |
|
305 | This variable, if set to a non-zero value, causes the pending hg commit | |
350 | to take place immediately as soon as the log message buffer is written. |
|
306 | to take place immediately as soon as the log message buffer is written. | |
351 |
If set to zero, only the |
|
307 | If set to zero, only the HGCommit mapping will cause the pending commit to | |
352 | occur. If not set, it defaults to 1. |
|
308 | occur. If not set, it defaults to 1. | |
353 |
|
309 | |||
354 |
|
|
310 | HGCommandHGExec *HGCommandHGExec* | |
355 |
|
311 | |||
356 |
This variable controls the executable used for all |
|
312 | This variable controls the executable used for all HG commands If not set, | |
357 |
it defaults to " |
|
313 | it defaults to "hg". | |
358 |
|
314 | |||
359 |
|
|
315 | HGCommandDeleteOnHide *HGCommandDeleteOnHide* | |
360 |
|
316 | |||
361 |
This variable, if set to a non-zero value, causes the temporary |
|
317 | This variable, if set to a non-zero value, causes the temporary HG result | |
362 | buffers to automatically delete themselves when hidden. |
|
318 | buffers to automatically delete themselves when hidden. | |
363 |
|
319 | |||
364 |
|
|
320 | HGCommandDiffOpt *HGCommandDiffOpt* | |
365 |
|
321 | |||
366 | This variable, if set, determines the options passed to the diff command of |
|
322 | This variable, if set, determines the options passed to the diff command of | |
367 |
|
|
323 | HG. If not set, it defaults to 'wbBc'. | |
368 |
|
324 | |||
369 |
|
|
325 | HGCommandDiffSplit *HGCommandDiffSplit* | |
370 |
|
326 | |||
371 |
This variable overrides the | |
|
327 | This variable overrides the |HGCommandSplit| variable, but only for buffers | |
372 |
created with |: |
|
328 | created with |:HGVimDiff|. | |
373 |
|
329 | |||
374 |
|
|
330 | HGCommandEdit *HGCommandEdit* | |
375 |
|
331 | |||
376 | This variable controls whether the original buffer is replaced ('edit') or |
|
332 | This variable controls whether the original buffer is replaced ('edit') or | |
377 | split ('split'). If not set, it defaults to 'edit'. |
|
333 | split ('split'). If not set, it defaults to 'edit'. | |
378 |
|
334 | |||
379 |
|
|
335 | HGCommandEnableBufferSetup *HGCommandEnableBufferSetup* | |
380 |
|
336 | |||
381 |
This variable, if set to a non-zero value, activates |
|
337 | This variable, if set to a non-zero value, activates HG buffer management | |
382 |
mode see (| |
|
338 | mode see (|hgcommand-buffer-management|). This mode means that two buffer | |
383 |
variables, ' |
|
339 | variables, 'HGRevision' and 'HGBranch', are set if the file is | |
384 |
|
|
340 | HG-controlled. This is useful for displaying version information in the | |
385 | status bar. |
|
341 | status bar. | |
386 |
|
342 | |||
387 |
|
|
343 | HGCommandInteractive *HGCommandInteractive* | |
388 |
|
344 | |||
389 | This variable, if set to a non-zero value, causes appropriate commands (for |
|
345 | This variable, if set to a non-zero value, causes appropriate commands (for | |
390 |
the moment, only |: |
|
346 | the moment, only |:HGReview|) to query the user for a revision to use instead | |
391 | of the current revision if none is specified. |
|
347 | of the current revision if none is specified. | |
392 |
|
348 | |||
393 |
|
|
349 | HGCommandNameMarker *HGCommandNameMarker* | |
394 |
|
350 | |||
395 | This variable, if set, configures the special attention-getting characters |
|
351 | This variable, if set, configures the special attention-getting characters | |
396 |
that appear on either side of the |
|
352 | that appear on either side of the hg buffer type in the buffer name. This | |
397 |
has no effect unless | |
|
353 | has no effect unless |HGCommandNameResultBuffers| is set to a true value. If | |
398 | not set, it defaults to '_'. |
|
354 | not set, it defaults to '_'. | |
399 |
|
355 | |||
400 |
|
|
356 | HGCommandNameResultBuffers *HGCommandNameResultBuffers* | |
401 |
|
357 | |||
402 |
This variable, if set to a true value, causes the |
|
358 | This variable, if set to a true value, causes the hg result buffers to be | |
403 |
named in the old way ('<source file name> _< |
|
359 | named in the old way ('<source file name> _<hg command>_'). If not set | |
404 | or set to a false value, the result buffer is nameless. |
|
360 | or set to a false value, the result buffer is nameless. | |
405 |
|
361 | |||
406 |
|
|
362 | HGCommandSplit *HGCommandSplit* | |
407 |
|
363 | |||
408 | This variable controls the orientation of the various window splits that |
|
364 | This variable controls the orientation of the various window splits that | |
409 |
may occur (such as with |
|
365 | may occur (such as with HGVimDiff, when using a HG command on a HG | |
410 |
command buffer, or when the | |
|
366 | command buffer, or when the |HGCommandEdit| variable is set to 'split'. | |
411 | If set to 'horizontal', the resulting windows will be on stacked on top of |
|
367 | If set to 'horizontal', the resulting windows will be on stacked on top of | |
412 | one another. If set to 'vertical', the resulting windows will be |
|
368 | one another. If set to 'vertical', the resulting windows will be | |
413 | side-by-side. If not set, it defaults to 'horizontal' for all but |
|
369 | side-by-side. If not set, it defaults to 'horizontal' for all but | |
414 |
|
|
370 | HGVimDiff windows. | |
415 |
|
371 | |||
416 |
5.2 |
|
372 | 5.2 HGCommand events *hgcommand-events* | |
417 |
|
373 | |||
418 |
For additional customization, |
|
374 | For additional customization, HGCommand can trigger user-defined events. | |
419 | Event handlers are provided by defining User event autocommands (see |
|
375 | Event handlers are provided by defining User event autocommands (see | |
420 |
|autocommand|, |User|) in the |
|
376 | |autocommand|, |User|) in the HGCommand group with patterns matching the | |
421 | event name. |
|
377 | event name. | |
422 |
|
378 | |||
423 | For instance, the following could be added to the vimrc to provide a 'q' |
|
379 | For instance, the following could be added to the vimrc to provide a 'q' | |
424 |
mapping to quit a |
|
380 | mapping to quit a HGCommand scratch buffer: | |
425 |
|
381 | |||
426 |
augroup |
|
382 | augroup HGCommand | |
427 |
au |
|
383 | au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q: bwipeout<cr> | |
428 | augroup END |
|
384 | augroup END | |
429 |
|
385 | |||
430 | The following hooks are available: |
|
386 | The following hooks are available: | |
431 |
|
387 | |||
432 |
|
|
388 | HGBufferCreated This event is fired just after a hg command | |
433 | result buffer is created and filled with the |
|
389 | result buffer is created and filled with the | |
434 |
result of a |
|
390 | result of a hg command. It is executed within | |
435 |
the context of the |
|
391 | the context of the HG command buffer. The | |
436 |
|
|
392 | HGCommand buffer variables may be useful for | |
437 | handlers of this event (please see |
|
393 | handlers of this event (please see | |
438 |
| |
|
394 | |hgcommand-buffer-variables|). | |
439 |
|
395 | |||
440 |
|
|
396 | HGBufferSetup This event is fired just after HG buffer setup | |
441 | occurs, if enabled. |
|
397 | occurs, if enabled. | |
442 |
|
398 | |||
443 |
|
|
399 | HGPluginInit This event is fired when the HGCommand plugin | |
444 | first loads. |
|
400 | first loads. | |
445 |
|
401 | |||
446 |
|
|
402 | HGPluginFinish This event is fired just after the HGCommand | |
447 | plugin loads. |
|
403 | plugin loads. | |
448 |
|
404 | |||
449 |
|
|
405 | HGVimDiffFinish This event is fired just after the HGVimDiff | |
450 | command executes to allow customization of, |
|
406 | command executes to allow customization of, | |
451 | for instance, window placement and focus. |
|
407 | for instance, window placement and focus. | |
452 |
|
408 | |||
453 |
5.3 |
|
409 | 5.3 HGCommand buffer naming *hgcommand-naming* | |
454 |
|
410 | |||
455 |
By default, the buffers containing the result of |
|
411 | By default, the buffers containing the result of HG commands are nameless | |
456 | scratch buffers. It is intended that buffer variables of those buffers be |
|
412 | scratch buffers. It is intended that buffer variables of those buffers be | |
457 | used to customize the statusline option so that the user may fully control the |
|
413 | used to customize the statusline option so that the user may fully control the | |
458 | display of result buffers. |
|
414 | display of result buffers. | |
459 |
|
415 | |||
460 | If the old-style naming is desired, please enable the |
|
416 | If the old-style naming is desired, please enable the | |
461 |
| |
|
417 | |HGCommandNameResultBuffers| variable. Then, each result buffer will receive | |
462 |
a unique name that includes the source file name, the |
|
418 | a unique name that includes the source file name, the HG command, and any | |
463 | extra data (such as revision numbers) that were part of the command. |
|
419 | extra data (such as revision numbers) that were part of the command. | |
464 |
|
420 | |||
465 |
5.4 |
|
421 | 5.4 HGCommand status line support *hgcommand-statusline* | |
466 |
|
422 | |||
467 | It is intended that the user will customize the |'statusline'| option to |
|
423 | It is intended that the user will customize the |'statusline'| option to | |
468 |
include |
|
424 | include HG result buffer attributes. A sample function that may be used in | |
469 |
the |'statusline'| option is provided by the plugin, |
|
425 | the |'statusline'| option is provided by the plugin, HGGetStatusLine(). In | |
470 | order to use that function in the status line, do something like the |
|
426 | order to use that function in the status line, do something like the | |
471 | following: |
|
427 | following: | |
472 |
|
428 | |||
473 |
set statusline=%<%f\ %{ |
|
429 | set statusline=%<%f\ %{HGGetStatusLine()}\ %h%m%r%=%l,%c%V\ %P | |
474 |
|
430 | |||
475 |
of which %{ |
|
431 | of which %{HGGetStatusLine()} is the relevant portion. | |
476 |
|
432 | |||
477 |
The sample |
|
433 | The sample HGGetStatusLine() function handles both HG result buffers and | |
478 |
|
|
434 | HG-managed files if HGCommand buffer management is enabled (please see | |
479 |
| |
|
435 | |hgcommand-buffer-management|). | |
480 |
|
436 | |||
481 |
5.5 |
|
437 | 5.5 HGCommand buffer management *hgcommand-buffer-management* | |
482 |
|
438 | |||
483 |
The |
|
439 | The HGCommand plugin can operate in buffer management mode, which means that | |
484 |
it attempts to set two buffer variables (' |
|
440 | it attempts to set two buffer variables ('HGRevision' and 'HGBranch') upon | |
485 |
entry into a buffer. This is rather slow because it means that ' |
|
441 | entry into a buffer. This is rather slow because it means that 'hg status' | |
486 | will be invoked at each entry into a buffer (during the |BufEnter| |
|
442 | will be invoked at each entry into a buffer (during the |BufEnter| | |
487 | autocommand). |
|
443 | autocommand). | |
488 |
|
444 | |||
489 | This mode is disabled by default. In order to enable it, set the |
|
445 | This mode is disabled by default. In order to enable it, set the | |
490 |
| |
|
446 | |HGCommandEnableBufferSetup| variable to a true (non-zero) value. Enabling | |
491 | this mode simply provides the buffer variables mentioned above. The user must |
|
447 | this mode simply provides the buffer variables mentioned above. The user must | |
492 | explicitly include those in the |'statusline'| option if they are to appear in |
|
448 | explicitly include those in the |'statusline'| option if they are to appear in | |
493 |
the status line (but see | |
|
449 | the status line (but see |hgcommand-statusline| for a simple way to do that). | |
494 |
|
450 | |||
495 | ============================================================================== |
|
451 | ============================================================================== | |
496 |
|
452 | |||
497 |
6. SSH "integration" * |
|
453 | 6. SSH "integration" *hgcommand-ssh* | |
498 |
|
454 | |||
499 | The following instructions are intended for use in integrating the |
|
455 | The following instructions are intended for use in integrating the | |
500 |
|
|
456 | hgcommand.vim plugin with an SSH-based HG environment. | |
501 |
|
457 | |||
502 |
Familiarity with SSH and |
|
458 | Familiarity with SSH and HG are assumed. | |
503 |
|
459 | |||
504 | These instructions assume that the intent is to have a message box pop up in |
|
460 | These instructions assume that the intent is to have a message box pop up in | |
505 | order to allow the user to enter a passphrase. If, instead, the user is |
|
461 | order to allow the user to enter a passphrase. If, instead, the user is | |
@@ -507,18 +463,18 b' comfortable using certificate-based auth' | |||||
507 | 6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then |
|
463 | 6.1.1 and 6.1.2 (and optionally 6.1.4) need to be followed; ssh should then | |
508 | work transparently. |
|
464 | work transparently. | |
509 |
|
465 | |||
510 |
6.1 Environment settings * |
|
466 | 6.1 Environment settings *hgcommand-ssh-env* | |
511 |
|
467 | |||
512 |
6.1.1 |
|
468 | 6.1.1 HGROOT should be set to something like: | |
513 |
|
469 | |||
514 | :ext:user@host:/path_to_repository |
|
470 | :ext:user@host:/path_to_repository | |
515 |
|
471 | |||
516 |
6.1.2 |
|
472 | 6.1.2 HG_RSH should be set to: | |
517 |
|
473 | |||
518 | ssh |
|
474 | ssh | |
519 |
|
475 | |||
520 |
Together, those settings tell |
|
476 | Together, those settings tell HG to use ssh as the transport when | |
521 |
performing |
|
477 | performing HG calls. | |
522 |
|
478 | |||
523 | 6.1.3 SSH_ASKPASS should be set to the password-dialog program. In my case, |
|
479 | 6.1.3 SSH_ASKPASS should be set to the password-dialog program. In my case, | |
524 | running gnome, it's set to: |
|
480 | running gnome, it's set to: | |
@@ -527,14 +483,14 b' 6.1.3 SSH_ASKPASS should be set to the p' | |||||
527 |
|
483 | |||
528 | This tells SSH how to get passwords if no input is available. |
|
484 | This tells SSH how to get passwords if no input is available. | |
529 |
|
485 | |||
530 |
6.1.4 OPTIONAL. You may need to set SSH_SERVER to the location of the |
|
486 | 6.1.4 OPTIONAL. You may need to set SSH_SERVER to the location of the hg | |
531 | executable on the remote (server) machine. |
|
487 | executable on the remote (server) machine. | |
532 |
|
488 | |||
533 |
6.2 |
|
489 | 6.2 HG wrapper program *hgcommand-ssh-wrapper* | |
534 |
|
490 | |||
535 | Now you need to convince SSH to use the password-dialog program. This means |
|
491 | Now you need to convince SSH to use the password-dialog program. This means | |
536 |
you need to execute SSH (and therefore |
|
492 | you need to execute SSH (and therefore HG) without standard input. The | |
537 |
following script is a simple perl wrapper that dissasociates the |
|
493 | following script is a simple perl wrapper that dissasociates the HG command | |
538 | from the current terminal. Specific steps to do this may vary from system to |
|
494 | from the current terminal. Specific steps to do this may vary from system to | |
539 | system; the following example works for me on linux. |
|
495 | system; the following example works for me on linux. | |
540 |
|
496 | |||
@@ -544,34 +500,34 b' use POSIX qw(setsid);' | |||||
544 | open STDIN, '/dev/null'; |
|
500 | open STDIN, '/dev/null'; | |
545 | fork and do {wait; exit;}; |
|
501 | fork and do {wait; exit;}; | |
546 | setsid; |
|
502 | setsid; | |
547 |
exec(' |
|
503 | exec('hg', @ARGV); | |
548 |
|
504 | |||
549 |
6.3 Configuring |
|
505 | 6.3 Configuring hgcommand.vim *hgcommand-ssh-config* | |
550 |
|
506 | |||
551 |
At this point, you should be able to use your wrapper script to invoke |
|
507 | At this point, you should be able to use your wrapper script to invoke HG with | |
552 |
various commands, and get the password dialog. All that's left is to make |
|
508 | various commands, and get the password dialog. All that's left is to make HG | |
553 | use your newly-created wrapper script. |
|
509 | use your newly-created wrapper script. | |
554 |
|
510 | |||
555 |
6.3.1 Tell |
|
511 | 6.3.1 Tell hgcommand.vim what HG executable to use. The easiest way to do this | |
556 | is globally, by putting the following in your .vimrc: |
|
512 | is globally, by putting the following in your .vimrc: | |
557 |
|
513 | |||
558 |
let |
|
514 | let HGCommandHGExec=/path/to/hg/wrapper/script | |
559 |
|
515 | |||
560 |
6.4 Where to go from here * |
|
516 | 6.4 Where to go from here *hgcommand-ssh-other* | |
561 |
|
517 | |||
562 |
The script given above works even when non-SSH |
|
518 | The script given above works even when non-SSH HG connections are used, | |
563 |
except possibly when interactively entering the message for |
|
519 | except possibly when interactively entering the message for HG commit log | |
564 |
(depending on the editor you use... VIM works fine). Since the |
|
520 | (depending on the editor you use... VIM works fine). Since the hgcommand.vim | |
565 | plugin handles that message without a terminal, the wrapper script can be used |
|
521 | plugin handles that message without a terminal, the wrapper script can be used | |
566 | all the time. |
|
522 | all the time. | |
567 |
|
523 | |||
568 |
This allows mixed-mode operation, where some work is done with SSH-based |
|
524 | This allows mixed-mode operation, where some work is done with SSH-based HG | |
569 | repositories, and others with pserver or local access. |
|
525 | repositories, and others with pserver or local access. | |
570 |
|
526 | |||
571 | It is possible, though beyond the scope of the plugin, to dynamically set the |
|
527 | It is possible, though beyond the scope of the plugin, to dynamically set the | |
572 |
|
|
528 | HG executable based on the HGROOT for the file being edited. The user | |
573 |
events provided (such as |
|
529 | events provided (such as HGBufferCreated and HGBufferSetup) can be used to | |
574 |
set a buffer-local value (b: |
|
530 | set a buffer-local value (b:HGCommandHGExec) to override the HG executable | |
575 | on a file-by-file basis. Alternatively, much the same can be done (less |
|
531 | on a file-by-file basis. Alternatively, much the same can be done (less | |
576 | automatically) by the various project-oriented plugins out there. |
|
532 | automatically) by the various project-oriented plugins out there. | |
577 |
|
533 | |||
@@ -580,11 +536,11 b' or ssh-agent are employed so that the us' | |||||
580 | too often. |
|
536 | too often. | |
581 |
|
537 | |||
582 | ============================================================================== |
|
538 | ============================================================================== | |
583 |
9. Tips * |
|
539 | 9. Tips *hgcommand-tips* | |
584 |
|
540 | |||
585 | 9.1 Split window annotation, by Michael Anderson |
|
541 | 9.1 Split window annotation, by Michael Anderson | |
586 |
|
542 | |||
587 |
:nmap <Leader> |
|
543 | :nmap <Leader>hgN :vs<CR><C-w>h<Leader>hgn:vertical res 40<CR> | |
588 | \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR> |
|
544 | \ggdddd:set scb<CR>:set nowrap<CR><C-w>lgg:set scb<CR> | |
589 | \:set nowrap<CR> |
|
545 | \:set nowrap<CR> | |
590 |
|
546 | |||
@@ -599,17 +555,11 b' 3) Your own code still has syntax highli' | |||||
599 |
|
555 | |||
600 | ============================================================================== |
|
556 | ============================================================================== | |
601 |
|
557 | |||
602 |
8. Known bugs * |
|
558 | 8. Known bugs *hgcommand-bugs* | |
603 |
|
559 | |||
604 | Please let me know if you run across any. |
|
560 | Please let me know if you run across any. | |
605 |
|
561 | |||
606 | CVSUnedit may, if a file is changed from the repository, provide prompt text |
|
562 | HGVimDiff, when using the original (real) source buffer as one of the diff | |
607 | to determine whether the changes should be thrown away. Currently, that text |
|
|||
608 | shows up in the CVS result buffer as information; there is no way for the user |
|
|||
609 | to actually respond to the prompt and the CVS unedit command does nothing. If |
|
|||
610 | this really bothers anyone, please let me know. |
|
|||
611 |
|
||||
612 | CVSVimDiff, when using the original (real) source buffer as one of the diff |
|
|||
613 | buffers, uses some hacks to try to restore the state of the original buffer |
|
563 | buffers, uses some hacks to try to restore the state of the original buffer | |
614 | when the scratch buffer containing the other version is destroyed. There may |
|
564 | when the scratch buffer containing the other version is destroyed. There may | |
615 | still be bugs in here, depending on many configuration details. |
|
565 | still be bugs in here, depending on many configuration details. |
This diff has been collapsed as it changes many lines, (1016 lines changed) Show them Hide them | |||||
@@ -1,77 +1,44 b'' | |||||
1 | " vim600: set foldmethod=marker: |
|
1 | " vim600: set foldmethod=marker: | |
2 | " |
|
2 | " | |
3 |
" Vim plugin to assist in working with |
|
3 | " Vim plugin to assist in working with HG-controlled files. | |
4 | " |
|
4 | " | |
5 | " Last Change: 2006/02/22 |
|
5 | " Last Change: 2006/02/22 | |
6 | " Version: 1.76 |
|
6 | " Version: 1.76 | |
7 | " Maintainer: Bob Hiestand <bob.hiestand@gmail.com> |
|
7 | " Maintainer: Mathieu Clabaut <mathieu.clabaut@gmail.com> | |
8 | " License: This file is placed in the public domain. |
|
8 | " License: This file is placed in the public domain. | |
9 | " Credits: {{{1 |
|
9 | " Credits: {{{1 | |
10 | " Mathieu Clabaut for many suggestions and improvements. |
|
10 | " Bob Hiestand <bob.hiestand@gmail.com> for the fabulous | |
11 | " |
|
11 | " cvscommand.vim from which this script was directly created by | |
12 | " Suresh Govindachar and Jeeva Chelladhurai for finding waaaay |
|
12 | " means of sed commands and minor tweaks. | |
13 | " too many bugs. |
|
|||
14 | " |
|
|||
15 | " Suresh Govindachar (again!) for finding the |
|
|||
16 | " fully-folded-last-line-delete bug. |
|
|||
17 | " |
|
|||
18 | " Albrecht Gass for the Delete-on-Hide behavior suggestion. |
|
|||
19 | " |
|
|||
20 | " Joe MacDonald for finding the CVS log message header bug and |
|
|||
21 | " pointing out that buffer refreshes are needed after CVS |
|
|||
22 | " \%(un\)\?edit. |
|
|||
23 | " |
|
|||
24 | " Srinath Avadhanula for the suggestion and original patch for |
|
|||
25 | " the CVSCommitOnWrite option and mapping hot key. |
|
|||
26 | " |
|
|||
27 | " John Sivak for helping to debug Windows issues and suggesting |
|
|||
28 | " the CVSEditors and CVSWatchers commands. |
|
|||
29 | " |
|
|||
30 | " Igor Levko for the patch to recognize numerical sticky tags. |
|
|||
31 | " |
|
|||
32 | " Domink Strasser for the patch to correct the status line for |
|
|||
33 | " CVSAdd'd files. |
|
|||
34 | " |
|
|||
35 | " Weerapong Sirikanya for finding a bug with CVSCommit and |
|
|||
36 | " autochdir. |
|
|||
37 | " |
|
|||
38 | " David Gotz for finding a bug with CVSVimDiff buffer splitting |
|
|||
39 | " and original buffer restoration. |
|
|||
40 | " |
|
|||
41 | " CJ van den Berg for the patch to not change working directory |
|
|||
42 | " when editing a non-CVS file. |
|
|||
43 | " |
|
|||
44 | " Luca Gerli for noticing bad behavior for keywords in files |
|
|||
45 | " after commit if split windows are used. |
|
|||
46 |
|
13 | |||
47 | " Section: Documentation {{{1 |
|
14 | " Section: Documentation {{{1 | |
48 | " |
|
15 | " | |
49 |
" Provides functions to invoke various |
|
16 | " Provides functions to invoke various HG commands on the current file | |
50 | " (either the current buffer, or, in the case of an directory buffer, the file |
|
17 | " (either the current buffer, or, in the case of an directory buffer, the file | |
51 | " on the current line). The output of the commands is captured in a new |
|
18 | " on the current line). The output of the commands is captured in a new | |
52 |
" scratch window. For convenience, if the functions are invoked on a |
|
19 | " scratch window. For convenience, if the functions are invoked on a HG | |
53 |
" output window, the original file is used for the |
|
20 | " output window, the original file is used for the hg operation instead after | |
54 |
" the window is split. This is primarily useful when running |
|
21 | " the window is split. This is primarily useful when running HGCommit and | |
55 |
" you need to see the changes made, so that |
|
22 | " you need to see the changes made, so that HGDiff is usable and shows up in | |
56 | " another window. |
|
23 | " another window. | |
57 | " |
|
24 | " | |
58 | " Command documentation {{{2 |
|
25 | " Command documentation {{{2 | |
59 | " |
|
26 | " | |
60 |
" |
|
27 | " HGAdd Performs "hg add" on the current file. | |
61 | " |
|
28 | " | |
62 |
" |
|
29 | " HGAnnotate Performs "hg annotate" on the current file. If an | |
63 | " argument is given, the argument is used as a revision |
|
30 | " argument is given, the argument is used as a revision | |
64 | " number to display. If not given an argument, it uses the |
|
31 | " number to display. If not given an argument, it uses the | |
65 | " most recent version of the file on the current branch. |
|
32 | " most recent version of the file on the current branch. | |
66 |
" Additionally, if the current buffer is a |
|
33 | " Additionally, if the current buffer is a HGAnnotate buffer | |
67 | " already, the version number on the current line is used. |
|
34 | " already, the version number on the current line is used. | |
68 | " |
|
35 | " | |
69 |
" If the ' |
|
36 | " If the 'HGCommandAnnotateParent' variable is set to a | |
70 | " non-zero value, the version previous to the one on the |
|
37 | " non-zero value, the version previous to the one on the | |
71 | " current line is used instead. This allows one to navigate |
|
38 | " current line is used instead. This allows one to navigate | |
72 | " back to examine the previous version of a line. |
|
39 | " back to examine the previous version of a line. | |
73 | " |
|
40 | " | |
74 |
" |
|
41 | " HGCommit[!] If called with arguments, this performs "hg commit" using | |
75 | " the arguments as the log message. |
|
42 | " the arguments as the log message. | |
76 | " |
|
43 | " | |
77 | " If '!' is used, an empty log message is committed. |
|
44 | " If '!' is used, an empty log message is committed. | |
@@ -83,40 +50,34 b'' | |||||
83 | " message. The commit can be abandoned if the log message |
|
50 | " message. The commit can be abandoned if the log message | |
84 | " buffer is deleted or wiped before being written. |
|
51 | " buffer is deleted or wiped before being written. | |
85 | " |
|
52 | " | |
86 |
" |
|
53 | " HGDiff With no arguments, this performs "hg diff" on the current | |
87 |
" file. With one argument, " |
|
54 | " file. With one argument, "hg diff" is performed on the | |
88 | " current file against the specified revision. With two |
|
55 | " current file against the specified revision. With two | |
89 |
" arguments, |
|
56 | " arguments, hg diff is performed between the specified | |
90 | " revisions of the current file. This command uses the |
|
57 | " revisions of the current file. This command uses the | |
91 |
" ' |
|
58 | " 'HGCommandDiffOpt' variable to specify diff options. If | |
92 | " that variable does not exist, then 'wbBc' is assumed. If |
|
59 | " that variable does not exist, then 'wbBc' is assumed. If | |
93 | " you wish to have no options, then set it to the empty |
|
60 | " you wish to have no options, then set it to the empty | |
94 | " string. |
|
61 | " string. | |
95 | " |
|
62 | " | |
96 | " CVSEdit Performs "cvs edit" on the current file. |
|
63 | " HGGotoOriginal Returns the current window to the source buffer if the | |
97 | " |
|
64 | " current buffer is a HG output buffer. | |
98 | " CVSEditors Performs "cvs editors" on the current file. |
|
|||
99 | " |
|
65 | " | |
100 | " CVSGotoOriginal Returns the current window to the source buffer if the |
|
66 | " HGLog Performs "hg log" on the current file. | |
101 | " current buffer is a CVS output buffer. |
|
|||
102 | " |
|
67 | " | |
103 | " CVSLog Performs "cvs log" on the current file. |
|
68 | " HGRevert Replaces the modified version of the current file with the | |
104 | " |
|
|||
105 | " CVSRevert Replaces the modified version of the current file with the |
|
|||
106 | " most recent version from the repository. |
|
69 | " most recent version from the repository. | |
107 | " |
|
70 | " | |
108 |
" |
|
71 | " HGReview Retrieves a particular version of the current file. If no | |
109 | " argument is given, the most recent version of the file on |
|
72 | " argument is given, the most recent version of the file on | |
110 | " the current branch is retrieved. The specified revision is |
|
73 | " the current branch is retrieved. The specified revision is | |
111 | " retrieved into a new buffer. |
|
74 | " retrieved into a new buffer. | |
112 | " |
|
75 | " | |
113 |
" |
|
76 | " HGStatus Performs "hg status" on the current file. | |
114 | " |
|
|||
115 | " CVSUnedit Performs "cvs unedit" on the current file. |
|
|||
116 | " |
|
77 | " | |
117 |
" |
|
78 | " HGUpdate Performs "hg update" on the current file. | |
118 | " |
|
79 | " | |
119 |
" |
|
80 | " HGVimDiff With no arguments, this prompts the user for a revision and | |
120 | " then uses vimdiff to display the differences between the |
|
81 | " then uses vimdiff to display the differences between the | |
121 | " current file and the specified revision. If no revision is |
|
82 | " current file and the specified revision. If no revision is | |
122 | " specified, the most recent version of the file on the |
|
83 | " specified, the most recent version of the file on the | |
@@ -139,171 +100,150 b'' | |||||
139 | " command on a different file will close the previous vimdiff |
|
100 | " command on a different file will close the previous vimdiff | |
140 | " buffers. |
|
101 | " buffers. | |
141 | " |
|
102 | " | |
142 | " CVSWatch Takes an argument which must be one of [on|off|add|remove]. |
|
|||
143 | " Performs "cvs watch" with the given argument on the current |
|
|||
144 | " file. |
|
|||
145 | " |
|
|||
146 | " CVSWatchers Performs "cvs watchers" on the current file. |
|
|||
147 | " |
|
|||
148 | " CVSWatchAdd Alias for "CVSWatch add" |
|
|||
149 | " |
|
|||
150 | " CVSWatchOn Alias for "CVSWatch on" |
|
|||
151 | " |
|
|||
152 | " CVSWatchOff Alias for "CVSWatch off" |
|
|||
153 | " |
|
|||
154 | " CVSWatchRemove Alias for "CVSWatch remove" |
|
|||
155 | " |
|
103 | " | |
156 | " Mapping documentation: {{{2 |
|
104 | " Mapping documentation: {{{2 | |
157 | " |
|
105 | " | |
158 | " By default, a mapping is defined for each command. User-provided mappings |
|
106 | " By default, a mapping is defined for each command. User-provided mappings | |
159 | " can be used instead by mapping to <Plug>CommandName, for instance: |
|
107 | " can be used instead by mapping to <Plug>CommandName, for instance: | |
160 | " |
|
108 | " | |
161 |
" nnoremap ,ca <Plug> |
|
109 | " nnoremap ,ca <Plug>HGAdd | |
162 | " |
|
110 | " | |
163 | " The default mappings are as follow: |
|
111 | " The default mappings are as follow: | |
164 | " |
|
112 | " | |
165 |
" <Leader> |
|
113 | " <Leader>hga HGAdd | |
166 |
" <Leader> |
|
114 | " <Leader>hgn HGAnnotate | |
167 |
" <Leader> |
|
115 | " <Leader>hgc HGCommit | |
168 |
" <Leader> |
|
116 | " <Leader>hgd HGDiff | |
169 | " <Leader>ce CVSEdit |
|
117 | " <Leader>hgg HGGotoOriginal | |
170 | " <Leader>ci CVSEditors |
|
118 | " <Leader>hgG HGGotoOriginal! | |
171 |
" <Leader> |
|
119 | " <Leader>hgl HGLog | |
172 | " <Leader>cG CVSGotoOriginal! |
|
120 | " <Leader>hgr HGReview | |
173 |
" <Leader> |
|
121 | " <Leader>hgs HGStatus | |
174 | " <Leader>cr CVSReview |
|
122 | " <Leader>hgu HGUpdate | |
175 | " <Leader>cs CVSStatus |
|
123 | " <Leader>hgv HGVimDiff | |
176 | " <Leader>ct CVSUnedit |
|
|||
177 | " <Leader>cu CVSUpdate |
|
|||
178 | " <Leader>cv CVSVimDiff |
|
|||
179 | " <Leader>cwv CVSWatchers |
|
|||
180 | " <Leader>cwa CVSWatchAdd |
|
|||
181 | " <Leader>cwn CVSWatchOn |
|
|||
182 | " <Leader>cwa CVSWatchOff |
|
|||
183 | " <Leader>cwr CVSWatchRemove |
|
|||
184 | " |
|
124 | " | |
185 | " Options documentation: {{{2 |
|
125 | " Options documentation: {{{2 | |
186 | " |
|
126 | " | |
187 | " Several variables are checked by the script to determine behavior as follow: |
|
127 | " Several variables are checked by the script to determine behavior as follow: | |
188 | " |
|
128 | " | |
189 |
" |
|
129 | " HGCommandAnnotateParent | |
190 | " This variable, if set to a non-zero value, causes the zero-argument form |
|
130 | " This variable, if set to a non-zero value, causes the zero-argument form | |
191 |
" of |
|
131 | " of HGAnnotate when invoked on a HGAnnotate buffer to go to the version | |
192 | " previous to that displayed on the current line. If not set, it defaults |
|
132 | " previous to that displayed on the current line. If not set, it defaults | |
193 | " to 0. |
|
133 | " to 0. | |
194 | " |
|
134 | " | |
195 |
" |
|
135 | " HGCommandCommitOnWrite | |
196 |
" This variable, if set to a non-zero value, causes the pending |
|
136 | " This variable, if set to a non-zero value, causes the pending hg commit | |
197 | " to take place immediately as soon as the log message buffer is written. |
|
137 | " to take place immediately as soon as the log message buffer is written. | |
198 |
" If set to zero, only the |
|
138 | " If set to zero, only the HGCommit mapping will cause the pending commit | |
199 | " to occur. If not set, it defaults to 1. |
|
139 | " to occur. If not set, it defaults to 1. | |
200 | " |
|
140 | " | |
201 |
" |
|
141 | " HGCommandDeleteOnHide | |
202 |
" This variable, if set to a non-zero value, causes the temporary |
|
142 | " This variable, if set to a non-zero value, causes the temporary HG result | |
203 | " buffers to automatically delete themselves when hidden. |
|
143 | " buffers to automatically delete themselves when hidden. | |
204 | " |
|
144 | " | |
205 |
" |
|
145 | " HGCommandDiffOpt | |
206 | " This variable, if set, determines the options passed to the diff command |
|
146 | " This variable, if set, determines the options passed to the diff command | |
207 |
" of |
|
147 | " of HG. If not set, it defaults to 'wbBc'. | |
208 | " |
|
148 | " | |
209 |
" |
|
149 | " HGCommandDiffSplit | |
210 |
" This variable overrides the |
|
150 | " This variable overrides the HGCommandSplit variable, but only for buffers | |
211 |
" created with |
|
151 | " created with HGVimDiff. | |
212 | " |
|
152 | " | |
213 |
" |
|
153 | " HGCommandEdit | |
214 | " This variable controls whether the original buffer is replaced ('edit') or |
|
154 | " This variable controls whether the original buffer is replaced ('edit') or | |
215 | " split ('split'). If not set, it defaults to 'edit'. |
|
155 | " split ('split'). If not set, it defaults to 'edit'. | |
216 | " |
|
156 | " | |
217 |
" |
|
157 | " HGCommandEnableBufferSetup | |
218 |
" This variable, if set to a non-zero value, activates |
|
158 | " This variable, if set to a non-zero value, activates HG buffer management | |
219 |
" mode. This mode means that two buffer variables, ' |
|
159 | " mode. This mode means that two buffer variables, 'HGRevision' and | |
220 |
" ' |
|
160 | " 'HGBranch', are set if the file is HG-controlled. This is useful for | |
221 | " displaying version information in the status bar. |
|
161 | " displaying version information in the status bar. | |
222 | " |
|
162 | " | |
223 |
" |
|
163 | " HGCommandInteractive | |
224 | " This variable, if set to a non-zero value, causes appropriate functions (for |
|
164 | " This variable, if set to a non-zero value, causes appropriate functions (for | |
225 |
" the moment, only |
|
165 | " the moment, only HGReview) to query the user for a revision to use | |
226 | " instead of the current revision if none is specified. |
|
166 | " instead of the current revision if none is specified. | |
227 | " |
|
167 | " | |
228 |
" |
|
168 | " HGCommandNameMarker | |
229 | " This variable, if set, configures the special attention-getting characters |
|
169 | " This variable, if set, configures the special attention-getting characters | |
230 |
" that appear on either side of the |
|
170 | " that appear on either side of the hg buffer type in the buffer name. | |
231 |
" This has no effect unless ' |
|
171 | " This has no effect unless 'HGCommandNameResultBuffers' is set to a true | |
232 | " value. If not set, it defaults to '_'. |
|
172 | " value. If not set, it defaults to '_'. | |
233 | " |
|
173 | " | |
234 |
" |
|
174 | " HGCommandNameResultBuffers | |
235 |
" This variable, if set to a true value, causes the |
|
175 | " This variable, if set to a true value, causes the hg result buffers to be | |
236 |
" named in the old way ('<source file name> _< |
|
176 | " named in the old way ('<source file name> _<hg command>_'). If not set | |
237 | " or set to a false value, the result buffer is nameless. |
|
177 | " or set to a false value, the result buffer is nameless. | |
238 | " |
|
178 | " | |
239 |
" |
|
179 | " HGCommandSplit | |
240 | " This variable controls the orientation of the various window splits that |
|
180 | " This variable controls the orientation of the various window splits that | |
241 |
" may occur (such as with |
|
181 | " may occur (such as with HGVimDiff, when using a HG command on a HG | |
242 |
" command buffer, or when the ' |
|
182 | " command buffer, or when the 'HGCommandEdit' variable is set to 'split'. | |
243 | " If set to 'horizontal', the resulting windows will be on stacked on top of |
|
183 | " If set to 'horizontal', the resulting windows will be on stacked on top of | |
244 | " one another. If set to 'vertical', the resulting windows will be |
|
184 | " one another. If set to 'vertical', the resulting windows will be | |
245 | " side-by-side. If not set, it defaults to 'horizontal' for all but |
|
185 | " side-by-side. If not set, it defaults to 'horizontal' for all but | |
246 |
" |
|
186 | " HGVimDiff windows. | |
247 | " |
|
187 | " | |
248 | " Event documentation {{{2 |
|
188 | " Event documentation {{{2 | |
249 |
" For additional customization, |
|
189 | " For additional customization, hgcommand.vim uses User event autocommand | |
250 |
" hooks. Each event is in the |
|
190 | " hooks. Each event is in the HGCommand group, and different patterns | |
251 | " match the various hooks. |
|
191 | " match the various hooks. | |
252 | " |
|
192 | " | |
253 | " For instance, the following could be added to the vimrc to provide a 'q' |
|
193 | " For instance, the following could be added to the vimrc to provide a 'q' | |
254 |
" mapping to quit a |
|
194 | " mapping to quit a HG buffer: | |
255 | " |
|
195 | " | |
256 |
" augroup |
|
196 | " augroup HGCommand | |
257 |
" au |
|
197 | " au HGCommand User HGBufferCreated silent! nmap <unique> <buffer> q :bwipeout<cr> | |
258 | " augroup END |
|
198 | " augroup END | |
259 | " |
|
199 | " | |
260 | " The following hooks are available: |
|
200 | " The following hooks are available: | |
261 | " |
|
201 | " | |
262 |
" |
|
202 | " HGBufferCreated This event is fired just after a hg command | |
263 | " result buffer is created and filled with the |
|
203 | " result buffer is created and filled with the | |
264 |
" result of a |
|
204 | " result of a hg command. It is executed within | |
265 | " the context of the new buffer. |
|
205 | " the context of the new buffer. | |
266 | " |
|
206 | " | |
267 |
" |
|
207 | " HGBufferSetup This event is fired just after HG buffer setup | |
268 | " occurs, if enabled. |
|
208 | " occurs, if enabled. | |
269 | " |
|
209 | " | |
270 |
" |
|
210 | " HGPluginInit This event is fired when the HGCommand plugin | |
271 | " first loads. |
|
211 | " first loads. | |
272 | " |
|
212 | " | |
273 |
" |
|
213 | " HGPluginFinish This event is fired just after the HGCommand | |
274 | " plugin loads. |
|
214 | " plugin loads. | |
275 | " |
|
215 | " | |
276 |
" |
|
216 | " HGVimDiffFinish This event is fired just after the HGVimDiff | |
277 | " command executes to allow customization of, |
|
217 | " command executes to allow customization of, | |
278 | " for instance, window placement and focus. |
|
218 | " for instance, window placement and focus. | |
279 | " |
|
219 | " | |
280 | " Section: Plugin header {{{1 |
|
220 | " Section: Plugin header {{{1 | |
281 |
|
221 | |||
282 |
" loaded_ |
|
222 | " loaded_hgcommand is set to 1 when the initialization begins, and 2 when it | |
283 | " completes. This allows various actions to only be taken by functions after |
|
223 | " completes. This allows various actions to only be taken by functions after | |
284 | " system initialization. |
|
224 | " system initialization. | |
285 |
|
225 | |||
286 |
if exists("loaded_ |
|
226 | if exists("loaded_hgcommand") | |
287 | finish |
|
227 | finish | |
288 | endif |
|
228 | endif | |
289 |
let loaded_ |
|
229 | let loaded_hgcommand = 1 | |
290 |
|
230 | |||
291 | if v:version < 602 |
|
231 | if v:version < 602 | |
292 |
echohl WarningMsg|echomsg " |
|
232 | echohl WarningMsg|echomsg "HGCommand 1.69 or later requires VIM 6.2 or later"|echohl None | |
293 | finish |
|
233 | finish | |
294 | endif |
|
234 | endif | |
295 |
|
235 | |||
296 | " Section: Event group setup {{{1 |
|
236 | " Section: Event group setup {{{1 | |
297 |
|
237 | |||
298 |
augroup |
|
238 | augroup HGCommand | |
299 | augroup END |
|
239 | augroup END | |
300 |
|
240 | |||
301 | " Section: Plugin initialization {{{1 |
|
241 | " Section: Plugin initialization {{{1 | |
302 |
silent do |
|
242 | silent do HGCommand User HGPluginInit | |
303 |
|
243 | |||
304 | " Section: Script variable initialization {{{1 |
|
244 | " Section: Script variable initialization {{{1 | |
305 |
|
245 | |||
306 |
let s: |
|
246 | let s:HGCommandEditFileRunning = 0 | |
307 | unlet! s:vimDiffRestoreCmd |
|
247 | unlet! s:vimDiffRestoreCmd | |
308 | unlet! s:vimDiffSourceBuffer |
|
248 | unlet! s:vimDiffSourceBuffer | |
309 | unlet! s:vimDiffBufferCount |
|
249 | unlet! s:vimDiffBufferCount | |
@@ -311,24 +251,24 b' unlet! s:vimDiffScratchList' | |||||
311 |
|
251 | |||
312 | " Section: Utility functions {{{1 |
|
252 | " Section: Utility functions {{{1 | |
313 |
|
253 | |||
314 |
" Function: s: |
|
254 | " Function: s:HGResolveLink() {{{2 | |
315 | " Fully resolve the given file name to remove shortcuts or symbolic links. |
|
255 | " Fully resolve the given file name to remove shortcuts or symbolic links. | |
316 |
|
256 | |||
317 |
function! s: |
|
257 | function! s:HGResolveLink(fileName) | |
318 | let resolved = resolve(a:fileName) |
|
258 | let resolved = resolve(a:fileName) | |
319 | if resolved != a:fileName |
|
259 | if resolved != a:fileName | |
320 |
let resolved = s: |
|
260 | let resolved = s:HGResolveLink(resolved) | |
321 | endif |
|
261 | endif | |
322 | return resolved |
|
262 | return resolved | |
323 | endfunction |
|
263 | endfunction | |
324 |
|
264 | |||
325 |
" Function: s: |
|
265 | " Function: s:HGChangeToCurrentFileDir() {{{2 | |
326 |
" Go to the directory in which the current |
|
266 | " Go to the directory in which the current HG-controlled file is located. | |
327 |
" If this is a |
|
267 | " If this is a HG command buffer, first switch to the original file. | |
328 |
|
268 | |||
329 |
function! s: |
|
269 | function! s:HGChangeToCurrentFileDir(fileName) | |
330 | let oldCwd=getcwd() |
|
270 | let oldCwd=getcwd() | |
331 |
let fileName=s: |
|
271 | let fileName=s:HGResolveLink(a:fileName) | |
332 | let newCwd=fnamemodify(fileName, ':h') |
|
272 | let newCwd=fnamemodify(fileName, ':h') | |
333 | if strlen(newCwd) > 0 |
|
273 | if strlen(newCwd) > 0 | |
334 | execute 'cd' escape(newCwd, ' ') |
|
274 | execute 'cd' escape(newCwd, ' ') | |
@@ -336,11 +276,11 b' function! s:CVSChangeToCurrentFileDir(fi' | |||||
336 | return oldCwd |
|
276 | return oldCwd | |
337 | endfunction |
|
277 | endfunction | |
338 |
|
278 | |||
339 |
" Function: s: |
|
279 | " Function: s:HGGetOption(name, default) {{{2 | |
340 | " Grab a user-specified option to override the default provided. Options are |
|
280 | " Grab a user-specified option to override the default provided. Options are | |
341 | " searched in the window, buffer, then global spaces. |
|
281 | " searched in the window, buffer, then global spaces. | |
342 |
|
282 | |||
343 |
function! s: |
|
283 | function! s:HGGetOption(name, default) | |
344 | if exists("s:" . a:name . "Override") |
|
284 | if exists("s:" . a:name . "Override") | |
345 | execute "return s:".a:name."Override" |
|
285 | execute "return s:".a:name."Override" | |
346 | elseif exists("w:" . a:name) |
|
286 | elseif exists("w:" . a:name) | |
@@ -354,19 +294,19 b' function! s:CVSGetOption(name, default)' | |||||
354 | endif |
|
294 | endif | |
355 | endfunction |
|
295 | endfunction | |
356 |
|
296 | |||
357 |
" Function: s: |
|
297 | " Function: s:HGEditFile(name, origBuffNR) {{{2 | |
358 | " Wrapper around the 'edit' command to provide some helpful error text if the |
|
298 | " Wrapper around the 'edit' command to provide some helpful error text if the | |
359 | " current buffer can't be abandoned. If name is provided, it is used; |
|
299 | " current buffer can't be abandoned. If name is provided, it is used; | |
360 | " otherwise, a nameless scratch buffer is used. |
|
300 | " otherwise, a nameless scratch buffer is used. | |
361 | " Returns: 0 if successful, -1 if an error occurs. |
|
301 | " Returns: 0 if successful, -1 if an error occurs. | |
362 |
|
302 | |||
363 |
function! s: |
|
303 | function! s:HGEditFile(name, origBuffNR) | |
364 | "Name parameter will be pasted into expression. |
|
304 | "Name parameter will be pasted into expression. | |
365 | let name = escape(a:name, ' *?\') |
|
305 | let name = escape(a:name, ' *?\') | |
366 |
|
306 | |||
367 |
let editCommand = s: |
|
307 | let editCommand = s:HGGetOption('HGCommandEdit', 'edit') | |
368 | if editCommand != 'edit' |
|
308 | if editCommand != 'edit' | |
369 |
if s: |
|
309 | if s:HGGetOption('HGCommandSplit', 'horizontal') == 'horizontal' | |
370 | if name == "" |
|
310 | if name == "" | |
371 | let editCommand = 'rightbelow new' |
|
311 | let editCommand = 'rightbelow new' | |
372 | else |
|
312 | else | |
@@ -388,28 +328,28 b' function! s:CVSEditFile(name, origBuffNR' | |||||
388 | endif |
|
328 | endif | |
389 |
|
329 | |||
390 | " Protect against useless buffer set-up |
|
330 | " Protect against useless buffer set-up | |
391 |
let s: |
|
331 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 | |
392 | try |
|
332 | try | |
393 | execute editCommand |
|
333 | execute editCommand | |
394 | finally |
|
334 | finally | |
395 |
let s: |
|
335 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 | |
396 | endtry |
|
336 | endtry | |
397 |
|
337 | |||
398 |
let b: |
|
338 | let b:HGOrigBuffNR=a:origBuffNR | |
399 |
let b: |
|
339 | let b:HGCommandEdit='split' | |
400 | endfunction |
|
340 | endfunction | |
401 |
|
341 | |||
402 |
" Function: s: |
|
342 | " Function: s:HGCreateCommandBuffer(cmd, cmdName, statusText, filename) {{{2 | |
403 | " Creates a new scratch buffer and captures the output from execution of the |
|
343 | " Creates a new scratch buffer and captures the output from execution of the | |
404 | " given command. The name of the scratch buffer is returned. |
|
344 | " given command. The name of the scratch buffer is returned. | |
405 |
|
345 | |||
406 |
function! s: |
|
346 | function! s:HGCreateCommandBuffer(cmd, cmdName, statusText, origBuffNR) | |
407 | let fileName=bufname(a:origBuffNR) |
|
347 | let fileName=bufname(a:origBuffNR) | |
408 |
|
348 | |||
409 | let resultBufferName='' |
|
349 | let resultBufferName='' | |
410 |
|
350 | |||
411 |
if s: |
|
351 | if s:HGGetOption("HGCommandNameResultBuffers", 0) | |
412 |
let nameMarker = s: |
|
352 | let nameMarker = s:HGGetOption("HGCommandNameMarker", '_') | |
413 | if strlen(a:statusText) > 0 |
|
353 | if strlen(a:statusText) > 0 | |
414 | let bufName=a:cmdName . ' -- ' . a:statusText |
|
354 | let bufName=a:cmdName . ' -- ' . a:statusText | |
415 | else |
|
355 | else | |
@@ -424,28 +364,29 b' function! s:CVSCreateCommandBuffer(cmd, ' | |||||
424 | endwhile |
|
364 | endwhile | |
425 | endif |
|
365 | endif | |
426 |
|
366 | |||
427 |
let |
|
367 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " " . a:cmd | |
428 | let cvsOut = system(cvsCommand) |
|
368 | echomsg "DBG :".hgCommand | |
|
369 | let hgOut = system(hgCommand) | |||
429 | " HACK: diff command does not return proper error codes |
|
370 | " HACK: diff command does not return proper error codes | |
430 |
if v:shell_error && a:cmdName != ' |
|
371 | if v:shell_error && a:cmdName != 'hgdiff' | |
431 |
if strlen( |
|
372 | if strlen(hgOut) == 0 | |
432 |
echoerr " |
|
373 | echoerr "HG command failed" | |
433 | else |
|
374 | else | |
434 |
echoerr " |
|
375 | echoerr "HG command failed: " . hgOut | |
435 | endif |
|
376 | endif | |
436 | return -1 |
|
377 | return -1 | |
437 | endif |
|
378 | endif | |
438 |
if strlen( |
|
379 | if strlen(hgOut) == 0 | |
439 | " Handle case of no output. In this case, it is important to check the |
|
380 | " Handle case of no output. In this case, it is important to check the | |
440 |
" file status, especially since |
|
381 | " file status, especially since hg edit/unedit may change the attributes | |
441 | " of the file with no visible output. |
|
382 | " of the file with no visible output. | |
442 |
|
383 | |||
443 |
echomsg "No output from |
|
384 | echomsg "No output from HG command" | |
444 | checktime |
|
385 | checktime | |
445 | return -1 |
|
386 | return -1 | |
446 | endif |
|
387 | endif | |
447 |
|
388 | |||
448 |
if s: |
|
389 | if s:HGEditFile(resultBufferName, a:origBuffNR) == -1 | |
449 | return -1 |
|
390 | return -1 | |
450 | endif |
|
391 | endif | |
451 |
|
392 | |||
@@ -453,11 +394,11 b' function! s:CVSCreateCommandBuffer(cmd, ' | |||||
453 | set noswapfile |
|
394 | set noswapfile | |
454 | set filetype= |
|
395 | set filetype= | |
455 |
|
396 | |||
456 |
if s: |
|
397 | if s:HGGetOption("HGCommandDeleteOnHide", 0) | |
457 | set bufhidden=delete |
|
398 | set bufhidden=delete | |
458 | endif |
|
399 | endif | |
459 |
|
400 | |||
460 |
silent 0put= |
|
401 | silent 0put=hgOut | |
461 |
|
402 | |||
462 | " The last command left a blank line at the end of the buffer. If the |
|
403 | " The last command left a blank line at the end of the buffer. If the | |
463 | " last line is folded (a side effect of the 'put') then the attempt to |
|
404 | " last line is folded (a side effect of the 'put') then the attempt to | |
@@ -475,22 +416,22 b' function! s:CVSCreateCommandBuffer(cmd, ' | |||||
475 |
|
416 | |||
476 | " Define the environment and execute user-defined hooks. |
|
417 | " Define the environment and execute user-defined hooks. | |
477 |
|
418 | |||
478 |
let b: |
|
419 | let b:HGSourceFile=fileName | |
479 |
let b: |
|
420 | let b:HGCommand=a:cmdName | |
480 | if a:statusText != "" |
|
421 | if a:statusText != "" | |
481 |
let b: |
|
422 | let b:HGStatusText=a:statusText | |
482 | endif |
|
423 | endif | |
483 |
|
424 | |||
484 |
silent do |
|
425 | silent do HGCommand User HGBufferCreated | |
485 | return bufnr("%") |
|
426 | return bufnr("%") | |
486 | endfunction |
|
427 | endfunction | |
487 |
|
428 | |||
488 |
" Function: s: |
|
429 | " Function: s:HGBufferCheck(hgBuffer) {{{2 | |
489 |
" Attempts to locate the original file to which |
|
430 | " Attempts to locate the original file to which HG operations were applied | |
490 | " for a given buffer. |
|
431 | " for a given buffer. | |
491 |
|
432 | |||
492 |
function! s: |
|
433 | function! s:HGBufferCheck(hgBuffer) | |
493 |
let origBuffer = getbufvar(a: |
|
434 | let origBuffer = getbufvar(a:hgBuffer, "HGOrigBuffNR") | |
494 | if origBuffer |
|
435 | if origBuffer | |
495 | if bufexists(origBuffer) |
|
436 | if bufexists(origBuffer) | |
496 | return origBuffer |
|
437 | return origBuffer | |
@@ -500,52 +441,54 b' function! s:CVSBufferCheck(cvsBuffer)' | |||||
500 | endif |
|
441 | endif | |
501 | else |
|
442 | else | |
502 | " No original buffer |
|
443 | " No original buffer | |
503 |
return a: |
|
444 | return a:hgBuffer | |
504 | endif |
|
445 | endif | |
505 | endfunction |
|
446 | endfunction | |
506 |
|
447 | |||
507 |
" Function: s: |
|
448 | " Function: s:HGCurrentBufferCheck() {{{2 | |
508 |
" Attempts to locate the original file to which |
|
449 | " Attempts to locate the original file to which HG operations were applied | |
509 | " for the current buffer. |
|
450 | " for the current buffer. | |
510 |
|
451 | |||
511 |
function! s: |
|
452 | function! s:HGCurrentBufferCheck() | |
512 |
return s: |
|
453 | return s:HGBufferCheck(bufnr("%")) | |
513 | endfunction |
|
454 | endfunction | |
514 |
|
455 | |||
515 |
" Function: s: |
|
456 | " Function: s:HGToggleDeleteOnHide() {{{2 | |
516 |
" Toggles on and off the delete-on-hide behavior of |
|
457 | " Toggles on and off the delete-on-hide behavior of HG buffers | |
517 |
|
458 | |||
518 |
function! s: |
|
459 | function! s:HGToggleDeleteOnHide() | |
519 |
if exists("g: |
|
460 | if exists("g:HGCommandDeleteOnHide") | |
520 |
unlet g: |
|
461 | unlet g:HGCommandDeleteOnHide | |
521 | else |
|
462 | else | |
522 |
let g: |
|
463 | let g:HGCommandDeleteOnHide=1 | |
523 | endif |
|
464 | endif | |
524 | endfunction |
|
465 | endfunction | |
525 |
|
466 | |||
526 |
" Function: s: |
|
467 | " Function: s:HGDoCommand(hgcmd, cmdName, statusText) {{{2 | |
527 |
" General skeleton for |
|
468 | " General skeleton for HG function execution. | |
528 | " Returns: name of the new command buffer containing the command results |
|
469 | " Returns: name of the new command buffer containing the command results | |
529 |
|
470 | |||
530 |
function! s: |
|
471 | function! s:HGDoCommand(cmd, cmdName, statusText) | |
531 |
let |
|
472 | let hgBufferCheck=s:HGCurrentBufferCheck() | |
532 |
if |
|
473 | if hgBufferCheck == -1 | |
533 | echo "Original buffer no longer exists, aborting." |
|
474 | echo "Original buffer no longer exists, aborting." | |
534 | return -1 |
|
475 | return -1 | |
535 | endif |
|
476 | endif | |
536 |
|
477 | |||
537 |
let fileName=bufname( |
|
478 | let fileName=bufname(hgBufferCheck) | |
538 | if isdirectory(fileName) |
|
479 | if isdirectory(fileName) | |
539 | let fileName=fileName . "/" . getline(".") |
|
480 | let fileName=fileName . "/" . getline(".") | |
540 | endif |
|
481 | endif | |
541 |
let realFileName = fnamemodify(s: |
|
482 | let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') | |
542 |
let oldCwd=s: |
|
483 | let oldCwd=s:HGChangeToCurrentFileDir(fileName) | |
543 | try |
|
484 | try | |
544 | if !filereadable('CVS/Root') |
|
485 | " TODO | |
545 | throw fileName . ' is not a CVS-controlled file.' |
|
486 | "if !filereadable('HG/Root') | |
546 | endif |
|
487 | "throw fileName . ' is not a HG-controlled file.' | |
|
488 | "endif | |||
547 | let fullCmd = a:cmd . ' "' . realFileName . '"' |
|
489 | let fullCmd = a:cmd . ' "' . realFileName . '"' | |
548 | let resultBuffer=s:CVSCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, cvsBufferCheck) |
|
490 | "echomsg "DEBUG".fullCmd | |
|
491 | let resultBuffer=s:HGCreateCommandBuffer(fullCmd, a:cmdName, a:statusText, hgBufferCheck) | |||
549 | return resultBuffer |
|
492 | return resultBuffer | |
550 | catch |
|
493 | catch | |
551 | echoerr v:exception |
|
494 | echoerr v:exception | |
@@ -556,77 +499,89 b' function! s:CVSDoCommand(cmd, cmdName, s' | |||||
556 | endfunction |
|
499 | endfunction | |
557 |
|
500 | |||
558 |
|
501 | |||
559 |
" Function: s: |
|
502 | " Function: s:HGGetStatusVars(revision, branch, repository) {{{2 | |
560 | " |
|
503 | " | |
561 |
" Obtains a |
|
504 | " Obtains a HG revision number and branch name. The 'revisionVar', | |
562 | " 'branchVar'and 'repositoryVar' arguments, if non-empty, contain the names of variables to hold |
|
505 | " 'branchVar'and 'repositoryVar' arguments, if non-empty, contain the names of variables to hold | |
563 | " the corresponding results. |
|
506 | " the corresponding results. | |
564 | " |
|
507 | " | |
565 | " Returns: string to be exec'd that sets the multiple return values. |
|
508 | " Returns: string to be exec'd that sets the multiple return values. | |
566 |
|
509 | |||
567 |
function! s: |
|
510 | function! s:HGGetStatusVars(revisionVar, branchVar, repositoryVar) | |
568 |
let |
|
511 | let hgBufferCheck=s:HGCurrentBufferCheck() | |
569 |
if |
|
512 | if hgBufferCheck == -1 | |
570 | return "" |
|
513 | return "" | |
571 | endif |
|
514 | endif | |
572 |
let fileName=bufname( |
|
515 | let fileName=bufname(hgBufferCheck) | |
573 |
let realFileName = fnamemodify(s: |
|
516 | let realFileName = fnamemodify(s:HGResolveLink(fileName), ':t') | |
574 |
let oldCwd=s: |
|
517 | let oldCwd=s:HGChangeToCurrentFileDir(fileName) | |
575 | try |
|
518 | try | |
576 | if !filereadable('CVS/Root') |
|
519 | ""TODO | |
577 | return "" |
|
520 | "if !filereadable('HG/Root') | |
578 | endif |
|
521 | "return "" | |
579 | let cvsCommand = s:CVSGetOption("CVSCommandCVSExec", "cvs") . " status " . escape(realFileName, ' *?\') |
|
522 | "endif | |
580 | let statustext=system(cvsCommand) |
|
523 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " status -mardui " . fileName | |
|
524 | let statustext=system(hgCommand) | |||
581 | if(v:shell_error) |
|
525 | if(v:shell_error) | |
582 | return "" |
|
526 | return "" | |
583 | endif |
|
527 | endif | |
584 | let revision=substitute(statustext, '^\_.*Working revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\)\_.*$', '\1', "") |
|
528 | if match(statustext, '^[?I]') >= 0 | |
585 |
|
||||
586 | " We can still be in a CVS-controlled directory without this being a CVS |
|
|||
587 | " file |
|
|||
588 | if match(revision, '^New file!$') >= 0 |
|
|||
589 | let revision="NEW" |
|
529 | let revision="NEW" | |
590 | elseif match(revision, '^\d\+\.\d\+\%(\.\d\+\.\d\+\)*$') >=0 |
|
530 | elseif match(statustext, '^[R]') >= 0 | |
591 | else |
|
531 | let revision="REMOVED" | |
592 | return "" |
|
532 | elseif match(statustext, '^[D]') >= 0 | |
|
533 | let revision="DELETED" | |||
|
534 | elseif match(statustext, '^[A]') >= 0 | |||
|
535 | let revision="ADDED" | |||
593 | endif |
|
536 | endif | |
594 |
|
537 | |||
|
538 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " parents -b " | |||
|
539 | let statustext=system(hgCommand) | |||
|
540 | if(v:shell_error) | |||
|
541 | return "" | |||
|
542 | endif | |||
|
543 | if exists('revision') | |||
595 | let returnExpression = "let " . a:revisionVar . "='" . revision . "'" |
|
544 | let returnExpression = "let " . a:revisionVar . "='" . revision . "'" | |
|
545 | else | |||
|
546 | let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "") | |||
|
547 | let returnExpression = "let " . a:revisionVar . "='" . revision . "'" | |||
|
548 | endif | |||
596 |
|
549 | |||
597 | if a:branchVar != "" |
|
550 | if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0 | |
598 |
let branch=substitute(statustext, '^\_.* |
|
551 | let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "") | |
599 | let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" |
|
552 | let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'" | |
600 | endif |
|
553 | endif | |
601 |
|
||||
602 | if a:repositoryVar != "" |
|
554 | if a:repositoryVar != "" | |
603 | let repository=substitute(statustext, '^\_.*Repository revision:\s*\(\d\+\%(\.\d\+\)\+\|New file!\|No revision control file\)\_.*$', '\1', "") |
|
555 | let hgCommand = s:HGGetOption("HGCommandHGExec", "hg") . " root " | |
604 | let repository=substitute(repository, '^New file!\|No revision control file$', 'NEW', "") |
|
556 | let roottext=system(hgCommand) | |
|
557 | let repository=substitute(roottext,'^.*/\([^/\n\r]*\)\n\_.*$','\1','') | |||
605 | let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'" |
|
558 | let returnExpression=returnExpression . " | let " . a:repositoryVar . "='" . repository . "'" | |
606 | endif |
|
559 | endif | |
607 |
|
560 | |||
|
561 | ||||
|
562 | ||||
608 | return returnExpression |
|
563 | return returnExpression | |
609 | finally |
|
564 | finally | |
610 | execute 'cd' escape(oldCwd, ' ') |
|
565 | execute 'cd' escape(oldCwd, ' ') | |
611 | endtry |
|
566 | endtry | |
612 | endfunction |
|
567 | endfunction | |
613 |
|
568 | |||
614 |
" Function: s: |
|
569 | " Function: s:HGSetupBuffer() {{{2 | |
615 |
" Attempts to set the b: |
|
570 | " Attempts to set the b:HGBranch, b:HGRevision and b:HGRepository variables. | |
616 |
|
571 | |||
617 |
function! s: |
|
572 | function! s:HGSetupBuffer() | |
618 |
if (exists("b: |
|
573 | if (exists("b:HGBufferSetup") && b:HGBufferSetup) | |
619 | " This buffer is already set up. |
|
574 | " This buffer is already set up. | |
620 | return |
|
575 | return | |
621 | endif |
|
576 | endif | |
622 |
|
577 | |||
623 |
if !s: |
|
578 | if !s:HGGetOption("HGCommandEnableBufferSetup", 0) | |
624 | \ || @% == "" |
|
579 | \ || @% == "" | |
625 |
\ || s: |
|
580 | \ || s:HGCommandEditFileRunning > 0 | |
626 |
\ || exists("b: |
|
581 | \ || exists("b:HGOrigBuffNR") | |
627 |
unlet! b: |
|
582 | unlet! b:HGRevision | |
628 |
unlet! b: |
|
583 | unlet! b:HGBranch | |
629 |
unlet! b: |
|
584 | unlet! b:HGRepository | |
630 | return |
|
585 | return | |
631 | endif |
|
586 | endif | |
632 |
|
587 | |||
@@ -638,47 +593,48 b' function! s:CVSSetupBuffer()' | |||||
638 | let branch="" |
|
593 | let branch="" | |
639 | let repository="" |
|
594 | let repository="" | |
640 |
|
595 | |||
641 |
exec s: |
|
596 | exec s:HGGetStatusVars('revision', 'branch', 'repository') | |
|
597 | "echomsg "DBG ".revision."#".branch."#".repository | |||
642 | if revision != "" |
|
598 | if revision != "" | |
643 |
let b: |
|
599 | let b:HGRevision=revision | |
644 | else |
|
600 | else | |
645 |
unlet! b: |
|
601 | unlet! b:HGRevision | |
646 | endif |
|
602 | endif | |
647 | if branch != "" |
|
603 | if branch != "" | |
648 |
let b: |
|
604 | let b:HGBranch=branch | |
649 | else |
|
605 | else | |
650 |
unlet! b: |
|
606 | unlet! b:HGBranch | |
651 | endif |
|
607 | endif | |
652 | if repository != "" |
|
608 | if repository != "" | |
653 |
let b: |
|
609 | let b:HGRepository=repository | |
654 | else |
|
610 | else | |
655 |
unlet! b: |
|
611 | unlet! b:HGRepository | |
656 | endif |
|
612 | endif | |
657 |
silent do |
|
613 | silent do HGCommand User HGBufferSetup | |
658 |
let b: |
|
614 | let b:HGBufferSetup=1 | |
659 | endfunction |
|
615 | endfunction | |
660 |
|
616 | |||
661 |
" Function: s: |
|
617 | " Function: s:HGMarkOrigBufferForSetup(hgbuffer) {{{2 | |
662 |
" Resets the buffer setup state of the original buffer for a given |
|
618 | " Resets the buffer setup state of the original buffer for a given HG buffer. | |
663 |
" Returns: The |
|
619 | " Returns: The HG buffer number in a passthrough mode. | |
664 |
|
620 | |||
665 |
function! s: |
|
621 | function! s:HGMarkOrigBufferForSetup(hgBuffer) | |
666 | checktime |
|
622 | checktime | |
667 |
if a: |
|
623 | if a:hgBuffer != -1 | |
668 |
let origBuffer = s: |
|
624 | let origBuffer = s:HGBufferCheck(a:hgBuffer) | |
669 | "This should never not work, but I'm paranoid |
|
625 | "This should never not work, but I'm paranoid | |
670 |
if origBuffer != a: |
|
626 | if origBuffer != a:hgBuffer | |
671 |
call setbufvar(origBuffer, " |
|
627 | call setbufvar(origBuffer, "HGBufferSetup", 0) | |
672 | endif |
|
628 | endif | |
673 | endif |
|
629 | endif | |
674 |
return a: |
|
630 | return a:hgBuffer | |
675 | endfunction |
|
631 | endfunction | |
676 |
|
632 | |||
677 |
" Function: s: |
|
633 | " Function: s:HGOverrideOption(option, [value]) {{{2 | |
678 |
" Provides a temporary override for the given |
|
634 | " Provides a temporary override for the given HG option. If no value is | |
679 | " passed, the override is disabled. |
|
635 | " passed, the override is disabled. | |
680 |
|
636 | |||
681 |
function! s: |
|
637 | function! s:HGOverrideOption(option, ...) | |
682 | if a:0 == 0 |
|
638 | if a:0 == 0 | |
683 | unlet! s:{a:option}Override |
|
639 | unlet! s:{a:option}Override | |
684 | else |
|
640 | else | |
@@ -686,14 +642,14 b' function! s:CVSOverrideOption(option, ..' | |||||
686 | endif |
|
642 | endif | |
687 | endfunction |
|
643 | endfunction | |
688 |
|
644 | |||
689 |
" Function: s: |
|
645 | " Function: s:HGWipeoutCommandBuffers() {{{2 | |
690 |
" Clears all current |
|
646 | " Clears all current HG buffers of the specified type for a given source. | |
691 |
|
647 | |||
692 |
function! s: |
|
648 | function! s:HGWipeoutCommandBuffers(originalBuffer, hgCommand) | |
693 | let buffer = 1 |
|
649 | let buffer = 1 | |
694 | while buffer <= bufnr('$') |
|
650 | while buffer <= bufnr('$') | |
695 |
if getbufvar(buffer, ' |
|
651 | if getbufvar(buffer, 'HGOrigBuffNR') == a:originalBuffer | |
696 |
if getbufvar(buffer, ' |
|
652 | if getbufvar(buffer, 'HGCommand') == a:hgCommand | |
697 | execute 'bw' buffer |
|
653 | execute 'bw' buffer | |
698 | endif |
|
654 | endif | |
699 | endif |
|
655 | endif | |
@@ -703,104 +659,92 b' endfunction' | |||||
703 |
|
659 | |||
704 | " Section: Public functions {{{1 |
|
660 | " Section: Public functions {{{1 | |
705 |
|
661 | |||
706 |
" Function: |
|
662 | " Function: HGGetRevision() {{{2 | |
707 |
" Global function for retrieving the current buffer's |
|
663 | " Global function for retrieving the current buffer's HG revision number. | |
708 | " Returns: Revision number or an empty string if an error occurs. |
|
664 | " Returns: Revision number or an empty string if an error occurs. | |
709 |
|
665 | |||
710 |
function! |
|
666 | function! HGGetRevision() | |
711 | let revision="" |
|
667 | let revision="" | |
712 |
exec s: |
|
668 | exec s:HGGetStatusVars('revision', '', '') | |
713 | return revision |
|
669 | return revision | |
714 | endfunction |
|
670 | endfunction | |
715 |
|
671 | |||
716 |
" Function: |
|
672 | " Function: HGDisableBufferSetup() {{{2 | |
717 | " Global function for deactivating the buffer autovariables. |
|
673 | " Global function for deactivating the buffer autovariables. | |
718 |
|
674 | |||
719 |
function! |
|
675 | function! HGDisableBufferSetup() | |
720 |
let g: |
|
676 | let g:HGCommandEnableBufferSetup=0 | |
721 |
silent! augroup! |
|
677 | silent! augroup! HGCommandPlugin | |
722 | endfunction |
|
678 | endfunction | |
723 |
|
679 | |||
724 |
" Function: |
|
680 | " Function: HGEnableBufferSetup() {{{2 | |
725 | " Global function for activating the buffer autovariables. |
|
681 | " Global function for activating the buffer autovariables. | |
726 |
|
682 | |||
727 |
function! |
|
683 | function! HGEnableBufferSetup() | |
728 |
let g: |
|
684 | let g:HGCommandEnableBufferSetup=1 | |
729 |
augroup |
|
685 | augroup HGCommandPlugin | |
730 | au! |
|
686 | au! | |
731 |
au BufEnter * call s: |
|
687 | au BufEnter * call s:HGSetupBuffer() | |
732 | augroup END |
|
688 | augroup END | |
733 |
|
689 | |||
734 | " Only auto-load if the plugin is fully loaded. This gives other plugins a |
|
690 | " Only auto-load if the plugin is fully loaded. This gives other plugins a | |
735 | " chance to run. |
|
691 | " chance to run. | |
736 |
if g:loaded_ |
|
692 | if g:loaded_hgcommand == 2 | |
737 |
call s: |
|
693 | call s:HGSetupBuffer() | |
738 | endif |
|
694 | endif | |
739 | endfunction |
|
695 | endfunction | |
740 |
|
696 | |||
741 |
" Function: |
|
697 | " Function: HGGetStatusLine() {{{2 | |
742 |
" Default (sample) status line entry for |
|
698 | " Default (sample) status line entry for HG files. This is only useful if | |
743 |
" |
|
699 | " HG-managed buffer mode is on (see the HGCommandEnableBufferSetup variable | |
744 | " for how to do this). |
|
700 | " for how to do this). | |
745 |
|
701 | |||
746 |
function! |
|
702 | function! HGGetStatusLine() | |
747 |
if exists('b: |
|
703 | if exists('b:HGSourceFile') | |
748 | " This is a result buffer |
|
704 | " This is a result buffer | |
749 |
let value='[' . b: |
|
705 | let value='[' . b:HGCommand . ' ' . b:HGSourceFile | |
750 |
if exists('b: |
|
706 | if exists('b:HGStatusText') | |
751 |
let value=value . ' ' . b: |
|
707 | let value=value . ' ' . b:HGStatusText | |
752 | endif |
|
708 | endif | |
753 | let value = value . ']' |
|
709 | let value = value . ']' | |
754 | return value |
|
710 | return value | |
755 | endif |
|
711 | endif | |
756 |
|
712 | |||
757 |
if exists('b: |
|
713 | if exists('b:HGRevision') | |
758 |
\ && b: |
|
714 | \ && b:HGRevision != '' | |
759 |
\ && exists('b: |
|
715 | \ && exists('b:HGBranch') | |
760 |
\ && b: |
|
716 | \ && b:HGBranch != '' | |
761 |
\ && exists('b: |
|
717 | \ && exists('b:HGRepository') | |
762 |
\ && b: |
|
718 | \ && b:HGRepository != '' | |
763 |
\ && exists('g: |
|
719 | \ && exists('g:HGCommandEnableBufferSetup') | |
764 |
\ && g: |
|
720 | \ && g:HGCommandEnableBufferSetup | |
765 | if b:CVSRevision == b:CVSRepository |
|
721 | return '[HG ' . b:HGRepository . '/' . b:HGBranch .'/' . b:HGRevision . ']' | |
766 | return '[CVS ' . b:CVSBranch . '/' . b:CVSRevision . ']' |
|
|||
767 | else |
|
|||
768 | return '[CVS ' . b:CVSBranch . '/' . b:CVSRevision . '/' . b:CVSRepository . ']' |
|
|||
769 | endif |
|
|||
770 | else |
|
722 | else | |
771 | return '' |
|
723 | return '' | |
772 | endif |
|
724 | endif | |
773 | endfunction |
|
725 | endfunction | |
774 |
|
726 | |||
775 |
" Section: |
|
727 | " Section: HG command functions {{{1 | |
776 |
|
728 | |||
777 |
" Function: s: |
|
729 | " Function: s:HGAdd() {{{2 | |
778 |
function! s: |
|
730 | function! s:HGAdd() | |
779 |
return s: |
|
731 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('add', 'hgadd', '')) | |
780 | endfunction |
|
732 | endfunction | |
781 |
|
733 | |||
782 |
" Function: s: |
|
734 | " Function: s:HGAnnotate(...) {{{2 | |
783 |
function! s: |
|
735 | function! s:HGAnnotate(...) | |
784 | if a:0 == 0 |
|
736 | if a:0 == 0 | |
785 |
if &filetype == " |
|
737 | if &filetype == "HGAnnotate" | |
786 |
" This is a |
|
738 | " This is a HGAnnotate buffer. Perform annotation of the version | |
787 | " indicated by the current line. |
|
739 | " indicated by the current line. | |
788 |
let revision = substitute(getline("."),'\(^[0-9 |
|
740 | let revision = substitute(getline("."),'\(^[0-9]*\):.*','\1','') | |
789 | let revmin = substitute(revision,'^[0-9.]*\.\([0-9]\+\)','\1','') |
|
741 | if s:HGGetOption('HGCommandAnnotateParent', 0) != 0 && revision > 0 | |
790 | let revmaj = substitute(revision,'^\([0-9.]*\)\.[0-9]\+','\1','') |
|
742 | let revision = revision - 1 | |
791 | if s:CVSGetOption('CVSCommandAnnotateParent', 0) != 0 |
|
|||
792 | let revmin = revmin - 1 |
|
|||
793 | endif |
|
|||
794 | if revmin == 0 |
|
|||
795 | " Jump to ancestor branch |
|
|||
796 | let revision = substitute(revmaj,'^\([0-9.]*\)\.[0-9]\+','\1','') |
|
|||
797 | else |
|
|||
798 | let revision=revmaj . "." . revmin |
|
|||
799 | endif |
|
743 | endif | |
800 | else |
|
744 | else | |
801 |
let revision= |
|
745 | let revision=HGGetRevision() | |
802 | if revision == "" |
|
746 | if revision == "" | |
803 |
echoerr "Unable to obtain |
|
747 | echoerr "Unable to obtain HG version information." | |
804 | return -1 |
|
748 | return -1 | |
805 | endif |
|
749 | endif | |
806 | endif |
|
750 | endif | |
@@ -813,27 +757,26 b' function! s:CVSAnnotate(...)' | |||||
813 | return -1 |
|
757 | return -1 | |
814 | endif |
|
758 | endif | |
815 |
|
759 | |||
816 |
let resultBuffer=s: |
|
760 | let resultBuffer=s:HGDoCommand('annotate -ndu -r ' . revision, 'hgannotate', revision) | |
|
761 | echomsg "DBG: ".resultBuffer | |||
817 | if resultBuffer != -1 |
|
762 | if resultBuffer != -1 | |
818 |
set filetype= |
|
763 | set filetype=HGAnnotate | |
819 | " Remove header lines from standard error |
|
|||
820 | silent v/^\d\+\%(\.\d\+\)\+/d |
|
|||
821 | endif |
|
764 | endif | |
822 |
|
765 | |||
823 | return resultBuffer |
|
766 | return resultBuffer | |
824 | endfunction |
|
767 | endfunction | |
825 |
|
768 | |||
826 |
" Function: s: |
|
769 | " Function: s:HGCommit() {{{2 | |
827 |
function! s: |
|
770 | function! s:HGCommit(...) | |
828 | " Handle the commit message being specified. If a message is supplied, it |
|
771 | " Handle the commit message being specified. If a message is supplied, it | |
829 | " is used; if bang is supplied, an empty message is used; otherwise, the |
|
772 | " is used; if bang is supplied, an empty message is used; otherwise, the | |
830 | " user is provided a buffer from which to edit the commit message. |
|
773 | " user is provided a buffer from which to edit the commit message. | |
831 | if a:2 != "" || a:1 == "!" |
|
774 | if a:2 != "" || a:1 == "!" | |
832 |
return s: |
|
775 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('commit -m "' . a:2 . '"', 'hgcommit', '')) | |
833 | endif |
|
776 | endif | |
834 |
|
777 | |||
835 |
let |
|
778 | let hgBufferCheck=s:HGCurrentBufferCheck() | |
836 |
if |
|
779 | if hgBufferCheck == -1 | |
837 | echo "Original buffer no longer exists, aborting." |
|
780 | echo "Original buffer no longer exists, aborting." | |
838 | return -1 |
|
781 | return -1 | |
839 | endif |
|
782 | endif | |
@@ -847,8 +790,8 b' function! s:CVSCommit(...)' | |||||
847 |
|
790 | |||
848 | let messageFileName = tempname() |
|
791 | let messageFileName = tempname() | |
849 |
|
792 | |||
850 |
let fileName=bufname( |
|
793 | let fileName=bufname(hgBufferCheck) | |
851 |
let realFilePath=s: |
|
794 | let realFilePath=s:HGResolveLink(fileName) | |
852 | let newCwd=fnamemodify(realFilePath, ':h') |
|
795 | let newCwd=fnamemodify(realFilePath, ':h') | |
853 | if strlen(newCwd) == 0 |
|
796 | if strlen(newCwd) == 0 | |
854 | " Account for autochdir being in effect, which will make this blank, but |
|
797 | " Account for autochdir being in effect, which will make this blank, but | |
@@ -858,7 +801,7 b' function! s:CVSCommit(...)' | |||||
858 |
|
801 | |||
859 | let realFileName=fnamemodify(realFilePath, ':t') |
|
802 | let realFileName=fnamemodify(realFilePath, ':t') | |
860 |
|
803 | |||
861 |
if s: |
|
804 | if s:HGEditFile(messageFileName, hgBufferCheck) == -1 | |
862 | return |
|
805 | return | |
863 | endif |
|
806 | endif | |
864 |
|
807 | |||
@@ -866,49 +809,49 b' function! s:CVSCommit(...)' | |||||
866 | let autoPattern = '\c' . messageFileName |
|
809 | let autoPattern = '\c' . messageFileName | |
867 |
|
810 | |||
868 | " Ensure existance of group |
|
811 | " Ensure existance of group | |
869 |
augroup |
|
812 | augroup HGCommit | |
870 | augroup END |
|
813 | augroup END | |
871 |
|
814 | |||
872 |
execute 'au |
|
815 | execute 'au HGCommit BufDelete' autoPattern 'call delete("' . messageFileName . '")' | |
873 |
execute 'au |
|
816 | execute 'au HGCommit BufDelete' autoPattern 'au! HGCommit * ' autoPattern | |
874 |
|
817 | |||
875 | " Create a commit mapping. The mapping must clear all autocommands in case |
|
818 | " Create a commit mapping. The mapping must clear all autocommands in case | |
876 |
" it is invoked when |
|
819 | " it is invoked when HGCommandCommitOnWrite is active, as well as to not | |
877 | " invoke the buffer deletion autocommand. |
|
820 | " invoke the buffer deletion autocommand. | |
878 |
|
821 | |||
879 |
execute 'nnoremap <silent> <buffer> <Plug> |
|
822 | execute 'nnoremap <silent> <buffer> <Plug>HGCommit '. | |
880 |
\ ':au! |
|
823 | \ ':au! HGCommit * ' . autoPattern . '<CR>'. | |
881 |
\ ':g/^ |
|
824 | \ ':g/^HG:/d<CR>'. | |
882 | \ ':update<CR>'. |
|
825 | \ ':update<CR>'. | |
883 |
\ ':call <SID> |
|
826 | \ ':call <SID>HGFinishCommit("' . messageFileName . '",' . | |
884 | \ '"' . newCwd . '",' . |
|
827 | \ '"' . newCwd . '",' . | |
885 | \ '"' . realFileName . '",' . |
|
828 | \ '"' . realFileName . '",' . | |
886 |
\ |
|
829 | \ hgBufferCheck . ')<CR>' | |
887 |
|
830 | |||
888 |
silent 0put =' |
|
831 | silent 0put ='HG: ----------------------------------------------------------------------' | |
889 |
silent put =\" |
|
832 | silent put =\"HG: Enter Log. Lines beginning with `HG:' are removed automatically\" | |
890 |
silent put =' |
|
833 | silent put ='HG: Type <leader>cc (or your own <Plug>HGCommit mapping)' | |
891 |
|
834 | |||
892 |
if s: |
|
835 | if s:HGGetOption('HGCommandCommitOnWrite', 1) == 1 | |
893 |
execute 'au |
|
836 | execute 'au HGCommit BufWritePre' autoPattern 'g/^HG:/d' | |
894 |
execute 'au |
|
837 | execute 'au HGCommit BufWritePost' autoPattern 'call s:HGFinishCommit("' . messageFileName . '", "' . newCwd . '", "' . realFileName . '", ' . hgBufferCheck . ') | au! * ' autoPattern | |
895 |
silent put =' |
|
838 | silent put ='HG: or write this buffer' | |
896 | endif |
|
839 | endif | |
897 |
|
840 | |||
898 |
silent put =' |
|
841 | silent put ='HG: to finish this commit operation' | |
899 |
silent put =' |
|
842 | silent put ='HG: ----------------------------------------------------------------------' | |
900 | $ |
|
843 | $ | |
901 |
let b: |
|
844 | let b:HGSourceFile=fileName | |
902 |
let b: |
|
845 | let b:HGCommand='HGCommit' | |
903 |
set filetype= |
|
846 | set filetype=hg | |
904 | finally |
|
847 | finally | |
905 | let &shellslash = shellSlashBak |
|
848 | let &shellslash = shellSlashBak | |
906 | endtry |
|
849 | endtry | |
907 |
|
850 | |||
908 | endfunction |
|
851 | endfunction | |
909 |
|
852 | |||
910 |
" Function: s: |
|
853 | " Function: s:HGDiff(...) {{{2 | |
911 |
function! s: |
|
854 | function! s:HGDiff(...) | |
912 | if a:0 == 1 |
|
855 | if a:0 == 1 | |
913 | let revOptions = '-r' . a:1 |
|
856 | let revOptions = '-r' . a:1 | |
914 | let caption = a:1 . ' -> current' |
|
857 | let caption = a:1 . ' -> current' | |
@@ -920,34 +863,25 b' function! s:CVSDiff(...)' | |||||
920 | let caption = '' |
|
863 | let caption = '' | |
921 | endif |
|
864 | endif | |
922 |
|
865 | |||
923 |
let |
|
866 | let hgdiffopt=s:HGGetOption('HGCommandDiffOpt', 'w') | |
924 |
|
867 | |||
925 |
if |
|
868 | if hgdiffopt == "" | |
926 | let diffoptionstring="" |
|
869 | let diffoptionstring="" | |
927 | else |
|
870 | else | |
928 |
let diffoptionstring=" -" . |
|
871 | let diffoptionstring=" -" . hgdiffopt . " " | |
929 | endif |
|
872 | endif | |
930 |
|
873 | |||
931 |
let resultBuffer = s: |
|
874 | let resultBuffer = s:HGDoCommand('diff ' . diffoptionstring . revOptions , 'hgdiff', caption) | |
932 | if resultBuffer != -1 |
|
875 | if resultBuffer != -1 | |
933 | set filetype=diff |
|
876 | set filetype=diff | |
934 | endif |
|
877 | endif | |
935 | return resultBuffer |
|
878 | return resultBuffer | |
936 | endfunction |
|
879 | endfunction | |
937 |
|
880 | |||
938 | " Function: s:CVSEdit() {{{2 |
|
|||
939 | function! s:CVSEdit() |
|
|||
940 | return s:CVSDoCommand('edit', 'cvsedit', '') |
|
|||
941 | endfunction |
|
|||
942 |
|
|
881 | ||
943 |
" Function: s: |
|
882 | " Function: s:HGGotoOriginal(["!]) {{{2 | |
944 |
function! s: |
|
883 | function! s:HGGotoOriginal(...) | |
945 | return s:CVSDoCommand('editors', 'cvseditors', '') |
|
884 | let origBuffNR = s:HGCurrentBufferCheck() | |
946 | endfunction |
|
|||
947 |
|
||||
948 | " Function: s:CVSGotoOriginal(["!]) {{{2 |
|
|||
949 | function! s:CVSGotoOriginal(...) |
|
|||
950 | let origBuffNR = s:CVSCurrentBufferCheck() |
|
|||
951 | if origBuffNR > 0 |
|
885 | if origBuffNR > 0 | |
952 | let origWinNR = bufwinnr(origBuffNR) |
|
886 | let origWinNR = bufwinnr(origBuffNR) | |
953 | if origWinNR == -1 |
|
887 | if origWinNR == -1 | |
@@ -960,7 +894,7 b' function! s:CVSGotoOriginal(...)' | |||||
960 | let buffnr = 1 |
|
894 | let buffnr = 1 | |
961 | let buffmaxnr = bufnr("$") |
|
895 | let buffmaxnr = bufnr("$") | |
962 | while buffnr <= buffmaxnr |
|
896 | while buffnr <= buffmaxnr | |
963 |
if getbufvar(buffnr, " |
|
897 | if getbufvar(buffnr, "HGOrigBuffNR") == origBuffNR | |
964 | execute "bw" buffnr |
|
898 | execute "bw" buffnr | |
965 | endif |
|
899 | endif | |
966 | let buffnr = buffnr + 1 |
|
900 | let buffnr = buffnr + 1 | |
@@ -970,26 +904,26 b' function! s:CVSGotoOriginal(...)' | |||||
970 | endif |
|
904 | endif | |
971 | endfunction |
|
905 | endfunction | |
972 |
|
906 | |||
973 |
" Function: s: |
|
907 | " Function: s:HGFinishCommit(messageFile, targetDir, targetFile) {{{2 | |
974 |
function! s: |
|
908 | function! s:HGFinishCommit(messageFile, targetDir, targetFile, origBuffNR) | |
975 | if filereadable(a:messageFile) |
|
909 | if filereadable(a:messageFile) | |
976 | let oldCwd=getcwd() |
|
910 | let oldCwd=getcwd() | |
977 | if strlen(a:targetDir) > 0 |
|
911 | if strlen(a:targetDir) > 0 | |
978 | execute 'cd' escape(a:targetDir, ' ') |
|
912 | execute 'cd' escape(a:targetDir, ' ') | |
979 | endif |
|
913 | endif | |
980 |
let resultBuffer=s: |
|
914 | let resultBuffer=s:HGCreateCommandBuffer('commit -F "' . a:messageFile . '" "'. a:targetFile . '"', 'hgcommit', '', a:origBuffNR) | |
981 | execute 'cd' escape(oldCwd, ' ') |
|
915 | execute 'cd' escape(oldCwd, ' ') | |
982 | execute 'bw' escape(a:messageFile, ' *?\') |
|
916 | execute 'bw' escape(a:messageFile, ' *?\') | |
983 | silent execute 'call delete("' . a:messageFile . '")' |
|
917 | silent execute 'call delete("' . a:messageFile . '")' | |
984 |
return s: |
|
918 | return s:HGMarkOrigBufferForSetup(resultBuffer) | |
985 | else |
|
919 | else | |
986 | echoerr "Can't read message file; no commit is possible." |
|
920 | echoerr "Can't read message file; no commit is possible." | |
987 | return -1 |
|
921 | return -1 | |
988 | endif |
|
922 | endif | |
989 | endfunction |
|
923 | endfunction | |
990 |
|
924 | |||
991 |
" Function: s: |
|
925 | " Function: s:HGLog() {{{2 | |
992 |
function! s: |
|
926 | function! s:HGLog(...) | |
993 | if a:0 == 0 |
|
927 | if a:0 == 0 | |
994 | let versionOption = "" |
|
928 | let versionOption = "" | |
995 | let caption = '' |
|
929 | let caption = '' | |
@@ -998,23 +932,23 b' function! s:CVSLog(...)' | |||||
998 | let caption = a:1 |
|
932 | let caption = a:1 | |
999 | endif |
|
933 | endif | |
1000 |
|
934 | |||
1001 |
let resultBuffer=s: |
|
935 | let resultBuffer=s:HGDoCommand('log' . versionOption, 'hglog', caption) | |
1002 | if resultBuffer != "" |
|
936 | if resultBuffer != "" | |
1003 | set filetype=rcslog |
|
937 | set filetype=rcslog | |
1004 | endif |
|
938 | endif | |
1005 | return resultBuffer |
|
939 | return resultBuffer | |
1006 | endfunction |
|
940 | endfunction | |
1007 |
|
941 | |||
1008 |
" Function: s: |
|
942 | " Function: s:HGRevert() {{{2 | |
1009 |
function! s: |
|
943 | function! s:HGRevert() | |
1010 |
return s: |
|
944 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('revert', 'hgrevert', '')) | |
1011 | endfunction |
|
945 | endfunction | |
1012 |
|
946 | |||
1013 |
" Function: s: |
|
947 | " Function: s:HGReview(...) {{{2 | |
1014 |
function! s: |
|
948 | function! s:HGReview(...) | |
1015 | if a:0 == 0 |
|
949 | if a:0 == 0 | |
1016 | let versiontag="" |
|
950 | let versiontag="" | |
1017 |
if s: |
|
951 | if s:HGGetOption('HGCommandInteractive', 0) | |
1018 | let versiontag=input('Revision: ') |
|
952 | let versiontag=input('Revision: ') | |
1019 | endif |
|
953 | endif | |
1020 | if versiontag == "" |
|
954 | if versiontag == "" | |
@@ -1028,69 +962,65 b' function! s:CVSReview(...)' | |||||
1028 | let versionOption=" -r " . versiontag . " " |
|
962 | let versionOption=" -r " . versiontag . " " | |
1029 | endif |
|
963 | endif | |
1030 |
|
964 | |||
1031 |
let resultBuffer = s: |
|
965 | let resultBuffer = s:HGDoCommand('cat' . versionOption, 'hgreview', versiontag) | |
1032 | if resultBuffer > 0 |
|
966 | if resultBuffer > 0 | |
1033 |
let &filetype=getbufvar(b: |
|
967 | let &filetype=getbufvar(b:HGOrigBuffNR, '&filetype') | |
1034 | endif |
|
968 | endif | |
1035 |
|
969 | |||
1036 | return resultBuffer |
|
970 | return resultBuffer | |
1037 | endfunction |
|
971 | endfunction | |
1038 |
|
972 | |||
1039 |
" Function: s: |
|
973 | " Function: s:HGStatus() {{{2 | |
1040 |
function! s: |
|
974 | function! s:HGStatus() | |
1041 |
return s: |
|
975 | return s:HGDoCommand('status', 'hgstatus', '') | |
1042 | endfunction |
|
|||
1043 |
|
||||
1044 | " Function: s:CVSUnedit() {{{2 |
|
|||
1045 | function! s:CVSUnedit() |
|
|||
1046 | return s:CVSDoCommand('unedit', 'cvsunedit', '') |
|
|||
1047 | endfunction |
|
976 | endfunction | |
1048 |
|
977 | |||
1049 | " Function: s:CVSUpdate() {{{2 |
|
978 | ||
1050 |
|
|
979 | " Function: s:HGUpdate() {{{2 | |
1051 | return s:CVSMarkOrigBufferForSetup(s:CVSDoCommand('update', 'update', '')) |
|
980 | function! s:HGUpdate() | |
|
981 | return s:HGMarkOrigBufferForSetup(s:HGDoCommand('update', 'update', '')) | |||
1052 | endfunction |
|
982 | endfunction | |
1053 |
|
983 | |||
1054 |
" Function: s: |
|
984 | " Function: s:HGVimDiff(...) {{{2 | |
1055 |
function! s: |
|
985 | function! s:HGVimDiff(...) | |
1056 |
let originalBuffer = s: |
|
986 | let originalBuffer = s:HGCurrentBufferCheck() | |
1057 |
let s: |
|
987 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 | |
1058 | try |
|
988 | try | |
1059 | " If there's already a VimDiff'ed window, restore it. |
|
989 | " If there's already a VimDiff'ed window, restore it. | |
1060 |
" There may only be one |
|
990 | " There may only be one HGVimDiff original window at a time. | |
1061 |
|
991 | |||
1062 | if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer |
|
992 | if exists("s:vimDiffSourceBuffer") && s:vimDiffSourceBuffer != originalBuffer | |
1063 | " Clear the existing vimdiff setup by removing the result buffers. |
|
993 | " Clear the existing vimdiff setup by removing the result buffers. | |
1064 |
call s: |
|
994 | call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') | |
1065 | endif |
|
995 | endif | |
1066 |
|
996 | |||
1067 | " Split and diff |
|
997 | " Split and diff | |
1068 | if(a:0 == 2) |
|
998 | if(a:0 == 2) | |
1069 | " Reset the vimdiff system, as 2 explicit versions were provided. |
|
999 | " Reset the vimdiff system, as 2 explicit versions were provided. | |
1070 | if exists('s:vimDiffSourceBuffer') |
|
1000 | if exists('s:vimDiffSourceBuffer') | |
1071 |
call s: |
|
1001 | call s:HGWipeoutCommandBuffers(s:vimDiffSourceBuffer, 'vimdiff') | |
1072 | endif |
|
1002 | endif | |
1073 |
let resultBuffer = s: |
|
1003 | let resultBuffer = s:HGReview(a:1) | |
1074 | if resultBuffer < 0 |
|
1004 | if resultBuffer < 0 | |
1075 |
echomsg "Can't open |
|
1005 | echomsg "Can't open HG revision " . a:1 | |
1076 | return resultBuffer |
|
1006 | return resultBuffer | |
1077 | endif |
|
1007 | endif | |
1078 |
let b: |
|
1008 | let b:HGCommand = 'vimdiff' | |
1079 | diffthis |
|
1009 | diffthis | |
1080 | let s:vimDiffBufferCount = 1 |
|
1010 | let s:vimDiffBufferCount = 1 | |
1081 | let s:vimDiffScratchList = '{'. resultBuffer . '}' |
|
1011 | let s:vimDiffScratchList = '{'. resultBuffer . '}' | |
1082 | " If no split method is defined, cheat, and set it to vertical. |
|
1012 | " If no split method is defined, cheat, and set it to vertical. | |
1083 | try |
|
1013 | try | |
1084 |
call s: |
|
1014 | call s:HGOverrideOption('HGCommandSplit', s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical'))) | |
1085 |
let resultBuffer=s: |
|
1015 | let resultBuffer=s:HGReview(a:2) | |
1086 | finally |
|
1016 | finally | |
1087 |
call s: |
|
1017 | call s:HGOverrideOption('HGCommandSplit') | |
1088 | endtry |
|
1018 | endtry | |
1089 | if resultBuffer < 0 |
|
1019 | if resultBuffer < 0 | |
1090 |
echomsg "Can't open |
|
1020 | echomsg "Can't open HG revision " . a:1 | |
1091 | return resultBuffer |
|
1021 | return resultBuffer | |
1092 | endif |
|
1022 | endif | |
1093 |
let b: |
|
1023 | let b:HGCommand = 'vimdiff' | |
1094 | diffthis |
|
1024 | diffthis | |
1095 | let s:vimDiffBufferCount = 2 |
|
1025 | let s:vimDiffBufferCount = 2 | |
1096 | let s:vimDiffScratchList = s:vimDiffScratchList . '{'. resultBuffer . '}' |
|
1026 | let s:vimDiffScratchList = s:vimDiffScratchList . '{'. resultBuffer . '}' | |
@@ -1098,22 +1028,22 b' function! s:CVSVimDiff(...)' | |||||
1098 | " Add new buffer |
|
1028 | " Add new buffer | |
1099 | try |
|
1029 | try | |
1100 | " Force splitting behavior, otherwise why use vimdiff? |
|
1030 | " Force splitting behavior, otherwise why use vimdiff? | |
1101 |
call s: |
|
1031 | call s:HGOverrideOption("HGCommandEdit", "split") | |
1102 |
call s: |
|
1032 | call s:HGOverrideOption("HGCommandSplit", s:HGGetOption('HGCommandDiffSplit', s:HGGetOption('HGCommandSplit', 'vertical'))) | |
1103 | if(a:0 == 0) |
|
1033 | if(a:0 == 0) | |
1104 |
let resultBuffer=s: |
|
1034 | let resultBuffer=s:HGReview() | |
1105 | else |
|
1035 | else | |
1106 |
let resultBuffer=s: |
|
1036 | let resultBuffer=s:HGReview(a:1) | |
1107 | endif |
|
1037 | endif | |
1108 | finally |
|
1038 | finally | |
1109 |
call s: |
|
1039 | call s:HGOverrideOption("HGCommandEdit") | |
1110 |
call s: |
|
1040 | call s:HGOverrideOption("HGCommandSplit") | |
1111 | endtry |
|
1041 | endtry | |
1112 | if resultBuffer < 0 |
|
1042 | if resultBuffer < 0 | |
1113 |
echomsg "Can't open current |
|
1043 | echomsg "Can't open current HG revision" | |
1114 | return resultBuffer |
|
1044 | return resultBuffer | |
1115 | endif |
|
1045 | endif | |
1116 |
let b: |
|
1046 | let b:HGCommand = 'vimdiff' | |
1117 | diffthis |
|
1047 | diffthis | |
1118 |
|
1048 | |||
1119 | if !exists('s:vimDiffBufferCount') |
|
1049 | if !exists('s:vimDiffBufferCount') | |
@@ -1121,7 +1051,7 b' function! s:CVSVimDiff(...)' | |||||
1121 | let s:vimDiffBufferCount = 2 |
|
1051 | let s:vimDiffBufferCount = 2 | |
1122 | let s:vimDiffScratchList = '{' . resultBuffer . '}' |
|
1052 | let s:vimDiffScratchList = '{' . resultBuffer . '}' | |
1123 |
|
1053 | |||
1124 |
" This could have been invoked on a |
|
1054 | " This could have been invoked on a HG result buffer, not the | |
1125 | " original buffer. |
|
1055 | " original buffer. | |
1126 | wincmd W |
|
1056 | wincmd W | |
1127 | execute 'buffer' originalBuffer |
|
1057 | execute 'buffer' originalBuffer | |
@@ -1151,168 +1081,115 b' function! s:CVSVimDiff(...)' | |||||
1151 | let saveModeline = getbufvar(currentBuffer, '&modeline') |
|
1081 | let saveModeline = getbufvar(currentBuffer, '&modeline') | |
1152 | try |
|
1082 | try | |
1153 | call setbufvar(currentBuffer, '&modeline', 0) |
|
1083 | call setbufvar(currentBuffer, '&modeline', 0) | |
1154 |
silent do |
|
1084 | silent do HGCommand User HGVimDiffFinish | |
1155 | finally |
|
1085 | finally | |
1156 | call setbufvar(currentBuffer, '&modeline', saveModeline) |
|
1086 | call setbufvar(currentBuffer, '&modeline', saveModeline) | |
1157 | endtry |
|
1087 | endtry | |
1158 | return resultBuffer |
|
1088 | return resultBuffer | |
1159 | finally |
|
1089 | finally | |
1160 |
let s: |
|
1090 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 | |
1161 | endtry |
|
1091 | endtry | |
1162 | endfunction |
|
1092 | endfunction | |
1163 |
|
1093 | |||
1164 | " Function: s:CVSWatch(onoff) {{{2 |
|
|||
1165 | function! s:CVSWatch(onoff) |
|
|||
1166 | if a:onoff !~ '^\c\%(on\|off\|add\|remove\)$' |
|
|||
1167 | echoerr "Argument to CVSWatch must be one of [on|off|add|remove]" |
|
|||
1168 | return -1 |
|
|||
1169 | end |
|
|||
1170 | return s:CVSDoCommand('watch ' . tolower(a:onoff), 'cvswatch', '') |
|
|||
1171 | endfunction |
|
|||
1172 |
|
||||
1173 | " Function: s:CVSWatchers() {{{2 |
|
|||
1174 | function! s:CVSWatchers() |
|
|||
1175 | return s:CVSDoCommand('watchers', 'cvswatchers', '') |
|
|||
1176 | endfunction |
|
|||
1177 |
|
||||
1178 | " Section: Command definitions {{{1 |
|
1094 | " Section: Command definitions {{{1 | |
1179 | " Section: Primary commands {{{2 |
|
1095 | " Section: Primary commands {{{2 | |
1180 |
com! |
|
1096 | com! HGAdd call s:HGAdd() | |
1181 |
com! -nargs=? |
|
1097 | com! -nargs=? HGAnnotate call s:HGAnnotate(<f-args>) | |
1182 |
com! -bang -nargs=? |
|
1098 | com! -bang -nargs=? HGCommit call s:HGCommit(<q-bang>, <q-args>) | |
1183 |
com! -nargs=* |
|
1099 | com! -nargs=* HGDiff call s:HGDiff(<f-args>) | |
1184 | com! CVSEdit call s:CVSEdit() |
|
1100 | com! -bang HGGotoOriginal call s:HGGotoOriginal(<q-bang>) | |
1185 | com! CVSEditors call s:CVSEditors() |
|
1101 | com! -nargs=? HGLog call s:HGLog(<f-args>) | |
1186 | com! -bang CVSGotoOriginal call s:CVSGotoOriginal(<q-bang>) |
|
1102 | com! HGRevert call s:HGRevert() | |
1187 |
com! -nargs=? |
|
1103 | com! -nargs=? HGReview call s:HGReview(<f-args>) | |
1188 | com! CVSRevert call s:CVSRevert() |
|
1104 | com! HGStatus call s:HGStatus() | |
1189 | com! -nargs=? CVSReview call s:CVSReview(<f-args>) |
|
1105 | com! HGUpdate call s:HGUpdate() | |
1190 | com! CVSStatus call s:CVSStatus() |
|
1106 | com! -nargs=* HGVimDiff call s:HGVimDiff(<f-args>) | |
1191 | com! CVSUnedit call s:CVSUnedit() |
|
|||
1192 | com! CVSUpdate call s:CVSUpdate() |
|
|||
1193 | com! -nargs=* CVSVimDiff call s:CVSVimDiff(<f-args>) |
|
|||
1194 | com! -nargs=1 CVSWatch call s:CVSWatch(<f-args>) |
|
|||
1195 | com! CVSWatchAdd call s:CVSWatch('add') |
|
|||
1196 | com! CVSWatchOn call s:CVSWatch('on') |
|
|||
1197 | com! CVSWatchOff call s:CVSWatch('off') |
|
|||
1198 | com! CVSWatchRemove call s:CVSWatch('remove') |
|
|||
1199 | com! CVSWatchers call s:CVSWatchers() |
|
|||
1200 |
|
1107 | |||
1201 |
" Section: |
|
1108 | " Section: HG buffer management commands {{{2 | |
1202 |
com! |
|
1109 | com! HGDisableBufferSetup call HGDisableBufferSetup() | |
1203 |
com! |
|
1110 | com! HGEnableBufferSetup call HGEnableBufferSetup() | |
1204 |
|
1111 | |||
1205 |
" Allow reloading |
|
1112 | " Allow reloading hgcommand.vim | |
1206 |
com! |
|
1113 | com! HGReload unlet! loaded_hgcommand | runtime plugin/hgcommand.vim | |
1207 |
|
1114 | |||
1208 | " Section: Plugin command mappings {{{1 |
|
1115 | " Section: Plugin command mappings {{{1 | |
1209 |
nnoremap <silent> <Plug> |
|
1116 | nnoremap <silent> <Plug>HGAdd :HGAdd<CR> | |
1210 |
nnoremap <silent> <Plug> |
|
1117 | nnoremap <silent> <Plug>HGAnnotate :HGAnnotate<CR> | |
1211 |
nnoremap <silent> <Plug> |
|
1118 | nnoremap <silent> <Plug>HGCommit :HGCommit<CR> | |
1212 |
nnoremap <silent> <Plug> |
|
1119 | nnoremap <silent> <Plug>HGDiff :HGDiff<CR> | |
1213 |
nnoremap <silent> <Plug> |
|
1120 | nnoremap <silent> <Plug>HGGotoOriginal :HGGotoOriginal<CR> | |
1214 |
nnoremap <silent> <Plug> |
|
1121 | nnoremap <silent> <Plug>HGClearAndGotoOriginal :HGGotoOriginal!<CR> | |
1215 |
nnoremap <silent> <Plug> |
|
1122 | nnoremap <silent> <Plug>HGLog :HGLog<CR> | |
1216 |
nnoremap <silent> <Plug> |
|
1123 | nnoremap <silent> <Plug>HGRevert :HGRevert<CR> | |
1217 |
nnoremap <silent> <Plug> |
|
1124 | nnoremap <silent> <Plug>HGReview :HGReview<CR> | |
1218 |
nnoremap <silent> <Plug> |
|
1125 | nnoremap <silent> <Plug>HGStatus :HGStatus<CR> | |
1219 |
nnoremap <silent> <Plug> |
|
1126 | nnoremap <silent> <Plug>HGUpdate :HGUpdate<CR> | |
1220 |
nnoremap <silent> <Plug> |
|
1127 | nnoremap <silent> <Plug>HGVimDiff :HGVimDiff<CR> | |
1221 |
nnoremap <silent> <Plug> |
|
1128 | nnoremap <silent> <Plug>HGWatchers :HGWatchers<CR> | |
1222 |
nnoremap <silent> <Plug> |
|
1129 | nnoremap <silent> <Plug>HGWatchAdd :HGWatchAdd<CR> | |
1223 |
nnoremap <silent> <Plug> |
|
1130 | nnoremap <silent> <Plug>HGWatchOn :HGWatchOn<CR> | |
1224 |
nnoremap <silent> <Plug> |
|
1131 | nnoremap <silent> <Plug>HGWatchOff :HGWatchOff<CR> | |
1225 |
nnoremap <silent> <Plug> |
|
1132 | nnoremap <silent> <Plug>HGWatchRemove :HGWatchRemove<CR> | |
1226 | nnoremap <silent> <Plug>CVSWatchOn :CVSWatchOn<CR> |
|
|||
1227 | nnoremap <silent> <Plug>CVSWatchOff :CVSWatchOff<CR> |
|
|||
1228 | nnoremap <silent> <Plug>CVSWatchRemove :CVSWatchRemove<CR> |
|
|||
1229 |
|
1133 | |||
1230 | " Section: Default mappings {{{1 |
|
1134 | " Section: Default mappings {{{1 | |
1231 |
if !hasmapto('<Plug> |
|
1135 | if !hasmapto('<Plug>HGAdd') | |
1232 |
nmap <unique> <Leader> |
|
1136 | nmap <unique> <Leader>hga <Plug>HGAdd | |
1233 | endif |
|
|||
1234 | if !hasmapto('<Plug>CVSAnnotate') |
|
|||
1235 | nmap <unique> <Leader>cn <Plug>CVSAnnotate |
|
|||
1236 | endif |
|
1137 | endif | |
1237 |
if !hasmapto('<Plug> |
|
1138 | if !hasmapto('<Plug>HGAnnotate') | |
1238 |
nmap <unique> <Leader> |
|
1139 | nmap <unique> <Leader>hgn <Plug>HGAnnotate | |
1239 | endif |
|
1140 | endif | |
1240 |
if !hasmapto('<Plug> |
|
1141 | if !hasmapto('<Plug>HGClearAndGotoOriginal') | |
1241 |
nmap <unique> <Leader> |
|
1142 | nmap <unique> <Leader>hgG <Plug>HGClearAndGotoOriginal | |
1242 | endif |
|
|||
1243 | if !hasmapto('<Plug>CVSDiff') |
|
|||
1244 | nmap <unique> <Leader>cd <Plug>CVSDiff |
|
|||
1245 | endif |
|
1143 | endif | |
1246 |
if !hasmapto('<Plug> |
|
1144 | if !hasmapto('<Plug>HGCommit') | |
1247 |
nmap <unique> <Leader>c |
|
1145 | nmap <unique> <Leader>hgc <Plug>HGCommit | |
1248 | endif |
|
|||
1249 | if !hasmapto('<Plug>CVSEditors') |
|
|||
1250 | nmap <unique> <Leader>ci <Plug>CVSEditors |
|
|||
1251 | endif |
|
1146 | endif | |
1252 |
if !hasmapto('<Plug> |
|
1147 | if !hasmapto('<Plug>HGDiff') | |
1253 |
nmap <unique> <Leader> |
|
1148 | nmap <unique> <Leader>hgd <Plug>HGDiff | |
1254 | endif |
|
1149 | endif | |
1255 |
if !hasmapto('<Plug> |
|
1150 | if !hasmapto('<Plug>HGGotoOriginal') | |
1256 |
nmap <unique> <Leader> |
|
1151 | nmap <unique> <Leader>hgg <Plug>HGGotoOriginal | |
1257 | endif |
|
|||
1258 | if !hasmapto('<Plug>CVSRevert') |
|
|||
1259 | nmap <unique> <Leader>cq <Plug>CVSRevert |
|
|||
1260 | endif |
|
1152 | endif | |
1261 |
if !hasmapto('<Plug> |
|
1153 | if !hasmapto('<Plug>HGLog') | |
1262 |
nmap <unique> <Leader> |
|
1154 | nmap <unique> <Leader>hgl <Plug>HGLog | |
1263 | endif |
|
|||
1264 | if !hasmapto('<Plug>CVSStatus') |
|
|||
1265 | nmap <unique> <Leader>cs <Plug>CVSStatus |
|
|||
1266 | endif |
|
1155 | endif | |
1267 |
if !hasmapto('<Plug> |
|
1156 | if !hasmapto('<Plug>HGRevert') | |
1268 |
nmap <unique> <Leader> |
|
1157 | nmap <unique> <Leader>hgq <Plug>HGRevert | |
1269 | endif |
|
1158 | endif | |
1270 |
if !hasmapto('<Plug> |
|
1159 | if !hasmapto('<Plug>HGReview') | |
1271 |
nmap <unique> <Leader> |
|
1160 | nmap <unique> <Leader>hgr <Plug>HGReview | |
1272 | endif |
|
|||
1273 | if !hasmapto('<Plug>CVSVimDiff') |
|
|||
1274 | nmap <unique> <Leader>cv <Plug>CVSVimDiff |
|
|||
1275 | endif |
|
1161 | endif | |
1276 |
if !hasmapto('<Plug> |
|
1162 | if !hasmapto('<Plug>HGStatus') | |
1277 |
nmap <unique> <Leader> |
|
1163 | nmap <unique> <Leader>hgs <Plug>HGStatus | |
1278 | endif |
|
|||
1279 | if !hasmapto('<Plug>CVSWatchAdd') |
|
|||
1280 | nmap <unique> <Leader>cwa <Plug>CVSWatchAdd |
|
|||
1281 | endif |
|
1164 | endif | |
1282 |
if !hasmapto('<Plug> |
|
1165 | if !hasmapto('<Plug>HGUpdate') | |
1283 |
nmap <unique> <Leader> |
|
1166 | nmap <unique> <Leader>hgu <Plug>HGUpdate | |
1284 | endif |
|
1167 | endif | |
1285 |
if !hasmapto('<Plug> |
|
1168 | if !hasmapto('<Plug>HGVimDiff') | |
1286 |
nmap <unique> <Leader> |
|
1169 | nmap <unique> <Leader>hgv <Plug>HGVimDiff | |
1287 | endif |
|
|||
1288 | if !hasmapto('<Plug>CVSWatchRemove') |
|
|||
1289 | nmap <unique> <Leader>cwr <Plug>CVSWatchRemove |
|
|||
1290 | endif |
|
1170 | endif | |
1291 |
|
1171 | |||
1292 | " Section: Menu items {{{1 |
|
1172 | " Section: Menu items {{{1 | |
1293 |
silent! aunmenu Plugin. |
|
1173 | silent! aunmenu Plugin.HG | |
1294 |
amenu <silent> &Plugin. |
|
1174 | amenu <silent> &Plugin.HG.&Add <Plug>HGAdd | |
1295 |
amenu <silent> &Plugin. |
|
1175 | amenu <silent> &Plugin.HG.A&nnotate <Plug>HGAnnotate | |
1296 |
amenu <silent> &Plugin. |
|
1176 | amenu <silent> &Plugin.HG.&Commit <Plug>HGCommit | |
1297 |
amenu <silent> &Plugin. |
|
1177 | amenu <silent> &Plugin.HG.&Diff <Plug>HGDiff | |
1298 |
amenu <silent> &Plugin. |
|
1178 | amenu <silent> &Plugin.HG.&Log <Plug>HGLog | |
1299 |
amenu <silent> &Plugin. |
|
1179 | amenu <silent> &Plugin.HG.Revert <Plug>HGRevert | |
1300 |
amenu <silent> &Plugin. |
|
1180 | amenu <silent> &Plugin.HG.&Review <Plug>HGReview | |
1301 |
amenu <silent> &Plugin. |
|
1181 | amenu <silent> &Plugin.HG.&Status <Plug>HGStatus | |
1302 |
amenu <silent> &Plugin. |
|
1182 | amenu <silent> &Plugin.HG.&Update <Plug>HGUpdate | |
1303 |
amenu <silent> &Plugin. |
|
1183 | amenu <silent> &Plugin.HG.&VimDiff <Plug>HGVimDiff | |
1304 |
amenu <silent> &Plugin. |
|
1184 | amenu <silent> &Plugin.HG.&Watchers <Plug>HGWatchers | |
1305 |
amenu <silent> &Plugin. |
|
1185 | amenu <silent> &Plugin.HG.WatchAdd <Plug>HGWatchAdd | |
1306 |
amenu <silent> &Plugin. |
|
1186 | amenu <silent> &Plugin.HG.WatchOn <Plug>HGWatchOn | |
1307 |
amenu <silent> &Plugin. |
|
1187 | amenu <silent> &Plugin.HG.WatchOff <Plug>HGWatchOff | |
1308 |
amenu <silent> &Plugin. |
|
1188 | amenu <silent> &Plugin.HG.WatchRemove <Plug>HGWatchRemove | |
1309 | amenu <silent> &Plugin.CVS.WatchOn <Plug>CVSWatchOn |
|
|||
1310 | amenu <silent> &Plugin.CVS.WatchOff <Plug>CVSWatchOff |
|
|||
1311 | amenu <silent> &Plugin.CVS.WatchRemove <Plug>CVSWatchRemove |
|
|||
1312 |
|
1189 | |||
1313 | " Section: Autocommands to restore vimdiff state {{{1 |
|
1190 | " Section: Autocommands to restore vimdiff state {{{1 | |
1314 |
function! s: |
|
1191 | function! s:HGVimDiffRestore(vimDiffBuff) | |
1315 |
let s: |
|
1192 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning + 1 | |
1316 | try |
|
1193 | try | |
1317 | if exists("s:vimDiffSourceBuffer") |
|
1194 | if exists("s:vimDiffSourceBuffer") | |
1318 | if a:vimDiffBuff == s:vimDiffSourceBuffer |
|
1195 | if a:vimDiffBuff == s:vimDiffSourceBuffer | |
@@ -1366,22 +1243,23 b' function! s:CVSVimDiffRestore(vimDiffBuf' | |||||
1366 | endif |
|
1243 | endif | |
1367 | endif |
|
1244 | endif | |
1368 | finally |
|
1245 | finally | |
1369 |
let s: |
|
1246 | let s:HGCommandEditFileRunning = s:HGCommandEditFileRunning - 1 | |
1370 | endtry |
|
1247 | endtry | |
1371 | endfunction |
|
1248 | endfunction | |
1372 |
|
1249 | |||
1373 |
augroup |
|
1250 | augroup HGVimDiffRestore | |
1374 | au! |
|
1251 | au! | |
1375 |
au BufUnload * call s: |
|
1252 | au BufUnload * call s:HGVimDiffRestore(expand("<abuf>")) | |
1376 | augroup END |
|
1253 | augroup END | |
1377 |
|
1254 | |||
1378 | " Section: Optional activation of buffer management {{{1 |
|
1255 | " Section: Optional activation of buffer management {{{1 | |
1379 |
|
1256 | |||
1380 |
if s: |
|
1257 | if s:HGGetOption('HGCommandEnableBufferSetup', 0) | |
1381 |
call |
|
1258 | call HGEnableBufferSetup() | |
1382 | endif |
|
1259 | endif | |
1383 |
|
1260 | |||
1384 | " Section: Plugin completion {{{1 |
|
1261 | " Section: Plugin completion {{{1 | |
1385 |
|
1262 | |||
1386 |
let loaded_ |
|
1263 | let loaded_hgcommand=2 | |
1387 |
silent do |
|
1264 | silent do HGCommand User HGPluginFinish | |
|
1265 | " vim:se expandtab sts=2 sw=2: |
General Comments 0
You need to be logged in to leave comments.
Login now