bzr branch
http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
0.8.9
by Szilveszter Farkas (Phanatic)
2006-07-08 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
1 |
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic) <szilveszter.farkas@gmail.com>
|
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
2 |
# Some parts of the code are:
|
3 |
# Copyright (C) 2005, 2006 by Canonical Ltd
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
4 |
#
|
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
5 |
# This program is free software; you can redistribute it and/or modify
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
8 |
# (at your option) any later version.
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
9 |
#
|
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
10 |
# This program is distributed in the hope that it will be useful,
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
14 |
#
|
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
15 |
# You should have received a copy of the GNU General Public License
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
19 |
import os |
|
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
20 |
|
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
21 |
from bzrlib.errors import (BzrError, NotBranchError, NotVersionedError, |
22 |
PermissionDenied) |
|
23 |
||
24 |
||
25 |
class MultipleMoveError(BzrError): |
|
26 |
""" Occurs when moving/renaming more than 2 files, but the last argument is not a directory |
|
27 |
|
|
28 |
May occur in:
|
|
29 |
fileops.move()
|
|
30 |
"""
|
|
31 |
||
32 |
||
33 |
class NoMatchingFiles(BzrError): |
|
34 |
""" No files found which could match the criteria |
|
35 |
|
|
36 |
May occur in:
|
|
37 |
fileops.remove()
|
|
38 |
"""
|
|
39 |
||
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
40 |
|
0.8.8
by Szilveszter Farkas (Phanatic)
2006-07-06 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
41 |
def move(names_list): |
42 |
""" Move or rename given files. |
|
43 |
|
|
44 |
:param file_list: if two elements, then rename the first to the second, if more elements then move all of them to the directory specified in the last element
|
|
0.8.1
by Szilveszter Farkas (Phanatic)
* backend/errors.py: some basic exceptions added |
45 |
"""
|
0.8.8
by Szilveszter Farkas (Phanatic)
2006-07-06 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
46 |
from bzrlib.builtins import tree_files |
47 |
||
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
48 |
tree, rel_names = tree_files(names_list) |
0.8.8
by Szilveszter Farkas (Phanatic)
2006-07-06 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
49 |
|
50 |
if os.path.isdir(names_list[-1]): |
|
51 |
# move into existing directory
|
|
52 |
for pair in tree.move(rel_names[:-1], rel_names[-1]): |
|
53 |
pass
|
|
54 |
else: |
|
55 |
if len(names_list) != 2: |
|
56 |
raise MultipleMoveError |
|
57 |
tree.rename_one(rel_names[0], rel_names[1]) |
|
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
58 |
|
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
59 |
|
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
60 |
def remove(file_list, new=False): |
61 |
""" Make selected files unversioned. |
|
62 |
|
|
63 |
:param file_list: list of files/directories to be removed
|
|
64 |
|
|
65 |
:param new: if True, the 'added' files will be removed
|
|
66 |
"""
|
|
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
67 |
import bzrlib |
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
68 |
from bzrlib.builtins import tree_files |
69 |
||
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
70 |
tree, file_list = tree_files(file_list) |
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
71 |
|
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
72 |
if new: |
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
73 |
from bzrlib.delta import compare_trees |
0.8.29
by Szilveszter Farkas (Phanatic)
Implemented Status window; some code cleanups. |
74 |
if (bzrlib.version_info[0] == 0) and (bzrlib.version_info[1] < 9): |
75 |
added = [compare_trees(tree.basis_tree(), tree, |
|
76 |
specific_files=file_list).added] |
|
77 |
else: |
|
78 |
added = [tree.changes_from(tree.basis_tree(), |
|
79 |
specific_files=file_list).added] |
|
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
80 |
file_list = sorted([f[0] for f in added[0]], reverse=True) |
81 |
if len(file_list) == 0: |
|
82 |
raise NoMatchingFiles |
|
83 |
||
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
84 |
tree.remove(file_list) |
85 |
||
0.8.2
by Szilveszter Farkas (Phanatic)
* backend/commit.py: commit() implemented |
86 |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
87 |
def status(filename): |
88 |
""" Get the status of a file. |
|
89 |
|
|
90 |
:param filename: the full path to the file
|
|
91 |
|
|
92 |
:return: renamed | added | removed | modified | unchanged | unknown
|
|
93 |
"""
|
|
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
94 |
import bzrlib |
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
95 |
from bzrlib.delta import compare_trees |
96 |
from bzrlib.workingtree import WorkingTree |
|
97 |
||
98 |
try: |
|
99 |
tree1 = WorkingTree.open_containing(filename)[0] |
|
0.11.1
by Jelmer Vernooij
Eliminate olive.backend.errors. |
100 |
except NotBranchError: |
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
101 |
return 'unknown' |
102 |
||
103 |
branch = tree1.branch |
|
104 |
tree2 = tree1.branch.repository.revision_tree(branch.last_revision()) |
|
105 |
||
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
106 |
# find the relative path to the given file (needed for proper delta)
|
107 |
wtpath = tree1.basedir |
|
108 |
fullpath = filename |
|
109 |
i = 0 |
|
110 |
wtsplit = wtpath.split('/') |
|
111 |
fpsplit = fullpath.split('/') |
|
112 |
fpcopy = fullpath.split('/') |
|
113 |
for item in fpsplit: |
|
114 |
if i is not len(wtsplit): |
|
115 |
if item == wtsplit[i]: |
|
116 |
del fpcopy[0] |
|
117 |
i = i + 1 |
|
118 |
rel = '/'.join(fpcopy) |
|
119 |
||
0.11.3
by Jelmer Vernooij
Remove more unused functions, imports |
120 |
delta = tree1.changes_from(tree2, |
0.8.23
by Szilveszter Farkas (Phanatic)
Visual feedback when Olive is busy; follow bzr API changes; commit dialog update |
121 |
want_unchanged=True, |
122 |
specific_files=[rel]) |
|
0.8.18
by Szilveszter Farkas (Phanatic)
2006-07-20 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
123 |
|
0.8.13
by Szilveszter Farkas (Phanatic)
2006-07-17 Szilveszter Farkas <Szilveszter.Farkas@gmail.com> |
124 |
if len(delta.renamed): |
125 |
return 'renamed' |
|
126 |
elif len(delta.added): |
|
127 |
return 'added' |
|
128 |
elif len(delta.removed): |
|
129 |
return 'removed' |
|
130 |
elif len(delta.modified): |
|
131 |
return 'modified' |
|
132 |
elif len(delta.unchanged): |
|
133 |
return 'unchanged' |
|
134 |
else: |
|
135 |
return 'unknown' |