Changeset 84550 in vbox for trunk/src/VBox/ValidationKit/testmanager/batch/vcs_import.py
- Timestamp:
- May 26, 2020 6:50:43 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/batch/vcs_import.py
r82968 r84550 2 2 # -*- coding: utf-8 -*- 3 3 # $Id$ 4 # pylint: disable=line-too-long5 4 6 5 """ … … 44 43 45 44 # Test Manager imports 46 from testmanager.core.db import TMDatabaseConnection; 47 from testmanager.core.vcsrevisions import VcsRevisionData, VcsRevisionLogic; 48 from common import utils; 45 from testmanager.config import g_kaBugTrackers; 46 from testmanager.core.db import TMDatabaseConnection; 47 from testmanager.core.vcsrevisions import VcsRevisionData, VcsRevisionLogic; 48 from testmanager.core.vcsbugreference import VcsBugReferenceData, VcsBugReferenceLogic; 49 from common import utils; 50 51 # Python 3 hacks: 52 if sys.version_info[0] >= 3: 53 long = int; # pylint: disable=redefined-builtin,invalid-name 54 49 55 50 56 class VcsImport(object): # pylint: disable=too-few-public-methods … … 52 58 Imports revision history from a VSC into the Test Manager database. 53 59 """ 60 61 class BugTracker(object): 62 def __init__(self, sDbName, sTag): 63 self.sDbName = sDbName; 64 self.sTag = sTag; 65 54 66 55 67 def __init__(self): … … 59 71 60 72 oParser = OptionParser() 61 oParser.add_option('-e', '--extra-option', dest = 'asExtraOptions', action = 'append', 73 oParser.add_option('-b', '--only-bug-refs', dest = 'fBugRefsOnly', action = 'store_true', 74 help = 'Only do bug references, not revisions.'); 75 oParser.add_option('-e', '--extra-option', dest = 'asExtraOptions', metavar = 'vcsoption', action = 'append', 62 76 help = 'Adds a extra option to the command retrieving the log.'); 63 77 oParser.add_option('-f', '--full', dest = 'fFull', action = 'store_true', … … 93 107 oDb = TMDatabaseConnection(); 94 108 oLogic = VcsRevisionLogic(oDb); 109 oBugLogic = VcsBugReferenceLogic(oDb); 95 110 96 111 # Where to start. 97 112 iStartRev = 0; 98 113 if not self.oConfig.fFull: 99 iStartRev = oLogic.getLastRevision(self.oConfig.sRepository); 114 if not self.oConfig.fBugRefsOnly: 115 iStartRev = oLogic.getLastRevision(self.oConfig.sRepository); 116 else: 117 iStartRev = oBugLogic.getLastRevision(self.oConfig.sRepository); 100 118 if iStartRev == 0: 101 119 iStartRev = self.oConfig.iStartRevision; … … 118 136 # Parse the XML and add the entries to the database. 119 137 oParser = ET.XMLParser(target = ET.TreeBuilder(), encoding = 'utf-8'); 120 oParser.feed(sLogXml.encode('utf-8')); # does its own decoding andprocessOutputChecked always gives us decoded utf-8 now.138 oParser.feed(sLogXml.encode('utf-8')); # Does its own decoding; processOutputChecked always gives us decoded utf-8 now. 121 139 oRoot = oParser.close(); 122 140 123 141 for oLogEntry in oRoot.findall('logentry'): 124 142 iRevision = int(oLogEntry.get('revision')); 125 sAuthor = oLogEntry.findtext('author' ).strip();143 sAuthor = oLogEntry.findtext('author', 'unspecified').strip(); # cvs2svn entries doesn't have an author. 126 144 sDate = oLogEntry.findtext('date').strip(); 127 sMessage = oLogEntry.findtext('msg', '').strip(); 145 sRawMsg = oLogEntry.findtext('msg', '').strip(); 146 sMessage = sRawMsg; 128 147 if sMessage == '': 129 148 sMessage = ' '; … … 133 152 utils.printOut(u'sDate=%s iRev=%u sAuthor=%s sMsg[%s]=%s' 134 153 % (sDate, iRevision, sAuthor, type(sMessage).__name__, sMessage)); 135 oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage); 136 oLogic.addVcsRevision(oData); 154 155 if not self.oConfig.fBugRefsOnly: 156 oData = VcsRevisionData().initFromValues(self.oConfig.sRepository, iRevision, sDate, sAuthor, sMessage); 157 oLogic.addVcsRevision(oData); 158 159 # Analyze the raw message looking for bug tracker references. 160 for sBugTrackerKey in g_kaBugTrackers: 161 oBugTracker = g_kaBugTrackers[sBugTrackerKey]; 162 for sTag in oBugTracker.asCommitTags: 163 off = sRawMsg.find(sTag); 164 while off >= 0: 165 off += len(sTag); 166 while off < len(sRawMsg) and sRawMsg[off].isspace(): 167 off += 1; 168 169 if off < len(sRawMsg) and sRawMsg[off].isdigit(): 170 offNum = off; 171 while off < len(sRawMsg) and sRawMsg[off].isdigit(): 172 off += 1; 173 try: 174 iBugNo = long(sRawMsg[offNum:off]); 175 except Exception as oXcpt: 176 utils.printErr(u'error! exception(r%s,"%s"): -> %s' % (iRevision, sRawMsg[offNum:off], oXcpt,)); 177 else: 178 if not self.oConfig.fQuiet: 179 utils.printOut(u' r%u -> sBugTracker=%s iBugNo=%s' 180 % (iRevision, oBugTracker.sDbId, iBugNo,)); 181 182 oBugData = VcsBugReferenceData().initFromValues(self.oConfig.sRepository, iRevision, 183 oBugTracker.sDbId, iBugNo); 184 oBugLogic.addVcsBugReference(oBugData); 185 186 # next 187 off = sRawMsg.find(sTag, off); 188 137 189 oDb.commit(); 138 190
Note:
See TracChangeset
for help on using the changeset viewer.