/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-21 18:18:20 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-20060721181820-450b5e29bb2614d9
2006-07-21  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * olive/olive.glade: some UI refreshment (push, remove and commit dialog)
    * olive/frontend/gtk/push.py: implemented 'push' functionality
    * olive/frontend/gtk/commit.py: implemented 'commit' functionality
    * olive/frontend/gtk/remove.py: implemented 'remove' functionality
    * olive/frontend/gtk/add.py: implemented 'add' functionality
    * olive/frontend/gtk/handler.py: implemented 'init' functionality
    * olive/backend/fileops.py: added recursive mode to add(), added
      NotBranchError exception to add() and remove()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
2
2
# Some parts of the code are:
3
3
# Copyright (C) 2005, 2006 by Canonical Ltd
4
 
#
 
4
 
5
5
# This program is free software; you can redistribute it and/or modify
6
6
# it under the terms of the GNU General Public License as published by
7
7
# the Free Software Foundation; either version 2 of the License, or
8
8
# (at your option) any later version.
9
 
#
 
9
 
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
13
# GNU General Public License for more details.
14
 
#
 
14
 
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, write to the Free Software
17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
22
 
23
23
from errors import (DirectoryAlreadyExists, MissingArgumentError,
24
24
                    MultipleMoveError, NoFilesSpecified, NoMatchingFiles,
25
 
                    NonExistingSource, NotBranchError, NotSameBranchError,
26
 
                    NotVersionedError, PermissionDenied)
 
25
                    NonExistingSource, NotBranchError, NotVersionedError)
27
26
 
28
27
def add(file_list, recursive=False):
29
28
    """ Add listed files to the branch. 
62
61
        if e.errno == 17:
63
62
            raise DirectoryAlreadyExists(directory)
64
63
    else:
65
 
        try:
66
 
            wt, dd = WorkingTree.open_containing(directory)
67
 
        except errors.NotBranchError:
68
 
            raise NotBranchError
69
 
        else:
70
 
            wt.add([dd])
 
64
        wt, dd = WorkingTree.open_containing(directory)
 
65
        wt.add([dd])
71
66
 
72
67
def move(names_list):
73
68
    """ Move or rename given files.
78
73
    
79
74
    if len(names_list) < 2:
80
75
        raise MissingArgumentError
81
 
    
82
 
    try:
83
 
        tree, rel_names = tree_files(names_list)
84
 
    except errors.NotBranchError:
85
 
        raise NotBranchError
86
 
    except errors.BzrCommandError:
87
 
        # not the same branch presumably
88
 
        raise NotSameBranchError
 
76
    tree, rel_names = tree_files(names_list)
89
77
        
90
78
    if os.path.isdir(names_list[-1]):
91
79
        # move into existing directory
103
91
    
104
92
    :param new: if True, the 'added' files will be removed
105
93
    """
106
 
    import bzrlib
107
94
    from bzrlib.builtins import tree_files
108
95
    
109
96
    try:
118
105
            raise NoFilesSpecified
119
106
    else:
120
107
        from bzrlib.delta import compare_trees
121
 
        if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9):
122
 
            added = [compare_trees(tree.basis_tree(), tree,
123
 
                                   specific_files=file_list).added]
124
 
        else:
125
 
            added = [tree.changes_from(tree.basis_tree(),
126
 
                                       specific_files=file_list).added]
 
108
        added = [compare_trees(tree.basis_tree(), tree,
 
109
                               specific_files=file_list).added]
127
110
        file_list = sorted([f[0] for f in added[0]], reverse=True)
128
111
        if len(file_list) == 0:
129
112
            raise NoMatchingFiles
152
135
    
153
136
    :return: renamed | added | removed | modified | unchanged | unknown
154
137
    """
155
 
    import bzrlib
156
138
    from bzrlib.delta import compare_trees
157
139
    from bzrlib.workingtree import WorkingTree
158
140
    
160
142
        tree1 = WorkingTree.open_containing(filename)[0]
161
143
    except errors.NotBranchError:
162
144
        return 'unknown'
163
 
    except errors.PermissionDenied:
164
 
        raise PermissionDenied(filename)
165
145
    
166
146
    branch = tree1.branch
167
147
    tree2 = tree1.branch.repository.revision_tree(branch.last_revision())
183
163
    rel = '/'.join(fpcopy)
184
164
    #print "DEBUG: rel =", rel
185
165
    
186
 
    if bzrlib.version_info[1] < 9:
187
 
        delta = compare_trees(old_tree=tree2,
188
 
                              new_tree=tree1,
189
 
                              want_unchanged=True,
190
 
                              specific_files=[rel])
191
 
    else:
192
 
        delta = tree1.changes_from(tree2,
193
 
                                   want_unchanged=True,
194
 
                                   specific_files=[rel])
 
166
    delta = compare_trees(old_tree=tree2,
 
167
                          new_tree=tree1,
 
168
                          want_unchanged=True,
 
169
                          specific_files=[rel])
195
170
    
196
171
    """ Debug information (could be usable in the future, so didn't cut out)
197
172
    print "DEBUG: delta.renamed:"