/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/frontend/gtk/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-05 01:37:16 UTC
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060905013716-ed1ce9389829a5a1
Integrate olive.backend.fileops

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
        
166
166
    def _load_right(self):
167
167
        """ Load data into the right panel. (Filelist) """
168
 
        import olive.backend.fileops as fileops
169
 
        
170
168
        # set cursor to busy
171
169
        self.comm.set_busy(self.treeview_right)
172
170
        
196
194
            liststore.append([gtk.STOCK_DIRECTORY, item, ''])
197
195
        for item in files:
198
196
            try:
199
 
                status = fileops.status(path + '/' + item)
 
197
                status = check_status(path + '/' + item)
200
198
            except errors.PermissionDenied:
201
199
                continue
202
200
            
398
396
    
399
397
    def refresh_right(self, path=None):
400
398
        """ Refresh the file list. """
401
 
        import olive.backend.fileops as fileops
402
 
        
403
399
        self.set_busy(self.treeview_right)
404
400
        
405
401
        if path is None:
436
432
            liststore.append([gtk.STOCK_DIRECTORY, item, ''])
437
433
        for item in files:
438
434
            try:
439
 
                status = fileops.status(path + '/' + item)
 
435
                status = check_status(path + '/' + item)
440
436
            except errors.PermissionDenied:
441
437
                continue
442
438
            
633
629
    def remove_bookmark(self, path):
634
630
        """ Remove bookmark. """
635
631
        return self.config.remove_section(path)
 
632
 
 
633
def check_status(filename):
 
634
    """ Get the status of a file.
 
635
    
 
636
    :param filename: the full path to the file
 
637
    
 
638
    :return: renamed | added | removed | modified | unchanged | unknown
 
639
    """
 
640
    import bzrlib
 
641
    from bzrlib.delta import compare_trees
 
642
    from bzrlib.workingtree import WorkingTree
 
643
    
 
644
    try:
 
645
        tree1 = WorkingTree.open_containing(filename)[0]
 
646
    except NotBranchError:
 
647
        return 'unknown'
 
648
    
 
649
    branch = tree1.branch
 
650
    tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
 
651
    
 
652
    # find the relative path to the given file (needed for proper delta)
 
653
    wtpath = tree1.basedir
 
654
    fullpath = filename
 
655
    i = 0
 
656
    wtsplit = wtpath.split('/')
 
657
    fpsplit = fullpath.split('/')
 
658
    fpcopy = fullpath.split('/')
 
659
    for item in fpsplit:
 
660
        if i is not len(wtsplit):
 
661
            if item == wtsplit[i]:
 
662
                del fpcopy[0]
 
663
            i = i + 1
 
664
    rel = '/'.join(fpcopy)
 
665
    
 
666
    delta = tree1.changes_from(tree2,
 
667
                                   want_unchanged=True,
 
668
                                   specific_files=[rel])
 
669
    
 
670
    if len(delta.renamed):
 
671
        return 'renamed'
 
672
    elif len(delta.added):
 
673
        return 'added'
 
674
    elif len(delta.removed):
 
675
        return 'removed'
 
676
    elif len(delta.modified):
 
677
        return 'modified'
 
678
    elif len(delta.unchanged):
 
679
        return 'unchanged'
 
680
    else:
 
681
        return 'unknown'