/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/backend/fileops.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-17 14:00:33 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060717140033-99c11b1dc94f07e2
2006-07-17  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * olive/frontend/gtk/dialog.py: some basic dialog stuff added
    * olive/frontend/gtk/handler.py: moved dialog stuff into dialog.py
    * olive/frontend/gtk/__init__.py: added Status column to filelist
    * olive/backend/fileops.py: implemented status()
    * TODO: added a TODO list

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
        raise NonExistingSource(source)
116
116
    
117
117
    move([source, target])
 
118
 
 
119
def status(filename):
 
120
    """ Get the status of a file.
 
121
    
 
122
    :param filename: the full path to the file
 
123
    
 
124
    :return: renamed | added | removed | modified | unchanged | unknown
 
125
    """
 
126
    from bzrlib.delta import compare_trees
 
127
    from bzrlib.workingtree import WorkingTree
 
128
    
 
129
    try:
 
130
        tree1 = WorkingTree.open_containing(filename)[0]
 
131
    except errors.NotBranchError:
 
132
        return 'unknown'
 
133
    
 
134
    branch = tree1.branch
 
135
    tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
 
136
    
 
137
    delta = compare_trees(old_tree=tree2,
 
138
                          new_tree=tree1,
 
139
                          want_unchanged=True,
 
140
                          specific_files=[filename])
 
141
    
 
142
    if len(delta.renamed):
 
143
        return 'renamed'
 
144
    elif len(delta.added):
 
145
        return 'added'
 
146
    elif len(delta.removed):
 
147
        return 'removed'
 
148
    elif len(delta.modified):
 
149
        return 'modified'
 
150
    elif len(delta.unchanged):
 
151
        return 'unchanged'
 
152
    else:
 
153
        return 'unknown'