def update_repository(app, trans, id, **kwds):
 message = None
 flush_needed = False
 sa_session = app.model.context.current
 repository = sa_session.query(app.model.Repository).get(app.security.decode_id(id))
 if (repository is None):
  return (None, 'Unknown repository ID')
 if (not (trans.user_is_admin() or trans.app.security_agent.user_can_administer_repository(trans.user, repository))):
  message = 'You are not the owner of this repository, so you cannot administer it.'
  return (None, message)
 for key in ('type', 'description', 'long_description', 'remote_repository_url', 'homepage_url'):
  if ((key in kwds) and (kwds[key] is not None) and (kwds[key] != getattr(repository, key))):
   setattr(repository, key, kwds[key])
   flush_needed = True
 if (('category_ids' in kwds) and isinstance(kwds['category_ids'], list)):
  category_associations = sa_session.query(app.model.RepositoryCategoryAssociation).filter((app.model.RepositoryCategoryAssociation.table.c.repository_id == app.security.decode_id(id)))
  for rca in category_associations:
   sa_session.delete(rca)
  for category_id in kwds['category_ids']:
   category = sa_session.query(app.model.Category).get(app.security.decode_id(category_id))
   if category:
    rca = app.model.RepositoryCategoryAssociation(repository, category)
    sa_session.add(rca)
   else:
    pass
  flush_needed = True
 if (('name' in kwds) and (kwds['name'] is not None) and (repository.name != kwds['name'])):
  if (repository.times_downloaded != 0):
   message = 'Repository names cannot be changed if the repository has been cloned.'
  else:
   message = validate_repository_name(trans.app, kwds['name'], trans.user)
  if message:
   return (None, message)
  repo_dir = repository.repo_path(app)
  old_lhs = ('repos/%s/%s' % (repository.user.username, repository.name))
  new_lhs = ('repos/%s/%s' % (repository.user.username, kwds['name']))
  trans.app.hgweb_config_manager.change_entry(old_lhs, new_lhs, repo_dir)
  hgrc_file = os.path.join(repo_dir, '.hg', 'hgrc')
  change_repository_name_in_hgrc_file(hgrc_file, kwds['name'])
  repository_admin_role = repository.admin_role
  repository_admin_role.name = get_repository_admin_role_name(str(kwds['name']), str(repository.user.username))
  trans.sa_session.add(repository_admin_role)
  repository.name = kwds['name']
  flush_needed = True
 if flush_needed:
  trans.sa_session.add(repository)
  trans.sa_session.flush()
  message = 'The repository information has been updated.'
 else:
  message = None
 return (repository, message)

def update_repository ( app , trans , id , ** kwds ) : message = None flush_needed = False sa_session = app . model . context . current repository = sa_session . query ( app . model . Repository ) . get ( app . security . decode_id ( id ) ) if ( repository is None ) : return ( None , 'Unknown repository ID' ) if ( not ( trans . user_is_admin ( ) or trans . app . security_agent . user_can_administer_repository ( trans . user , repository ) ) ) : message = 'You are not the owner of this repository, so you cannot administer it.' return ( None , message ) for key in ( 'type' , 'description' , 'long_description' , 'remote_repository_url' , 'homepage_url' ) : if ( ( key in kwds ) and ( kwds [ key ] is not None ) and ( kwds [ key ] != getattr ( repository , key ) ) ) : setattr ( repository , key , kwds [ key ] ) flush_needed = True if ( ( 'category_ids' in kwds ) and isinstance ( kwds [ 'category_ids' ] , list ) ) : category_associations = sa_session . query ( app . model . RepositoryCategoryAssociation ) . filter ( ( app . model . RepositoryCategoryAssociation . table . c . repository_id == app . security . decode_id ( id ) ) ) for rca in category_associations : sa_session . delete ( rca ) for category_id in kwds [ 'category_ids' ] : category = sa_session . query ( app . model . Category ) . get ( app . security . decode_id ( category_id ) ) if category : rca = app . model . RepositoryCategoryAssociation ( repository , category ) sa_session . add ( rca ) else : pass flush_needed = True if ( ( 'name' in kwds ) and ( kwds [ 'name' ] is not None ) and ( repository . name != kwds [ 'name' ] ) ) : if ( repository . times_downloaded != 0 ) : message = 'Repository names cannot be changed if the repository has been cloned.' else : message = validate_repository_name ( trans . app , kwds [ 'name' ] , trans . user ) if message : return ( None , message ) repo_dir = repository . repo_path ( app ) old_lhs = ( 'repos/%s/%s' % ( repository . user . username , repository . name ) ) new_lhs = ( 'repos/%s/%s' % ( repository . user . username , kwds [ 'name' ] ) ) trans . app . hgweb_config_manager . change_entry ( old_lhs , new_lhs , repo_dir ) hgrc_file = os . path . join ( repo_dir , '.hg' , 'hgrc' ) change_repository_name_in_hgrc_file ( hgrc_file , kwds [ 'name' ] ) repository_admin_role = repository . admin_role repository_admin_role . name = get_repository_admin_role_name ( str ( kwds [ 'name' ] ) , str ( repository . user . username ) ) trans . sa_session . add ( repository_admin_role ) repository . name = kwds [ 'name' ] flush_needed = True if flush_needed : trans . sa_session . add ( repository ) trans . sa_session . flush ( ) message = 'The repository information has been updated.' else : message = None return ( repository , message )
update the cloned repository to changeset_revision .