def refresh_commit_info(self, oid, seen, lazy=True): from allura.model.repository import CommitDoc ci_doc = CommitDoc.m.get(_id=oid) if ci_doc and lazy: return False ci = self._git.rev_parse(oid) args = dict(tree_id=ci.tree.hexsha, committed=Object( name=h.really_unicode(ci.committer.name), email=h.really_unicode(ci.committer.email), date=datetime.utcfromtimestamp(ci.committed_date)), authored=Object(name=h.really_unicode(ci.author.name), email=h.really_unicode(ci.author.email), date=datetime.utcfromtimestamp( ci.authored_date)), message=h.really_unicode(ci.message or ''), child_ids=[], parent_ids=[p.hexsha for p in ci.parents]) if ci_doc: ci_doc.update(**args) ci_doc.m.save() else: ci_doc = CommitDoc(dict(args, _id=ci.hexsha)) try: ci_doc.m.insert(safe=True) except DuplicateKeyError: if lazy: return False self.refresh_tree_info(ci.tree, seen, lazy) return True
def refresh_commit_info(self, oid, seen_object_ids, lazy=True): from allura.model.repository import CommitDoc ci_doc = CommitDoc.m.get(_id=oid) if ci_doc and lazy: return False revno = self._revno(oid) rev = self._revision(oid) try: log_entry = self._svn.log(self._url, revision_start=rev, limit=1, discover_changed_paths=True)[0] except pysvn.ClientError: log.info('ClientError processing %r %r, treating as empty', oid, self._repo, exc_info=True) log_entry = Object(date='', message='', changed_paths=[]) log_date = None if hasattr(log_entry, 'date'): log_date = datetime.utcfromtimestamp(log_entry.date) user = Object(name=h.really_unicode(log_entry.get( 'author', '--none--')), email='', date=log_date) args = dict(tree_id=None, committed=user, authored=user, message=h.really_unicode( log_entry.get("message", "--none--")), parent_ids=[], child_ids=[]) if revno > 1: args['parent_ids'] = [self._oid(revno - 1)] if ci_doc: ci_doc.update(**args) ci_doc.m.save() else: ci_doc = CommitDoc(dict(args, _id=oid)) try: ci_doc.m.insert() except DuplicateKeyError: if lazy: return False return True