-
Notifications
You must be signed in to change notification settings - Fork 3
/
svn_commands.py
880 lines (749 loc) · 28.4 KB
/
svn_commands.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
import sublime
import sublime_plugin
import os
import os.path
import re
import subprocess
import time
from .lib import util, thread, settings, output, panels
LOG_PARSE = r'-{72}[\r\n]+r(\d+) \| ([^|]+) \| ([^|]+) \| [^\n\r]+[\n\r]+(.+)'
STATUS_PARSE = r'(^[A-W\?\!\ >]+?) +(\+ +)?(.*)'
INFO_PARSE_REVISION = r'Revision: (\d+)'
INFO_PARSE_LAST_CHANGE = r'Last Changed Rev: (\d+)'
INFO_PARSE_URL = r'URL: ([^\n]*)'
class HypnoSvnCommand(sublime_plugin.WindowCommand):
"""Base command for svn commands"""
recent_files = []
svn_tests = [
'versionned',
'changed'
]
def __init__(self, window):
"""Initializes the HypnoSvnCommand object"""
super().__init__(window)
self.svn_name = 'SVN Command'
self.tests = {
'enabled': True
}
self.native_only = False
def nothing(self, nothing1=None, nothing2=None, nothing3=None, **args):
"""Does nothing, just a placeholder for things I don't handle"""
return
def get_svn_path(self):
"""Gets the command to run for native SVN"""
svn_path = settings.get_native('svnPath', False)
if svn_path == False:
return 'svn '
else:
return svn_path + ' '
def run_command(self, cmd, files=None, log=True, async=True, on_complete=None):
"""Starts a process for a native command"""
return thread.Process(self.svn_name, self.get_svn_path() + cmd, files, log, async, on_complete)
def run_tortoise(self, cmd, files):
"""Starts a process for a TortoiseSVN command"""
if not util.use_tortoise():
sublime.error_message('Tortoise command can not be run: ' + cmd)
return
command = '"' + settings.get_tortoise_path() + '" /command:' + cmd + ' /path:"%s"' % util.tortoise_path(files)
util.debug(command)
return subprocess.Popen(command, stdout=subprocess.PIPE)
def test_versionned(self, result):
"""Tests output to verify if a file is versionned"""
return re.search(INFO_PARSE_REVISION, result, re.M) is not None
def is_versionned(self, files):
"""Runs a native command to verify if a file is versionned"""
if len(files) == 0:
return False
for f in files:
p = self.run_command('info', [f], False, False)
if self.test_versionned(p.output() + p.error()) is True:
return True
return False
def is_changed(self, files):
"""Runs a status command to see if a file has been changed since last revision"""
p = self.run_command('status', files, False, False)
return bool(p.output())
def is_unchanged(self, files):
"""Checks if a file is unchanged since last revision"""
return not self.is_changed(files)
def is_single(self, files):
"""Checks if the list of files contains only 1 file"""
if len(files) == 1:
return True
return False
def is_file(self, files):
"""Checks if a file is actually a file"""
if self.is_single(files) and os.path.isfile(files[0]):
return True
return False
def is_folder(self, files):
"""Checks if a file is actually a folder"""
if self.is_single(files) and not os.path.isfile(files[0]):
return True
return False
def test_all(self, files):
"""Gets the result of all of the tests"""
uid = "*".join(files)
for tests in HypnoSvnCommand.recent_files:
if time.time() - tests['timestamp'] > 1:
HypnoSvnCommand.recent_files.remove(tests)
continue
if uid == tests['uid']:
return tests
tests = {
'uid': uid,
'file': self.is_file(files),
'folder': self.is_folder(files),
'single': self.is_single(files),
'native': util.use_native(),
'tortoise': util.use_tortoise()
}
if not settings.get("disableSVNChecks", default=False):
tests['versionned'] = self.is_versionned(files)
tests['changed'] = self.is_changed(files)
tests['enabled'] = tests['native'] or tests['tortoise']
tests['timestamp'] = time.time()
HypnoSvnCommand.recent_files.append(tests)
return tests
def on_complete_select(self, values):
"""Handles completion of the MultiSelect"""
self.files = values
def parse_changes(self, raw):
"""Parses the output of a status command for use in a MultiSelect"""
matches = re.findall(STATUS_PARSE, raw, re.M)
if len(matches) < 1:
sublime.status_message('No changes')
return False
items = []
for change, modifier, path in matches:
inSVN = self.is_versionned([path])
item = {
'label': path,
'value': path,
'selected': inSVN
}
items.append(item)
self.items = items
return True
def on_changes_available(self, process):
"""Shows the list of changes to the user"""
output = process.output()
if not self.parse_changes(output):
return
panels.MultiSelect(self.items, self.on_complete_select, show_select_all=True)
def select_changes(self):
"""Gets the committable changes"""
thread.Process('Log', self.get_svn_path() + 'status', self.files, False, True, self.on_changes_available)
def get_url(self, file):
"""Gets the svn url for a file"""
p = self.run_command('info', [file], False, False)
m = re.search(INFO_PARSE_URL, p.output(), re.M)
return m.group(1)
def run(self, cmd="", paths=None, group=-1, index=-1):
"""Runs the command"""
if cmd is "":
return
files = util.get_files(paths, group, index)
self.svn_name = cmd.upper()
self.run_command(cmd, files)
def is_visible(self, paths=None, group=-1, index=-1):
"""Checks if the command should be visible"""
files = util.get_files(paths, group, index)
tests = self.test_all(files)
svn_checks_off = settings.get("disableSVNChecks", default=False)
for key in self.tests:
if svn_checks_off and key in HypnoSvnCommand.svn_tests:
continue
if tests[key] != self.tests[key]:
util.debug(self.svn_name + " is not visible because a test failed (%s)" % str(key))
return False
if self.native_only is not False and util.prefer_tortoise(self.native_only):
return False;
return True
class HypnoSvnCommitCommand(HypnoSvnCommand):
"""A command that handles committing to SVN"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Commit'
self.tests = {
'versionned': True,
'enabled': True
}
self.files = None
self.message = None
def commit(self):
"""Runs the native commit command"""
self.run_command('commit -m "' + util.escape_quotes(self.message) + '"', self.files)
def verify(self):
"""Checks with the user if the commit is valid"""
if sublime.ok_cancel_dialog(self.message + '\n\nFiles:\n' + '\n'.join(self.files)):
self.commit()
def on_done_input(self, value):
"""Handles completion of the input panel"""
self.message = value
minSize = settings.get_native('commitMessageSize', 0)
if minSize > 0 and len(value) < minSize:
sublime.status_message('Commit message too short')
return
if settings.get_native('commitConfirm', True):
self.verify()
else:
self.commit()
def show_message_panel(self):
"""Opens an input panel to get the commit message"""
sublime.active_window().show_input_panel('Commit message', '', self.on_done_input, self.nothing, self.nothing)
def on_complete_select(self, values):
"""Handles completion of the MultiSelect"""
self.files = values
self.show_message_panel()
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('commit'):
self.run_tortoise('commit', files)
return
if not util.use_native():
return
self.files = files
if self.is_file(files):
self.show_message_panel()
else:
self.select_changes()
class HypnoSvnUpdateRevisionCommand(HypnoSvnCommand):
"""A command that updates to a particular revision instead of HEAD"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Update to revision'
self.tests = {
'versionned': True,
'enabled': True
}
self.files = None
self.revisions = None
self.logs = None
def on_done_input(self, value):
"""Handles the result of the input panel"""
self.svn_name = 'Update to revision (%s)' % value
self.run_command('update -r %s' % value, self.files)
def on_select(self, index):
"""Handles the result of the quickpanel"""
if index < 0:
return
if index >= len(self.revisions):
self.number = self.number * 2
self.get_revisions(self.number)
revision = self.revisions[index]
self.svn_name = 'Update to revision (%s)' % revision
self.run_command('update -r %s' % revision, self.files)
def parse_logs(self, raw):
"""Parses the logs"""
matches = re.findall(LOG_PARSE, raw, re.M)
revisions = []
logs = []
show_more = len(matches) >= self.number
for revision, author, date, message in matches:
revisions.append(revision)
logs.append([revision + ': ' + message, author, date])
if int(revision) is 1:
show_more = False
if (show_more):
logs.append('More revisions...')
self.revisions = revisions
self.logs = logs
def on_logs_available(self, process):
"""Handles the logs being available"""
output = process.output()
self.parse_logs(output)
util.debug('found revisions:' + self.revisions[0] + '-' + self.revisions[-1])
if len(self.logs) > 0:
sublime.active_window().show_quick_panel(self.logs, self.on_select)
def get_revisions(self, revisions):
"""Runs a process to get log output"""
thread.Process('Log', self.get_svn_path() + 'log -r HEAD:1 -l ' + str(revisions), self.files, False, True, self.on_logs_available)
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('update'):
self.run_tortoise('update /rev', files)
return
if not util.use_native():
return
self.files = files
show_history = settings.get_native('updateToRevisionHistory', True)
if (show_history):
self.number = settings.get_native('updateToRevisionHistorySize', 20)
self.get_revisions(self.number)
else:
sublime.active_window().show_input_panel('Which revision', '', self.on_done_input, self.nothing, self.nothing)
class HypnoSvnUpdateCommand(HypnoSvnCommand):
"""A command that updates to HEAD"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Update'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('update'):
self.run_tortoise('update', files)
return
if not util.use_native():
return
self.run_command('update', files)
class HypnoSvnLogCommand(HypnoSvnCommand):
"""A command the gets recent logs"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Log'
self.tests = {
'versionned': True,
'native': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('log'):
self.run_tortoise('log', files)
return
if not util.use_native():
return
revisions = settings.get_native('logHistorySize', 20)
if isinstance(revisions, int) and revisions > 0:
self.run_command('log -v -l %s' % revisions, files)
else:
self.run_command('log -v', files)
class HypnoSvnLogNumberCommand(HypnoSvnCommand):
"""A command the gets a specific number of log entries"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Log N'
self.tests = {
'versionned': True,
'native': True
}
self.native_only = 'log'
self.files = None
def on_done_input(self, value):
"""Handles completion of an input panel"""
try:
revisions = int(value)
except:
return
if revisions < 1:
return
revisions = str(revisions)
self.svn_name = 'Log (' + revisions + ')'
self.run_command('log -v -l %s' % revisions, self.files)
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
if not util.use_native():
return
util.debug(self.svn_name)
self.files = util.get_files(paths, group, index)
revisions = settings.get_native('logHistorySize', 20)
sublime.active_window().show_input_panel('Number of logs...', str(revisions), self.on_done_input, self.nothing, self.nothing)
class HypnoSvnStatusCommand(HypnoSvnCommand):
"""A command that checks the status of the files"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Check for Modifications'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('status'):
self.run_tortoise('repostatus', files)
return
if not util.use_native():
return
self.run_command('status', files)
class HypnoSvnAddCommand(HypnoSvnCommand):
"""Adds unversionned files to the repo"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Add'
self.tests = {
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('add'):
self.run_tortoise('add', files)
return
if not util.use_native():
return
self.run_command('add', files)
class HypnoSvnDeleteCommand(HypnoSvnCommand):
"""Deletes versionned files from the repo"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Delete'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('delete'):
self.run_tortoise('remove', files)
return
if not util.use_native():
return
self.run_command('delete', files)
class HypnoSvnRevertAllCommand(HypnoSvnCommand):
"""Reverts changes made to the working copy"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Revert All'
self.tests = {
'versionned': True,
'native': True
}
self.native_only = 'revert'
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
self.run_command('revert -R', files)
def is_visible(self, paths=None, group=-1, index=-1):
if settings.get_native('alwaysEnableRevertAll', False):
self.native_only = False
value = super().is_visible(paths, group, index)
self.native_only = 'revert'
return value
class HypnoSvnRevertCommand(HypnoSvnCommand):
"""Reverts changes made to the working copy"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Revert'
self.tests = {
'versionned': True,
'enabled': True
}
self.files = None
def revert(self):
"""Runs the revert command on the sepcified files."""
self.run_command('revert', self.files)
def on_complete_select(self, values):
"""Handles completion of the MultiSelect"""
self.files = values
self.revert()
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('revert'):
self.run_tortoise('revert', files)
return
if not util.use_native():
return
self.files = files
if self.is_file(files):
self.revert()
else:
self.select_changes()
class HypnoSvnCleanupCommand(HypnoSvnCommand):
"""Cleans up broken repos"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Cleanup'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('cleanup'):
self.run_tortoise('cleanup', files)
return
if not util.use_native():
return
self.run_command('cleanup', files)
class HypnoSvnLockCommand(HypnoSvnCommand):
"""Gets a lock on the selected files"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Lock'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('lock'):
self.run_tortoise('lock', files)
return
if not util.use_native():
return
self.run_command('lock', files)
class HypnoSvnStealLockCommand(HypnoSvnCommand):
"""Steals a lock from another user"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Steal Lock'
self.tests = {
'versionned': True,
'native': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
if not util.use_native():
return
files = util.get_files(paths, group, index)
self.run_command('lock --force', files)
class HypnoSvnUnlockCommand(HypnoSvnCommand):
"""Unlocks the repo"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Unlock'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('unlock'):
self.run_tortoise('unlock', files)
return
if not util.use_native():
return
self.run_command('unlock', files)
class HypnoSvnDiffCommand(HypnoSvnCommand):
"""Lists the changes to a working copy file"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Diff'
self.tests = {
'versionned': True,
'enabled': True,
'file': True,
'changed': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('diff'):
self.run_tortoise('diff', files)
return
if not util.use_native():
return
command = settings.get_native('diffCommand', False)
if command is not False:
thread.Process(self.svn_name, command, files, log=False, async=True, interactive=True)
else:
self.run_command('diff', files)
def is_visible(self, paths=None, group=-1, index=-1):
command = False
if not util.prefer_tortoise('diff'):
command = settings.get_native('diffCommand', False)
if command is not False:
tests = self.tests
self.tests = {
'versionned': True,
'enabled': True,
'changed': True
}
value = super().is_visible(paths, group, index)
if command is not False:
self.tests = tests
return value
class HypnoSvnDiffPreviousCommand(HypnoSvnCommand):
"""Lists the changes between latest and previous revisions"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Diff With Previous'
self.tests = {
'versionned': True,
'enabled': True,
'file': True,
'changed': False
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
p = self.run_command('info', files, False, False)
output = p.output()
current = re.search(INFO_PARSE_REVISION, output).group(1)
last = str(int(re.search(INFO_PARSE_LAST_CHANGE, output).group(1)) - 1)
if util.prefer_tortoise('diff'):
self.run_tortoise('diff /startrev:' + last + ' /endrev:' + current, files)
return
if not util.use_native():
return
self.run_command('diff -r ' + last + ':' + current, files)
class HypnoSvnRenameCommand(HypnoSvnCommand):
"""Renames a file or folder in SVN"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Rename'
self.tests = {
'versionned': True,
'enabled': True,
'single': True
}
def on_done_input(self, value):
"""Handles completion of an input panel"""
src = os.path.join(self.head, self.tail)
dest = os.path.join(self.head, value)
self.run_command('rename --parents', [src, dest])
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('rename'):
self.run_tortoise('rename', files)
return
if not util.use_native():
return
self.head, self.tail = os.path.split(files[0])
sublime.active_window().show_input_panel('Rename...', self.tail, self.on_done_input, self.nothing, self.nothing)
class HypnoSvnMoveCommand(HypnoSvnCommand):
"""Moves a file or folder in SVN"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Move'
self.tests = {
'versionned': True,
'native': True, #TortoiseProc does not seem to have an equivalent
'single': True
}
def on_done_input(self, value):
"""Handles completion of an input panel"""
self.run_command('mv --parents', [self.src, value])
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
self.src = files[0]
sublime.active_window().show_input_panel('Move...', files[0], self.on_done_input, self.nothing, self.nothing)
class HypnoSvnBlameCommand(HypnoSvnCommand):
"""Checks who has made the last changes to each line in a file"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Blame'
self.tests = {
'versionned': True,
'enabled': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('blame'):
self.run_tortoise('blame', files)
return
self.run_command('blame', files)
class HypnoSvnConflictEditorCommand(HypnoSvnCommand):
"""Opens the TortoiseSVN conflict editor"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Conflict Editor'
self.tests = {
'versionned': True,
'tortoise': True
}
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
self.run_tortoise('conflicteditor', files)
class HypnoSvnResolveCommand(HypnoSvnCommand):
"""Resolves conflicts"""
options = [
'base',
'working',
'mine-conflict',
'theirs-conflict',
'mine-full',
'theirs-full'
]
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Resolve'
self.tests = {
'versionned': True,
'enabled': True,
'single': True
}
def on_select(self, index):
"""Handles which option for resolution"""
self.run_command('resolve -R --accept ' + HypnoSvnResolveCommand.options[index], self.files)
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.use_tortoise():
self.run_tortoise('resolve', files)
return
self.files = files
sublime.active_window().show_quick_panel(HypnoSvnResolveCommand.options, self.on_select)
class HypnoSvnCheckoutCommand(HypnoSvnCommand):
"""Checks out a repo"""
def __init__(self, window):
"""Initialize the command object"""
super().__init__(window)
self.svn_name = 'Checkout'
self.tests = {
'versionned': False,
'enabled': True,
'folder': True
}
def on_done_input(self, value):
"""Handles completion of the input panel"""
self.run_command('checkout', [value, self.files[0]])
def run(self, paths=None, group=-1, index=-1):
"""Runs the command"""
util.debug(self.svn_name)
files = util.get_files(paths, group, index)
if util.prefer_tortoise('checkout'):
self.run_tortoise('checkout', files)
return
if not util.use_native():
return
self.files = files
sublime.active_window().show_input_panel('Checkout from...', 'http://', self.on_done_input, self.nothing, self.nothing)