Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

bugtraq: moved bugtraq from hgtk to util

Changeset ceb6119bdfa4

Parent b38306779932

by Lloyd Markle

Changes to 6 files · Browse files at ceb6119bdfa4 Showing diff from parent b38306779932 Diff from another changeset...

 
14
15
16
17
 
18
19
20
21
22
23
24
 
14
15
16
 
17
18
19
 
 
20
21
22
@@ -14,11 +14,9 @@
 from PyQt4.Qsci import QsciScintilla, QsciAPIs, QsciLexerMakefile    from tortoisehg.hgqt.i18n import _ -from tortoisehg.util import hglib, shlib, wconfig +from tortoisehg.util import hglib, shlib, wconfig, bugtraq  from tortoisehg.hgqt import qtlib, qscilib, status, cmdui, branchop, revpanel   -from tortoisehg.hgtk import bugtraq -  # Technical Debt for CommitWidget  # disable commit button while no message is entered or no files are selected  # qtlib decode failure dialog (ask for retry locale, suggest HGENCODING)
 
9
10
11
12
 
13
14
15
16
17
18
19
20
 
9
10
11
 
12
13
14
15
 
 
16
17
18
@@ -9,12 +9,10 @@
   from mercurial import ui, util, error   -from tortoisehg.util import hglib, settings, paths, wconfig, i18n +from tortoisehg.util import hglib, settings, paths, wconfig, i18n, bugtraq  from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt import qtlib, qscilib, thgrepo   -from tortoisehg.hgtk import bugtraq -  from PyQt4.QtCore import *  from PyQt4.QtGui import *  
