Changeset 3206
- Timestamp:
- 02/11/08 05:23:02 (10 months ago)
- Files:
-
- gitplugin/0.11/tracext/git/git_fs.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gitplugin/0.11/tracext/git/git_fs.py
r3205 r3206 14 14 15 15 from trac.core import * 16 from trac.util import TracError, shorten_line , escape17 from trac.util.datefmt import utc 16 from trac.util import TracError, shorten_line 17 from trac.util.datefmt import utc, FixedOffset 18 18 from trac.versioncontrol.api import \ 19 19 Changeset, Node, Repository, IRepositoryConnector, NoSuchChangeset, NoSuchNode … … 24 24 25 25 from genshi.builder import tag 26 from genshi.core import Markup, escape 26 27 27 28 from datetime import datetime … … 67 68 # relied upon by GitChangeset 68 69 70 _rendered_props = ('Parents','Children','git-committer','git-author') 71 69 72 def match_property(self, name, mode): 70 if (name in ('Parents','Children') and mode == 'revprop'): 73 if name in ('Parents','Children','git-committer','git-author') \ 74 and mode == 'revprop': 71 75 return 8 # default renderer has priority 1 72 76 return 0 73 77 74 78 def render_property(self, name, mode, context, props): 75 assert name in ('Parents','Children')76 77 revs = props[name]78 79 79 def sha_link(sha): 80 80 return self._format_sha_link(context, 'sha', sha, sha) 81 81 82 return tag([tag(sha_link(rev), ', ') for rev in revs[:-1]], 83 sha_link(revs[-1])) 84 82 if name in ('Parents','Children'): 83 revs = props[name] 84 85 return tag([tag(sha_link(rev), ', ') for rev in revs[:-1]], 86 sha_link(revs[-1])) 87 88 if name in ('git-committer', 'git-author'): 89 user_,time_ = props[name] 90 _str = user_ + " / " + time_.strftime('%Y-%m-%dT%H:%M:%SZ%z') 91 return unicode(_str) 92 93 raise TracError("internal error") 85 94 86 95 ####################### … … 330 339 } 331 340 341 # helper 342 def __parse_user_time(self, s): 343 """parse author/committer attribute lines and return 344 (user,timestamp)""" 345 (user,time,tz_str) = s.rsplit(None, 2) 346 tz = FixedOffset((int(tz_str)*6)/10, tz_str) 347 time = datetime.fromtimestamp(float(time), tz) 348 return (user,time) 349 332 350 def __init__(self, git, sha): 333 351 self.git = git … … 338 356 self.props = props 339 357 340 committer = props['committer'][0]341 342 358 assert 'children' not in props 343 359 _children = list(git.children(sha)) … … 345 361 props['children'] = _children 346 362 347 (user,time,tz) = committer.rsplit(None, 2)348 349 time = datetime.fromtimestamp(float(time), utc) 350 Changeset.__init__(self, sha, msg, user , time)363 # use 1st committer as changeset owner/timestamp 364 (user_, time_) = self.__parse_user_time(props['committer'][0]) 365 366 Changeset.__init__(self, sha, msg, user_, time_) 351 367 352 368 def get_properties(self): … … 357 373 properties['Children'] = self.props['children'] 358 374 if 'committer' in self.props: 359 properties['git-committer'] = "\n".join(self.props['committer']) 375 properties['git-committer'] = \ 376 self.__parse_user_time(self.props['committer'][0]) 360 377 if 'author' in self.props: 361 git_author = "\n".join(self.props['author'])378 git_author = self.__parse_user_time(self.props['author'][0]) 362 379 if not (properties.has_key('git-committer') and 363 380 properties['git-committer'] == git_author):
