-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVNBrowse.mm
646 lines (544 loc) · 20.3 KB
/
SVNBrowse.mm
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
#import "SVNBrowse.h"
#import "SVNLog.h"
#import "SVNProperties.h"
#import "SVNProgress.h"
#import "SVNBlame.h"
#import "main.h"
NSMutableDictionary *FindEntry(NSMutableArray *array, NSString *name) {
for (NSMutableDictionary *i in array) {
if ([(NSString*)[i objectForKey:@"name"] isEqualToString:name])
return i;
}
return 0;
}
@interface SVNBrowseAdder : NSObject <SVNdelegate> {
NSMutableArray *array;
NSMutableDictionary *root;
id obj;
}
-(id)initWithArray:(NSMutableArray*)_array on:(id)_obj;
@end
//------------------------------------------------------------------------------
// SVNBrowseAdder
//------------------------------------------------------------------------------
@implementation SVNBrowseAdder
-(id)initWithArray:(NSMutableArray*)_array on:(id)_obj {
if (self = [super init]) {
array = [_array retain];
obj = [_obj retain];
}
return self;
}
-(id)initWithArray:(NSMutableArray*)_array on:(id)_obj withRoot:(NSMutableDictionary*)_root {
if (self = [self initWithArray:_array on:_obj])
root = _root;
return self;
}
-(void)dealloc {
[obj release];
[super dealloc];
}
-(void)add:(id)value {
[obj willChangeValueForKey:@"data"];
[array addObject:value];
[obj didChangeValueForKey:@"data"];
}
-(svn_error_t*)SVNlist:(const svn_dirent_t*)entry path:(const char*)path abspath:(const char*)abs_path lock:(const svn_lock_t*)lock pool:(apr_pool_t*)pool {
NSMutableDictionary *info;
NSString *name = [NSString stringWithUTF8String:path];
if (!path[0]) {
if (!root)
return 0;
info = root;
} else {
if (FindEntry(array, name))
return 0;
info = [NSMutableDictionary dictionaryWithDictionary:@{
@"name": name,
@"path": [[NSString stringWithUTF8String:abs_path] stringByAppendingPathComponent:name],
@"isLeaf": [NSNumber numberWithBool:entry->kind != svn_node_dir],
}];
}
[info setValue:[NSNumber numberWithUnsignedLongLong:entry->created_rev] forKey:@"revision"];
[info setValue:(NSDate*)SVNdate(entry->time) forKey:@"date"];
if (entry->last_author)
[info setValue:[NSString stringWithUTF8String:entry->last_author] forKey:@"author"];
if (entry->kind != svn_node_dir) {
[info setValue:[name getUTIDescription] forKey:@"type"];
[info setValue:[NSNumber numberWithUnsignedLongLong:entry->size] forKey:@"size"];
}
if (lock)
[info setValue:[NSString stringWithUTF8String:lock->owner] forKey:@"lock"];
if (info != root)
[self performSelectorOnMainThread:@selector(add:) withObject:info waitUntilDone:NO];
return 0;
}
@end
//------------------------------------------------------------------------------
// SVNBrowse
//------------------------------------------------------------------------------
enum COLS {
COL_PATH,
COL_TYPE,
COL_REVISION,
COL_AUTHOR,
COL_SIZE,
COL_DATE,
COL_LOCK
};
@implementation SVNBrowse
-(id)init {
if (self = [self initWithWindowNibName:@"SVNBrowse"]) {
[self setShouldCascadeWindows:NO];
[self setWindowFrameAutosaveName:@"SVNBrowse"];
[self setLogo];
data = [NSMutableArray new];
revision = SVNrevision::head();
svn = new SVNcontext;
queue = dispatch_queue_create("browse", NULL);
}
return self;
}
-(void)windowDidLoad {
[super windowDidLoad];
[outline registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
[outline setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
[outline setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO];
}
-(void)dealloc {
[data release];
[root release];
dispatch_release(queue);
[super dealloc];
}
-(void)windowWillClose:(NSNotification*)notification {
[self release];
}
-(void)updateFolder:(NSMutableDictionary*)item {
NSMutableArray *children = [item objectForKey:@"children"];
if (!children) {
children = [[NSMutableArray new] autorelease];
[item setValue:children forKey:@"children"];
}
NSProgressIndicator *prog = [NSProgressIndicator new];
[item setValue:prog forKey:@"progress"];
NSString *path = [item objectForKey:@"path"];
dispatch_async(queue, ^ {
SVNBrowseAdder *adder = [[SVNBrowseAdder alloc] initWithArray:children on:self];
svn_error_t *err = svn->GetList(adder, [self get_url:path], revision);
[prog removeFromSuperview];
[item removeObjectForKey:@"progress"];
[prog release];
if (err)
svn->LogErrorMessage(err);
});
}
-(void)listFolder:(NSMutableDictionary*)item {
if ([item objectForKey:@"children"])
return;
[self updateFolder:item];
}
-(void)setRevision:(SVNrevision)_revision {
revision = _revision;
}
-(void)setRoot:(NSString*)_root {
if (!root || ![root isEqualToString:_root]) {
[root release];
root = [_root retain];
NSMutableDictionary *item = [NSMutableDictionary dictionaryWithDictionary:@{
@"name": root,
@"path": root,
@"isLeaf": [NSNumber numberWithBool:false],
}];
[self willChangeValueForKey:@"data"];
[data removeAllObjects];
[data addObject:item];
[self didChangeValueForKey:@"data"];
}
}
-(void)setURL:(NSString*)path isDir:(bool)dir {
[SVNService addLRU:@"repository" value:path];
[self willChangeValueForKey:@"data"];
NSString *relative = [path relativeTo:root];
NSArray *comps = [relative pathComponents];
NSMutableArray *array = data;
NSMutableDictionary *item = [array objectAtIndex:0];
NSIndexPath *index = [NSIndexPath indexPathWithIndex:0];
path = @"/";
for (int i = 0, n = [comps count] - (dir ? 0 : 1); i < n; i++) {
[self listFolder:item];
array = [item objectForKey:@"children"];
NSString *name = [comps objectAtIndex:i];
path = [path stringByAppendingPathComponent:name];
name = [name stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
item = FindEntry(array, name);
if (!item) {
item = [NSMutableDictionary dictionaryWithDictionary:@{
@"name": name,
@"path": path,
@"isLeaf": [NSNumber numberWithBool:false],
}];
[array addObject:item];
}
index = [index indexPathByAddingIndex:[array indexOfObject:item]];
}
[self didChangeValueForKey:@"data"];
[tree_controller setSelectionIndexPath:index];
}
-(void)browseFromInfo:(SVNClientInfo*)info {
[self setRoot:info->repos_root_URL];
[self setURL:info->URL isDir:info->kind == svn_node_dir];
[url_text setStringValue:info->URL];
}
-(svn_error_t*)svn_browse:(NSString*)path {
svn_client_info2_t *info;
svn_error_t *err = svn->GetInfo(path, revision, &info);
if (!err)
[self browseFromInfo:[SVNClientInfo createWithCType:info]];
return err;
}
//------------------------------------------------------------------------------
// actions
//------------------------------------------------------------------------------
-(NSTreeNode*)get_clicked_node {
return [outline itemAtRow:[outline clickedRow]];
}
-(NSMutableDictionary*)get_clicked {
return [[self get_clicked_node] representedObject];
}
-(NSString*)get_url:(NSString*)path {
if ([path characterAtIndex:0] == '/')
path = [root stringByAppendingString:path];
return [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
-(IBAction)set_url:(id)sender {
NSString *url = [sender stringValue];
if ([url hasSuffix:@"/"])
url = [url substringToIndex:[url length] - 1];
dispatch_async(queue, ^ {
svn_client_info2_t *info;
if (svn_error_t *err = svn->WithWindow([self window])->GetInfo(url, revision, &info)) {
SVNErrorAlertMainThread([self window], err);
} else {
[self performSelectorOnMainThread:@selector(browseFromInfo:)
withObject:[SVNClientInfo createWithCType:info]
waitUntilDone:NO
];
}
});
}
-(IBAction)select:(id)sender {
NSInteger i = [outline selectedRow];
if (i != -1) {
NSMutableDictionary *item = [[outline itemAtRow:i] representedObject];
[url_text setStringValue:[self get_url:[item objectForKey:@"path"]]];
}
}
-(IBAction)open:(id)sender {
NSMutableDictionary *item = [self get_clicked];
NSString *fn = [NSTemporaryDirectory() stringByAppendingPathComponent:[item objectForKey:@"name"]];
svn->GetFile(SVNstreamFILE([fn UTF8String]), [self get_url:[item objectForKey:@"path"]], revision);
[[NSWorkspace sharedWorkspace] openFile:fn];
}
-(IBAction)open_with:(id)sender {
NSMutableDictionary *item = [self get_clicked];
NSString *url = [self get_url:[item objectForKey:@"path"]];
NSString *fn = [NSTemporaryDirectory() stringByAppendingPathComponent:[item objectForKey:@"name"]];
if (NSString *app = [sender representedObject]) {
svn->GetFile(SVNstreamFILE([fn UTF8String]), url, revision);
[[NSWorkspace sharedWorkspace] openFile:fn withApplication:app];
} else {
[self chooseApplication:^(NSURL *app) {
svn->GetFile(SVNstreamFILE([fn UTF8String]), url, revision);
[[NSWorkspace sharedWorkspace] openFile:fn withApplication:[app path]];
}];
}
}
-(IBAction)show_log:(id)sender {
NSMutableDictionary *item = [self get_clicked];
[[SVNLog new] svn_log:[NSArray arrayWithObject:[self get_url:[item objectForKey:@"path"]]] fromRevision:revision];
}
-(IBAction)blame:(id)sender {
NSMutableDictionary *item = [self get_clicked];
[[SVNBlame new] svn_blame:[self get_url:[item objectForKey:@"path"]] fromRevision:1 toRevision:revision];
}
-(IBAction)checkout:(id)sender {
NSMutableDictionary *item = [self get_clicked];
NSSavePanel *dlg = [NSSavePanel savePanel];
NSString *name = [item objectForKey:@"name"];
if ([name isEqualToString:@"trunk"])
name = [[[item objectForKey:@"path"] stringByDeletingLastPathComponent] lastPathComponent];
[dlg setNameFieldStringValue:name];
[dlg setCanCreateDirectories:YES];
[dlg setAllowedFileTypes:[NSArray arrayWithObject:@"public.folder"]];
[dlg beginSheetModalForWindow:[self window] completionHandler: ^(NSInteger result) {
if (result == NSOKButton) {
NSURL *output = [dlg URL];
SVNProgress *prog = [[SVNProgress alloc] initWithTitle:@"Checkout"];
dispatch_async(
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0),
^ {
APRarray<svn_revnum_t> revs;
[prog finishedWithError:prog->svn->Checkout(prog, [self get_url:[item objectForKey:@"path"]], [output path])];
});
}
}];
}
-(IBAction)create_folder:(id)sender {
NSTreeNode *node = [self get_clicked_node];
[outline expandItem:node expandChildren:NO];
NSMutableDictionary *item = [node representedObject];
NSMutableArray *children = [item objectForKey:@"children"];
NSString *path = [item objectForKey:@"path"];
NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:@{
@"name": @"new folder",
@"path": [path stringByAppendingPathComponent:@"?"],
@"isLeaf": [NSNumber numberWithBool:false],
}];
[self willChangeValueForKey:@"data"];
[children addObject:info];
[self didChangeValueForKey:@"data"];
int childindex = 0;
for (NSTreeNode *child in [node childNodes]) {
if ([child representedObject] == info)
break;
childindex++;
}
NSUInteger indices[32], i = 0;
indices[32 - ++i] = childindex;
while (NSTreeNode *parent = [node parentNode]) {
indices[32 - ++i] = [[parent childNodes] indexOfObject:node];
node = parent;
}
NSIndexPath *index = [NSIndexPath indexPathWithIndexes:indices + 32 - i length:i];
[tree_controller setSelectionIndexPath:index];
NSInteger row = [outline selectedRow];
[outline editColumn:0 row:row withEvent:nil select:YES];
}
-(IBAction)add_file:(id)sender {
[outline expandItem:[self get_clicked_node] expandChildren:NO];
NSMutableDictionary *item = [self get_clicked];
NSString *path = [item objectForKey:@"path"];
NSOpenPanel *dlg = [NSOpenPanel openPanel];
[dlg setCanChooseDirectories:YES];
[dlg setAllowsMultipleSelection:YES];
[dlg beginSheetModalForWindow:[self window] completionHandler: ^(NSInteger result) {
if (result == NSOKButton) {
for (NSURL *i in [dlg URLs]) {
NSString *path2 = [path stringByAppendingPathComponent:[[i path] lastPathComponent]];
SVNcontext::LogErrorMessage(
svn->Import(self, [i path], [self get_url:path2])
);
}
[self updateFolder:item];
}
}];
}
-(IBAction)rename:(id)sender {
[outline editColumn:0 row:[outline clickedRow] withEvent:nil select:YES];
}
-(IBAction)remove:(id)sender {
NSTreeNode *node = [self get_clicked_node];
NSTreeNode *parent = [node parentNode];
NSMutableDictionary *item = [node representedObject];
SVNcontext::LogErrorMessage(
svn->Delete(self, [NSArray arrayWithObject:[self get_url:[item objectForKey:@"path"]]])
);
NSMutableArray *children = [[parent representedObject] objectForKey:@"children"];
[self willChangeValueForKey:@"data"];
[children removeObject:item];
[self didChangeValueForKey:@"data"];
}
-(IBAction)save:(id)sender {
NSMutableDictionary *item = [self get_clicked];
NSSavePanel *dlg = [NSSavePanel savePanel];
[dlg setNameFieldStringValue:[item objectForKey:@"name"]];
[dlg beginSheetModalForWindow:[self window] completionHandler: ^(NSInteger result) {
if (result == NSOKButton) {
NSURL *output = [dlg URL];
svn->GetFile(SVNstreamFILE([[output path] UTF8String]), [self get_url:[item objectForKey:@"path"]], revision);
}
}];
}
-(IBAction)copy_url:(id)sender {
NSMutableDictionary *item = [self get_clicked];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];
[pboard writeObjects:[NSArray arrayWithObject:[self get_url:[item objectForKey:@"path"]]]];
}
-(IBAction)show_props:(id)sender {
NSMutableDictionary *item = [self get_clicked];
[[SVNProperties new] svn_props:[self get_url:[item objectForKey:@"path"]] atRevision:revision];
}
-(svn_error_t*)SVNcommit:(const svn_commit_info_t*)commit_info pool:(apr_pool_t*)pool {
return 0;
}
//------------------------------------------------------------------------------
// NSMenuDelegate
//------------------------------------------------------------------------------
- (void)menuNeedsUpdate:(NSMenu*)menu {
NSMutableDictionary *item = [self get_clicked];
BOOL dir = ![[item objectForKey:@"isLeaf"] boolValue];
for (NSMenuItem *i in [menu itemArray]) {
SEL action = [i action];
[i setEnabled: !(dir
? action == @selector(open:)
|| action == @selector(blame:)
|| action == @selector(save:)
: action == @selector(refresh:)
|| action == @selector(add_file:)
|| action == @selector(add_folder:)
|| action == @selector(create_folder:)
)
];
}
NSString *path = [item objectForKey:@"path"];
NSMenuItem *openwith = [menu itemWithTitle:@"Open with"];
[openwith setSubmenu:[self openWithFor:path]];
[openwith setEnabled:!dir];
}
//------------------------------------------------------------------------------
// NSOutlineViewDelegate
//------------------------------------------------------------------------------
-(void)outlineViewItemWillExpand:(NSNotification*)n {
NSTreeNode *node = [[n userInfo] objectForKey:@"NSObject"];
[self listFolder:[node representedObject]];
}
-(NSCell*)outlineView:(NSOutlineView*)ov dataCellForTableColumn:(NSTableColumn*)col item:(id)item {
if (!col)
return nil;
NSString *identifier = col.identifier;
if (identifier && [identifier isEqualToString:@"name"]) {
NSString *ext = [[[item representedObject] objectForKey:@"path"] pathExtension];
IconTextCell *cell = [[IconTextCell new] autorelease];
if ([ext isEqualToString:@""] && ![[[item representedObject] objectForKey:@"isLeaf"] boolValue])
ext = NSFileTypeForHFSTypeCode(kGenericFolderIcon);
cell.icon = [[NSWorkspace sharedWorkspace] iconForFileType:ext];
return cell;
}
return [[NSTextFieldCell new] autorelease];
}
-(void)outlineView:(NSOutlineView*)ov willDisplayOutlineCell:(NSCell*)cell forTableColumn:(NSTableColumn*)col item:(id)item {
if (item) {
if (NSProgressIndicator *prog = [[item representedObject] objectForKey:@"progress"]) {
NSRect rect = [ov frameOfOutlineCellAtRow:[ov rowForItem:item]];
[prog setFrame:rect];
if (![prog superview]) {
[prog setStyle:NSProgressIndicatorSpinningStyle];
[prog setIndeterminate:YES];
[prog startAnimation:self];
[ov addSubview:prog];
}
}
}
}
- (void)controlTextDidEndEditing:(NSNotification*)notification {
int i = [[[notification userInfo] valueForKey:@"NSTextMovement"]intValue];
if (i == NSReturnTextMovement) {
NSString *value = [[notification object] stringValue];
NSMutableDictionary *info = [[outline itemAtRow:[outline selectedRow]] representedObject];
NSString *path0 = [info objectForKey:@"path"];
NSString *path1 = [[path0 stringByDeletingLastPathComponent] stringByAppendingPathComponent:value];
NSString *url1 = [self get_url:path1];
[info setObject:path1 forKey:@"path"];
svn_error_t *err;
if ([[path0 lastPathComponent] isEqualToString:@"?"]) {
err = svn->MakeDirs(self, [NSArray arrayWithObject:url1]);
} else {
NSString *url0 = [self get_url:path0];
err = svn->Rename(self, url0, url1);
}
SVNcontext::LogErrorMessage(err);
}
}
//-----------------------------------------
// drag ...
//-----------------------------------------
-(BOOL)outlineView:(NSOutlineView*)ov writeItems:(NSArray*)items toPasteboard:(NSPasteboard*)pboard {
drop_items = [items retain];
[pboard declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:self];
[pboard setPropertyList:[NSArray arrayWithObject:@"public.item"] forType:NSFilesPromisePboardType];
return YES;
}
-(NSArray*)outlineView:(NSOutlineView*)ov namesOfPromisedFilesDroppedAtDestination:(NSURL*)dest forDraggedItems:(NSArray*)items {
drop_dest = [[dest path] retain];
NSMutableArray *array = [NSMutableArray arrayWithCapacity:[items count]];
for (NSTreeNode *node in items) {
NSMutableDictionary *info = [node representedObject];
NSString *path = [info objectForKey:@"path"];
NSLog(@"%@\n", path);
[array addObject:[path lastPathComponent]];
}
return array;
}
-(void)outlineView:(NSOutlineView*)ov draggingSession:(NSDraggingSession*)session endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation {
if (operation & NSDragOperationDelete) {
NSMutableArray *paths = [NSMutableArray new];
[self willChangeValueForKey:@"data"];
for (NSTreeNode *node in drop_items) {
NSMutableDictionary *item = [node representedObject];
NSTreeNode *parent = [node parentNode];
NSMutableArray *children = [[parent representedObject] objectForKey:@"children"];
[children removeObject:item];
[paths addObject:[self get_url:[item objectForKey:@"path"]]];
}
[self didChangeValueForKey:@"data"];
SVNcontext::LogErrorMessage(svn->Delete(self, paths));
[paths release];
} else if (operation & NSDragOperationCopy) {
for (NSTreeNode *node in drop_items) {
NSMutableDictionary *item = [node representedObject];
NSString *path = [item objectForKey:@"path"];
SVNcontext::LogErrorMessage(
svn->GetFile([drop_dest stringByAppendingPathComponent:[path lastPathComponent]], [self get_url:path], revision)
);
}
}
[drop_items release];
[drop_dest release];
drop_items = nil;
drop_dest = nil;
}
//-----------------------------------------
// ... and drop
//-----------------------------------------
-(NSDragOperation)outlineView:(NSOutlineView*)ov validateDrop:(id<NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)childIndex {
if (!item)
return NSDragOperationNone;
NSTreeNode *node = item;
if ([[[node representedObject] objectForKey:@"isLeaf"] boolValue] && childIndex == NSOutlineViewDropOnItemIndex)
return NSDragOperationNone;
return NSDragOperationGeneric;
}
-(BOOL)outlineView:(NSOutlineView*)ov acceptDrop:(id<NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)childIndex {
NSTreeNode *node = item;
NSMutableDictionary *folder = [node representedObject];
NSString *path = [folder objectForKey:@"path"];
if ([[[node representedObject] objectForKey:@"isLeaf"] boolValue]) {
NSTreeNode *target = [node parentNode];
childIndex = [[target childNodes] indexOfObject:node] + 1;
node = target;
} else {
if (childIndex == NSOutlineViewDropOnItemIndex)
childIndex = 0;
}
NSArray *classes = [NSArray arrayWithObject:[NSURL class]];
SVNProgress *prog = [[SVNProgress alloc] initWithTitle:@"Import"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^ {
__block NSInteger insertionIndex = childIndex;
__block svn_error_t *err = 0;
[info enumerateDraggingItemsWithOptions:0 forView:ov classes:classes searchOptions:nil usingBlock:^(NSDraggingItem *drag, NSInteger index, BOOL *stop) {
NSString *srce = [drag.item path];
NSString *name = [srce lastPathComponent];
NSString *path2 = [path stringByAppendingFormat:@"/%@", name];
err = svn->Import(prog, srce, [self get_url:path2]);
insertionIndex++;
}];
[prog finishedWithError:err];
dispatch_async(queue, ^ {
[self updateFolder:folder];
});
});
return YES;
}
@end