Debian Codegraph @

lib/revisionview.py

raw symbols SCIP
1 # QBrz - Qt frontend to Breezy commands
2 #
3 # Copyright (C) 2006-2007 Gary van der Merwe <[email protected]>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
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.
14 #
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 from PyQt5 import QtCore, QtWidgets
20
21 from breezy.plugins.qbrz.lib.diffwindow import DiffWindow
22 from breezy.plugins.qbrz.lib.diff_arg import InternalDiffArgProvider
23 from breezy.plugins.qbrz.lib.revisionmessagebrowser import RevisionMessageBrowser
24 from breezy.plugins.qbrz.lib.i18n import gettext
25 from breezy.plugins.qbrz.lib.lazycachedrevloader import load_revisions
26
27
28 # DiffWindow has alot of stuff that we need, so we just extend it.
29 class RevisionView(DiffWindow):
30 """Shows information, and a diff for a revision, in a window."""
31
32 def __init__(self, revid, branch, parent=None):
33 self.branch = branch
34 self.revid = revid
35
36 args = InternalDiffArgProvider(None, revid, branch, branch)
37 DiffWindow.__init__(self, args, parent, allow_refresh=False)
38
39 self.message_browser = RevisionMessageBrowser(self)
40 self.message_browser.set_display_revids([self.revid], branch.repository)
41
42 vsplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
43 vsplitter.addWidget(self.message_browser)
44 vsplitter.addWidget(self.stack)
45 vsplitter.setStretchFactor(0, 1)
46 vsplitter.setStretchFactor(1, 3)
47
48 self.centralwidget.layout().insertWidget(1, vsplitter)
49 self.centralwidget.layout().removeWidget(self.stack)
50
51 self.set_diff_title()
52
53 def initial_load(self):
54 self.throbber.show()
55 load_revisions([self.revid], self.branch.repository, pass_prev_loaded_rev=True, revisions_loaded=self.revisions_loaded)
56
57 def revisions_loaded(self, loaded_revs, last_call):
58 revision = loaded_revs[self.revid]
59 self.arg_provider.old_revid = revision.parent_ids[0]
60 super(RevisionView, self).initial_load()
61 self.throbber.hide()
62
63 def set_diff_title(self):
64 title = [gettext("Revision"), self.revid]
65 self.set_title_and_icon(title)
66
67 def restoreSize(self, name, defaultSize):
68 super(RevisionView, self).restoreSize("revisionview", defaultSize)