14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
21
pygtk.require("2.0")
26
from guifiles import GLADEFILENAME
33
import bzrlib.errors as errors
35
if bzrlib.version_info < (0, 9):
36
# function deprecated after 0.9
37
from bzrlib.delta import compare_trees
39
from bzrlib.status import show_tree_status
40
from bzrlib.workingtree import WorkingTree
42
from dialog import OliveDialog
30
45
""" Display Status window and perform the needed actions. """
31
def __init__(self, wt, wtpath):
46
def __init__(self, gladefile, comm, dialog):
32
47
""" Initialize the Status window. """
33
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_status')
48
self.gladefile = gladefile
49
self.glade = gtk.glade.XML(self.gladefile, 'window_status')
51
# Communication object
35
56
# Get the Status window widget
36
57
self.window = self.glade.get_widget('window_status')
41
59
# Check if current location is a branch
42
file_id = self.wt.path2id(wtpath)
61
(self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
62
branch = self.wt.branch
63
except errors.NotBranchError:
69
file_id = self.wt.path2id(path)
71
self.notbranch = False
44
76
# Set the old working tree
45
77
self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
66
98
column.add_attribute(cell, "text", 0)
67
99
self.treeview.append_column(column)
69
delta = self.wt.changes_from(self.old_tree)
101
if bzrlib.version_info < (0, 9):
102
delta = compare_trees(self.old_tree, self.wt)
104
delta = self.wt.changes_from(self.old_tree)
73
106
if len(delta.added):
75
107
titer = self.model.append(None, [ _('Added'), None ])
76
108
for path, id, kind in delta.added:
77
109
self.model.append(titer, [ path, path ])
79
111
if len(delta.removed):
81
112
titer = self.model.append(None, [ _('Removed'), None ])
82
113
for path, id, kind in delta.removed:
83
114
self.model.append(titer, [ path, path ])
85
116
if len(delta.renamed):
87
117
titer = self.model.append(None, [ _('Renamed'), None ])
88
118
for oldpath, newpath, id, kind, text_modified, meta_modified \
90
120
self.model.append(titer, [ oldpath, newpath ])
92
122
if len(delta.modified):
94
123
titer = self.model.append(None, [ _('Modified'), None ])
95
124
for path, id, kind, text_modified, meta_modified in delta.modified:
96
125
self.model.append(titer, [ path, path ])
98
127
done_unknown = False
99
128
for path in self.wt.unknowns():
101
129
if not done_unknown:
102
130
titer = self.model.append(None, [ _('Unknown'), None ])
103
131
done_unknown = True
104
132
self.model.append(titer, [ path, path ])
107
self.model.append(None, [ _('No changes.'), None ])
109
134
self.treeview.expand_all()
111
136
def display(self):
112
137
""" Display the Diff window. """
113
self.window.show_all()
139
self.dialog.error_dialog(_('Directory is not a branch'),
140
_('You can perform this action only in a branch.'))
143
self.window.show_all()
115
145
def close(self, widget=None):
116
146
self.window.destroy()