/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 commit/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2006-05-19 22:45:58 UTC
  • Revision ID: jelmer@samba.org-20060519224558-f252c67413e52989
Add framework for commit dialog

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
__version__ = "0.8"
 
18
__author__ = "Jelmer Vernooij <jelmer@samba.org>"
 
19
 
 
20
from bzrlib.workingtree import WorkingTree
 
21
from bzrlib.commands import Command, register_command
 
22
from bzrlib.commit import Commit
 
23
from bzrlib.errors import (BzrCommandError, PointlessCommit, ConflictsInTree, 
 
24
           StrictCommitFailed)
 
25
 
 
26
class cmd_gcommit(Command):
 
27
    """GTK+ commit dialog
 
28
 
 
29
    Graphical user interface for committing revisions"""
 
30
    
 
31
    takes_args = []
 
32
    takes_options = []
 
33
 
 
34
    def run(self, filename=None):
 
35
        import pygtk
 
36
        pygtk.require("2.0")
 
37
 
 
38
        try:
 
39
            import gtk
 
40
        except RuntimeError, e:
 
41
            if str(e) == "could not open display":
 
42
                raise NoDisplayError
 
43
 
 
44
        from gcommit import GCommitDialog
 
45
 
 
46
        (wt, path) = WorkingTree.open_containing(filename)
 
47
        branch = wt.branch
 
48
 
 
49
        file_id = wt.path2id(path)
 
50
 
 
51
        if file_id is None:
 
52
            raise NotVersionedError(filename)
 
53
 
 
54
        dialog = GCommitDialog()
 
55
        dialog.connect("destroy", lambda w: gtk.main_quit())
 
56
        dialog.set_title(path + " - Commit")
 
57
        dialog.show()
 
58
 
 
59
        gtk.main()
 
60
 
 
61
        Commit().commit(working_tree=wt,message=dialog.message,
 
62
                specific_files=dialog.specific_files)
 
63
 
 
64
register_command(cmd_gcommit)