File: qct

package info (click to toggle)
qct 1.7-3.2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 504 kB
  • ctags: 306
  • sloc: python: 3,594; makefile: 80
file content (147 lines) | stat: -rw-r--r-- 4,988 bytes parent folder | download | duplicates (3)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python

# qct - Commit Tool
#
# Copyright 2006 Steve Borho
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

import sys, os
import getopt
from PyQt4 import QtGui
from qctlib.gui_logic import CommitTool

def show_help():
    'Show help'
    print '''Qct GUI Commit Tool

    Qct will attempt to auto-detect the repository you are running
    inside of, but will also accept a command line argument specifying
    the VCS back-end you intend to use.

    qct [ --hg | --p4 | --svn | --bzr | --cvs | --mtn | --cg ]
    qct [  -h  |  -4  |   -s  |  -b   |  -c   |  -m   ]
    qct [ --help | --version ]

    See the man page for more usage details and consult the INSTALL file for
    more detailed documentation about each VCS back-end.

    qct always tries to operate out of current directory, but in some
    instances it must move context to your repository root.

    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'''

# Standalone command line application

if __name__ == "__main__":
    # parse command line options
    opts = []
    try:
        opts, args = getopt.getopt(sys.argv[1:], "s4bghcmvu:",
                ["svn", "p4", "bzr", "hg", "cvs", "mtn", "version",
                    "help", "cg", "gui"])
    except getopt.error, msg:
        pass

    app = QtGui.QApplication(sys.argv)

    for o in opts:
        if o[0] == "--gui":
            class DirDialog(QtGui.QFileDialog):
                def __init__(self, parent=None):
                    QtGui.QFileDialog.__init__(self, parent)

                def show (self):
                    dialog = QtGui.QFileDialog.getExistingDirectory (self, 
                                                                     "Open Directory",
                                                                     "",
                                                                     QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontResolveSymlinks)

                    return dialog

            dirdialog = DirDialog()
            ret = dirdialog.show()
            os.chdir (ret)
            opts.remove (o)
            break
        
    vcs = None
    initRepoArgs = {}
    if len(opts) == 0:
        # default to auto-detect VCS back-end if no matches were found
        if os.path.exists('.hg/'):
            print "Auto-detected Mercurial repository"
            from qctlib.vcs.hg import qctVcsHg
            vcs = qctVcsHg()
        elif os.path.exists('.bzr/'):
            print "Auto-detected Bazaar repository"
            from qctlib.vcs.bzr import qctVcsBzr
            vcs = qctVcsBzr()
        elif os.path.exists('.svn/'):
            print "Auto-detected Subversion repository"
            from qctlib.vcs.svn import qctVcsSvn
            vcs = qctVcsSvn()
        elif os.path.exists('.git/'):
            print "Auto-detected Git (Cogito) repository"
            from qctlib.vcs.cg import qctVcsCg
            vcs = qctVcsCg()
        elif os.path.exists('_MTN/'):
            print "Auto-detected Monotone repository"
            from qctlib.vcs.mtn import qctVcsMtn
            vcs = qctVcsMtn()
        elif os.path.exists('CVS/'):
            print "Auto-detected CVS repository"
            from qctlib.vcs.cvs import qctVcsCvs
            vcs = qctVcsCvs()
        else:
            from qctlib.vcs.hg import qctVcsHg
            vcs = qctVcsHg()

    # process options
    for opt, arg in opts:
        if opt in ('--version', '-v'):
            from qctlib.version import qct_version
            print qct_version
        elif opt == '-u':
            initRepoArgs['username'] = arg
        elif opt == '--help':
            show_help()
        elif opt == '--cg':
            from qctlib.vcs.cg import qctVcsCg
            vcs = qctVcsCg()
        elif opt in ("-4", "--p4"):
            from qctlib.vcs.p4 import qctVcsP4
            vcs = qctVcsP4()
        elif opt in ("-h", "--hg"):
            from qctlib.vcs.hg import qctVcsHg
            vcs = qctVcsHg()
        elif opt in ("-b", "--bzr"):
            from qctlib.vcs.bzr import qctVcsBzr
            vcs = qctVcsBzr()
        elif opt in ("-s", "--svn"):
            from qctlib.vcs.svn import qctVcsSvn
            vcs = qctVcsSvn()
        elif opt in ("-c", "--cvs"):
            from qctlib.vcs.cvs import qctVcsCvs
            vcs = qctVcsCvs()
        elif opt in ("-m", "--mtn"):
            from qctlib.vcs.mtn import qctVcsMtn
            vcs = qctVcsMtn()

    if not vcs or vcs.initRepo(sys.argv, **initRepoArgs) != 0:
        sys.exit()

    # Now we know it's worth the trouble to open the GUI
        
    dialog = CommitTool(vcs)
    dialog.show()
    sys.exit(app.exec_())