Changeset 2 in tailor
- Timestamp:
- 06/01/04 16:05:59 (9 years ago)
- Hash name:
- 20040601140559-97f81-b669594864cb35290fbe4848e6645e73057a8caf
- Location:
- cvsync
- Files:
-
- 2 added
- 2 edited
-
svn.py (modified) (4 diffs)
-
tests/__init__.py (modified) (1 diff)
-
tests/svn.py (added)
-
tests/testrepo.dump (added)
Legend:
- Unmodified
- Added
- Removed
-
cvsync/svn.py
r1 r2 101 101 102 102 class SvnLog(SystemCommand): 103 COMMAND = "svn log --quiet --revision %(startrev)s:HEAD %(source)s" 103 COMMAND = "svn log %(quiet)s %(xml)s --revision %(startrev)s:%(endrev)s %(source)s" 104 105 def __call__(self, output=None, dry_run=False, **kwargs): 106 quiet = kwargs.get('quiet', True) 107 if quiet == True: 108 kwargs['quiet'] = '--quiet' 109 elif quiet == False: 110 kwargs['quiet'] = '' 111 112 xml = kwargs.get('xml', False) 113 if xml: 114 kwargs['xml'] = '--xml' 115 output = True 116 else: 117 kwargs['xml'] = '' 118 119 startrev = kwargs.get('startrev') 120 if not startrev: 121 kwargs['startrev'] = 'BASE' 122 123 endrev = kwargs.get('endrev') 124 if not endrev: 125 kwargs['endrev'] = 'HEAD' 126 127 output = SystemCommand.__call__(self, output=output, 128 dry_run=dry_run, **kwargs) 129 130 if xml: 131 # parse the output and return the result 132 pass 133 134 return output 104 135 105 136 … … 110 141 def getHeadRevision(source, baserev): 111 142 """Using ``svn log`` determine the HEAD revision of a source.""" 143 144 # XXX: this is, by any means, the worst of all the possible ways 145 # of getting this kind of information from the svn server, 146 # but I did not manage to get any of the others actually work. 112 147 113 148 svnlog = SvnLog() … … 119 154 return head 120 155 156 121 157 class SvnWorkingDir(object): 122 158 """Represent a SVN working directory.""" … … 137 173 else: 138 174 return mayberel 175 176 def log(self): 177 """Return an object representation of the ``svn log`` thru HEAD.""" 178 179 svnlog = SvnLog(working_dir=self.root) 180 out = svnlog(quiet='--verbose', output=True, xml=True, source='.') 181 182 from xml.sax import parseString 183 from xml.sax.handler import ContentHandler 184 185 class SvnRevisionLogEntry(object): 186 def __init__(self): 187 self.revision = 0 188 self.author = '' 189 self.date = '' 190 self.msg = '' 191 self.paths = [] 192 193 class SvnXMLLogHandler(ContentHandler): 194 def __init__(self): 195 self.revisions = [] 196 self.current = None 197 self.current_field = [] 198 199 def startElement(self, name, attributes): 200 if name == 'logentry': 201 self.current = SvnRevisionLogEntry() 202 self.current.revision = int(attributes['revision']) 203 elif name in ['author', 'date', 'msg']: 204 self.current_field = [] 205 elif name == 'path': 206 self.current_field = [] 207 if attributes.has_key('copyfrom-path'): 208 self.current_path_action = (attributes['action'], 209 attributes['copyfrom-path'], 210 attributes['copyfrom-rev']) 211 else: 212 self.current_path_action = attributes['action'] 213 214 215 def endElement(self, name): 216 if name == 'logentry': 217 self.revisions.append(self.current) 218 self.current = None 219 elif name in ['author', 'date', 'msg']: 220 setattr(self.current, name, ''.join(self.current_field)) 221 elif name == 'path': 222 self.current.paths.append( (''.join(self.current_field), 223 self.current_path_action) ) 224 225 def characters(self, data): 226 self.current_field.append(data) 227 228 handler = SvnXMLLogHandler() 229 parseString(out.getvalue(), handler) 230 return handler.revisions 139 231 140 232 def update(self): -
cvsync/tests/__init__.py
r1 r2 11 11 from cvs import * 12 12 from bice import * 13 from svn import * 13 14 14 15 SystemCommand.VERBOSE = False
Note: See TracChangeset
for help on using the changeset viewer.