Change 1 of 1 Show Entire File tortoisehg/​hgtk/​bugtraq.py Stacked
 
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -1,172 +0,0 @@
-from ctypes import * -import comtypes -import pythoncom -from comtypes import IUnknown, GUID, COMMETHOD, POINTER -from comtypes.typeinfo import ITypeInfo -from comtypes.client import CreateObject -from comtypes.automation import _midlSAFEARRAY -from _winreg import * - -class IBugTraqProvider(IUnknown): - _iid_ = GUID("{298B927C-7220-423C-B7B4-6E241F00CD93}") - _methods_ = [ - COMMETHOD([], HRESULT, "ValidateParameters", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), - COMMETHOD([], HRESULT, "GetLinkText", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), - COMMETHOD([], HRESULT, "GetCommitMessage", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['in'], comtypes.BSTR, "commonRoot"), - (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), - (['in'], comtypes.BSTR, "originalMessage"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) - ] - -class IBugTraqProvider2(IBugTraqProvider): - _iid_ = GUID("{C5C85E31-2F9B-4916-A7BA-8E27D481EE83}") - _methods_ = [ - COMMETHOD([], HRESULT, "GetCommitMessage2", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['in'], comtypes.BSTR, "commonURL"), - (['in'], comtypes.BSTR, "commonRoot"), - (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), - (['in'], comtypes.BSTR, "originalMessage"), - (['in'], comtypes.BSTR, "bugID"), - (['out'], POINTER(comtypes.BSTR), "bugIDOut"), - (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropNames"), - (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropValues"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), - COMMETHOD([], HRESULT, "CheckCommit", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['in'], comtypes.BSTR, "commonURL"), - (['in'], comtypes.BSTR, "commonRoot"), - (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), - (['in'], comtypes.BSTR, "commitMessage"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), - COMMETHOD([], HRESULT, "OnCommitFinished", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "commonRoot"), - (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), - (['in'], comtypes.BSTR, "logMessage"), - (['in'], comtypes.c_long, "revision"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), - COMMETHOD([], HRESULT, "HasOptions", - (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), - COMMETHOD([], HRESULT, "ShowOptionsDialog", - (['in'], comtypes.c_long, "hParentWnd"), - (['in'], comtypes.BSTR, "parameters"), - (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) - ] - - -class BugTraq: - #svnjiraguid = "{CF732FD7-AA8A-4E9D-9E15-025E4D1A7E9D}" - - def __init__(self, guid): - self.guid = guid - self.bugtr = None - - def _get_bugtraq_object(self): - if self.bugtr == None: - obj = CreateObject(self.guid) - try: - self.bugtr = obj.QueryInterface(IBugTraqProvider2) - except COMError: - return None - return self.bugtr - - def get_commit_message(self, parameters, logmessage): - commonurl = "" - commonroot = "" - bugid = "" - bstrarray = _midlSAFEARRAY(comtypes.BSTR) - pathlist = bstrarray.from_param(()) - - bugtr = self._get_bugtraq_object() - if self.supports_bugtraq2_interface(): - (bugid, revPropNames, revPropValues, newmessage) = bugtr.GetCommitMessage2( - 0, parameters, commonurl, commonroot, pathlist, logmessage, bugid) - else: - newmessage = bugtr.GetCommitMessage( - 0, parameters, commonroot, pathlist, logmessage) - - return newmessage - - def on_commit_finished(self, logmessage): - if not self.supports_bugtraq2_interface(): - return "" - - commonroot = "" - bstrarray = _midlSAFEARRAY(comtypes.BSTR) - pathlist = bstrarray.from_param(()) - - bugtr = self._get_bugtraq_object() - errormessage = bugtr.OnCommitFinished(0, commonroot, pathlist, - logmessage, 0) - return errormessage - - def show_options_dialog(self, options): - if not self.has_options(): - return "" - - bugtr = self._get_bugtraq_object() - options = bugtr.ShowOptionsDialog(0, options) - return options - - def has_options(self): - if not self.supports_bugtraq2_interface(): - return False - - bugtr = self._get_bugtraq_object() - return bugtr.HasOptions() != 0 - - def get_link_text(self, parameters): - bugtr = self._get_bugtraq_object() - return bugtr.GetLinkText(0, parameters) - - def supports_bugtraq2_interface(self): - bugtr = self._get_bugtraq_object() - try: - bugtr.HasOptions() - return True - except (ValueError, AttributeError): - return False - - -def get_issue_plugins(): - cm = pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr, - None, pythoncom.CLSCTX_INPROC,pythoncom.IID_ICatInformation) - CATID_BugTraqProvider = pythoncom.MakeIID( - "{3494FA92-B139-4730-9591-01135D5E7831}") - ret = [] - enumerator = cm.EnumClassesOfCategories((CATID_BugTraqProvider,),()) - while 1: - try: - clsid = enumerator.Next() - if clsid == (): - break - except pythoncom.com_error: - break - ret.extend(clsid) - return ret - -def get_plugin_name(clsid): - key = OpenKey(HKEY_CLASSES_ROOT, r"CLSID\%s" % clsid) - try: - keyvalue = QueryValueEx(key, None)[0] - except WindowsError: - keyvalue = None - key.Close() - return keyvalue - -def get_issue_plugins_with_names(): - pluginclsids = get_issue_plugins() - keyandnames = [(key, get_plugin_name(key)) for key in pluginclsids] - return [kn for kn in keyandnames if kn[1] is not None]
 
20
21
22
23
 
24
25
26
 
28
29
30
31
32
33
34
 
20
21
22
 
23
24
25
26
 
28
29
30
 
31
32
33
@@ -20,7 +20,7 @@
 from mercurial import hg, util, patch, cmdutil, extensions    from tortoisehg.util.i18n import _ -from tortoisehg.util import shlib, hglib, i18n +from tortoisehg.util import shlib, hglib, i18n, bugtraq    keep = i18n.keepgettext()   @@ -28,7 +28,6 @@
 from tortoisehg.hgtk.status import FM_PATH, FM_PATH_UTF8  from tortoisehg.hgtk import csinfo, gtklib, thgconfig, gdialog, hgcmd  from tortoisehg.hgtk import thgmq, textview -from tortoisehg.hgtk import bugtraq    class BranchOperationDialog(gtk.Dialog):   def __init__(self, branch, close, repo):
 
19
20
21
22
 
23
24
25
 
19
20
21
 
22
23
24
25
@@ -19,7 +19,7 @@
 from tortoisehg.hgtk import dialog, gdialog, gtklib, hgcmd    try: - from tortoisehg.hgtk import bugtraq + from tortoisehg.util import bugtraq   bugtraq.get_issue_plugins_with_names()  except ImportError:   bugtraq = None
Change 1 of 1 Show Entire File tortoisehg/​util/​bugtraq.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
@@ -0,0 +1,172 @@
+from ctypes import * +import comtypes +import pythoncom +from comtypes import IUnknown, GUID, COMMETHOD, POINTER +from comtypes.typeinfo import ITypeInfo +from comtypes.client import CreateObject +from comtypes.automation import _midlSAFEARRAY +from _winreg import * + +class IBugTraqProvider(IUnknown): + _iid_ = GUID("{298B927C-7220-423C-B7B4-6E241F00CD93}") + _methods_ = [ + COMMETHOD([], HRESULT, "ValidateParameters", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), + COMMETHOD([], HRESULT, "GetLinkText", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), + COMMETHOD([], HRESULT, "GetCommitMessage", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['in'], comtypes.BSTR, "commonRoot"), + (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), + (['in'], comtypes.BSTR, "originalMessage"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) + ] + +class IBugTraqProvider2(IBugTraqProvider): + _iid_ = GUID("{C5C85E31-2F9B-4916-A7BA-8E27D481EE83}") + _methods_ = [ + COMMETHOD([], HRESULT, "GetCommitMessage2", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['in'], comtypes.BSTR, "commonURL"), + (['in'], comtypes.BSTR, "commonRoot"), + (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), + (['in'], comtypes.BSTR, "originalMessage"), + (['in'], comtypes.BSTR, "bugID"), + (['out'], POINTER(comtypes.BSTR), "bugIDOut"), + (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropNames"), + (['out'], POINTER(_midlSAFEARRAY(comtypes.BSTR)), "revPropValues"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), + COMMETHOD([], HRESULT, "CheckCommit", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['in'], comtypes.BSTR, "commonURL"), + (['in'], comtypes.BSTR, "commonRoot"), + (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), + (['in'], comtypes.BSTR, "commitMessage"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), + COMMETHOD([], HRESULT, "OnCommitFinished", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "commonRoot"), + (['in'], _midlSAFEARRAY(comtypes.BSTR), "pathList"), + (['in'], comtypes.BSTR, "logMessage"), + (['in'], comtypes.c_long, "revision"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ), + COMMETHOD([], HRESULT, "HasOptions", + (['out', 'retval'], POINTER(comtypes.c_int16), "pRetVal") ), + COMMETHOD([], HRESULT, "ShowOptionsDialog", + (['in'], comtypes.c_long, "hParentWnd"), + (['in'], comtypes.BSTR, "parameters"), + (['out', 'retval'], POINTER(comtypes.BSTR), "pRetVal") ) + ] + + +class BugTraq: + #svnjiraguid = "{CF732FD7-AA8A-4E9D-9E15-025E4D1A7E9D}" + + def __init__(self, guid): + self.guid = guid + self.bugtr = None + + def _get_bugtraq_object(self): + if self.bugtr == None: + obj = CreateObject(self.guid) + try: + self.bugtr = obj.QueryInterface(IBugTraqProvider2) + except COMError: + return None + return self.bugtr + + def get_commit_message(self, parameters, logmessage): + commonurl = "" + commonroot = "" + bugid = "" + bstrarray = _midlSAFEARRAY(comtypes.BSTR) + pathlist = bstrarray.from_param(()) + + bugtr = self._get_bugtraq_object() + if self.supports_bugtraq2_interface(): + (bugid, revPropNames, revPropValues, newmessage) = bugtr.GetCommitMessage2( + 0, parameters, commonurl, commonroot, pathlist, logmessage, bugid) + else: + newmessage = bugtr.GetCommitMessage( + 0, parameters, commonroot, pathlist, logmessage) + + return newmessage + + def on_commit_finished(self, logmessage): + if not self.supports_bugtraq2_interface(): + return "" + + commonroot = "" + bstrarray = _midlSAFEARRAY(comtypes.BSTR) + pathlist = bstrarray.from_param(()) + + bugtr = self._get_bugtraq_object() + errormessage = bugtr.OnCommitFinished(0, commonroot, pathlist, + logmessage, 0) + return errormessage + + def show_options_dialog(self, options): + if not self.has_options(): + return "" + + bugtr = self._get_bugtraq_object() + options = bugtr.ShowOptionsDialog(0, options) + return options + + def has_options(self): + if not self.supports_bugtraq2_interface(): + return False + + bugtr = self._get_bugtraq_object() + return bugtr.HasOptions() != 0 + + def get_link_text(self, parameters): + bugtr = self._get_bugtraq_object() + return bugtr.GetLinkText(0, parameters) + + def supports_bugtraq2_interface(self): + bugtr = self._get_bugtraq_object() + try: + bugtr.HasOptions() + return True + except (ValueError, AttributeError): + return False + + +def get_issue_plugins(): + cm = pythoncom.CoCreateInstance(pythoncom.CLSID_StdComponentCategoriesMgr, + None, pythoncom.CLSCTX_INPROC,pythoncom.IID_ICatInformation) + CATID_BugTraqProvider = pythoncom.MakeIID( + "{3494FA92-B139-4730-9591-01135D5E7831}") + ret = [] + enumerator = cm.EnumClassesOfCategories((CATID_BugTraqProvider,),()) + while 1: + try: + clsid = enumerator.Next() + if clsid == (): + break + except pythoncom.com_error: + break + ret.extend(clsid) + return ret + +def get_plugin_name(clsid): + key = OpenKey(HKEY_CLASSES_ROOT, r"CLSID\%s" % clsid) + try: + keyvalue = QueryValueEx(key, None)[0] + except WindowsError: + keyvalue = None + key.Close() + return keyvalue + +def get_issue_plugins_with_names(): + pluginclsids = get_issue_plugins() + keyandnames = [(key, get_plugin_name(key)) for key in pluginclsids] + return [kn for kn in keyandnames if kn[1] is not None]