~ubuntu-branches/ubuntu/maverick/svn-workbench/maverick

« back to all changes in this revision

Viewing changes to Source/wb_subversion_list_handler_common.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-07-30 23:33:06 UTC
  • mfrom: (2.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080730233306-f4radlcg6d8dr9k8
Tags: 1.5.4-2
Fix wx import. Closes: #492605.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
'''
2
2
 ====================================================================
3
 
 Copyright (c) 2003-2006 Barry A Scott.  All rights reserved.
 
3
 Copyright (c) 2003-2007 Barry A Scott.  All rights reserved.
4
4
 
5
5
 This software is licensed as described in the file LICENSE.txt,
6
6
 which you should have received as part of this distribution.
26
26
import wb_subversion_info_dialog
27
27
import wb_subversion_properties_dialog
28
28
import wb_subversion_diff
 
29
import wb_config
29
30
 
30
31
col_labels = [
31
32
        ('Name',        25, 10, 100, wx.LIST_FORMAT_LEFT),
146
147
        return self.is_project_parent
147
148
 
148
149
    def updateStatus( self ):
149
 
        self.project_info.updateStatus()
 
150
        try:
 
151
            self.project_info.updateStatus()
 
152
        except pysvn.ClientError, e:
 
153
            print 'Error: %s' % e.args[0]
150
154
 
151
155
    def getBranchOriginRevision( self ):
152
156
        if self.__branch_origin_revision is None:
236
240
        if len(filter_text) > 0:
237
241
            if filter_field == 'Name':
238
242
                self.all_files = [f for f in self.project_info.getFilesStatus()
239
 
                            if filter_text in f.path[prefix_len:]]
 
243
                            if filter_text.lower() in f.path[prefix_len:].lower()]
240
244
            elif filter_field == 'Author':
241
245
                self.all_files = [f for f in self.project_info.getFilesStatus()
242
 
                            if f.entry is not None and filter_text in f.entry.commit_author]
 
246
                            if f.entry is not None and filter_text.lower() in f.entry.commit_author.lower()]
243
247
        else:
244
248
            self.all_files = self.project_info.getFilesStatus()
245
249
 
 
250
        view_prefs = self.app.prefs.getView()
 
251
        if view_prefs.view_onlychanges:
 
252
            modified_states = [ pysvn.wc_status_kind.modified,
 
253
                                pysvn.wc_status_kind.added,
 
254
                                pysvn.wc_status_kind.deleted,
 
255
                                pysvn.wc_status_kind.conflicted,
 
256
                                ]
 
257
            af = self.all_files
 
258
            self.all_files = []
 
259
            for f in af:
 
260
                text_status = self.getTextStatus(f)
 
261
                prop_status = self.getPropStatus(f)
 
262
                if text_status in modified_states or prop_status in modified_states:
 
263
                    self.all_files.append( f )
 
264
                    
246
265
        self.all_files.sort( SortList( sort_data, self.project_info ) )
247
266
 
248
267
        self.__restoreListSelectionState( selection_state )
310
329
        return self.column_info.getColumnOrder()[col]
311
330
 
312
331
    def OnGetItemText( self, index, col ):
313
 
 
314
 
        prefix_len = len( self.project_info.wc_path ) + 1
 
332
        prefix_len = len( self.project_info.wc_path )
 
333
        if not self.project_info.wc_path.endswith( os.sep ):
 
334
            prefix_len += 1
315
335
 
316
336
        column = self.column_info.getNameByColumn( col )
317
337
 
354
374
 
355
375
    def OnGetItemAttr( self, index ):
356
376
        if self.project_info.need_checkout:
357
 
            colour = wx.RED
 
377
            colour = wb_config.colour_status_need_checkout
358
378
        else:
359
379
            colour = self.statusColour( self.all_files[ index ] )
360
380
 
365
385
 
366
386
        return self.all_item_attr[ colour ]
367
387
 
 
388
    def isItemImageFolder(self, item):
 
389
        if self.project_info.need_checkout:
 
390
            return True
 
391
 
 
392
        elif self.GetItemIsDir( item ):
 
393
            return True
 
394
 
 
395
        else:
 
396
            return False
 
397
 
 
398
    def GetItemIsDir(self, item):
 
399
        status = self.all_files[ item ]
 
400
        if status.entry is None:
 
401
            is_dir = os.path.isdir( status.path )
 
402
        else:
 
403
            is_dir = status.entry.kind == pysvn.node_kind.dir
 
404
        return is_dir
 
405
    
368
406
    def __get_NameColumn( self, status, prefix_len ):
369
407
        if status.entry is None:
370
408
            is_dir = os.path.isdir( status.path )
422
460
 
423
461
    def __get_LockCommentColumn( self, status ):
424
462
        if status.repos_lock is not None:
425
 
            comment = status.repos_lock['comment'].replace( '\n', ' ' )
426
 
        else:
 
463
            comment = status.repos_lock.comment.replace( '\n', ' ' )
 
464
        elif status.entry is not None and status.entry.lock_comment is not None:
427
465
            comment = status.entry.lock_comment.replace( '\n', ' ' )
 
466
        else:
 
467
            comment = ''
428
468
        return comment
429
469
 
430
470
    def __get_LockOwnerColumn( self, status ):
431
471
        if status.repos_lock is not None:
432
 
            comment = status.repos_lock['owner']
 
472
            owner = status.repos_lock.owner
 
473
        elif status.entry is not None and status.entry.lock_owner is not None:
 
474
            owner = status.entry.lock_owner
433
475
        else:
434
 
            comment = status.entry.lock_owner
435
 
        return comment
 
476
            owner = ''
 
477
        return owner
436
478
 
437
479
    def getState( self, all_rows ):
438
480
        if len(all_rows) == 0:
453
495
        state.need_checkin = True
454
496
        state.conflict = True
455
497
        state.file_exists = True
 
498
        state.is_folder = True
456
499
 
457
500
        for row in all_rows:
458
501
            filename = self.all_files[ row ].path
464
507
                state.modified = False
465
508
                state.conflict = False
466
509
                state.file_exists = False
 
510
            else:
 
511
                state.is_folder = False
467
512
 
468
513
            text_status = self.getTextStatus( row )
469
514
            if text_status in [pysvn.wc_status_kind.unversioned]:
470
515
                state.versioned = False
471
 
            else:
 
516
 
 
517
            if text_status not in [pysvn.wc_status_kind.unversioned, pysvn.wc_status_kind.ignored]:
472
518
                state.unversioned = False
473
519
 
474
520
            state.new_versioned = state.new_versioned and text_status in [pysvn.wc_status_kind.added]
481
527
                                pysvn.wc_status_kind.conflicted])
482
528
            state.need_checkin = state.need_checkin and (text_status in [pysvn.wc_status_kind.added,
483
529
                                    pysvn.wc_status_kind.deleted,
 
530
                                    pysvn.wc_status_kind.replaced,
484
531
                                    pysvn.wc_status_kind.modified]
485
532
                            or
486
533
                            prop_status in [pysvn.wc_status_kind.added,
487
534
                                    pysvn.wc_status_kind.deleted,
 
535
                                    pysvn.wc_status_kind.replaced,
488
536
                                    pysvn.wc_status_kind.modified])
489
537
            state.conflict = state.conflict and text_status in [pysvn.wc_status_kind.conflicted]
490
538
 
531
579
        if status.entry is None:
532
580
            return ''
533
581
        else:
534
 
            return os.path.join( self.project_info.wc_path, status.entry.conflict_old )
 
582
            return os.path.join( self.project_info.wc_path,
 
583
                    status.entry.conflict_old )
535
584
 
536
585
    def getConflictNew( self, row_or_status ):
537
586
        status = self.getStatusFromRowOrStatus( row_or_status )
561
610
        return wb_subversion_utils._status_format( status )
562
611
 
563
612
    def getAllGreyFilenames( self ):
564
 
        raise NotImplemented
 
613
        raise NotImplementedError
565
614
 
566
615
    def statusColour( self, status ):
567
616
        # default colour when nothing special is know for the file
568
 
        colour = wx.BLACK
 
617
        colour = wb_config.colour_status_normal
569
618
 
570
619
        # show that a file is on the clipboard
571
620
        if status.path in self.getAllGreyFilenames():
572
 
            colour = wx.Colour( 128, 128, 128 )
 
621
            colour = wb_config.colour_status_disabled
573
622
 
574
623
        # show that a file is uncontrolled
575
624
        elif status.entry is None:
576
 
            colour = wx.GREEN
 
625
            colour = wb_config.colour_status_unversioned
577
626
 
578
627
        else:
579
628
            # show a file is locked
580
629
            if( status.is_locked ):
581
 
                colour = wx.RED
 
630
                colour = wb_config.colour_status_locked
582
631
            # show a file is modified
583
632
            elif( self.getTextStatus( status ) != pysvn.wc_status_kind.normal
584
633
            or self.getPropStatus( status ) not in [pysvn.wc_status_kind.normal,pysvn.wc_status_kind.none]
585
634
            or status.is_copied or status.is_switched ):
586
 
                colour = wx.BLUE
 
635
                colour = wb_config.colour_status_modified
587
636
 
588
637
        return colour
589
638
 
719
768
                                    info1,
720
769
                                    info2 )
721
770
 
722
 
            if type(generator) == types.GeneratorType:
723
 
                while True:
724
 
                    try:
725
 
                        where_to_go_next = generator.next()
726
 
                    except StopIteration:
727
 
                        # no problem all done
728
 
                        break
 
771
                if type(generator) == types.GeneratorType:
 
772
                    while True:
 
773
                        try:
 
774
                            where_to_go_next = generator.next()
 
775
                        except StopIteration:
 
776
                            # no problem all done
 
777
                            break
729
778
 
730
 
                    yield where_to_go_next
 
779
                        yield where_to_go_next
731
780
 
732
781
        self.app.setAction( 'Ready' )
733
782
 
779
828
        self.app.setAction( 'Ready' )
780
829
 
781
830
    def Cmd_File_History( self, all_rows ):
782
 
        dialog = wb_subversion_history.HistoryDialog( self.app.frame.tree_panel.tree_ctrl )
 
831
        dialog = wb_subversion_history.LogHistoryDialog( self.app, self.app.frame.tree_panel.tree_ctrl )
783
832
        result = dialog.ShowModal()
784
833
        if result != wx.ID_OK:
785
834
            return
795
844
                            self.project_info,
796
845
                            filename,
797
846
                            dialog.getLimit(),
798
 
                            dialog.getRevisionEnd() )
 
847
                            dialog.getRevisionEnd(),
 
848
                            dialog.getIncludeTags() )
799
849
                ok = True
800
850
            except pysvn.ClientError, e:
801
851
                self.app.log_client_error( e )
949
999
        __pychecker__ = '--no-returnvalues'
950
1000
 
951
1001
        if field == SubversionListHandlerCommon.col_name:
952
 
            return status.path
 
1002
            return status.path.lower()
 
1003
 
953
1004
        if field == SubversionListHandlerCommon.col_state:
954
1005
            # Use positive text_status first
955
1006
            # then positive prop_status
1001
1052
 
1002
1053
 
1003
1054
        if field == SubversionListHandlerCommon.col_eol_style:
1004
 
            return self.project_info.getProperty( status.path, 'svn:eol-style' )
 
1055
            value = self.project_info.getProperty( status.path, 'svn:eol-style' )
 
1056
            if value in ['', None]:
 
1057
                if self.sort_data.getOrder() > 0:
 
1058
                    value = (1, u'')
 
1059
                else:
 
1060
                    value = (-1, u'')
 
1061
            else:
 
1062
                value = (0, value)
 
1063
 
 
1064
            return value
1005
1065
 
1006
1066
        if field == SubversionListHandlerCommon.col_mime_type:
1007
1067
            return self.project_info.getProperty( status.path, 'svn:mime-type' )
1008
1068
 
 
1069
        if field == SubversionListHandlerCommon.col_lock_owner:
 
1070
            if status.repos_lock is not None:
 
1071
                value = status.repos_lock.owner
 
1072
            elif status.entry is not None:
 
1073
                value = status.entry.lock_owner
 
1074
            else:
 
1075
                value = u''
 
1076
 
 
1077
            if value in ['', None]:
 
1078
                if self.sort_data.getOrder() > 0:
 
1079
                    value = (1, u'')
 
1080
                else:
 
1081
                    value = (-1, u'')
 
1082
            else:
 
1083
                value = (0, value)
 
1084
 
 
1085
            return value
 
1086
 
 
1087
        if field == SubversionListHandlerCommon.col_lock_comment:
 
1088
            if status.repos_lock is not None:
 
1089
                value = status.repos_lock.comment.replace( '\n', ' ' )
 
1090
            elif status.entry is not None and status.entry.lock_comment is not None:
 
1091
                value = status.entry.lock_comment.replace( '\n', ' ' )
 
1092
            else:
 
1093
                value = u''
 
1094
 
 
1095
            if value in ['', None]:
 
1096
                if self.sort_data.getOrder() > 0:
 
1097
                    value = (1, u'')
 
1098
                else:
 
1099
                    value = (-1, u'')
 
1100
            else:
 
1101
                value = (0, value)
 
1102
 
 
1103
            return value
 
1104
 
1009
1105
        raise wb_exceptions.InternalError( 'SortList does not support field %s' % field )
1010
1106
 
1011
1107
class SortListCtrl(SortList):