File: qctBzrPlugin.py

package info (click to toggle)
qct 1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 464 kB
  • ctags: 280
  • sloc: python: 3,592; makefile: 79
file content (70 lines) | stat: -rw-r--r-- 2,191 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Qct commit tool plugin for bazaar (bzr)
#
# Copyright 2006 Steve Borho <steve@borho.org>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
#
# To install, copy this file into ~/.bazaar/plugins

from bzrlib.commands import Command, register_command

class cmd_qct(Command):
    """Qt-based GUI Commit Tool
    
       This command will open a window from which you
       can browse all of the pending changes you have made
       to your branch.  You can then type in a commit log
       message and commit your changes to the repository.
       You can remove files from the commit list by de-selecting
       them in the file list.

       Keyboard Shortcuts:

       CTRL-O  - Commit selected files
       CTRL-R  - Refresh file list
       CTRL-N  - View diffs of next file in list
       CTRL-[] - Page up/down through file diffs
       CTRL-U  - Unselect all files
       CTRL-F  - Clear file filter text
       ESC     - Abort and exit
    """

    def run(self):
        from bzrlib.branch import Branch
        from bzrlib.errors import NoWorkingTree
        from bzrlib.workingtree import WorkingTree
        from bzrlib import urlutils

        import os
        from PyQt4 import QtCore, QtGui
        from qctlib.gui_logic import CommitTool
        from qctlib.vcs.bzr import qctVcsBzr

        def local_path(path):
            if path.startswith("file://"):
                return urlutils.local_path_from_url(path)
            else:
                return urlutils.unescape(path)

        try:
            branch = WorkingTree.open_containing(u'.')[0].branch
        except NoWorkingTree:
            branch = Branch.open_containing(u'.')[0]

        branch_root = branch.bzrdir.root_transport.base
        # print "Branch root at " + branch_root
        os.chdir(local_path(branch_root))
        vcs = qctVcsBzr()
        if vcs.initRepo(None) != 0:
            return

        try:
            app = QtGui.QApplication([])
            dialog = CommitTool(vcs)
            dialog.show()
            app.exec_()
        except SystemExit:
            pass

register_command(cmd_qct)