Changeset - b2c3d4568a5f
[Not reviewed]
Merge default
0 36 0
Mads Kiilerich (mads) - 3 years ago 2023-03-31 21:29:14
mads@kiilerich.com
Merge stable
10 files changed:
0 comments (0 inline, 0 general)
CONTRIBUTORS
Show inline comments
 
List of contributors to Kallithea project:
 

	
 
    Mads Kiilerich <mads@kiilerich.com> 2016-2023
 
    Manuel Jacob <me@manueljacob.de> 2019-2020 2022-2023
 
    Mathias De Mare <mathias.de_mare@nokia.com> 2023
 
    Asterios Dimitriou <steve@pci.gr> 2016-2017 2020 2022
 
    Jaime Marquínez Ferrándiz <weblate@jregistros.fastmail.net> 2022
 
    Louis Bertrand <louis.bertrand@durhamcollege.ca> 2022
 
    toras9000 <toras9000@gmail.com> 2022
 
    yzqzss <yzqzss@othing.xyz> 2022
 
    МАН69К <weblate@mah69k.net> 2022
 
    Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 2014-2021
 
    Mads Kiilerich <mads@kiilerich.com> 2016-2021
 
    ssantos <ssantos@web.de> 2018-2021
 
    Private <adamantine.sword@gmail.com> 2019-2021
 
    Étienne Gilli <etienne@gilli.io> 2020-2021
 
    fresh <fresh190@protonmail.com> 2020-2021
 
    robertus <robertuss12@gmail.com> 2020-2021
 
    Eugenia Russell <eugenia.russell2019@gmail.com> 2021
 
    Michalis <michalisntovas@yahoo.gr> 2021
 
    vs <vsuhachev@yandex.ru> 2021
 
    Александр <akonn7@mail.ru> 2021
 
    Asterios Dimitriou <steve@pci.gr> 2016-2017 2020
 
    Allan Nordhøy <epost@anotheragency.no> 2017-2020
 
    Anton Schur <tonich.sh@gmail.com> 2017 2020
 
    Manuel Jacob <me@manueljacob.de> 2019-2020
 
    Artem <kovalevartem.ru@gmail.com> 2020
 
    David Ignjić <ignjic@gmail.com> 2020
 
    Dennis Fink <dennis.fink@c3l.lu> 2020
 
    J. Lavoie <j.lavoie@net-c.ca> 2020
 
    Ross Thomas <ross@lns-nevasoft.com> 2020
 
    Tim Ooms <tatankat@users.noreply.github.com> 2020
 
    Andrej Shadura <andrew@shadura.me> 2012 2014-2017 2019
 
    Étienne Gilli <etienne.gilli@gmail.com> 2015-2017 2019
 
    Adi Kriegisch <adi@cg.tuwien.ac.at> 2019
 
    Danni Randeris <danniranderis@gmail.com> 2019
 
    Edmund Wong <ewong@crazy-cat.org> 2019
 
    Elizabeth Sherrock <lizzyd710@gmail.com> 2019
 
    Hüseyin Tunç <huseyin.tunc@bulutfon.com> 2019
 
    leela <53352@protonmail.com> 2019
 
    Mateusz Mendel <mendelm9@gmail.com> 2019
 
    Nathan <bonnemainsnathan@gmail.com> 2019
 
    Oleksandr Shtalinberg <o.shtalinberg@gmail.com> 2019
 
    THANOS SIOURDAKIS <siourdakisthanos@gmail.com> 2019
 
    Wolfgang Scherer <wolfgang.scherer@gmx.de> 2019
 
    Христо Станев <hstanev@gmail.com> 2019
 
    Dominik Ruf <dominikruf@gmail.com> 2012 2014-2018
 
    Michal Čihař <michal@cihar.com> 2014-2015 2018
 
    Branko Majic <branko@majic.rs> 2015 2018
 
    Chris Rule <crule@aegistg.com> 2018
docs/api/api.rst
Show inline comments
 
@@ -2,49 +2,49 @@
 

	
 
===
 
API
 
===
 

	
 
Kallithea has a simple JSON RPC API with a single schema for calling all API
 
methods. Everything is available by sending JSON encoded http(s) requests to
 
``<your_server>/_admin/api``.
 

	
 

	
 
API keys
 
--------
 

	
 
Every Kallithea user automatically receives an API key, which they can
 
view under "My Account". On this page, API keys can also be revoked, and
 
additional API keys can be generated.
 

	
 

	
 
API access
 
----------
 

	
 
Clients must send JSON encoded JSON-RPC requests::
 

	
 
    {
 
        "id: "<id>",
 
        "id": "<id>",
 
        "api_key": "<api_key>",
 
        "method": "<method_name>",
 
        "args": {"<arg_key>": "<arg_val>"}
 
    }
 

	
 
For example, to pull to a local "CPython" mirror using curl::
 

	
 
    curl https://kallithea.example.com/_admin/api -X POST -H 'content-type:text/plain' \
 
        --data-binary '{"id":1,"api_key":"xe7cdb2v278e4evbdf5vs04v832v0efvcbcve4a3","method":"pull","args":{"repoid":"CPython"}}'
 

	
 
In general, provide
 
 - *id*, a value of any type, can be used to match the response with the request that it is replying to.
 
 - *api_key*, for authentication and permission validation.
 
 - *method*, the name of the method to call -- a list of available methods can be found below.
 
 - *args*, the arguments to pass to the method.
 

	
 
.. note::
 

	
 
    api_key can be found or set on the user account page.
 

	
 
The response to the JSON-RPC API call will always be a JSON structure::
 

	
 
    {
 
        "id": <id>,  # the id that was used in the request
 
@@ -94,1158 +94,1317 @@ so you don't have to specify them every 
 
API methods
 
-----------
 

	
 

	
 
pull
 
^^^^
 

	
 
Pull the given repo from remote location. Can be used to automatically keep
 
remote repos up to date.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "pull"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : "Pulled from `<reponame>`"
 
    error :  null
 
    error : null
 

	
 
rescan_repos
 
^^^^^^^^^^^^
 

	
 
Rescan repositories. If ``remove_obsolete`` is set,
 
Kallithea will delete repos that are in the database but not in the filesystem.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "rescan_repos"
 
    args :    {
 
                "remove_obsolete" : "<boolean = Optional(False)>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : "{'added': [<list of names of added repos>],
 
               'removed': [<list of names of removed repos>]}"
 
    error :  null
 
    error : null
 

	
 
invalidate_cache
 
^^^^^^^^^^^^^^^^
 

	
 
Invalidate the cache for a repository.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with admin or write access to the repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "invalidate_cache"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : "Caches of repository `<reponame>`"
 
    error :  null
 
    error : null
 

	
 
get_ip
 
^^^^^^
 

	
 
Return IP address as seen from Kallithea server, together with all
 
defined IP addresses for given user.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_ip"
 
    args :    {
 
                "userid" : "<user_id or username>",
 
                "userid" : "<user_id or username>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
                 "ip_addr_server": <ip_from_clien>",
 
                 "user_ips": [
 
                 "ip_addr_server" : <ip_from_client>",
 
                 "user_ips" : [
 
                                {
 
                                   "ip_addr": "<ip_with_mask>",
 
                                   "ip_range": ["<start_ip>", "<end_ip>"],
 
                                   "ip_addr" : "<ip_with_mask>",
 
                                   "ip_range" : ["<start_ip>", "<end_ip>"]
 
                                },
 
                                ...
 
                             ]
 
                              ]
 
             }
 

	
 
    error :  null
 
    error : null
 

	
 
get_user
 
^^^^^^^^
 

	
 
Get a user by username or userid. The result is empty if user can't be found.
 
If userid param is skipped, it is set to id of user who is calling this method.
 
Any userid can be specified when the command is executed using the api_key of a user with admin rights.
 
Regular users can only specify their own userid.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_user"
 
    args :    {
 
                "userid" : "<username or user_id Optional(=apiuser)>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: None if user does not exist or
 
            {
 
    result : None if user does not exist or
 
             {
 
                "user_id" :     "<user_id>",
 
                "api_key" :     "<api_key>",
 
                "username" :    "<username>",
 
                "firstname":    "<firstname>",
 
                "firstname" :   "<firstname>",
 
                "lastname" :    "<lastname>",
 
                "email" :       "<email>",
 
                "emails":       "<list_of_all_additional_emails>",
 
                "emails" :      "<list_of_all_additional_emails>",
 
                "ip_addresses": "<list_of_ip_addresses_for_user>",
 
                "active" :      "<bool>",
 
                "admin" :       "<bool>",
 
                "admin" :       "<bool>",
 
                "ldap_dn" :     "<ldap_dn>",
 
                "last_login":   "<last_login>",
 
                "last_login" :  "<last_login>",
 
                "permissions": {
 
                    "global": ["hg.create.repository",
 
                               "repository.read",
 
                               "hg.register.manual_activate"],
 
                    "repositories": {"repo1": "repository.none"},
 
                    "repositories_groups": {"Group1": "group.read"}
 
                 },
 
            }
 
    error:  null
 
                    "repositories" : {"repo1" : "repository.none"},
 
                    "repositories_groups" : {"Group1" : "group.read"}
 
                 }
 
             }
 
    error : null
 

	
 
get_users
 
^^^^^^^^^
 

	
 
List all existing users.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_users"
 
    args :    { }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: [
 
    result : [
 
              {
 
                "user_id" :     "<user_id>",
 
                "api_key" :     "<api_key>",
 
                "username" :    "<username>",
 
                "firstname":    "<firstname>",
 
                "firstname" :   "<firstname>",
 
                "lastname" :    "<lastname>",
 
                "email" :       "<email>",
 
                "emails":       "<list_of_all_additional_emails>",
 
                "emails" :      "<list_of_all_additional_emails>",
 
                "ip_addresses": "<list_of_ip_addresses_for_user>",
 
                "active" :      "<bool>",
 
                "admin" :       "<bool>",
 
                "admin" :       "<bool>",
 
                "ldap_dn" :     "<ldap_dn>",
 
                "last_login":   "<last_login>",
 
                "last_login" :  "<last_login>"
 
              },
 
 
            ]
 
    error:  null
 
             ]
 
    error : null
 

	
 
.. _create-user:
 

	
 
create_user
 
^^^^^^^^^^^
 

	
 
Create new user.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "create_user"
 
    args :    {
 
                "username" :  "<username>",
 
                "email" :     "<useremail>",
 
                "password" :  "<password = Optional(None)>",
 
                "firstname" : "<firstname> = Optional(None)",
 
                "lastname" :  "<lastname> = Optional(None)",
 
                "active" :    "<bool> = Optional(True)",
 
                "admin" :     "<bool> = Optional(False)",
 
                "ldap_dn" :   "<ldap_dn> = Optional(None)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "created new user `<username>`",
 
              "user": {
 
              "user" : {
 
                "user_id" :  "<user_id>",
 
                "username" : "<username>",
 
                "firstname": "<firstname>",
 
                "lastname" : "<lastname>",
 
                "email" :    "<email>",
 
                "emails":    "<list_of_all_additional_emails>",
 
                "emails" :   "<list_of_all_additional_emails>",
 
                "active" :   "<bool>",
 
                "admin" :    "<bool>",
 
                "admin" :    "<bool>",
 
                "ldap_dn" :  "<ldap_dn>",
 
                "last_login": "<last_login>",
 
              },
 
            }
 
    error:  null
 
                "last_login": "<last_login>"
 
              }
 
             }
 
    error : null
 

	
 
Example::
 

	
 
    kallithea-api create_user username:bent email:bent@example.com firstname:Bent lastname:Bentsen extern_type:ldap extern_name:uid=bent,dc=example,dc=com
 

	
 
update_user
 
^^^^^^^^^^^
 

	
 
Update the given user if such user exists.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "update_user"
 
    args :    {
 
                "userid" : "<user_id or username>",
 
                "username" :  "<username> = Optional(None)",
 
                "email" :     "<useremail> = Optional(None)",
 
                "password" :  "<password> = Optional(None)",
 
                "firstname" : "<firstname> = Optional(None)",
 
                "lastname" :  "<lastname> = Optional(None)",
 
                "active" :    "<bool> = Optional(None)",
 
                "admin" :     "<bool> = Optional(None)",
 
                "ldap_dn" :   "<ldap_dn> = Optional(None)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "updated user ID:<userid> <username>",
 
              "user": {
 
              "user" : {
 
                "user_id" :  "<user_id>",
 
                "api_key" :  "<api_key>",
 
                "username" : "<username>",
 
                "firstname": "<firstname>",
 
                "lastname" : "<lastname>",
 
                "email" :    "<email>",
 
                "emails":    "<list_of_all_additional_emails>",
 
                "emails" :   "<list_of_all_additional_emails>",
 
                "active" :   "<bool>",
 
                "admin" :    "<bool>",
 
                "admin" :    "<bool>",
 
                "ldap_dn" :  "<ldap_dn>",
 
                "last_login": "<last_login>",
 
              },
 
            }
 
    error:  null
 
                "last_login": "<last_login>"
 
              }
 
             }
 
    error : null
 

	
 
delete_user
 
^^^^^^^^^^^
 

	
 
Delete the given user if such a user exists.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "delete_user"
 
    args :    {
 
                "userid" : "<user_id or username>",
 
                "userid" : "<user_id or username>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "deleted user ID:<userid> <username>",
 
              "user": null
 
            }
 
    error:  null
 
              "user" : null
 
             }
 
    error : null
 

	
 
get_user_group
 
^^^^^^^^^^^^^^
 

	
 
Get an existing user group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_user_group"
 
    args :    {
 
                "usergroupid" : "<user group id or name>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : None if group not exist
 
             {
 
               "users_group_id" : "<id>",
 
               "group_name" :     "<groupname>",
 
               "active":          "<bool>",
 
               "active" :         "<bool>",
 
               "members" :  [
 
                              {
 
                                "user_id" :  "<user_id>",
 
                                "api_key" :  "<api_key>",
 
                                "username" : "<username>",
 
                                "firstname": "<firstname>",
 
                                "lastname" : "<lastname>",
 
                                "email" :    "<email>",
 
                                "emails":    "<list_of_all_additional_emails>",
 
                                "emails" :   "<list_of_all_additional_emails>",
 
                                "active" :   "<bool>",
 
                                "admin" :    "<bool>",
 
                                "admin" :    "<bool>",
 
                                "ldap_dn" :  "<ldap_dn>",
 
                                "last_login": "<last_login>",
 
                                "last_login": "<last_login>"
 
                              },
 
 
                            ]
 
             }
 
    error : null
 

	
 
get_user_groups
 
^^^^^^^^^^^^^^^
 

	
 
List all existing user groups.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_user_groups"
 
    args :    { }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : [
 
               {
 
               "users_group_id" : "<id>",
 
               "group_name" :     "<groupname>",
 
               "active":          "<bool>",
 
               "active" :         "<bool>"
 
               },
 
 
              ]
 
    error : null
 

	
 
create_user_group
 
^^^^^^^^^^^^^^^^^
 

	
 
Create a new user group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "create_user_group"
 
    args:     {
 
    args :    {
 
                "group_name": "<groupname>",
 
                "owner" :     "<owner_name_or_id = Optional(=apiuser)>",
 
                "active":     "<bool> = Optional(True)"
 
                "active" :    "<bool> = Optional(True)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "msg": "created new user group `<groupname>`",
 
              "users_group": {
 
    result : {
 
              "msg" : "created new user group `<groupname>`",
 
              "users_group" : {
 
                     "users_group_id" : "<id>",
 
                     "group_name" :     "<groupname>",
 
                     "active":          "<bool>",
 
               },
 
            }
 
    error:  null
 
                     "active" :         "<bool>"
 
               }
 
             }
 
    error : null
 

	
 
add_user_to_user_group
 
^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Adds a user to a user group. If the user already is in that group, success will be
 
Add a user to a user group. If the user already is in that group, success will be
 
``false``.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "add_user_user_group"
 
    args:     {
 
    args :    {
 
                "usersgroupid" : "<user group id or name>",
 
                "userid" : "<user_id or username>",
 
                "userid" : "<user_id or username>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "success": True|False # depends on if member is in group
 
              "msg": "added member `<username>` to a user group `<groupname>` |
 
                      User is already in that group"
 
            }
 
    error:  null
 
    result : {
 
              "success" : True|False,  # depends on if member is in group
 
              "msg" : "added member `<username>` to a user group `<groupname>` |
 
                       User is already in that group"
 
             }
 
    error : null
 

	
 
remove_user_from_user_group
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Remove a user from a user group. If the user isn't in the given group, success will
 
be ``false``.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "remove_user_from_user_group"
 
    args:     {
 
    args :    {
 
                "usersgroupid" : "<user group id or name>",
 
                "userid" : "<user_id or username>",
 
                "userid" : "<user_id or username>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
              "success" : True|False,  # depends on if member is in group
 
              "msg" : "removed member <username> from user group <groupname> |
 
                       User wasn't in group"
 
             }
 
    error : null
 

	
 
get_repo_group
 
^^^^^^^^^^^^^^
 

	
 
Get an existing repository group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo_group"
 
    args :    {
 
                "repogroupid" : "<repo group id or name>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "success":  True|False,  # depends on if member is in group
 
              "msg": "removed member <username> from user group <groupname> |
 
                      User wasn't in group"
 
            }
 
    error:  null
 
    result :
 
               {
 
               "group_id" :          "<id>",
 
               "group_name" :        "<groupname>",
 
               "group_description" : "<groupdescription>",
 
               "parent_group" :      "<groupid>"|null,
 
               "repositories" :      "<list_of_all_repo_names_in_group>",
 
               "owner" :             "<owner>",
 
               "members" :           [
 
                                       {
 
                                         "name" : "<name>",
 
                                         "type" : "user",
 
                                         "permission" : "group.(none|read|write|admin)"
 
                                       },
 
                                       {
 
                                         "name" : "<name>",
 
                                         "type" : "user_group",
 
                                         "permission" : "group.(none|read|write|admin)"
 
                                       },
 
 
                                     ]
 

	
 
               },
 
    error : null
 

	
 
get_repo_groups
 
^^^^^^^^^^^^^^^
 

	
 
List all existing repository groups.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo_groups"
 
    args :    { }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : [
 
               {
 
               "group_id" :          "<id>",
 
               "group_name" :        "<groupname>",
 
               "group_description" : "<groupdescription>",
 
               "parent_group" :      "<groupid>"|null,
 
               "repositories" :      "<list_of_all_repo_names_in_group>",
 
               "owner" :             "<owner>"
 
               },
 
 
              ]
 
    error : null
 

	
 
create_repo_group
 
^^^^^^^^^^^^^^^^^
 

	
 
Create a new repository group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "create_repo_group"
 
    args :    {
 
                "group_name" :       "<group_name>",
 
                "description" :      "<description> = Optional("")",
 
                "owner" :            "<username or user_id> = Optional(None)",
 
                "parent" :           "<reponame or id> = Optional(None)",
 
                "copy_permissions" : "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
                "msg" : "created new repo group `<group_name>`",
 
                "repo_group" : {
 
                                 "group_id" :          <id>,
 
                                 "group_name" :        "<parent_group>/<group_name>",
 
                                 "group_description" : "<description>",
 
                                 "parent_group" :      <id>|null,
 
                                 "repositories" :      <list of repositories>,
 
                                 "owner" :             "<user_name>"
 
                                }
 

	
 
update_repo_group
 
^^^^^^^^^^^^^^^^^
 

	
 
Update a repository group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "update_repo_group"
 
    args :    {
 
                "repogroupid" :         "<id>",
 
                "group_name" :       "<group_name> = Optional(None)",
 
                "description" :      "<description> = Optional(None)",
 
                "owner" :            "<username or user_id> = Optional(None)",
 
                "parent" :           "<reponame or id> = Optional(None)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
                "msg" : "updated repository group ID:<id> <group_name>",
 
                "repo_group" : {
 
                                 "group_id" :          <id>,
 
                                 "group_name" :        "<parent_group>/<group_name>",
 
                                 "group_description" : "<description>",
 
                                 "parent_group" :      <id>|null,
 
                                 "repositories" :      <list of repositories>,
 
                                 "owner" :             "<user_name>"
 
                                }
 

	
 
delete_repo_group
 
^^^^^^^^^^^^^^^^^
 

	
 
Delete a repository group.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "delete_repo_group"
 
    args :    {
 
                "repogroupid" : "<id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result : {
 
                "msg" : "deleted repo group ID:<id> <group_name>",
 
                "repo_group" : null
 
              }
 

	
 
get_repo
 
^^^^^^^^
 

	
 
Get an existing repository by its name or repository_id. Members will contain
 
either users_group or users associated to that repository.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with at least read access to the repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo"
 
    args:     {
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "with_revision_names": "<bool> = Optional(False)",
 
                "with_pullrequests": "<bool> = Optional(False)",
 
                "with_revision_names" : "<bool> = Optional(False)",
 
                "with_pullrequests" : "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: None if repository does not exist or
 
            {
 
    result : None if repository does not exist or
 
             {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "enable_downloads":  "<bool>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>",
 
                "private":           "<bool>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<date_time_created>",
 
                "description" :      "<description>",
 
                "landing_rev":       "<landing_rev>",
 
                "last_changeset":    {
 
                                       "author":   "<full_author>",
 
                                       "date":     "<date_time_of_commit>",
 
                                       "message":  "<commit_message>",
 
                                       "raw_id":   "<raw_id>",
 
                                       "revision": "<numeric_revision>",
 
                                       "short_id": "<short_id>"
 
                "landing_rev" :      "<landing_rev>",
 
                "last_changeset" :   {
 
                                         "author" :  "<full_author>",
 
                                         "date" :    "<date_time_of_commit>",
 
                                         "message" : "<commit_message>",
 
                                         "raw_id" :  "<raw_id>",
 
                                         "revision": "<numeric_revision>",
 
                                         "short_id": "<short_id>"
 
                                     },
 
                "owner":             "<repo_owner>",
 
                "fork_of":           "<name_of_fork_parent>",
 
                "members" :     [
 
                "owner" :            "<repo_owner>",
 
                "fork_of" :          "<name_of_fork_parent>",
 
                "members" :   [
 
                                  {
 
                                    "type":        "user",
 
                                    "type" :       "user",
 
                                    "user_id" :    "<user_id>",
 
                                    "api_key" :    "<api_key>",
 
                                    "username" :   "<username>",
 
                                    "firstname":   "<firstname>",
 
                                    "firstname" :  "<firstname>",
 
                                    "lastname" :   "<lastname>",
 
                                    "email" :      "<email>",
 
                                    "emails":      "<list_of_all_additional_emails>",
 
                                    "emails" :     "<list_of_all_additional_emails>",
 
                                    "active" :     "<bool>",
 
                                    "admin" :      "<bool>",
 
                                    "admin" :      "<bool>",
 
                                    "ldap_dn" :    "<ldap_dn>",
 
                                    "last_login":  "<last_login>",
 
                                    "last_login" : "<last_login>",
 
                                    "permission" : "repository.(read|write|admin)"
 
                                  },
 
 
                                  {
 
                                    "type":      "users_group",
 
                                    "type" :     "users_group",
 
                                    "id" :       "<usersgroupid>",
 
                                    "name" :     "<usersgroupname>",
 
                                    "active":    "<bool>",
 
                                    "active" :   "<bool>",
 
                                    "permission" : "repository.(read|write|admin)"
 
                                  },
 
 
                                ],
 
                 "followers":   [
 
                              ],
 
                "followers" : [
 
                                  {
 
                                    "user_id" :     "<user_id>",
 
                                    "username" :    "<username>",
 
                                    "api_key" :     "<api_key>",
 
                                    "firstname":    "<firstname>",
 
                                    "firstname" :   "<firstname>",
 
                                    "lastname" :    "<lastname>",
 
                                    "email" :       "<email>",
 
                                    "emails":       "<list_of_all_additional_emails>",
 
                                    "emails" :      "<list_of_all_additional_emails>",
 
                                    "ip_addresses": "<list_of_ip_addresses_for_user>",
 
                                    "active" :      "<bool>",
 
                                    "admin" :       "<bool>",
 
                                    "admin" :       "<bool>",
 
                                    "ldap_dn" :     "<ldap_dn>",
 
                                    "last_login":   "<last_login>",
 
                                    "last_login" :  "<last_login>"
 
                                  },
 
 
                                ],
 
                 <if with_revision_names == True>
 
                 "tags": {
 
                            "<tagname>": "<raw_id>",
 
                              ],
 
                <if with_revision_names == True>
 
                "tags" : {
 
                            "<tagname>" : "<raw_id>",
 
                            ...
 
                         },
 
                 "branches": {
 
                            "<branchname>": "<raw_id>",
 
                        },
 
                "branches" : {
 
                            "<branchname>" : "<raw_id>",
 
                            ...
 
                         },
 
                 "bookmarks": {
 
                            "<bookmarkname>": "<raw_id>",
 
                        },
 
                "bookmarks" : {
 
                            "<bookmarkname>" : "<raw_id>",
 
                            ...
 
                         },
 
                        },
 
                <if with_pullrequests == True>
 
                "pull_requests": [
 
                "pull_requests" : [
 
                  {
 
                    "status": "<pull_request_status>",
 
                    "pull_request_id": <pull_request_id>,
 
                    "description": "<pull_request_description>",
 
                    "title": "<pull_request_title>",
 
                    "url": "<pull_request_url>",
 
                    "reviewers": [
 
                    "status" : "<pull_request_status>",
 
                    "pull_request_id" : <pull_request_id>,
 
                    "description" : "<pull_request_description>",
 
                    "title" : "<pull_request_title>",
 
                    "url" : "<pull_request_url>",
 
                    "reviewers" : [
 
                      {
 
                        "username": "<user_id>",
 
                        "username" : "<user_id>"
 
                      },
 
                      ...
 
                    ],
 
                    "org_repo_url": "<repo_url>",
 
                    "org_ref_parts": [
 
                    "org_repo_url" : "<repo_url>",
 
                    "org_ref_parts" : [
 
                      "<ref_type>",
 
                      "<ref_name>",
 
                      "<raw_id>"
 
                    ],
 
                    "other_ref_parts": [
 
                    "other_ref_parts" : [
 
                      "<ref_type>",
 
                      "<ref_name>",
 
                      "<raw_id>"
 
                    ],
 
                    "comments": [
 
                    "comments" : [
 
                      {
 
                        "username": "<user_id>",
 
                        "text": "<comment text>",
 
                        "comment_id": "<comment_id>",
 
                        "username" : "<user_id>",
 
                        "text" : "<comment text>",
 
                        "comment_id" : "<comment_id>"
 
                      },
 
                      ...
 
                    ],
 
                    "owner": "<username>",
 
                    "statuses": [
 
                    "owner" : "<username>",
 
                    "statuses" : [
 
                      {
 
                        "status": "<status_of_review>",        # "under_review", "approved" or "rejected"
 
                        "reviewer": "<user_id>",
 
                        "modified_at": "<date_time_of_review>" # iso 8601 date, server's timezone
 
                        "status" : "<status_of_review>",        # "under_review", "approved" or "rejected"
 
                        "reviewer" : "<user_id>",
 
                        "modified_at" : "<date_time_of_review>" # iso 8601 date, server's timezone
 
                      },
 
                      ...
 
                    ],
 
                    "revisions": [
 
                    "revisions" : [
 
                      "<raw_id>",
 
                      ...
 
                    ]
 
                  },
 
                  ...
 
                ]
 
            }
 
    error:  null
 
             }
 
    error : null
 

	
 
get_repos
 
^^^^^^^^^
 

	
 
List all existing repositories.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with at least read access to the repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repos"
 
    args:     { }
 
    args :    { }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: [
 
    result : [
 
              {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<datetimecreated>",
 
                "description" :      "<description>",
 
                "landing_rev":       "<landing_rev>",
 
                "owner":             "<repo_owner>",
 
                "fork_of":           "<name_of_fork_parent>",
 
                "enable_downloads":  "<bool>",
 
                "enable_statistics": "<bool>",
 
                "landing_rev" :      "<landing_rev>",
 
                "owner" :            "<repo_owner>",
 
                "fork_of" :          "<name_of_fork_parent>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>"
 
              },
 
 
            ]
 
    error:  null
 
             ]
 
    error : null
 

	
 
get_repo_nodes
 
^^^^^^^^^^^^^^
 

	
 
Return a list of files and directories for a given path at the given revision.
 
It is possible to specify ret_type to show only ``files`` or ``dirs``.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "get_repo_nodes"
 
    args:     {
 
                "repoid" : "<reponame or repo_id>"
 
                "revision"  : "<revision>",
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "revision" :  "<revision>",
 
                "root_path" : "<root_path>",
 
                "ret_type"  : "<ret_type> = Optional('all')"
 
                "ret_type" :  "<ret_type> = Optional('all')"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: [
 
    result : [
 
              {
 
                "name" :        "<name>"
 
                "type" :        "<type>",
 
                "name" :        "<name>",
 
                "type" :        "<type>"
 
              },
 
 
            ]
 
    error:  null
 
             ]
 
    error : null
 

	
 
create_repo
 
^^^^^^^^^^^
 

	
 
Create a repository. If the repository name contains "/", the repository will be
 
created in the repository group indicated by that path. Any such repository
 
groups need to exist before calling this method, or the call will fail.
 
For example "foo/bar/baz" will create a repository "baz" inside the repository
 
group "bar" which itself is in a repository group "foo", but both "foo" and
 
"bar" already need to exist before calling this method.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with create repository permission.
 
Regular users cannot specify owner parameter.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "create_repo"
 
    args:     {
 
    args :    {
 
                "repo_name" :        "<reponame>",
 
                "owner" :            "<owner_name_or_id = Optional(=apiuser)>",
 
                "repo_type" :        "<repo_type> = Optional('hg')",
 
                "description" :      "<description> = Optional('')",
 
                "private" :          "<bool> = Optional(False)",
 
                "clone_uri" :        "<clone_uri> = Optional(None)",
 
                "landing_rev" :      "<landing_rev> = Optional('tip')",
 
                "enable_downloads":  "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)",
 
                "enable_downloads" : "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "msg": "Created new repository `<reponame>`",
 
              "repo": {
 
    result : {
 
              "msg" : "Created new repository `<reponame>`",
 
              "repo" : {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<datetimecreated>",
 
                "description" :      "<description>",
 
                "landing_rev":       "<landing_rev>",
 
                "owner":             "<username or user_id>",
 
                "fork_of":           "<name_of_fork_parent>",
 
                "enable_downloads":  "<bool>",
 
                "enable_statistics": "<bool>",
 
              },
 
            }
 
    error:  null
 
                "landing_rev" :      "<landing_rev>",
 
                "owner" :            "<username or user_id>",
 
                "fork_of" :          "<name_of_fork_parent>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>"
 
              }
 
             }
 
    error : null
 

	
 
update_repo
 
^^^^^^^^^^^
 

	
 
Update a repository.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with create repository permission.
 
Regular users cannot specify owner parameter.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "update_repo"
 
    args:     {
 
                "repoid" :           "<reponame or repo_id>"
 
    args :    {
 
                "repoid" :           "<reponame or repo_id>",
 
                "name" :             "<reponame> = Optional('')",
 
                "group" :            "<group_id> = Optional(None)",
 
                "owner" :            "<owner_name_or_id = Optional(=apiuser)>",
 
                "description" :      "<description> = Optional('')",
 
                "private" :          "<bool> = Optional(False)",
 
                "clone_uri" :        "<clone_uri> = Optional(None)",
 
                "landing_rev" :      "<landing_rev> = Optional('tip')",
 
                "enable_downloads":  "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)",
 
                "enable_downloads" : "<bool> = Optional(False)",
 
                "enable_statistics": "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "msg": "updated repo ID:repo_id `<reponame>`",
 
              "repository": {
 
    result : {
 
              "msg" : "updated repo ID:repo_id `<reponame>`",
 
              "repository" : {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_name" :        "<reponame>",
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "private":           "<bool>",
 
                "private" :          "<bool>",
 
                "created_on" :       "<datetimecreated>",
 
                "description" :      "<description>",
 
                "landing_rev":       "<landing_rev>",
 
                "owner":             "<username or user_id>",
 
                "fork_of":           "<name_of_fork_parent>",
 
                "enable_downloads":  "<bool>",
 
                "landing_rev" :      "<landing_rev>",
 
                "owner" :            "<username or user_id>",
 
                "fork_of" :          "<name_of_fork_parent>",
 
                "enable_downloads" : "<bool>",
 
                "enable_statistics": "<bool>",
 
                "last_changeset":    {
 
                                       "author":   "<full_author>",
 
                                       "date":     "<date_time_of_commit>",
 
                                       "message":  "<commit_message>",
 
                                       "raw_id":   "<raw_id>",
 
                "last_changeset" :   {
 
                                       "author" :  "<full_author>",
 
                                       "date" :    "<date_time_of_commit>",
 
                                       "message" : "<commit_message>",
 
                                       "raw_id" :  "<raw_id>",
 
                                       "revision": "<numeric_revision>",
 
                                       "short_id": "<short_id>"
 
                                     }
 
              },
 
            }
 
    error:  null
 
              }
 
             }
 
    error : null
 

	
 
fork_repo
 
^^^^^^^^^
 

	
 
Create a fork of the given repo. If using Celery, this will
 
return success message immediately and a fork will be created
 
asynchronously.
 
This command can only be executed using the api_key of a user with admin
 
rights, or with the global fork permission, by a regular user with create
 
repository permission and at least read access to the repository.
 
Regular users cannot specify owner parameter.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "fork_repo"
 
    args:     {
 
    args :    {
 
                "repoid" :          "<reponame or repo_id>",
 
                "fork_name":        "<forkname>",
 
                "owner":            "<username or user_id = Optional(=apiuser)>",
 
                "description":      "<description>",
 
                "fork_name" :       "<forkname>",
 
                "owner" :           "<username or user_id = Optional(=apiuser)>",
 
                "description" :     "<description>",
 
                "copy_permissions": "<bool>",
 
                "private":          "<bool>",
 
                "landing_rev":      "<landing_rev>"
 

	
 
                "private" :         "<bool>",
 
                "landing_rev" :     "<landing_rev>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "msg": "Created fork of `<reponame>` as `<forkname>`",
 
              "success": true
 
            }
 
    error:  null
 
    result : {
 
              "msg" : "Created fork of `<reponame>` as `<forkname>`",
 
              "success" : true
 
             }
 
    error : null
 

	
 
delete_repo
 
^^^^^^^^^^^
 

	
 
Delete a repository.
 
This command can only be executed using the api_key of a user with admin rights,
 
or that of a regular user with admin access to the repository.
 
When ``forks`` param is set it is possible to detach or delete forks of the deleted repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "delete_repo"
 
    args:     {
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "forks"  : "`delete` or `detach` = Optional(None)"
 
                "forks" :  "`delete` or `detach` = Optional(None)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "msg": "Deleted repository `<reponame>`",
 
              "success": true
 
            }
 
    error:  null
 
    result : {
 
              "msg" : "Deleted repository `<reponame>`",
 
              "success" : true
 
             }
 
    error : null
 

	
 
grant_user_permission
 
^^^^^^^^^^^^^^^^^^^^^
 

	
 
Grant permission for a user on the given repository, or update the existing one if found.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "grant_user_permission"
 
    args:     {
 
                "repoid" : "<reponame or repo_id>"
 
                "userid" : "<username or user_id>"
 
                "perm" :       "(repository.(none|read|write|admin))",
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "userid" : "<username or user_id>",
 
                "perm" :       "(repository.(none|read|write|admin))"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
 
              "success": true
 
            }
 
    error:  null
 
              "success" : true
 
             }
 
    error : null
 

	
 
revoke_user_permission
 
^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Revoke permission for a user on the given repository.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "revoke_user_permission"
 
    args:     {
 
                "repoid" : "<reponame or repo_id>"
 
    method :  "revoke_user_permission"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "userid" : "<username or user_id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
 
              "success": true
 
            }
 
    error:  null
 
              "success" : true
 
             }
 
    error : null
 

	
 
grant_user_group_permission
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Grant permission for a user group on the given repository, or update the
 
existing one if found.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method :  "grant_user_group_permission"
 
    args:     {
 
                "repoid" : "<reponame or repo_id>"
 
                "usersgroupid" : "<user group id or name>"
 
                "perm" : "(repository.(none|read|write|admin))",
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "usersgroupid" : "<user group id or name>",
 
                "perm" : "(repository.(none|read|write|admin))"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
 
              "success": true
 
            }
 
    error:  null
 
              "success" : true
 
             }
 
    error : null
 

	
 
revoke_user_group_permission
 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 

	
 
Revoke permission for a user group on the given repository.
 
This command can only be executed using the api_key of a user with admin rights.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "revoke_user_group_permission"
 
    args:     {
 
                "repoid" : "<reponame or repo_id>"
 
    method :  "revoke_user_group_permission"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "usersgroupid" : "<user group id or name>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
    result : {
 
              "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
 
              "success": true
 
            }
 
    error:  null
 
              "success" : true
 
             }
 
    error : null
 

	
 
get_changesets
 
^^^^^^^^^^^^^^
 

	
 
Get changesets of a given repository. This command can only be executed using the api_key
 
of a user with read permissions to the repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "get_changesets"
 
    args:     {
 
    method :  "get_changesets"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "start": "<revision number> = Optional(None)",
 
                "end": "<revision number> = Optional(None)",
 
                "start_date": "<date> = Optional(None)",    # in "%Y-%m-%dT%H:%M:%S" format
 
                "end_date": "<date> = Optional(None)",      # in "%Y-%m-%dT%H:%M:%S" format
 
                "branch_name": "<branch name filter> = Optional(None)",
 
                "reverse": "<bool> = Optional(False)",
 
                "with_file_list": "<bool> = Optional(False)"
 
                "start" : "<revision number> = Optional(None)",
 
                "end" : "<revision number> = Optional(None)",
 
                "start_date" : "<date> = Optional(None)",    # in "%Y-%m-%dT%H:%M:%S" format
 
                "end_date" : "<date> = Optional(None)",      # in "%Y-%m-%dT%H:%M:%S" format
 
                "branch_name" : "<branch name filter> = Optional(None)",
 
                "reverse" : "<bool> = Optional(False)",
 
                "with_file_list" : "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: [
 
    result : [
 
    {
 
      "raw_id": "<raw_id>",
 
      "short_id": "short_id": "<short_id>",
 
      "author": "<full_author>",
 
      "date": "<date_time_of_commit>",
 
      "message": "<commit_message>",
 
      "revision": "<numeric_revision>",
 
      "raw_id" : "<raw_id>",
 
      "short_id" : "<short_id>",
 
      "author" : "<full_author>",
 
      "date" : "<date_time_of_commit>",
 
      "message" : "<commit_message>",
 
      "revision" : "<numeric_revision>",
 
      <if with_file_list == True>
 
      "added": [<list of added files>],
 
      "changed": [<list of changed files>],
 
      "removed": [<list of removed files>]
 
      "added" : [<list of added files>],
 
      "changed" : [<list of changed files>],
 
      "removed" : [<list of removed files>]
 
    },
 
    ...
 
    ]
 
    error:  null
 
    error : null
 

	
 
get_changeset
 
^^^^^^^^^^^^^
 

	
 
Get information and review status for a given changeset. This command can only
 
be executed using the api_key of a user with read permissions to the
 
repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "get_changeset"
 
    args:     {
 
    method :  "get_changeset"
 
    args :    {
 
                "repoid" : "<reponame or repo_id>",
 
                "raw_id" : "<raw_id>",
 
                "with_reviews": "<bool> = Optional(False)"
 
                "with_reviews" : "<bool> = Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
              "author":   "<full_author>",
 
              "date":     "<date_time_of_commit>",
 
              "message":  "<commit_message>",
 
              "raw_id":   "<raw_id>",
 
    result : {
 
              "author" :  "<full_author>",
 
              "date" :    "<date_time_of_commit>",
 
              "message" : "<commit_message>",
 
              "raw_id" :  "<raw_id>",
 
              "revision": "<numeric_revision>",
 
              "short_id": "<short_id>",
 
              "reviews": [{
 
                    "reviewer":   "<username>",
 
                    "modified_at": "<date_time_of_review>",  # iso 8601 date, server's timezone
 
                    "status":   "<status_of_review>",        # "under_review", "approved" or "rejected"
 
              "reviews" : [{
 
                    "reviewer" :  "<username>",
 
                    "modified_at" : "<date_time_of_review>",  # iso 8601 date, server's timezone
 
                    "status" :  "<status_of_review>",        # "under_review", "approved" or "rejected"
 
                 },
 
                 ...
 
              ]
 
            }
 
    error:  null
 
             }
 
    error : null
 

	
 
Example output::
 

	
 
    {
 
      "id" : 1,
 
      "error" : null,
 
      "result" : {
 
        "author" : {
 
          "email" : "user@example.com",
 
          "name" : "Kallithea Admin"
 
        },
 
        "changed" : [],
 
        "short_id" : "e1022d3d28df",
 
        "date" : "2017-03-28T09:09:03",
 
        "added" : [
 
          "README.rst"
 
        ],
 
        "removed" : [],
 
        "revision" : 0,
 
        "raw_id" : "e1022d3d28dfba02f626cde65dbe08f4ceb0e4e7",
 
        "message" : "Added file via Kallithea",
 
        "id" : "e1022d3d28dfba02f626cde65dbe08f4ceb0e4e7",
 
        "reviews" : [
 
          {
 
            "status" : "under_review",
 
            "modified_at" : "2017-03-28T09:17:08.618",
 
            "reviewer" : "user"
 
          }
 
        ]
 
      }
 
    }
 

	
 
get_pullrequest
 
^^^^^^^^^^^^^^^
 

	
 
Get information and review status for a given pull request. This command can only be executed
 
using the api_key of a user with read permissions to the original repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "get_pullrequest"
 
    args:     {
 
                "pullrequest_id" : "<pullrequest_id>",
 
    method :  "get_pullrequest"
 
    args :    {
 
                "pullrequest_id" : "<pullrequest_id>"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: {
 
        "status": "<pull_request_status>",
 
        "pull_request_id": <pull_request_id>,
 
        "description": "<pull_request_description>",
 
        "title": "<pull_request_title>",
 
        "url": "<pull_request_url>",
 
        "reviewers": [
 
    result : {
 
        "status" : "<pull_request_status>",
 
        "pull_request_id" : <pull_request_id>,
 
        "description" : "<pull_request_description>",
 
        "title" : "<pull_request_title>",
 
        "url" : "<pull_request_url>",
 
        "reviewers" : [
 
          {
 
            "username": "<user_name>",
 
            "username" : "<user_name>"
 
          },
 
          ...
 
        ],
 
        "org_repo_url": "<repo_url>",
 
        "org_ref_parts": [
 
        "org_repo_url" : "<repo_url>",
 
        "org_ref_parts" : [
 
          "<ref_type>",
 
          "<ref_name>",
 
          "<raw_id>"
 
        ],
 
        "other_ref_parts": [
 
        "other_ref_parts" : [
 
          "<ref_type>",
 
          "<ref_name>",
 
          "<raw_id>"
 
        ],
 
        "comments": [
 
        "comments" : [
 
          {
 
            "username": "<user_name>",
 
            "text": "<comment text>",
 
            "comment_id": "<comment_id>",
 
            "username" : "<user_name>",
 
            "text" : "<comment text>",
 
            "comment_id" : "<comment_id>"
 
          },
 
          ...
 
        ],
 
        "owner": "<username>",
 
        "statuses": [
 
        "owner" : "<username>",
 
        "statuses" : [
 
          {
 
            "status": "<status_of_review>",        # "under_review", "approved" or "rejected"
 
            "reviewer": "<user_name>",
 
            "modified_at": "<date_time_of_review>" # iso 8601 date, server's timezone
 
            "status" : "<status_of_review>",        # "under_review", "approved" or "rejected"
 
            "reviewer" : "<user_name>",
 
            "modified_at" : "<date_time_of_review>" # iso 8601 date, server's timezone
 
          },
 
          ...
 
        ],
 
        "revisions": [
 
        "revisions" : [
 
          "<raw_id>",
 
          ...
 
        ]
 
    },
 
    error:  null
 
    error : null
 

	
 
comment_pullrequest
 
^^^^^^^^^^^^^^^^^^^
 

	
 
Add comment, change status or close a given pull request. This command can only be executed
 
using the api_key of a user with read permissions to the original repository.
 

	
 
INPUT::
 

	
 
    id : <id_for_response>
 
    api_key : "<api_key>"
 
    method  : "comment_pullrequest"
 
    args:     {
 
                "pull_request_id":  "<pull_request_id>",
 
                "comment_msg":      Optional(''),
 
                "status":           Optional(None),     # "under_review", "approved" or "rejected"
 
                "close_pr":         Optional(False)",
 
    method :  "comment_pullrequest"
 
    args :    {
 
                "pull_request_id" : "<pull_request_id>",
 
                "comment_msg" :     Optional(''),
 
                "status" :          Optional(None),     # "under_review", "approved" or "rejected"
 
                "close_pr" :        Optional(False)"
 
              }
 

	
 
OUTPUT::
 

	
 
    id : <id_given_in_input>
 
    result: True
 
    error:  null
 
    result : True
 
    error : null
 

	
 

	
 
API access for web views
 
------------------------
 

	
 
Kallithea HTTP entry points can also be accessed without login using bearer
 
authentication by including this header with the request::
 

	
 
    Authentication: Bearer <api_key>
 

	
 
Alternatively, the API key can be passed in the URL query string using
 
``?api_key=<api_key>``, though this is not recommended due to the increased
 
risk of API key leaks, and support will likely be removed in the future.
 

	
 
Exposing raw diffs is a good way to integrate with
 
third-party services like code review, or build farms that can download archives.
docs/conf.py
Show inline comments
 
@@ -26,49 +26,49 @@ sys.path.insert(0, os.path.abspath('..')
 

	
 
# If your documentation needs a minimal Sphinx version, state it here.
 
#needs_sphinx = '1.0'
 

	
 
# Add any Sphinx extension module names here, as strings. They can be extensions
 
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
 
              'sphinx.ext.intersphinx', 'sphinx.ext.todo',
 
              'sphinx.ext.viewcode']
 

	
 
# Add any paths that contain templates here, relative to this directory.
 
templates_path = ['_templates']
 

	
 
# The suffix of source filenames.
 
source_suffix = '.rst'
 

	
 
# The encoding of source files.
 
#source_encoding = 'utf-8-sig'
 

	
 
# The master toctree document.
 
master_doc = 'index'
 

	
 
# General information about the project.
 
project = 'Kallithea'
 
copyright = '2010-2022 by various authors, licensed as GPLv3.'
 
copyright = '2010-2023 by various authors, licensed as GPLv3.'
 

	
 
# The version info for the project you're documenting, acts as replacement for
 
# |version| and |release|, also used in various other places throughout the
 
# built documents.
 
#
 
# The short X.Y version.
 
root = os.path.dirname(os.path.dirname(__file__))
 
sys.path.append(root)
 
version = kallithea.__version__
 
# The full version, including alpha/beta/rc tags.
 
release = kallithea.__version__
 

	
 
# The language for content autogenerated by Sphinx. Refer to documentation
 
# for a list of supported languages.
 
#language = None
 

	
 
# There are two options for replacing |today|: either, you set today to some
 
# non-false value, then it is used:
 
#today = ''
 
# Else, today_fmt is used as the format for a strftime call.
 
#today_fmt = '%B %d, %Y'
 

	
 
# List of patterns, relative to source directory, that match files and
 
# directories to ignore when looking for source files.
kallithea/controllers/admin/repo_groups.py
Show inline comments
 
@@ -55,48 +55,49 @@ class RepoGroupsController(base.BaseCont
 

	
 
    @LoginRequired(allow_default_user=True)
 
    def _before(self, *args, **kwargs):
 
        super(RepoGroupsController, self)._before(*args, **kwargs)
 

	
 
    def __load_defaults(self, extras=(), exclude=()):
 
        """extras is used for keeping current parent ignoring permissions
 
        exclude is used for not moving group to itself TODO: also exclude descendants
 
        Note: only admin can create top level groups
 
        """
 
        repo_groups = AvailableRepoGroupChoices('admin', extras)
 
        exclude_group_ids = set(rg.group_id for rg in exclude)
 
        c.repo_groups = [rg for rg in repo_groups
 
                         if rg[0] not in exclude_group_ids]
 

	
 
    def __load_data(self, group_id):
 
        """
 
        Load defaults settings for edit, and update
 

	
 
        :param group_id:
 
        """
 
        repo_group = db.RepoGroup.get_or_404(group_id)
 
        data = repo_group.get_dict()
 
        data['group_name'] = repo_group.name
 
        data['owner'] = repo_group.owner.username
 

	
 
        # fill repository group users
 
        for p in repo_group.repo_group_to_perm:
 
            data.update({'u_perm_%s' % p.user.username:
 
                             p.permission.permission_name})
 

	
 
        # fill repository group groups
 
        for p in repo_group.users_group_to_perm:
 
            data.update({'g_perm_%s' % p.users_group.users_group_name:
 
                             p.permission.permission_name})
 

	
 
        return data
 

	
 
    def _revoke_perms_on_yourself(self, form_result):
 
        _up = [u for u in form_result['perms_updates'] if request.authuser.username == u[0]]
 
        _new = [u for u in form_result['perms_new'] if request.authuser.username == u[0]]
 
        if _new and _new[0][1] != 'group.admin' or _up and _up[0][1] != 'group.admin':
 
            return True
 
        return False
 

	
 
    def index(self, format='html'):
 
        _list = db.RepoGroup.query(sorted=True).all()
 
        group_iter = RepoGroupList(_list, perm_level='admin')
 
        repo_groups_data = []
 
@@ -125,49 +126,49 @@ class RepoGroupsController(base.BaseCont
 
                                             repo_count)
 
            })
 

	
 
        c.data = {
 
            "sort": None,
 
            "dir": "asc",
 
            "records": repo_groups_data
 
        }
 

	
 
        return base.render('admin/repo_groups/repo_groups.html')
 

	
 
    def create(self):
 
        self.__load_defaults()
 

	
 
        # permissions for can create group based on parent_id are checked
 
        # here in the Form
 
        repo_group_form = RepoGroupForm(repo_groups=c.repo_groups)
 
        form_result = None
 
        try:
 
            form_result = repo_group_form.to_python(dict(request.POST))
 
            gr = RepoGroupModel().create(
 
                group_name=form_result['group_name'],
 
                group_description=form_result['group_description'],
 
                parent=form_result['parent_group_id'],
 
                owner=request.authuser.user_id, # TODO: make editable
 
                owner=request.authuser.user_id,
 
                copy_permissions=form_result['group_copy_permissions']
 
            )
 
            meta.Session().commit()
 
            # TODO: in future action_logger(, '', '', '')
 
        except formencode.Invalid as errors:
 
            return htmlfill.render(
 
                base.render('admin/repo_groups/repo_group_add.html'),
 
                defaults=errors.value,
 
                errors=errors.error_dict or {},
 
                prefix_error=False,
 
                encoding="UTF-8",
 
                force_defaults=False)
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            webutils.flash(_('Error occurred during creation of repository group %s')
 
                    % request.POST.get('group_name'), category='error')
 
            if form_result is None:
 
                raise
 
            parent_group_id = form_result['parent_group_id']
 
            # TODO: maybe we should get back to the main view, not the admin one
 
            raise HTTPFound(location=url('repos_groups', parent_group=parent_group_id))
 
        webutils.flash(_('Created repository group %s') % gr.group_name,
 
                category='success')
 
        raise HTTPFound(location=url('repos_group_home', group_name=gr.group_name))
kallithea/controllers/api/api.py
Show inline comments
 
@@ -44,1289 +44,1003 @@ from kallithea.model.comment import Chan
 
from kallithea.model.gist import GistModel
 
from kallithea.model.pull_request import PullRequestModel
 
from kallithea.model.repo import RepoModel
 
from kallithea.model.repo_group import RepoGroupModel
 
from kallithea.model.scm import ScmModel, UserGroupList
 
from kallithea.model.user import UserModel
 
from kallithea.model.user_group import UserGroupModel
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def store_update(updates, attr, name):
 
    """
 
    Stores param in updates dict if it's not None (i.e. if user explicitly set
 
    a parameter). This allows easy updates of passed in params.
 
    """
 
    if attr is not None:
 
        updates[name] = attr
 

	
 

	
 
def get_user_or_error(userid):
 
    """
 
    Get user by id or name or return JsonRPCError if not found
 

	
 
    :param userid:
 
    """
 
    user = UserModel().get_user(userid)
 
    if user is None:
 
        raise JSONRPCError("user `%s` does not exist" % (userid,))
 
    return user
 

	
 

	
 
def get_repo_or_error(repoid):
 
    """
 
    Get repo by id or name or return JsonRPCError if not found
 

	
 
    :param repoid:
 
    """
 
    repo = RepoModel().get_repo(repoid)
 
    if repo is None:
 
        raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 
    return repo
 

	
 

	
 
def get_repo_group_or_error(repogroupid):
 
    """
 
    Get repo group by id or name or return JsonRPCError if not found
 

	
 
    :param repogroupid:
 
    """
 
    repo_group = db.RepoGroup.guess_instance(repogroupid)
 
    if repo_group is None:
 
        raise JSONRPCError(
 
            'repository group `%s` does not exist' % (repogroupid,))
 
    return repo_group
 

	
 

	
 
def get_user_group_or_error(usergroupid):
 
    """
 
    Get user group by id or name or return JsonRPCError if not found
 

	
 
    :param usergroupid:
 
    """
 
    user_group = UserGroupModel().get_group(usergroupid)
 
    if user_group is None:
 
        raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 
    return user_group
 

	
 

	
 
def get_perm_or_error(permid, prefix=None):
 
    """
 
    Get permission by id or name or return JsonRPCError if not found
 

	
 
    :param permid:
 
    """
 
    perm = db.Permission.get_by_key(permid)
 
    if perm is None:
 
        raise JSONRPCError('permission `%s` does not exist' % (permid,))
 
    if prefix:
 
        if not perm.permission_name.startswith(prefix):
 
            raise JSONRPCError('permission `%s` is invalid, '
 
                               'should start with %s' % (permid, prefix))
 
    return perm
 

	
 

	
 
def get_gist_or_error(gistid):
 
    """
 
    Get gist by id or gist_access_id or return JsonRPCError if not found
 

	
 
    :param gistid:
 
    """
 
    gist = GistModel().get_gist(gistid)
 
    if gist is None:
 
        raise JSONRPCError('gist `%s` does not exist' % (gistid,))
 
    return gist
 

	
 

	
 
class ApiController(JSONRPCController):
 
    """
 
    API Controller
 

	
 
    The authenticated user can be found as request.authuser.
 

	
 
    Example function::
 

	
 
        def func(arg1, arg2,...):
 
            pass
 

	
 
    Each function should also **raise** JSONRPCError for any
 
    errors that happens.
 
    """
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def test(self, args):
 
        return args
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def pull(self, repoid, clone_uri=None):
 
        """
 
        Triggers a pull from remote location on given repo. Can be used to
 
        automatically keep remote repos up to date. This command can be executed
 
        only using api_key belonging to user with admin rights
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param clone_uri: repository URI to pull from (optional)
 
        :type clone_uri: str
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg": "Pulled from `<repository name>`"
 
            "repository": "<repository name>"
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "Unable to pull changes from `<reponame>`"
 
          }
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                "msg" : "Pulled from `<repository name>`",
 
                "repository" : "<repository name>"
 
            }
 
            error : null
 
        """
 

	
 
        repo = get_repo_or_error(repoid)
 

	
 
        try:
 
            ScmModel().pull_changes(repo.repo_name,
 
                                    request.authuser.username,
 
                                    request.ip_addr,
 
                                    clone_uri=clone_uri)
 
            return dict(
 
                msg='Pulled from `%s`' % repo.repo_name,
 
                repository=repo.repo_name
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'Unable to pull changes from `%s`' % repo.repo_name
 
            )
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def rescan_repos(self, remove_obsolete=False):
 
        """
 
        Triggers rescan repositories action. If remove_obsolete is set
 
        than also delete repos that are in database but not in the filesystem.
 
        aka "clean zombies". This command can be executed only using api_key
 
        belonging to user with admin rights.
 

	
 
        :param remove_obsolete: deletes repositories from
 
            database that are not found on the filesystem
 
        :type remove_obsolete: Optional(bool)
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            'added': [<added repository name>,...]
 
            'removed': [<removed repository name>,...]
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            'Error occurred during rescan repositories action'
 
          }
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                'added': [<added repository name>,...]
 
                'removed': [<removed repository name>,...]
 
            }
 
            error : null
 
        """
 

	
 
        try:
 
            rm_obsolete = remove_obsolete
 
            added, removed = repo2db_mapper(ScmModel().repo_scan(),
 
                                            remove_obsolete=rm_obsolete)
 
            return {'added': added, 'removed': removed}
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'Error occurred during rescan repositories action'
 
            )
 

	
 
    def invalidate_cache(self, repoid):
 
        """
 
        Invalidate cache for repository.
 
        This command can be executed only using api_key belonging to user with admin
 
        rights or regular user that have write or admin or write access to repository.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            'msg': Cache for repository `<repository name>` was invalidated,
 
            'repository': <repository name>
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            'Error occurred during cache invalidation action'
 
          }
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                'msg': Cache for repository `<repository name>` was invalidated,
 
                'repository': <repository name>
 
            }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('write')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        try:
 
            ScmModel().mark_for_invalidation(repo.repo_name)
 
            return dict(
 
                msg='Cache for repository `%s` was invalidated' % (repoid,),
 
                repository=repo.repo_name
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'Error occurred during cache invalidation action'
 
            )
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def get_ip(self, userid=None):
 
        """
 
        Shows IP address as seen from Kallithea server, together with all
 
        defined IP addresses for given user. If userid is not passed data is
 
        returned for user who's calling this function.
 
        This command can be executed only using api_key belonging to user with
 
        admin rights.
 

	
 
        :param userid: username to show ips for
 
        :type userid: Optional(str or int)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                         "server_ip_addr": "<ip_from_clien>",
 
                         "user_ips": [
 
                         "server_ip_addr" : "<ip_from_client>",
 
                         "user_ips" : [
 
                                        {
 
                                           "ip_addr": "<ip_with_mask>",
 
                                           "ip_range": ["<start_ip>", "<end_ip>"],
 
                                           "ip_addr" : "<ip_with_mask>",
 
                                           "ip_range" : ["<start_ip>", "<end_ip>"]
 
                                        },
 
                                        ...
 
                                     ]
 
                                      ]
 
            }
 

	
 
            error : null
 
        """
 
        if userid is None:
 
            userid = request.authuser.user_id
 
        user = get_user_or_error(userid)
 
        ips = db.UserIpMap.query().filter(db.UserIpMap.user == user).all()
 
        return dict(
 
            server_ip_addr=request.ip_addr,
 
            user_ips=ips
 
        )
 

	
 
    # alias for old
 
    show_ip = get_ip
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def get_server_info(self):
 
        """
 
        return server info, including Kallithea version and installed packages
 

	
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            'modules': [<module name>,...]
 
            'py_version': <python version>,
 
            'platform': <platform type>,
 
            'kallithea_version': <kallithea version>
 
          }
 
          error :  null
 
            id : <id_given_in_input>
 
            result : {
 
                'modules' : [ [<module name>, <module version>], ...]
 
                'py_version' : <python version>,
 
                'platform' : <platform type>,
 
                'kallithea_version' : <kallithea version>,
 
                'git_version' : '<git version>',
 
                'git_path' : '<git path>'
 
            }
 
            error : null
 
        """
 
        return db.Setting.get_server_info()
 

	
 
    def get_user(self, userid=None):
 
        """
 
        Gets a user by username or user_id, Returns empty result if user is
 
        not found. If userid param is skipped it is set to id of user who is
 
        calling this method. This command can be executed only using api_key
 
        belonging to user with admin rights, or regular users that cannot
 
        specify different userid than theirs
 

	
 
        :param userid: user to get data for
 
        :type userid: Optional(str or int)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: None if user does not exist or
 
                    {
 
            result : None if user does not exist or
 
                     {
 
                        "user_id" :     "<user_id>",
 
                        "api_key" :     "<api_key>",
 
                        "api_keys":     "[<list of all API keys including additional ones>]"
 
                        "username" :    "<username>",
 
                        "firstname":    "<firstname>",
 
                        "firstname" :   "<firstname>",
 
                        "lastname" :    "<lastname>",
 
                        "email" :       "<email>",
 
                        "emails":       "[<list of all emails including additional ones>]",
 
                        "ip_addresses": "[<ip_address_for_user>,...]",
 
                        "emails" :      "[<list of all emails including additional ones>]",
 
                        "active" :      "<bool: user active>",
 
                        "admin" :       "<bool: user is admin>",
 
                        "extern_name" : "<extern_name>",
 
                        "extern_type" : "<extern type>
 
                        "last_login":   "<last_login>",
 
                        "permissions": {
 
                            "global": ["hg.create.repository",
 
                                       "repository.read",
 
                                       "hg.register.manual_activate"],
 
                            "repositories": {"repo1": "repository.none"},
 
                            "repositories_groups": {"Group1": "group.read"}
 
                         },
 
                    }
 

	
 
            error:  null
 

	
 
                        "admin" :       "<bool: user is admin>",
 
                        "permissions" : {
 
                            "global" : ["hg.create.repository",
 
                                        "repository.read",
 
                                        "hg.register.manual_activate"],
 
                            "repositories" : {"repo1" : "repository.none"},
 
                            "repositories_groups" : {"Group1" : "group.read"},
 
                            "user_groups" : { "usrgrp1" : "usergroup.admin" }
 
                         }
 
                     }
 
            error : null
 
        """
 
        if not HasPermissionAny('hg.admin')():
 
            # make sure normal user does not pass someone else userid,
 
            # he is not allowed to do that
 
            if userid is not None and userid != request.authuser.user_id:
 
                raise JSONRPCError(
 
                    'userid is not the same as your user'
 
                )
 

	
 
        if userid is None:
 
            userid = request.authuser.user_id
 

	
 
        user = get_user_or_error(userid)
 
        data = user.get_api_data()
 
        data['permissions'] = AuthUser(user_id=user.user_id).permissions
 
        return data
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def get_users(self):
 
        """
 
        Lists all existing users. This command can be executed only using api_key
 
        belonging to user with admin rights.
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: [<user_object>, ...]
 
            error:  null
 
            result : [<user_object>, ...]
 
            error : null
 
        """
 

	
 
        return [
 
            user.get_api_data()
 
            for user in db.User.query()
 
                .order_by(db.User.username)
 
                .filter_by(is_default_user=False)
 
        ]
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def create_user(self, username, email, password='',
 
                    firstname='', lastname='',
 
                    active=True, admin=False,
 
                    extern_type=db.User.DEFAULT_AUTH_TYPE,
 
                    extern_name=''):
 
        """
 
        Creates new user. Returns new user object. This command can
 
        be executed only using api_key belonging to user with admin rights.
 

	
 
        :param username: new username
 
        :type username: str or int
 
        :param email: email
 
        :type email: str
 
        :param password: password
 
        :type password: Optional(str)
 
        :param firstname: firstname
 
        :type firstname: Optional(str)
 
        :param lastname: lastname
 
        :type lastname: Optional(str)
 
        :param active: active
 
        :type active: Optional(bool)
 
        :param admin: admin
 
        :type admin: Optional(bool)
 
        :param extern_name: name of extern
 
        :type extern_name: Optional(str)
 
        :param extern_type: extern_type
 
        :type extern_type: Optional(str)
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "created new user `<username>`",
 
                      "user": <user_obj>
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "user `<username>` already exist"
 
            or
 
            "email `<email>` already exist"
 
            or
 
            "failed to create user `<username>`"
 
          }
 

	
 
                      "user" : <user_obj>
 
                     }
 
            error : null
 
        """
 

	
 
        if db.User.get_by_username(username):
 
            raise JSONRPCError("user `%s` already exist" % (username,))
 

	
 
        if db.User.get_by_email(email):
 
            raise JSONRPCError("email `%s` already exist" % (email,))
 

	
 
        try:
 
            user = UserModel().create_or_update(
 
                username=username,
 
                password=password,
 
                email=email,
 
                firstname=firstname,
 
                lastname=lastname,
 
                active=active,
 
                admin=admin,
 
                extern_type=extern_type,
 
                extern_name=extern_name
 
            )
 
            meta.Session().commit()
 
            return dict(
 
                msg='created new user `%s`' % username,
 
                user=user.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to create user `%s`' % (username,))
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def update_user(self, userid, username=None,
 
                    email=None, password=None,
 
                    firstname=None, lastname=None,
 
                    active=None, admin=None,
 
                    extern_type=None, extern_name=None):
 
        """
 
        updates given user if such user exists. This command can
 
        be executed only using api_key belonging to user with admin rights.
 

	
 
        :param userid: userid to update
 
        :type userid: str or int
 
        :param username: new username
 
        :type username: str or int
 
        :param email: email
 
        :type email: str
 
        :param password: password
 
        :type password: Optional(str)
 
        :param firstname: firstname
 
        :type firstname: Optional(str)
 
        :param lastname: lastname
 
        :type lastname: Optional(str)
 
        :param active: active
 
        :type active: Optional(bool)
 
        :param admin: admin
 
        :type admin: Optional(bool)
 
        :param extern_name:
 
        :type extern_name: Optional(str)
 
        :param extern_type:
 
        :type extern_type: Optional(str)
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "updated user ID:<userid> <username>",
 
                      "user": <user_object>,
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to update user `<username>`"
 
          }
 

	
 
                      "user" : <user_object>
 
                     }
 
            error : null
 
        """
 

	
 
        user = get_user_or_error(userid)
 

	
 
        # only non optional arguments will be stored in updates
 
        updates = {}
 

	
 
        try:
 

	
 
            store_update(updates, username, 'username')
 
            store_update(updates, password, 'password')
 
            store_update(updates, email, 'email')
 
            store_update(updates, firstname, 'name')
 
            store_update(updates, lastname, 'lastname')
 
            store_update(updates, active, 'active')
 
            store_update(updates, admin, 'admin')
 
            store_update(updates, extern_name, 'extern_name')
 
            store_update(updates, extern_type, 'extern_type')
 

	
 
            user = UserModel().update_user(user, **updates)
 
            meta.Session().commit()
 
            return dict(
 
                msg='updated user ID:%s %s' % (user.user_id, user.username),
 
                user=user.get_api_data()
 
            )
 
        except DefaultUserException:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('editing default user is forbidden')
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to update user `%s`' % (userid,))
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def delete_user(self, userid):
 
        """
 
        deletes given user if such user exists. This command can
 
        be executed only using api_key belonging to user with admin rights.
 

	
 
        :param userid: user to delete
 
        :type userid: str or int
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "deleted user ID:<userid> <username>",
 
                      "user": null
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to delete user ID:<userid> <username>"
 
          }
 

	
 
                      "user" : null
 
                     }
 
            error : null
 
        """
 
        user = get_user_or_error(userid)
 

	
 
        try:
 
            UserModel().delete(userid)
 
            meta.Session().commit()
 
            return dict(
 
                msg='deleted user ID:%s %s' % (user.user_id, user.username),
 
                user=None
 
            )
 
        except Exception:
 

	
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to delete user ID:%s %s'
 
                               % (user.user_id, user.username))
 

	
 
    # permission check inside
 
    def get_user_group(self, usergroupid):
 
        """
 
        Gets an existing user group. This command can be executed only using api_key
 
        belonging to user with admin rights or user who has at least
 
        read access to user group.
 

	
 
        :param usergroupid: id of user_group to edit
 
        :type usergroupid: str or int
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : None if group not exist
 
                     {
 
                       "users_group_id" : "<id>",
 
                       "group_name" :     "<groupname>",
 
                       "active":          "<bool>",
 
                       "members" :  [<user_obj>,...]
 
                       "group_description" : "<description>",
 
                       "active" :         "<bool>",
 
                       "owner" :          "<username>",
 
                       "members" :        [<user_obj>,...]
 
                     }
 
            error : null
 

	
 
        """
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        data = user_group.get_api_data()
 
        return data
 

	
 
    # permission check inside
 
    def get_user_groups(self):
 
        """
 
        Lists all existing user groups. This command can be executed only using
 
        api_key belonging to user with admin rights or user who has at least
 
        read access to user group.
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result : [<user_group_obj>,...]
 
            error : null
 
        """
 

	
 
        return [
 
            user_group.get_api_data()
 
            for user_group in UserGroupList(db.UserGroup.query().all(), perm_level='read')
 
        ]
 

	
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
 
    def create_user_group(self, group_name, description='',
 
                          owner=None, active=True):
 
        """
 
        Creates new user group. This command can be executed only using api_key
 
        belonging to user with admin rights or an user who has create user group
 
        permission
 

	
 
        :param group_name: name of new user group
 
        :type group_name: str
 
        :param description: group description
 
        :type description: str
 
        :param owner: owner of group. If not passed apiuser is the owner
 
        :type owner: Optional(str or int)
 
        :param active: group is active
 
        :type active: Optional(bool)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
                      "msg": "created new user group `<groupname>`",
 
                      "user_group": <user_group_object>
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "user group `<group name>` already exist"
 
            or
 
            "failed to create group `<group name>`"
 
          }
 

	
 
            result : {
 
                      "msg" : "created new user group `<groupname>`",
 
                      "user_group" : <user_group_object>
 
                     }
 
            error : null
 
        """
 

	
 
        if UserGroupModel().get_by_name(group_name):
 
            raise JSONRPCError("user group `%s` already exist" % (group_name,))
 

	
 
        try:
 
            if owner is None:
 
                owner = request.authuser.user_id
 

	
 
            owner = get_user_or_error(owner)
 
            ug = UserGroupModel().create(name=group_name, description=description,
 
                                         owner=owner, active=active)
 
            meta.Session().commit()
 
            return dict(
 
                msg='created new user group `%s`' % group_name,
 
                user_group=ug.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to create group `%s`' % (group_name,))
 

	
 
    # permission check inside
 
    def update_user_group(self, usergroupid, group_name=None,
 
                          description=None, owner=None,
 
                          active=None):
 
        """
 
        Updates given usergroup.  This command can be executed only using api_key
 
        belonging to user with admin rights or an admin of given user group
 

	
 
        :param usergroupid: id of user group to update
 
        :type usergroupid: str or int
 
        :param group_name: name of new user group
 
        :type group_name: str
 
        :param description: group description
 
        :type description: str
 
        :param owner: owner of group.
 
        :type owner: Optional(str or int)
 
        :param active: group is active
 
        :type active: Optional(bool)
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg": 'updated user group ID:<user group id> <user group name>',
 
            "user_group": <user_group_object>
 
            "msg" : 'updated user group ID:<user group id> <user group name>',
 
            "user_group" : <user_group_object>
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to update user group `<user group name>`"
 
          }
 

	
 
          error : null
 
        """
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('admin')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        if owner is not None:
 
            owner = get_user_or_error(owner)
 

	
 
        updates = {}
 
        store_update(updates, group_name, 'users_group_name')
 
        store_update(updates, description, 'user_group_description')
 
        store_update(updates, owner, 'owner')
 
        store_update(updates, active, 'users_group_active')
 
        try:
 
            UserGroupModel().update(user_group, updates)
 
            meta.Session().commit()
 
            return dict(
 
                msg='updated user group ID:%s %s' % (user_group.users_group_id,
 
                                                     user_group.users_group_name),
 
                user_group=user_group.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to update user group `%s`' % (usergroupid,))
 

	
 
    # permission check inside
 
    def delete_user_group(self, usergroupid):
 
        """
 
        Delete given user group by user group id or name.
 
        This command can be executed only using api_key
 
        belonging to user with admin rights or an admin of given user group
 

	
 
        :param usergroupid:
 
        :type usergroupid: int
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg": "deleted user group ID:<user_group_id> <user_group_name>"
 
            "msg" : "deleted user group ID:<user_group_id> <user_group_name>"
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to delete user group ID:<user_group_id> <user_group_name>"
 
            or
 
            "RepoGroup assigned to <repo_groups_list>"
 
          }
 

	
 
          error : null
 
        """
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('admin')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            UserGroupModel().delete(user_group)
 
            meta.Session().commit()
 
            return dict(
 
                msg='deleted user group ID:%s %s' %
 
                    (user_group.users_group_id, user_group.users_group_name),
 
                user_group=None
 
            )
 
        except UserGroupsAssignedException as e:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(str(e))
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to delete user group ID:%s %s' %
 
                               (user_group.users_group_id,
 
                                user_group.users_group_name)
 
                               )
 

	
 
    # permission check inside
 
    def add_user_to_user_group(self, usergroupid, userid):
 
        """
 
        Adds a user to a user group. If user exists in that group success will be
 
        `false`. This command can be executed only using api_key
 
        belonging to user with admin rights  or an admin of given user group
 

	
 
        :param usergroupid:
 
        :type usergroupid: int
 
        :param userid:
 
        :type userid: int
 
        belonging to user with admin rights or an admin of a given user group
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
              "success": True|False # depends on if member is in group
 
              "msg": "added member `<username>` to user group `<groupname>` |
 
                      User is already in that group"
 

	
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to add member to user group `<user_group_name>`"
 
          }
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                "success" : True|False # depends on if member is in group
 
                "msg" : "added member `<username>` to a user group `<groupname>` |
 
                         User is already in that group"
 
            }
 
            error : null
 
        """
 
        user = get_user_or_error(userid)
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('admin')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            ugm = UserGroupModel().add_user_to_group(user_group, user)
 
            success = True if ugm is not True else False
 
            msg = 'added member `%s` to user group `%s`' % (
 
                user.username, user_group.users_group_name
 
            )
 
            msg = msg if success else 'User is already in that group'
 
            meta.Session().commit()
 

	
 
            return dict(
 
                success=success,
 
                msg=msg
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to add member to user group `%s`' % (
 
                    user_group.users_group_name,
 
                )
 
            )
 

	
 
    # permission check inside
 
    def remove_user_from_user_group(self, usergroupid, userid):
 
        """
 
        Removes a user from a user group. If user is not in given group success will
 
        be `false`. This command can be executed only
 
        using api_key belonging to user with admin rights or an admin of given user group
 

	
 
        :param usergroupid:
 
        :param userid:
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
                      "success":  True|False,  # depends on if member is in group
 
                      "msg": "removed member <username> from user group <groupname> |
 
                              User wasn't in group"
 
                    }
 
            error:  null
 

	
 
            result : {
 
                      "success" : True|False,  # depends on if member is in group
 
                      "msg" : "removed member <username> from user group <groupname> |
 
                               User wasn't in group"
 
                     }
 
            error : null
 
        """
 
        user = get_user_or_error(userid)
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasUserGroupPermissionLevel('admin')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            success = UserGroupModel().remove_user_from_group(user_group, user)
 
            msg = 'removed member `%s` from user group `%s`' % (
 
                user.username, user_group.users_group_name
 
            )
 
            msg = msg if success else "User wasn't in group"
 
            meta.Session().commit()
 
            return dict(success=success, msg=msg)
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to remove member from user group `%s`' % (
 
                    user_group.users_group_name,
 
                )
 
            )
 

	
 
    # permission check inside
 
    def get_repo(self, repoid,
 
                 with_revision_names=False,
 
                 with_pullrequests=False):
 
        """
 
        Gets an existing repository by it's name or repository_id. Members will return
 
        either users_group or user associated to that repository. This command can be
 
        executed only using api_key belonging to user with admin
 
        rights or regular user that have at least read access to repository.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            {
 
                "repo_id" :          "<repo_id>",
 
                "repo_name" :        "<reponame>"
 
                "repo_type" :        "<repo_type>",
 
                "clone_uri" :        "<clone_uri>",
 
                "enable_downloads":  "<bool>",
 
                "enable_statistics": "<bool>",
 
                "private":           "<bool>",
 
                "created_on" :       "<date_time_created>",
 
                "description" :      "<description>",
 
                "landing_rev":       "<landing_rev>",
 
                "last_changeset":    {
 
                                       "author":   "<full_author>",
 
                                       "date":     "<date_time_of_commit>",
 
                                       "message":  "<commit_message>",
 
                                       "raw_id":   "<raw_id>",
 
                                       "revision": "<numeric_revision>",
 
                                       "short_id": "<short_id>"
 
                                     }
 
                "owner":             "<repo_owner>",
 
                "fork_of":           "<name_of_fork_parent>",
 
                "members" :     [
 
                                  {
 
                                    "name":     "<username>",
 
                                    "type" :    "user",
 
                                    "permission" : "repository.(read|write|admin)"
 
                                  },
 
 
                                  {
 
                                    "name":     "<usergroup name>",
 
                                    "type" :    "user_group",
 
                                    "permission" : "usergroup.(read|write|admin)"
 
                                  },
 
 
                                ]
 
                 "followers":   [<user_obj>, ...],
 
                 <if with_revision_names == True>
 
                 "tags": {
 
                            "<tagname>": "<raw_id>",
 
                            ...
 
                         },
 
                 "branches": {
 
                            "<branchname>": "<raw_id>",
 
                            ...
 
                         },
 
                 "bookmarks": {
 
                            "<bookmarkname>": "<raw_id>",
 
                            ...
 
                         },
 
            }
 
          }
 
          error :  null
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                        "repo_id" :          "<repo_id>",
 
                        "repo_name" :        "<reponame>",
 
                        "repo_type" :        "<repo_type>",
 
                        "clone_uri" :        "<clone_uri>",
 
                        "enable_downloads" : "<bool>",
 
                        "enable_statistics": "<bool>",
 
                        "private" :          "<bool>",
 
                        "created_on" :       "<date_time_created>",
 
                        "description" :      "<description>",
 
                        "landing_rev" :      "<landing_rev>",
 
                        "last_changeset" :   {
 
                                                 "author" :  "<full_author>",
 
                                                 "date" :    "<date_time_of_commit>",
 
                                                 "message" : "<commit_message>",
 
                                                 "raw_id" :  "<raw_id>",
 
                                                 "revision": "<numeric_revision>",
 
                                                 "short_id": "<short_id>"
 
                                             },
 
                        "owner" :            "<repo_owner>",
 
                        "fork_of" :          "<name_of_fork_parent>",
 
                        "members" :     [
 
                                            {
 
                                                "name" :    "<username>",
 
                                                "type" :    "user",
 
                                                "permission" : "repository.(read|write|admin)"
 
                                            },
 
 
                                            {
 
                                                "name" :    "<usergroup name>",
 
                                                "type" :    "user_group",
 
                                                "permission" : "usergroup.(read|write|admin)"
 
                                            },
 
 
                                        ],
 
                        "followers" :  [<user_obj>, ...],
 
                        <if with_revision_names == True>
 
                        "tags" : {
 
                                    "<tagname>" : "<raw_id>",
 
                                    ...
 
                                },
 
                        "branches" : {
 
                                    "<branchname>" : "<raw_id>",
 
                                    ...
 
                                },
 
                        "bookmarks" : {
 
                                    "<bookmarkname>" : "<raw_id>",
 
                                    ...
 
                                }
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('read')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        members = []
 
        for user in repo.repo_to_perm:
 
            perm = user.permission.permission_name
 
            user = user.user
 
            user_data = {
 
                'name': user.username,
 
                'type': "user",
 
                'permission': perm
 
            }
 
            members.append(user_data)
 

	
 
        for user_group in repo.users_group_to_perm:
 
            perm = user_group.permission.permission_name
 
            user_group = user_group.users_group
 
            user_group_data = {
 
                'name': user_group.users_group_name,
 
                'type': "user_group",
 
                'permission': perm
 
            }
 
            members.append(user_group_data)
 

	
 
        followers = [
 
            uf.user.get_api_data()
 
            for uf in repo.followers
 
        ]
 

	
 
        data = repo.get_api_data(with_revision_names=with_revision_names,
 
                                 with_pullrequests=with_pullrequests)
 
        data['members'] = members
 
        data['followers'] = followers
 
        return data
 

	
 
    # permission check inside
 
    def get_repos(self):
 
        """
 
        Lists all existing repositories. This command can be executed only using
 
        api_key belonging to user with admin rights or regular user that have
 
        admin, write or read access to repository.
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: [
 
            result : [
 
                      {
 
                        "repo_id" :          "<repo_id>",
 
                        "repo_name" :        "<reponame>"
 
                        "repo_name" :        "<reponame>",
 
                        "repo_type" :        "<repo_type>",
 
                        "clone_uri" :        "<clone_uri>",
 
                        "private": :         "<bool>",
 
                        "private" :          "<bool>",
 
                        "created_on" :       "<datetimecreated>",
 
                        "description" :      "<description>",
 
                        "landing_rev":       "<landing_rev>",
 
                        "owner":             "<repo_owner>",
 
                        "fork_of":           "<name_of_fork_parent>",
 
                        "enable_downloads":  "<bool>",
 
                        "enable_statistics": "<bool>",
 
                        "landing_rev" :      "<landing_rev>",
 
                        "owner" :            "<repo_owner>",
 
                        "fork_of" :          "<name_of_fork_parent>",
 
                        "enable_downloads" : "<bool>",
 
                        "enable_statistics": "<bool>"
 
                      },
 
 
                    ]
 
            error:  null
 
                     ]
 
            error : null
 
        """
 
        if not HasPermissionAny('hg.admin')():
 
            repos = request.authuser.get_all_user_repos()
 
        else:
 
            repos = db.Repository.query()
 

	
 
        return [
 
            repo.get_api_data()
 
            for repo in repos
 
        ]
 

	
 
    # permission check inside
 
    def get_repo_nodes(self, repoid, revision, root_path,
 
                       ret_type='all'):
 
        """
 
        returns a list of nodes and it's children in a flat list for a given path
 
        at given revision. It's possible to specify ret_type to show only `files` or
 
        `dirs`.  This command can be executed only using api_key belonging to
 
        user with admin rights or regular user that have at least read access to repository.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param revision: revision for which listing should be done
 
        :type revision: str
 
        :param root_path: path from which start displaying
 
        :type root_path: str
 
        :param ret_type: return type 'all|files|dirs' nodes
 
        :type ret_type: Optional(str)
 

	
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: [
 
            result : [
 
                      {
 
                        "name" :        "<name>"
 
                        "type" :        "<type>",
 
                        "name" :        "<name>",
 
                        "type" :        "<type>"
 
                      },
 
 
                    ]
 
            error:  null
 
                     ]
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('read')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        _map = {}
 
        try:
 
            _d, _f = ScmModel().get_nodes(repo, revision, root_path,
 
                                          flat=False)
 
            _map = {
 
                'all': _d + _f,
 
                'files': _f,
 
                'dirs': _d,
 
            }
 
            return _map[ret_type]
 
        except KeyError:
 
            raise JSONRPCError('ret_type must be one of %s'
 
                               % (','.join(sorted(_map))))
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to get repo: `%s` nodes' % repo.repo_name
 
            )
 

	
 
    # permission check inside
 
    def create_repo(self, repo_name, owner=None,
 
                    repo_type=None, description='',
 
                    private=False, clone_uri=None,
 
                    landing_rev='rev:tip',
 
                    enable_statistics=None,
 
                    enable_downloads=None,
 
                    copy_permissions=False):
 
        """
 
        Creates a repository. The repository name contains the full path, but the
 
        parent repository group must exist. For example "foo/bar/baz" require the groups
 
        "foo" and "bar" (with "foo" as parent), and create "baz" repository with
 
        "bar" as group. This command can be executed only using api_key
 
        belonging to user with admin rights or regular user that have create
 
        repository permission. Regular users cannot specify owner parameter
 

	
 
        :param repo_name: repository name
 
        :type repo_name: str
 
        :param owner: user_id or username
 
        :type owner: Optional(str)
 
        :param repo_type: 'hg' or 'git'
 
        :type repo_type: Optional(str)
 
        :param description: repository description
 
        :type description: Optional(str)
 
        :param private:
 
        :type private: bool
 
        :param clone_uri:
 
        :type clone_uri: str
 
        :param landing_rev: <rev_type>:<rev>
 
        :type landing_rev: str
 
        :param enable_downloads:
 
        :type enable_downloads: bool
 
        :param enable_statistics:
 
        :type enable_statistics: bool
 
        :param copy_permissions: Copy permission from group that repository is
 
            being created.
 
        :type copy_permissions: bool
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
                      "msg": "Created new repository `<reponame>`",
 
                      "success": true,
 
                      "task": "<celery task id or None if done sync>"
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
             'failed to create repository `<repo_name>`
 
          }
 

	
 
            result : {
 
                      "msg" : "Created new repository `<reponame>`",
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        group_name = None
 
        repo_name_parts = repo_name.split('/')
 
        if len(repo_name_parts) > 1:
 
            group_name = '/'.join(repo_name_parts[:-1])
 
            repo_group = db.RepoGroup.get_by_group_name(group_name)
 
            if repo_group is None:
 
                raise JSONRPCError("repo group `%s` not found" % group_name)
 
            if not(HasPermissionAny('hg.admin')() or HasRepoGroupPermissionLevel('write')(group_name)):
 
                raise JSONRPCError("no permission to create repo in %s" % group_name)
 
        else:
 
            if not HasPermissionAny('hg.admin', 'hg.create.repository')():
 
                raise JSONRPCError("no permission to create top level repo")
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if owner is not None:
 
                # forbid setting owner for non-admins
 
                raise JSONRPCError(
 
                    'Only Kallithea admin can specify `owner` param'
 
                )
 
        if owner is None:
 
            owner = request.authuser.user_id
 

	
 
        owner = get_user_or_error(owner)
 

	
 
        if RepoModel().get_by_repo_name(repo_name):
 
            raise JSONRPCError("repo `%s` already exist" % repo_name)
 

	
 
        defs = db.Setting.get_default_repo_settings(strip_prefix=True)
 
        if private is None:
 
            private = defs.get('repo_private') or False
 
        if repo_type is None:
 
            repo_type = defs.get('repo_type')
 
        if enable_statistics is None:
 
            enable_statistics = defs.get('repo_enable_statistics')
 
        if enable_downloads is None:
 
            enable_downloads = defs.get('repo_enable_downloads')
 

	
 
        try:
 
            data = dict(
 
                repo_name=repo_name_parts[-1],
 
                repo_name_full=repo_name,
 
                repo_type=repo_type,
 
                repo_description=description,
 
                repo_private=private,
 
                clone_uri=clone_uri,
 
                repo_group=group_name,
 
                repo_landing_rev=landing_rev,
 
                enable_statistics=enable_statistics,
 
                enable_downloads=enable_downloads,
 
                repo_enable_statistics=enable_statistics,
 
                repo_enable_downloads=enable_downloads,
 
                repo_copy_permissions=copy_permissions,
 
            )
 

	
 
            RepoModel().create(form_data=data, cur_user=owner.username)
 
            # no commit, it's done in RepoModel, or async via celery
 
            return dict(
 
                msg="Created new repository `%s`" % (repo_name,),
 
                success=True,  # cannot return the repo data here since fork
 
                               # can be done async
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to create repository `%s`' % (repo_name,))
 

	
 
    # permission check inside
 
    def update_repo(self, repoid, name=None,
 
                    owner=None,
 
                    group=None,
 
                    description=None, private=None,
 
                    clone_uri=None, landing_rev=None,
 
                    enable_statistics=None,
 
                    enable_downloads=None):
 

	
 
        """
 
        Updates repo
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param name:
 
        :param owner:
 
        :param group:
 
        :param description:
 
        :param private:
 
        :param clone_uri:
 
        :param landing_rev:
 
        :param enable_statistics:
 
        :param enable_downloads:
 
        """
 
        repo = get_repo_or_error(repoid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('admin')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
            if (name != repo.repo_name and repo.group_id is None and
 
                not HasPermissionAny('hg.create.repository')()
 
            ):
 
                raise JSONRPCError('no permission to create (or move) top level repositories')
 

	
 
            if owner is not None:
 
                # forbid setting owner for non-admins
 
                raise JSONRPCError(
 
                    'Only Kallithea admin can specify `owner` param'
 
                )
 

	
 
        updates = {}
 
        repo_group = group
 
        if repo_group is not None:
 
            repo_group = get_repo_group_or_error(repo_group)  # TODO: repos can thus currently not be moved to root
 
            if repo_group.group_id != repo.group_id:
 
                if not(HasPermissionAny('hg.admin')() or HasRepoGroupPermissionLevel('write')(repo_group.group_name)):
 
                    raise JSONRPCError("no permission to create (or move) repo in %s" % repo_group.group_name)
 
@@ -1344,81 +1058,71 @@ class ApiController(JSONRPCController):
 

	
 
            RepoModel().update(repo, **updates)
 
            meta.Session().commit()
 
            return dict(
 
                msg='updated repo ID:%s %s' % (repo.repo_id, repo.repo_name),
 
                repository=repo.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to update repo `%s`' % repoid)
 

	
 
    # permission check inside
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.fork.repository')
 
    def fork_repo(self, repoid, fork_name,
 
                  owner=None,
 
                  description='', copy_permissions=False,
 
                  private=False, landing_rev='rev:tip'):
 
        """
 
        Creates a fork of given repo. In case of using celery this will
 
        immediately return success message, while fork is going to be created
 
        asynchronous. This command can be executed only using api_key belonging to
 
        user with admin rights or regular user that have fork permission, and at least
 
        read access to forking repository. Regular users cannot specify owner parameter.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param fork_name:
 
        :param owner:
 
        :param description:
 
        :param copy_permissions:
 
        :param private:
 
        :param landing_rev:
 

	
 
        INPUT::
 

	
 
            id : <id_for_response>
 
            api_key : "<api_key>"
 
            args:     {
 
            method :  "fork_repo"
 
            args :    {
 
                        "repoid" :          "<reponame or repo_id>",
 
                        "fork_name":        "<forkname>",
 
                        "owner":            "<username or user_id = Optional(=apiuser)>",
 
                        "description":      "<description>",
 
                        "fork_name" :       "<forkname>",
 
                        "owner" :           "<username or user_id = Optional(=apiuser)>",
 
                        "description" :     "<description>",
 
                        "copy_permissions": "<bool>",
 
                        "private":          "<bool>",
 
                        "landing_rev":      "<landing_rev>"
 
                        "private" :         "<bool>",
 
                        "landing_rev" :     "<landing_rev>"
 
                      }
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
                      "msg": "Created fork of `<reponame>` as `<forkname>`",
 
                      "success": true,
 
                      "task": "<celery task id or None if done sync>"
 
                    }
 
            error:  null
 

	
 
            result : {
 
                      "msg" : "Created fork of `<reponame>` as `<forkname>`",
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 
        repo_name = repo.repo_name
 

	
 
        _repo = RepoModel().get_by_repo_name(fork_name)
 
        if _repo:
 
            type_ = 'fork' if _repo.fork else 'repo'
 
            raise JSONRPCError("%s `%s` already exist" % (type_, fork_name))
 

	
 
        group_name = None
 
        fork_name_parts = fork_name.split('/')
 
        if len(fork_name_parts) > 1:
 
            group_name = '/'.join(fork_name_parts[:-1])
 
            repo_group = db.RepoGroup.get_by_group_name(group_name)
 
            if repo_group is None:
 
                raise JSONRPCError("repo group `%s` not found" % group_name)
 
            if not(HasPermissionAny('hg.admin')() or HasRepoGroupPermissionLevel('write')(group_name)):
 
                raise JSONRPCError("no permission to create repo in %s" % group_name)
 
        else:
 
            if not HasPermissionAny('hg.admin', 'hg.create.repository')():
 
                raise JSONRPCError("no permission to create top level repo")
 

	
 
        if HasPermissionAny('hg.admin')():
 
            pass
 
@@ -1451,914 +1155,747 @@ class ApiController(JSONRPCController):
 
            )
 
            RepoModel().create_fork(form_data, cur_user=owner.username)
 
            # no commit, it's done in RepoModel, or async via celery
 
            return dict(
 
                msg='Created fork of `%s` as `%s`' % (repo.repo_name,
 
                                                      fork_name),
 
                success=True,  # cannot return the repo data here since fork
 
                               # can be done async
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to fork repository `%s` as `%s`' % (repo_name,
 
                                                            fork_name)
 
            )
 

	
 
    # permission check inside
 
    def delete_repo(self, repoid, forks=''):
 
        """
 
        Deletes a repository. This command can be executed only using api_key belonging
 
        to user with admin rights or regular user that have admin access to repository.
 
        When `forks` param is set it's possible to detach or delete forks of deleting
 
        repository
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param forks: `detach` or `delete`, what do do with attached forks for repo
 
        :type forks: Optional(str)
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
                      "msg": "Deleted repository `<reponame>`",
 
                      "success": true
 
                    }
 
            error:  null
 

	
 
            result : {
 
                      "msg" : "Deleted repository `<reponame>`",
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('admin')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
        try:
 
            handle_forks = forks
 
            _forks_msg = ''
 
            _forks = [f for f in repo.forks]
 
            if handle_forks == 'detach':
 
                _forks_msg = ' ' + 'Detached %s forks' % len(_forks)
 
            elif handle_forks == 'delete':
 
                _forks_msg = ' ' + 'Deleted %s forks' % len(_forks)
 
            elif _forks:
 
                raise JSONRPCError(
 
                    'Cannot delete `%s` it still contains attached forks' %
 
                    (repo.repo_name,)
 
                )
 

	
 
            RepoModel().delete(repo, forks=forks)
 
            meta.Session().commit()
 
            return dict(
 
                msg='Deleted repository `%s`%s' % (repo.repo_name, _forks_msg),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to delete repository `%s`' % (repo.repo_name,)
 
            )
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def grant_user_permission(self, repoid, userid, perm):
 
        """
 
        Grant permission for user on given repository, or update existing one
 
        if found. This command can be executed only using api_key belonging to user
 
        with admin rights.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param userid:
 
        :param perm: (repository.(none|read|write|admin))
 
        :type perm: str
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Granted perm: `<perm>` for user: `<username>` in repo: `<reponame>`",
 
                      "success": true
 
                    }
 
            error:  null
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 
        user = get_user_or_error(userid)
 
        perm = get_perm_or_error(perm)
 

	
 
        try:
 

	
 
            RepoModel().grant_user_permission(repo=repo, user=user, perm=perm)
 

	
 
            meta.Session().commit()
 
            return dict(
 
                msg='Granted perm: `%s` for user: `%s` in repo: `%s`' % (
 
                    perm.permission_name, user.username, repo.repo_name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user: `%s` in repo: `%s`' % (
 
                    userid, repoid
 
                )
 
            )
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def revoke_user_permission(self, repoid, userid):
 
        """
 
        Revoke permission for user on given repository. This command can be executed
 
        only using api_key belonging to user with admin rights.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param userid:
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Revoked perm for user: `<username>` in repo: `<reponame>`",
 
                      "success": true
 
                    }
 
            error:  null
 

	
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 

	
 
        repo = get_repo_or_error(repoid)
 
        user = get_user_or_error(userid)
 
        try:
 
            RepoModel().revoke_user_permission(repo=repo, user=user)
 
            meta.Session().commit()
 
            return dict(
 
                msg='Revoked perm for user: `%s` in repo: `%s`' % (
 
                    user.username, repo.repo_name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user: `%s` in repo: `%s`' % (
 
                    userid, repoid
 
                )
 
            )
 

	
 
    # permission check inside
 
    def grant_user_group_permission(self, repoid, usergroupid, perm):
 
        """
 
        Grant permission for user group on given repository, or update
 
        existing one if found. This command can be executed only using
 
        api_key belonging to user with admin rights.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param usergroupid: id of usergroup
 
        :type usergroupid: str or int
 
        :param perm: (repository.(none|read|write|admin))
 
        :type perm: str
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
 
            "success": true
 

	
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to edit permission for user group: `<usergroup>` in repo `<repo>`'
 
          }
 

	
 
            id : <id_given_in_input>
 
            result : {
 
                "msg" : "Granted perm: `<perm>` for group: `<usersgroupname>` in repo: `<reponame>`",
 
                "success" : true
 
            }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 
        perm = get_perm_or_error(perm)
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('admin')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            RepoModel().grant_user_group_permission(
 
                repo=repo, group_name=user_group, perm=perm)
 

	
 
            meta.Session().commit()
 
            return dict(
 
                msg='Granted perm: `%s` for user group: `%s` in '
 
                    'repo: `%s`' % (
 
                        perm.permission_name, user_group.users_group_name,
 
                        repo.repo_name
 
                    ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user group: `%s` in '
 
                'repo: `%s`' % (
 
                    usergroupid, repo.repo_name
 
                )
 
            )
 

	
 
    # permission check inside
 
    def revoke_user_group_permission(self, repoid, usergroupid):
 
        """
 
        Revoke permission for user group on given repository. This command can be
 
        executed only using api_key belonging to user with admin rights.
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param usergroupid:
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Revoked perm for group: `<usersgroupname>` in repo: `<reponame>`",
 
                      "success": true
 
                    }
 
            error:  null
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        repo = get_repo_or_error(repoid)
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoPermissionLevel('admin')(repo.repo_name):
 
                raise JSONRPCError('repository `%s` does not exist' % (repoid,))
 

	
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError('user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            RepoModel().revoke_user_group_permission(
 
                repo=repo, group_name=user_group)
 

	
 
            meta.Session().commit()
 
            return dict(
 
                msg='Revoked perm for user group: `%s` in repo: `%s`' % (
 
                    user_group.users_group_name, repo.repo_name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user group: `%s` in '
 
                'repo: `%s`' % (
 
                    user_group.users_group_name, repo.repo_name
 
                )
 
            )
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def get_repo_group(self, repogroupid):
 
        """
 
        Returns given repo group together with permissions, and repositories
 
        inside the group
 

	
 
        :param repogroupid: id/name of repository group
 
        :type repogroupid: str or int
 
        """
 
        repo_group = get_repo_group_or_error(repogroupid)
 

	
 
        members = []
 
        for user in repo_group.repo_group_to_perm:
 
            perm = user.permission.permission_name
 
            user = user.user
 
            user_data = {
 
                'name': user.username,
 
                'type': "user",
 
                'permission': perm
 
            }
 
            members.append(user_data)
 

	
 
        for user_group in repo_group.users_group_to_perm:
 
            perm = user_group.permission.permission_name
 
            user_group = user_group.users_group
 
            user_group_data = {
 
                'name': user_group.users_group_name,
 
                'type': "user_group",
 
                'permission': perm
 
            }
 
            members.append(user_group_data)
 

	
 
        data = repo_group.get_api_data()
 
        data["members"] = members
 
        return data
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def get_repo_groups(self):
 
        """
 
        Returns all repository groups
 

	
 
        """
 
        return [
 
            repo_group.get_api_data()
 
            for repo_group in db.RepoGroup.query()
 
        ]
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def create_repo_group(self, group_name, description='',
 
                          owner=None,
 
                          parent=None,
 
                          copy_permissions=False):
 
        """
 
        Creates a repository group. This command can be executed only using
 
        api_key belonging to user with admin rights.
 

	
 
        :param group_name:
 
        :type group_name:
 
        :param description:
 
        :type description:
 
        :param owner:
 
        :type owner:
 
        :param parent:
 
        :type parent:
 
        :param copy_permissions:
 
        :type copy_permissions:
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
              "msg": "created new repo group `<repo_group_name>`"
 
              "repo_group": <repogroup_object>
 
              "msg" : "created new repo group `<repo_group_name>`",
 
              "repo_group" : <repogroup_object>
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            failed to create repo group `<repogroupid>`
 
          }
 

	
 
          error : null
 
        """
 
        if db.RepoGroup.get_by_group_name(group_name):
 
            raise JSONRPCError("repo group `%s` already exist" % (group_name,))
 

	
 
        if owner is None:
 
            owner = request.authuser.user_id
 
        group_description = description
 
        parent_group = None
 
        if parent is not None:
 
            parent_group = get_repo_group_or_error(parent)
 

	
 
        try:
 
            repo_group = RepoGroupModel().create(
 
                group_name=group_name,
 
                group_description=group_description,
 
                owner=owner,
 
                parent=parent_group,
 
                copy_permissions=copy_permissions
 
            )
 
            meta.Session().commit()
 
            return dict(
 
                msg='created new repo group `%s`' % group_name,
 
                repo_group=repo_group.get_api_data()
 
            )
 
        except Exception:
 

	
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to create repo group `%s`' % (group_name,))
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def update_repo_group(self, repogroupid, group_name=None,
 
                          description=None,
 
                          owner=None,
 
                          parent=None):
 
        """
 
        TODO
 
        """
 
        repo_group = get_repo_group_or_error(repogroupid)
 
        parent_repo_group_id = None if parent is None else get_repo_group_or_error(parent).group_id
 

	
 
        updates = {}
 
        try:
 
            store_update(updates, group_name, 'group_name')
 
            store_update(updates, description, 'group_description')
 
            store_update(updates, owner, 'owner')
 
            store_update(updates, parent, 'parent_group')
 
            store_update(updates, parent_repo_group_id, 'parent_group_id')
 
            repo_group = RepoGroupModel().update(repo_group, updates)
 
            meta.Session().commit()
 
            return dict(
 
                msg='updated repository group ID:%s %s' % (repo_group.group_id,
 
                                                           repo_group.group_name),
 
                repo_group=repo_group.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to update repository group `%s`'
 
                               % (repogroupid,))
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def delete_repo_group(self, repogroupid):
 
        """
 

	
 
        :param repogroupid: name or id of repository group
 
        :type repogroupid: str or int
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            'msg': 'deleted repo group ID:<repogroupid> <repogroupname>
 
            'repo_group': null
 
            'msg' : 'deleted repo group ID:<repogroupid> <repogroupname>
 
            'repo_group' : null
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to delete repo group ID:<repogroupid> <repogroupname>"
 
          }
 

	
 
          error : null
 
        """
 
        repo_group = get_repo_group_or_error(repogroupid)
 

	
 
        try:
 
            RepoGroupModel().delete(repo_group)
 
            meta.Session().commit()
 
            return dict(
 
                msg='deleted repo group ID:%s %s' %
 
                    (repo_group.group_id, repo_group.group_name),
 
                repo_group=None
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to delete repo group ID:%s %s' %
 
                               (repo_group.group_id, repo_group.group_name)
 
                               )
 

	
 
    # permission check inside
 
    def grant_user_permission_to_repo_group(self, repogroupid, userid,
 
                                            perm, apply_to_children='none'):
 
        """
 
        Grant permission for user on given repository group, or update existing
 
        one if found. This command can be executed only using api_key belonging
 
        to user with admin rights, or user who has admin right to given repository
 
        group.
 

	
 
        :param repogroupid: name or id of repository group
 
        :type repogroupid: str or int
 
        :param userid:
 
        :param perm: (group.(none|read|write|admin))
 
        :type perm: str
 
        :param apply_to_children: 'none', 'repos', 'groups', 'all'
 
        :type apply_to_children: str
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Granted perm: `<perm>` (recursive:<apply_to_children>) for user: `<username>` in repo group: `<repo_group_name>`",
 
                      "success": true
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to edit permission for user: `<userid>` in repo group: `<repo_group_name>`"
 
          }
 

	
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 

	
 
        repo_group = get_repo_group_or_error(repogroupid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoGroupPermissionLevel('admin')(repo_group.group_name):
 
                raise JSONRPCError('repository group `%s` does not exist' % (repogroupid,))
 

	
 
        user = get_user_or_error(userid)
 
        perm = get_perm_or_error(perm, prefix='group.')
 

	
 
        try:
 
            RepoGroupModel().add_permission(repo_group=repo_group,
 
                                            obj=user,
 
                                            obj_type="user",
 
                                            perm=perm,
 
                                            recursive=apply_to_children)
 
            meta.Session().commit()
 
            return dict(
 
                msg='Granted perm: `%s` (recursive:%s) for user: `%s` in repo group: `%s`' % (
 
                    perm.permission_name, apply_to_children, user.username, repo_group.name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user: `%s` in repo group: `%s`' % (
 
                    userid, repo_group.name))
 

	
 
    # permission check inside
 
    def revoke_user_permission_from_repo_group(self, repogroupid, userid,
 
                                               apply_to_children='none'):
 
        """
 
        Revoke permission for user on given repository group. This command can
 
        be executed only using api_key belonging to user with admin rights, or
 
        user who has admin right to given repository group.
 

	
 
        :param repogroupid: name or id of repository group
 
        :type repogroupid: str or int
 
        :param userid:
 
        :type userid:
 
        :param apply_to_children: 'none', 'repos', 'groups', 'all'
 
        :type apply_to_children: str
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Revoked perm (recursive:<apply_to_children>) for user: `<username>` in repo group: `<repo_group_name>`",
 
                      "success": true
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to edit permission for user: `<userid>` in repo group: `<repo_group_name>`"
 
          }
 

	
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 

	
 
        repo_group = get_repo_group_or_error(repogroupid)
 

	
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoGroupPermissionLevel('admin')(repo_group.group_name):
 
                raise JSONRPCError('repository group `%s` does not exist' % (repogroupid,))
 

	
 
        user = get_user_or_error(userid)
 

	
 
        try:
 
            RepoGroupModel().delete_permission(repo_group=repo_group,
 
                                               obj=user,
 
                                               obj_type="user",
 
                                               recursive=apply_to_children)
 

	
 
            meta.Session().commit()
 
            return dict(
 
                msg='Revoked perm (recursive:%s) for user: `%s` in repo group: `%s`' % (
 
                    apply_to_children, user.username, repo_group.name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user: `%s` in repo group: `%s`' % (
 
                    userid, repo_group.name))
 

	
 
    # permission check inside
 
    def grant_user_group_permission_to_repo_group(
 
            self, repogroupid, usergroupid, perm,
 
            apply_to_children='none'):
 
        """
 
        Grant permission for user group on given repository group, or update
 
        existing one if found. This command can be executed only using
 
        api_key belonging to user with admin rights, or user who has admin
 
        right to given repository group.
 

	
 
        :param repogroupid: name or id of repository group
 
        :type repogroupid: str or int
 
        :param usergroupid: id of usergroup
 
        :type usergroupid: str or int
 
        :param perm: (group.(none|read|write|admin))
 
        :type perm: str
 
        :param apply_to_children: 'none', 'repos', 'groups', 'all'
 
        :type apply_to_children: str
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg" : "Granted perm: `<perm>` (recursive:<apply_to_children>) for user group: `<usersgroupname>` in repo group: `<repo_group_name>`",
 
            "success": true
 

	
 
            "success" : true
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to edit permission for user group: `<usergroup>` in repo group: `<repo_group_name>`"
 
          }
 

	
 
          error : null
 
        """
 
        repo_group = get_repo_group_or_error(repogroupid)
 
        perm = get_perm_or_error(perm, prefix='group.')
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoGroupPermissionLevel('admin')(repo_group.group_name):
 
                raise JSONRPCError(
 
                    'repository group `%s` does not exist' % (repogroupid,))
 

	
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError(
 
                    'user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            RepoGroupModel().add_permission(repo_group=repo_group,
 
                                            obj=user_group,
 
                                            obj_type="user_group",
 
                                            perm=perm,
 
                                            recursive=apply_to_children)
 
            meta.Session().commit()
 
            return dict(
 
                msg='Granted perm: `%s` (recursive:%s) for user group: `%s` in repo group: `%s`' % (
 
                    perm.permission_name, apply_to_children,
 
                    user_group.users_group_name, repo_group.name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user group: `%s` in '
 
                'repo group: `%s`' % (
 
                    usergroupid, repo_group.name
 
                )
 
            )
 

	
 
    # permission check inside
 
    def revoke_user_group_permission_from_repo_group(
 
            self, repogroupid, usergroupid,
 
            apply_to_children='none'):
 
        """
 
        Revoke permission for user group on given repository. This command can be
 
        executed only using api_key belonging to user with admin rights, or
 
        user who has admin right to given repository group.
 

	
 
        :param repogroupid: name or id of repository group
 
        :type repogroupid: str or int
 
        :param usergroupid:
 
        :param apply_to_children: 'none', 'repos', 'groups', 'all'
 
        :type apply_to_children: str
 

	
 
        OUTPUT::
 

	
 
            id : <id_given_in_input>
 
            result: {
 
            result : {
 
                      "msg" : "Revoked perm (recursive:<apply_to_children>) for user group: `<usersgroupname>` in repo group: `<repo_group_name>`",
 
                      "success": true
 
                    }
 
            error:  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to edit permission for user group: `<usergroup>` in repo group: `<repo_group_name>`"
 
          }
 

	
 

	
 
                      "success" : true
 
                     }
 
            error : null
 
        """
 
        repo_group = get_repo_group_or_error(repogroupid)
 
        user_group = get_user_group_or_error(usergroupid)
 
        if not HasPermissionAny('hg.admin')():
 
            if not HasRepoGroupPermissionLevel('admin')(repo_group.group_name):
 
                raise JSONRPCError(
 
                    'repository group `%s` does not exist' % (repogroupid,))
 

	
 
            if not HasUserGroupPermissionLevel('read')(user_group.users_group_name):
 
                raise JSONRPCError(
 
                    'user group `%s` does not exist' % (usergroupid,))
 

	
 
        try:
 
            RepoGroupModel().delete_permission(repo_group=repo_group,
 
                                               obj=user_group,
 
                                               obj_type="user_group",
 
                                               recursive=apply_to_children)
 
            meta.Session().commit()
 
            return dict(
 
                msg='Revoked perm (recursive:%s) for user group: `%s` in repo group: `%s`' % (
 
                    apply_to_children, user_group.users_group_name, repo_group.name
 
                ),
 
                success=True
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError(
 
                'failed to edit permission for user group: `%s` in repo group: `%s`' % (
 
                    user_group.users_group_name, repo_group.name
 
                )
 
            )
 

	
 
    def get_gist(self, gistid):
 
        """
 
        Get given gist by id
 

	
 
        :param gistid: id of private or public gist
 
        :type gistid: str
 
        """
 
        gist = get_gist_or_error(gistid)
 
        if not HasPermissionAny('hg.admin')():
 
            if gist.owner_id != request.authuser.user_id:
 
                raise JSONRPCError('gist `%s` does not exist' % (gistid,))
 
        return gist.get_api_data()
 

	
 
    def get_gists(self, userid=None):
 
        """
 
        Get all gists for given user. If userid is empty returned gists
 
        are for user who called the api
 

	
 
        :param userid: user to get gists for
 
        :type userid: Optional(str or int)
 
        """
 
        if not HasPermissionAny('hg.admin')():
 
            # make sure normal user does not pass someone else userid,
 
            # he is not allowed to do that
 
            if userid is not None and userid != request.authuser.user_id:
 
                raise JSONRPCError(
 
                    'userid is not the same as your user'
 
                )
 

	
 
        if userid is None:
 
            user_id = request.authuser.user_id
 
        else:
 
            user_id = get_user_or_error(userid).user_id
 

	
 
        return [
 
            gist.get_api_data()
 
            for gist in db.Gist().query()
 
                .filter_by(is_expired=False)
 
                .filter(db.Gist.owner_id == user_id)
 
                .order_by(db.Gist.created_on.desc())
 
        ]
 

	
 
    def create_gist(self, files, owner=None,
 
                    gist_type=db.Gist.GIST_PUBLIC, lifetime=-1,
 
                    description=''):
 

	
 
        """
 
        Creates new Gist
 

	
 
        :param files: files to be added to gist
 
            {'filename': {'content':'...', 'lexer': null},
 
             'filename2': {'content':'...', 'lexer': null}}
 
        :type files: dict
 
        :param owner: gist owner, defaults to api method caller
 
        :type owner: Optional(str or int)
 
        :param gist_type: type of gist 'public' or 'private'
 
        :type gist_type: Optional(str)
 
        :param lifetime: time in minutes of gist lifetime
 
        :type lifetime: Optional(int)
 
        :param description: gist description
 
        :type description: Optional(str)
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "msg": "created new gist",
 
            "gist": {}
 
            "msg" : "created new gist",
 
            "gist" : <gist_object>
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to create gist"
 
          }
 

	
 
          error : null
 
        """
 
        try:
 
            if owner is None:
 
                owner = request.authuser.user_id
 

	
 
            owner = get_user_or_error(owner)
 

	
 
            gist = GistModel().create(description=description,
 
                                      owner=owner,
 
                                      ip_addr=request.ip_addr,
 
                                      gist_mapping=files,
 
                                      gist_type=gist_type,
 
                                      lifetime=lifetime)
 
            meta.Session().commit()
 
            return dict(
 
                msg='created new gist',
 
                gist=gist.get_api_data()
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to create gist')
 

	
 
    # permission check inside
 
    def delete_gist(self, gistid):
 
        """
 
        Deletes existing gist
 

	
 
        :param gistid: id of gist to delete
 
        :type gistid: str
 

	
 
        OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : {
 
            "deleted gist ID: <gist_id>",
 
            "gist": null
 
            "msg" : "deleted gist ID: <gist_id>",
 
            "gist" : null
 
          }
 
          error :  null
 

	
 
        ERROR OUTPUT::
 

	
 
          id : <id_given_in_input>
 
          result : null
 
          error :  {
 
            "failed to delete gist ID:<gist_id>"
 
          }
 

	
 
          error : null
 
        """
 
        gist = get_gist_or_error(gistid)
 
        if not HasPermissionAny('hg.admin')():
 
            if gist.owner_id != request.authuser.user_id:
 
                raise JSONRPCError('gist `%s` does not exist' % (gistid,))
 

	
 
        try:
 
            GistModel().delete(gist)
 
            meta.Session().commit()
 
            return dict(
 
                msg='deleted gist ID:%s' % (gist.gist_access_id,),
 
                gist=None
 
            )
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            raise JSONRPCError('failed to delete gist ID:%s'
 
                               % (gist.gist_access_id,))
 

	
 
    # permission check inside
 
    def get_changesets(self, repoid, start=None, end=None, start_date=None,
 
                       end_date=None, branch_name=None, reverse=False, with_file_list=False, max_revisions=None):
 
        """
 
        TODO
 
        """
 
        repo = get_repo_or_error(repoid)
 
        if not HasRepoPermissionLevel('read')(repo.repo_name):
 
            raise JSONRPCError('Access denied to repo %s' % repo.repo_name)
 

	
 
        format = "%Y-%m-%dT%H:%M:%S"
 
        try:
 
            return [e.__json__(with_file_list) for e in
 
                repo.scm_instance.get_changesets(start,
 
                                                 end,
 
                                                 datetime.strptime(start_date, format) if start_date else None,
 
                                                 datetime.strptime(end_date, format) if end_date else None,
 
                                                 branch_name,
 
                                                 reverse, max_revisions)]
 
        except EmptyRepositoryError as e:
 
            raise JSONRPCError('Repository is empty')
 

	
 
    # permission check inside
 
    def get_changeset(self, repoid, raw_id, with_reviews=False):
 
    def get_changeset(self, repoid, raw_id, with_reviews=False, with_comments=False, with_inline_comments=False):
 
        """
 
        TODO
 
        """
 
        repo = get_repo_or_error(repoid)
 
        if not HasRepoPermissionLevel('read')(repo.repo_name):
 
            raise JSONRPCError('Access denied to repo %s' % repo.repo_name)
 
        changeset = repo.get_changeset(raw_id)
 
        if isinstance(changeset, EmptyChangeset):
 
            raise JSONRPCError('Changeset %s does not exist' % raw_id)
 

	
 
        info = dict(changeset.as_dict())
 

	
 
        if with_reviews:
 
            reviews = ChangesetStatusModel().get_statuses(
 
                                repo.repo_name, raw_id)
 
                                repo.repo_name, changeset.raw_id)
 
            info["reviews"] = reviews
 

	
 
        if with_comments:
 
            comments = ChangesetCommentsModel().get_comments(
 
                                repo.repo_id, changeset.raw_id)
 
            info["comments"] = comments
 

	
 
        if with_inline_comments:
 
            inline_comments = ChangesetCommentsModel().get_inline_comments(
 
                                repo.repo_id, changeset.raw_id)
 
            info["inline_comments"] = inline_comments
 

	
 
        return info
 

	
 
    # permission check inside
 
    def get_pullrequest(self, pullrequest_id):
 
        """
 
        Get given pull request by id
 
        """
 
        pull_request = db.PullRequest.get(pullrequest_id)
 
        if pull_request is None:
 
            raise JSONRPCError('pull request `%s` does not exist' % (pullrequest_id,))
 
        if not HasRepoPermissionLevel('read')(pull_request.org_repo.repo_name):
 
            raise JSONRPCError('not allowed')
 
        return pull_request.get_api_data()
 

	
 
    # permission check inside
 
    def comment_pullrequest(self, pull_request_id, comment_msg='', status=None, close_pr=False):
 
        """
 
        Add comment, close and change status of pull request.
 
        """
 
        apiuser = get_user_or_error(request.authuser.user_id)
 
        pull_request = db.PullRequest.get(pull_request_id)
 
        if pull_request is None:
 
            raise JSONRPCError('pull request `%s` does not exist' % (pull_request_id,))
 
        if (not HasRepoPermissionLevel('read')(pull_request.org_repo.repo_name)):
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -14,48 +14,49 @@
 
"""
 
kallithea.controllers.pullrequests
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
pull requests controller for Kallithea for initializing pull requests
 

	
 
This file was forked by the Kallithea project in July 2014.
 
Original author and date, and relevant copyright and licensing information is below:
 
:created_on: May 7, 2012
 
:author: marcink
 
:copyright: (c) 2013 RhodeCode GmbH, and others.
 
:license: GPLv3, see LICENSE.md for more details.
 
"""
 

	
 
import logging
 
import traceback
 

	
 
import formencode
 
import mercurial.unionrepo
 
from tg import request
 
from tg import tmpl_context as c
 
from tg.i18n import ugettext as _
 
from webob.exc import HTTPBadRequest, HTTPForbidden, HTTPFound, HTTPNotFound
 

	
 
import kallithea
 
import kallithea.lib.helpers as h
 
from kallithea.controllers import base
 
from kallithea.controllers.changeset import create_cs_pr_comment, delete_cs_pr_comment
 
from kallithea.lib import auth, diffs, webutils
 
from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
 
from kallithea.lib.graphmod import graph_data
 
from kallithea.lib.page import Page
 
from kallithea.lib.utils2 import ascii_bytes, safe_bytes, safe_int
 
from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError, EmptyRepositoryError
 
from kallithea.lib.webutils import url
 
from kallithea.model import db, meta
 
from kallithea.model.changeset_status import ChangesetStatusModel
 
from kallithea.model.comment import ChangesetCommentsModel
 
from kallithea.model.forms import PullRequestForm, PullRequestPostForm
 
from kallithea.model.pull_request import CreatePullRequestAction, CreatePullRequestIterationAction, PullRequestModel
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
def _get_reviewer(user_id):
 
    """Look up user by ID and validate it as a potential reviewer."""
 
    try:
 
        user = db.User.get(int(user_id))
 
@@ -473,48 +474,50 @@ class PullrequestsController(base.BaseRe
 
        for x in c.pull_request.revisions:
 
            try:
 
                c.cs_ranges.append(org_scm_instance.get_changeset(x))
 
            except ChangesetDoesNotExistError:
 
                c.cs_ranges = []
 
                webutils.flash(_('Revision %s not found in %s') % (x, c.cs_repo.repo_name),
 
                    'error')
 
                break
 
        c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ...
 
        revs = [ctx.revision for ctx in reversed(c.cs_ranges)]
 
        c.jsdata = graph_data(org_scm_instance, revs)
 

	
 
        c.is_range = False
 
        try:
 
            if c.a_ref_type == 'rev': # this looks like a free range where target is ancestor
 
                cs_a = org_scm_instance.get_changeset(c.a_rev)
 
                root_parents = c.cs_ranges[0].parents
 
                c.is_range = cs_a in root_parents
 
                #c.merge_root = len(root_parents) > 1 # a range starting with a merge might deserve a warning
 
        except ChangesetDoesNotExistError: # probably because c.a_rev not found
 
            pass
 
        except IndexError: # probably because c.cs_ranges is empty, probably because revisions are missing
 
            pass
 

	
 
        rev_limit = safe_int(kallithea.CONFIG.get('next_iteration_rev_limit'), 0)
 

	
 
        avail_revs = set()
 
        avail_show = []
 
        c.cs_branch_name = c.cs_ref_name
 
        c.a_branch_name = None
 
        other_scm_instance = c.a_repo.scm_instance
 
        c.update_msg = ""
 
        c.update_msg_other = ""
 
        try:
 
            if not c.cs_ranges:
 
                c.update_msg = _('Error: changesets not found when displaying pull request from %s.') % c.cs_rev
 
            elif org_scm_instance.alias == 'hg' and c.a_ref_name != 'ancestor':
 
                if c.cs_ref_type != 'branch':
 
                    c.cs_branch_name = org_scm_instance.get_changeset(c.cs_ref_name).branch # use ref_type ?
 
                c.a_branch_name = c.a_ref_name
 
                if c.a_ref_type != 'branch':
 
                    try:
 
                        c.a_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ?
 
                    except EmptyRepositoryError:
 
                        c.a_branch_name = 'null' # not a branch name ... but close enough
 
                # candidates: descendants of old head that are on the right branch
 
                #             and not are the old head itself ...
 
                #             and nothing at all if old head is a descendant of target ref name
 
                if not c.is_range and other_scm_instance._repo.revs('present(%s)::&%s', c.cs_ranges[-1].raw_id, c.a_branch_name):
 
                    c.update_msg = _('This pull request has already been merged to %s.') % c.a_branch_name
 
@@ -542,48 +545,56 @@ class PullrequestsController(base.BaseRe
 
                        else:
 
                            c.update_msg = _('No additional changesets found for iterating on this pull request.')
 
                    else:
 
                        show = set()
 
                        avail_revs = set() # drop revs[0]
 
                        c.update_msg = _('No additional changesets found for iterating on this pull request.')
 

	
 
                    # TODO: handle branch heads that not are tip-most
 
                    brevs = org_scm_instance._repo.revs('%s - %ld - %s', c.cs_branch_name, avail_revs, revs[0])
 
                    if brevs:
 
                        # also show changesets that are on branch but neither ancestors nor descendants
 
                        show.update(org_scm_instance._repo.revs('::%ld - ::%ld - ::%s', brevs, avail_revs, c.a_branch_name))
 
                        show.add(revs[0]) # make sure graph shows this so we can see how they relate
 
                        c.update_msg_other = _('Note: Branch %s has another head: %s.') % (c.cs_branch_name,
 
                            org_scm_instance.get_changeset(max(brevs)).short_id)
 

	
 
                    avail_show = sorted(show, reverse=True)
 

	
 
            elif org_scm_instance.alias == 'git':
 
                c.cs_repo.scm_instance.get_changeset(c.cs_rev) # check it exists - raise ChangesetDoesNotExistError if not
 
                c.update_msg = _("Git pull requests don't support iterating yet.")
 
        except ChangesetDoesNotExistError:
 
            c.update_msg = _('Error: some changesets not found when displaying pull request from %s.') % c.cs_rev
 

	
 
        if rev_limit:
 
            if len(avail_revs) - 1 > rev_limit:
 
                c.update_msg = _('%d additional changesets are not shown.') % (len(avail_revs) - 1)
 
                avail_show = []
 
            elif len(avail_show) - 1 > rev_limit:
 
                c.update_msg = _('%d changesets available for merging are not shown.') % (len(avail_show) - len(avail_revs))
 
                avail_show = sorted(avail_revs, reverse=True)
 

	
 
        c.avail_revs = avail_revs
 
        c.avail_cs = [org_scm_instance.get_changeset(r) for r in avail_show]
 
        c.avail_jsdata = graph_data(org_scm_instance, avail_show)
 

	
 
        raw_ids = [x.raw_id for x in c.cs_ranges]
 
        c.cs_comments = c.cs_repo.get_comments(raw_ids)
 
        c.cs_statuses = c.cs_repo.statuses(raw_ids)
 

	
 
        ignore_whitespace_diff = h.get_ignore_whitespace_diff(request.GET)
 
        diff_context_size = h.get_diff_context_size(request.GET)
 
        fulldiff = request.GET.get('fulldiff')
 
        diff_limit = None if fulldiff else self.cut_off_limit
 

	
 
        # we swap org/other ref since we run a simple diff on one repo
 
        log.debug('running diff between %s and %s in %s',
 
                  c.a_rev, c.cs_rev, org_scm_instance.path)
 
        try:
 
            raw_diff = diffs.get_diff(org_scm_instance, rev1=c.a_rev, rev2=c.cs_rev,
 
                                      ignore_whitespace=ignore_whitespace_diff, context=diff_context_size)
 
        except ChangesetDoesNotExistError:
 
            raw_diff = safe_bytes(_("The diff can't be shown - the PR revisions could not be found."))
 
        diff_processor = diffs.DiffProcessor(raw_diff, diff_limit=diff_limit)
 
        c.limited_diff = diff_processor.limited_diff
 
        c.file_diff_data = []
kallithea/i18n/be/LC_MESSAGES/kallithea.po
Show inline comments
 
# Copyright (C) 2016 Various authors, licensing as GPLv3
 
# This file is distributed under the same license as the Kallithea project.
 

	
 
msgid ""
 
msgstr ""
 
"Report-Msgid-Bugs-To: translations@kallithea-scm.org\n"
 
"Language: be\n"
 
"MIME-Version: 1.0\n"
 
"Content-Type: text/plain; charset=UTF-8\n"
 
"Content-Transfer-Encoding: 8bit\n"
 
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
 
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
 
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
 
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
 

	
 
msgid "Repository not found in the filesystem"
 
msgstr "Рэпазітар не знойдзены на файлавай сістэме"
 

	
 
msgid "There are no changesets yet"
 
msgstr "Яшчэ не было змен"
 

	
 
msgid "Changeset for %s %s not found in %s"
 
msgstr "Набор змен для %s %s не знойдзены ў %s"
 

	
 
msgid "None"
 
msgstr "Нічога"
 

	
 
msgid "(closed)"
 
msgstr "(зачынена)"
 

	
 
msgid "Successfully deleted pull request %s"
 
msgstr "Pull-запыт %s паспяхова выдалены"
 

	
 
msgid "Such revision does not exist for this repository"
 
msgstr "Няма такой рэвізіі ў гэтым рэпазітары"
 

	
 
msgid "Could not find other repository %s"
 
msgstr "Не атрымалася знайсці іншы рэпазітар %s"
 
@@ -1393,60 +1393,63 @@ msgstr "Карыстальнік/група карыстальнікаў"
 
msgid "Default"
 
msgstr "Па змоўчанні"
 

	
 
msgid "Revoke"
 
msgstr "Адклікаць"
 

	
 
msgid "Add new"
 
msgstr "Дадаць новы"
 

	
 
msgid "Both"
 
msgstr "Абедзьве"
 

	
 
msgid "Remove this group"
 
msgstr "Выдаліць гэту групу"
 

	
 
msgid "Confirm to delete this group"
 
msgstr "Пацвердзіце выдаленне гэтай групы карыстальнікаў"
 

	
 
msgid "Repository Groups Administration"
 
msgstr "Адміністраванне груп рэпазітароў"
 

	
 
msgid "Number of Top-level Repositories"
 
msgstr "Лік рэпазітароў верхняга ўзроўня"
 

	
 
msgid "Type of repository to create."
 
msgstr "Тып стваранага рэпазітара."
 

	
 
msgid "Repository URL"
 
msgstr "URL рэпазітара"
 

	
 
msgid ""
 
"Keep it short and to the point. Use a README file for longer descriptions."
 
msgstr ""
 
"Кароткае і асэнсаванае. Для разгорнутага апісання выкарыстоўвайце файл "
 
"README."
 

	
 
msgid "Optionally select a group to put this repository into."
 
msgstr "Апцыянальна абраць групу, у якую змясціць дадзены рэпазітар."
 

	
 
msgid "Type of repository to create."
 
msgstr "Тып стваранага рэпазітара."
 

	
 
msgid "Landing revision"
 
msgstr "Рэвізія для выгрузкі"
 

	
 
msgid "%s Creating Repository"
 
msgstr "Стварэнне рэпазітара %s"
 

	
 
msgid "Creating repository"
 
msgstr "Стварэнне рэпазітара"
 

	
 
msgid "%s Repository Settings"
 
msgstr "Налады рэпазітара %s"
 

	
 
msgid "Extra Fields"
 
msgstr "Дадатковыя палі"
 

	
 
msgid "Remote"
 
msgstr "Выдалены"
 

	
 
msgid "Statistics"
 
msgstr "Статыстыка"
 

	
 
msgid "Parent"
 
msgstr "Бацькоўская група"
 

	
 
@@ -1508,55 +1511,48 @@ msgstr "Увядзіце кароткае імя поля"
 
msgid "New field description"
 
msgstr "Апісанне поля"
 

	
 
msgid "Enter description of a field"
 
msgstr "Увядзіце апісанне поля"
 

	
 
msgid "Extra fields are disabled."
 
msgstr "Дадатковыя палі адключаныя."
 

	
 
msgid "Private Repository"
 
msgstr "Прыватны рэпазітар"
 

	
 
msgid "Remote repository URL"
 
msgstr "URL аддаленага рэпазітара"
 

	
 
msgid "Pull Changes from Remote Repository"
 
msgstr "Занесці змены з аддаленага рэпазітара"
 

	
 
msgid "Confirm to pull changes from remote repository."
 
msgstr "Пацвердзіце спампоўку змен з аддаленага рэпазітара."
 

	
 
msgid "Remote repository"
 
msgstr "Аддалены рэпазітар"
 

	
 
msgid "Repository URL"
 
msgstr "URL рэпазітара"
 

	
 
msgid "Default revision for files page, downloads, whoosh and readme"
 
msgstr ""
 
"Рэвізія па змоўчанні, з якой будзе рабіцца выгрузка файлаў пры спампоўцы"
 

	
 
msgid "Change owner of this repository."
 
msgstr "Змяніць уладальніка рэпазітара."
 

	
 
msgid "Reset Statistics"
 
msgstr "Скід статыстыкі"
 

	
 
msgid "Confirm to remove current statistics."
 
msgstr "Пацвердзіце скіданне статыстыкі."
 

	
 
msgid "Repositories Administration"
 
msgstr "Адміністраванне рэпазітароў"
 

	
 
msgid "State"
 
msgstr "Стан"
 

	
 
msgid "Settings Administration"
 
msgstr "Адміністраванне налад"
 

	
 
msgid "Hooks"
 
msgstr "Хукі"
 

	
 
msgid "Full Text Search"
 
msgstr "Паўнатэкставы пошук"
 

	
 
@@ -1870,53 +1866,53 @@ msgstr "Дадаць яшчэ адзін каментар"
 
msgid "Stop following this repository"
 
msgstr "Адмяніць назіранне за рэпазітаром"
 

	
 
msgid "Start following this repository"
 
msgstr "Назіраць за рэпазітаром"
 

	
 
msgid "Group"
 
msgstr "Група"
 

	
 
msgid "Loading ..."
 
msgstr "Загрузка..."
 

	
 
msgid "loading ..."
 
msgstr "загрузка..."
 

	
 
msgid "Search truncated"
 
msgstr "Пошук усечаны"
 

	
 
msgid "No matching files"
 
msgstr "Няма супадзенняў"
 

	
 
msgid "Open New Pull Request from {0}"
 
msgstr "Стварыць новы pull-запыт з {0}"
 

	
 
msgid "Open New Pull Request for {0} &rarr; {1}"
 
msgstr "Стварыць новы pull-запыт для {0} &rarr; {1}"
 

	
 
msgid "Show Selected Changesets {0} &rarr; {1}"
 
msgstr "Паказаць выбраныя наборы змен: {0} &rarr; {1}"
 
msgid "Open New Pull Request for {0}"
 
msgstr "Стварыць новы pull-запыт для {0}"
 

	
 
msgid "Show Selected Changesets {0}"
 
msgstr "Паказаць выбраныя наборы змен {0}"
 

	
 
msgid "Selection Link"
 
msgstr "Спасылка выбару"
 

	
 
msgid "Collapse Diff"
 
msgstr "Згарнуць параўнанне"
 

	
 
msgid "Expand Diff"
 
msgstr "Разгарнуць параўнанне"
 

	
 
msgid "No revisions"
 
msgstr "Няма рэвізій"
 

	
 
msgid "Failed to revoke permission"
 
msgstr "Не атрымалася адклікаць прывілеі"
 

	
 
msgid "Confirm to revoke permission for {0}: {1}?"
 
msgstr "Пацвердзіце выдаленне прывілею для {0}: {1}?"
 

	
 
msgid "Select changeset"
 
msgstr "Выбраць набор змен"
 

	
 
msgid "Specify changeset"
 
msgstr "Выбраць набор змен"
kallithea/i18n/de/LC_MESSAGES/kallithea.po
Show inline comments
 
@@ -937,50 +937,50 @@ msgstr ""
 

	
 
msgid "Cannot assign this group as parent"
 
msgstr "Kann diese Gruppe nicht als vorgesetzt setzen"
 

	
 
msgid "Group \"%(group_name)s\" already exists"
 
msgstr "Gruppe \"%(group_name)s\" existiert bereits"
 

	
 
msgid "Repository with name \"%(group_name)s\" already exists"
 
msgstr "Es gibt bereits ein Repository mit \"%(group_name)s\""
 

	
 
msgid "Invalid characters (non-ascii) in password"
 
msgstr "Üngültige(nicht ASCII) Zeichen im Passwort"
 

	
 
msgid "Invalid old password"
 
msgstr "Ungültiges altes Passwort"
 

	
 
msgid "Passwords do not match"
 
msgstr "Die Passwörter stimmen nicht überein"
 

	
 
msgid "Repository named %(repo)s already exists"
 
msgstr "Es gibt bereits ein Repository mit \"%(repo)s\""
 

	
 
msgid "Repository \"%(repo)s\" already exists in group \"%(group)s\""
 
msgstr ""
 
"Es gibt bereits ein Repository mit \"%(repo)s\" in der Gruppe \"%(group)s"
 
"\""
 
"Es gibt bereits ein Repository mit \"%(repo)s\" in der Gruppe "
 
"\"%(group)s\""
 

	
 
msgid "Repository group with name \"%(repo)s\" already exists"
 
msgstr "Eine Repositorygruppe mit dem Namen \"%(repo)s\" existiert bereits"
 

	
 
msgid "Invalid repository URL"
 
msgstr "Ungültige Repository-URL"
 

	
 
msgid "Fork has to be the same type as parent"
 
msgstr "Forke um den selben typ wie der Vorgesetze zu haben"
 

	
 
msgid "You don't have permissions to create repository in this group"
 
msgstr ""
 
"Du hast nicht die erforderlichen Berechtigungen, um in dieser Gruppe ein "
 
"Repository zu erzeugen"
 

	
 
msgid "no permission to create repository in root location"
 
msgstr "keine Berechtigung, um ein Repository auf höchster Ebene anzulegen"
 

	
 
msgid "You don't have permissions to create a group in this location"
 
msgstr ""
 
"Sie haben keine Berechtigung, um an diesem Ort ein Repository anzulegen"
 

	
 
msgid "This username or user group name is not valid"
 
msgstr "Dieser Benutzername oder Benutzergruppenname ist nicht gültig"
 
@@ -1594,87 +1594,93 @@ msgstr "Benutzergruppen hinzufügen oder ändern"
 

	
 
msgid "Default"
 
msgstr "Vorgabe"
 

	
 
msgid "Revoke"
 
msgstr "Zurückziehen"
 

	
 
msgid "Add new"
 
msgstr "Neues hinzufügen"
 

	
 
msgid "Apply to children"
 
msgstr "Auf untergeordnete Elemente anwenden"
 

	
 
msgid "Both"
 
msgstr "Beide"
 

	
 
msgid ""
 
"Set or revoke permission to all children of that group, including non-"
 
"private repositories and other groups if selected."
 
msgstr ""
 
"Setzen oder zurückziehen von Berechtigungen bezüglich aller "
 
"untergeordneten Elemente, einschließlich nicht-privater Repositories und "
 
"anderer Gruppen, falls ausgewählt."
 

	
 
msgid "Type name of user"
 
msgstr "Typname des Benutzers"
 

	
 
msgid "Remove this group"
 
msgstr "Diese Gruppe löschen"
 

	
 
msgid "Confirm to delete this group"
 
msgstr "Löschen der Gruppe bestätigen"
 

	
 
msgid "Repository group %s"
 
msgstr "Repository-Gruppe %s"
 

	
 
msgid "Repository Groups Administration"
 
msgstr "Repositorygruppenverwaltung"
 

	
 
msgid "Number of Top-level Repositories"
 
msgstr "Anzahl der Repositories oberster Ebene"
 

	
 
msgid "Type of repository to create."
 
msgstr "Repository Typ der erstellt werden soll."
 

	
 
msgid "Clone remote repository"
 
msgstr "Entferntes Repository clonen"
 

	
 
msgid "Repository URL"
 
msgstr "Repository URL"
 

	
 
msgid ""
 
"Optional: URL of a remote repository. If set, the repository will be "
 
"created as a clone from this URL."
 
msgstr ""
 
"Optional: URL eines entfernten Repositories. Falls gesetzt, dann wird das "
 
"Repository als Clon von dieser URL erstellt."
 

	
 
msgid ""
 
"Keep it short and to the point. Use a README file for longer descriptions."
 
msgstr ""
 
"Halten Sie es kurz und prägnant. Benutzen Sie eine README-Datei für "
 
"längere Beschreibungen."
 

	
 
msgid "Optionally select a group to put this repository into."
 
msgstr ""
 
"Wähle bei Bedarf eine Gruppe, der dieses Repository zugeordnet werden "
 
"soll."
 

	
 
msgid "Type of repository to create."
 
msgstr "Repository Typ der erstellt werden soll."
 

	
 
msgid "Landing revision"
 
msgstr "Start Revision"
 

	
 
msgid ""
 
"Default revision for files page, downloads, full text search index and "
 
"readme generation"
 
msgstr ""
 
"Vorgabe-Revision für Datei-Seiten, Downloads, Volltext-Indizierung und "
 
"Doku-Erzeugung"
 

	
 
msgid "%s Creating Repository"
 
msgstr "%s Erstelle Repository"
 

	
 
msgid "Creating repository"
 
msgstr "Repository erzeugen"
 

	
 
msgid ""
 
"Repository \"%(repo_name)s\" is being created, you will be redirected "
 
"when this process is finished.repo_name"
 
msgstr ""
 
"Repository \"%(repo_name)s\" wird erzeugt. Sie werden dorthin umgeleitet, "
 
"sobald der Prozess abgeschlossen ist."
 

	
 
msgid ""
 
@@ -1773,82 +1779,58 @@ msgstr "Beschreibung des neuen Felds"
 
msgid "Enter description of a field"
 
msgstr "Beschreibung eines Felds eingeben"
 

	
 
msgid "Extra fields are disabled."
 
msgstr "Zusatzfelder sind deaktiviert."
 

	
 
msgid "Private Repository"
 
msgstr "Privates Repository"
 

	
 
msgid "Fork of repository"
 
msgstr "Fork des Repository"
 

	
 
msgid "Remote repository URL"
 
msgstr "URL des entfernten Repository"
 

	
 
msgid "Pull Changes from Remote Repository"
 
msgstr "Hole Änderungen vom entfernten Repository"
 

	
 
msgid "Confirm to pull changes from remote repository."
 
msgstr "Bestätige die Abholung von Änderungen vom entfernten Repository."
 

	
 
msgid "This repository does not have a remote repository URL."
 
msgstr "Für dieses Repository ist keine nicht-lokale URL angegeben."
 

	
 
msgid ""
 
"In case this repository is renamed or moved into another group the "
 
"repository URL changes.\n"
 
"                               Using the above permanent URL guarantees "
 
"that this repository always will be accessible on that URL.\n"
 
"                               This is useful for CI systems, or any "
 
"other cases that you need to hardcode the URL into a 3rd party service."
 
msgstr ""
 
"Falls dieses Repository umbenannt oder in eine andere Gruppe verschoben "
 
"wird, ändert sich seine URL.\n"
 
"Die Verwendung der permanenten URL garantiert, dass dieses Repository "
 
"immer über diese URL erreichbar sein wird.\n"
 
"Dies ist insbesondere für CI-Systeme oder in Fällen nützlich, in denen "
 
"die URL des Repositories bei Dritten dauerhaft eingetragen wird."
 

	
 
msgid "Remote repository"
 
msgstr "Entferntes Repository"
 

	
 
msgid "Repository URL"
 
msgstr "Repository URL"
 

	
 
msgid ""
 
"Optional: URL of a remote repository. If set, the repository can be "
 
"pulled from this URL."
 
msgstr ""
 
"Optional: URL eines entfernten Repositories. Falls gesetzt, dann kann das "
 
"Repository von dieser URL bezogen werden."
 

	
 
msgid "Default revision for files page, downloads, whoosh and readme"
 
msgstr "Standardrevision für Dateiseite, Downloads, Whoosh und Readme"
 

	
 
msgid "Type name of user"
 
msgstr "Typname des Benutzers"
 

	
 
msgid "Change owner of this repository."
 
msgstr "Besitzer des Repositorys ändern."
 

	
 
msgid "Processed commits"
 
msgstr "Verarbeitete Commits"
 

	
 
msgid "Processed progress"
 
msgstr "Verarbeiteter Fortschritt"
 

	
 
msgid "Reset Statistics"
 
msgstr "Statistiken zurücksetzen"
 

	
 
msgid "Confirm to remove current statistics."
 
msgstr "Bestätigen Sie, um die aktuellen Statistiken zu entfernen."
 

	
 
msgid "Repositories Administration"
 
msgstr "Repositoryverwaltung"
 

	
 
msgid "State"
 
msgstr "Zustand"
 

	
 
msgid "Settings Administration"
 
msgstr "Einstellungsverwaltung"
 

	
 
@@ -2475,29 +2457,26 @@ msgstr "Datei geändert"
 
msgid "file removed"
 
msgstr "Datei entfernt"
 

	
 
msgid "Clone from"
 
msgstr "Clone von"
 

	
 
msgid "Clone URL"
 
msgstr "Clone-URL"
 

	
 
msgid "Download as zip"
 
msgstr "Herunterladen als zip"
 

	
 
msgid "Feed"
 
msgstr "Feed"
 

	
 
msgid "Latest Changes"
 
msgstr "Letzte Änderungen"
 

	
 
msgid "Quick Start"
 
msgstr "Schnelleinstieg"
 

	
 
msgid "Add or upload files directly via Kallithea"
 
msgstr "Dateien direkt über Kallithea hinzufügen oder hochladen"
 

	
 
msgid "Readme file from revision %s:%s"
 
msgstr "Liesmich-Datei von Revision %s:%s"
 

	
 
msgid "Download %s as %s"
 
msgstr "%s als %s herunterladen"
kallithea/i18n/el/LC_MESSAGES/kallithea.po
Show inline comments
 
@@ -556,48 +556,55 @@ msgid "Repositories successfully rescann
 
msgstr ""
 
"Τα αποθετήρια ξανασαρώθηκαν επιτυχώς. Προστέθηκαν: %s. Αφαιρέθηκαν %s."
 

	
 
msgid "Invalidated %s repositories"
 
msgstr "Ακυρώθηκαν %s αποθετήρια"
 

	
 
msgid "Updated application settings"
 
msgstr "Ενημερώθηκαν οι ρυθμίσεις της εφαρμογής"
 

	
 
msgid "Updated visualisation settings"
 
msgstr "Ενημερώθηκαν οι ρυθμίσεις της απεικόνισης"
 

	
 
msgid "Error occurred during updating visualisation settings"
 
msgstr "Παρουσιάστηκε σφάλμα κατά την ενημέρωση των ρυθμίσεων απεικόνισης"
 

	
 
msgid "Please enter email address"
 
msgstr "Παρακαλώ εισάγετε την διεύθυνση ηλεκτρονικού ταχυδρομείου"
 

	
 
msgid "Send email task created"
 
msgstr "Δημιουργήθηκε η εργασία της αποστολής ηλεκτρονικού ταχυδρομείου"
 

	
 
msgid "Hook already exists"
 
msgstr "Το άγκιστρο υπάρχει ήδη"
 

	
 
msgid ""
 
"Hook names with \".kallithea_\" are reserved for internal use. Please use "
 
"another hook name."
 
msgstr ""
 
"Άγκιστρα με το όνομα \".kallithea_\" είναι δεσμευμένα για εσωτερική "
 
"χρήση. Παρακαλώ δώστε άλλο όνομα στο άγκιστρο."
 

	
 
msgid "Added new hook"
 
msgstr "Προσθήκη νέου άγκιστρου"
 

	
 
msgid "Updated hooks"
 
msgstr "Τα άγκιστρα ενημερώθηκαν"
 

	
 
msgid "Error occurred during hook creation"
 
msgstr "Παρουσιάστηκε σφάλμα κατά την δημιουργία του άγκιστρου"
 

	
 
msgid "Whoosh reindex task scheduled"
 
msgstr "Προγραμματίστηκε η αναδημιουργία ευρετηρίου για το Whoosh"
 

	
 
msgid "Created user group %s"
 
msgstr "Δημιουργήθηκε η ομάδα χρηστών %s"
 

	
 
msgid "Error occurred during creation of user group %s"
 
msgstr "Παρουσιάστηκε σφάλμα κατά τη δημιουργία της ομάδας χρηστών %s"
 

	
 
msgid "Updated user group %s"
 
msgstr "Ενημερώθηκε η ομάδα χρηστών %s"
 

	
 
msgid "Error occurred during update of user group %s"
 
msgstr "Παρουσιάστηκε σφάλμα κατά την ενημέρωση της ομάδας χρηστών %s"
 

	
 
@@ -644,48 +651,54 @@ msgid "An error occurred while adding IP
 
msgstr "Παρουσιάστηκε σφάλμα κατά την προσθήκη της IP διεύθυνσης"
 

	
 
msgid "Removed IP address from user whitelist"
 
msgstr "Η IP διεύθυνση αφαιρέθηκε από τη λίστα επιτρεπόμενων του χρήστη"
 

	
 
msgid "You need to be a registered user to perform this action"
 
msgstr ""
 
"Πρέπει να είστε εγγεγραμμένος χρήστης για να εκτελέσετε αυτή την ενέργεια"
 

	
 
msgid "You need to be signed in to view this page"
 
msgstr "Πρέπει να είστε συνδεμένος για να δείτε αυτήν τη σελίδα"
 

	
 
msgid "Binary file"
 
msgstr "Δυαδικό αρχείο"
 

	
 
msgid ""
 
"Changeset was too big and was cut off, use diff menu to display this diff"
 
msgstr ""
 
"Το σετ αλλαγών ήταν πολύ μεγάλο και αποκόπηκε, χρησιμοποιήστε το μενού "
 
"διαφορών για να εμφανίσετε τις διαφορές"
 

	
 
msgid "No changes detected"
 
msgstr "Δεν εντοπίστηκαν αλλαγές"
 

	
 
msgid "Show whitespace changes"
 
msgstr "Εμφάνιση αλλαγής κενού"
 

	
 
msgid "Ignore whitespace changes"
 
msgstr "Αγνόηση αλλαγής κενού"
 

	
 
msgid "Increase diff context to %(num)s lines"
 
msgstr "Αύξηση του diff πλαισίου σε %(num)s γραμμές"
 

	
 
msgid "Deleted branch: %s"
 
msgstr "Διαγραφή κλάδου: %s"
 

	
 
msgid "Created tag: %s"
 
msgstr "Δημιουργηθείσα ετικέτα: %s"
 

	
 
msgid "Changeset %s not found"
 
msgstr "Δεν βρέθηκε το σετ αλλαγών %s"
 

	
 
msgid "Show all combined changesets %s->%s"
 
msgstr "Εμφάνιση όλων των συνδυασμένων σετ αλλαγών %s->%s"
 

	
 
msgid "Compare view"
 
msgstr "Σύγκριση εμφάνισης"
 

	
 
msgid "and"
 
msgstr "και"
 

	
 
msgid "%s more"
 
msgstr "%s επιπλέον"
 

	
 
@@ -761,48 +774,96 @@ msgstr "[σταμάτησε να ακολουθεί] αποθετήριο δεδομένων"
 
msgid " and %s more"
 
msgstr " και %s περισσότερα"
 

	
 
msgid "No files"
 
msgstr "Δεν υπάρχουν αρχεία"
 

	
 
msgid "new file"
 
msgstr "νέο αρχείο"
 

	
 
msgid "mod"
 
msgstr "τροποποιημένο"
 

	
 
msgid "del"
 
msgstr "διαγραμμένο"
 

	
 
msgid "rename"
 
msgstr "μετονομασία"
 

	
 
msgid "chmod"
 
msgstr "chmod"
 

	
 
msgid "SSH key is missing"
 
msgstr "Το κλειδί SSH λείπει"
 

	
 
msgid ""
 
"Invalid SSH key - it must have both a key type and a base64 part, like "
 
"'ssh-rsa ASRNeaZu4FA...xlJp='"
 
msgstr ""
 
"Άκυρο κλειδί SSH - πρέπει να έχει έναν τύπο κλειδιού καθώς και ένα τμήμα "
 
"base64, όπως \"ssh-rsa ASRNeaZu4FA ... xlJp =\""
 

	
 
msgid ""
 
"Invalid SSH key - it must start with key type 'ssh-rsa', 'ssh-dss', 'ssh-"
 
"ed448', or 'ssh-ed25519'"
 
msgstr ""
 
"Άκυρο κλειδί SSH - πρέπει να ξεκινά με τύπο κλειδιού 'ssh-rsa',ssh-"
 
"dss','ssh-ed448' ή 'ssh-ed25519'"
 

	
 
msgid "Invalid SSH key - unexpected characters in base64 part %r"
 
msgstr "Άκυρο κλειδί SSH - μη αναμενόμενοι χαρακτήρες στο τμήμα base64 %r"
 

	
 
msgid ""
 
"Invalid SSH key - base64 part %r seems truncated (it can't be decoded)"
 
msgstr ""
 
"Άκυρο κλειδί SSH - το base64 μέρος %r φαίνεται κομμένο (δεν μπορεί να "
 
"αποκωδικοποιηθεί)"
 

	
 
msgid ""
 
"Invalid SSH key - base64 part %r seems truncated (it contains a partial "
 
"string length)"
 
msgstr ""
 
"Άκυρο κλειδί SSH - το base64 μέρος %r φαίνεται κομμένο (περιέχει ένα "
 
"μερικό μήκος συμβολοσειράς)"
 

	
 
msgid ""
 
"Invalid SSH key - base64 part %r seems truncated (it is too short for "
 
"declared string length %s)"
 
msgstr ""
 
"Άκυρο κλειδί SSH - το τμήμα base64 %r φαίνεται να είναι κομμένο (είναι "
 
"πολύ μικρό για το δηλωμένο μήκος συμβολοσειράς %s)"
 

	
 
msgid ""
 
"Invalid SSH key - base64 part %r seems truncated (it contains too few "
 
"strings for a %s key)"
 
msgstr ""
 
"Άκυρο κλειδί SSH - το base64 τμήμα %r φαίνεται να είναι περικομμένο "
 
"(περιέχει πολύ λίγες συμβολοσειρές για ένα κλειδί %s)"
 

	
 
msgid "Invalid SSH key - it is a %s key but the base64 part contains %r"
 
msgstr ""
 
"Άκυρο κλειδί SSH - είναι ένα κλειδί %s αλλά το base64 μέρος περιέχει %r"
 

	
 
msgid "%d year"
 
msgid_plural "%d years"
 
msgstr[0] "%d έτος"
 
msgstr[1] "%d έτη"
 

	
 
msgid "%d month"
 
msgid_plural "%d months"
 
msgstr[0] "%d μήνας"
 
msgstr[1] "%d μήνες"
 

	
 
msgid "%d day"
 
msgid_plural "%d days"
 
msgstr[0] "%d ημέρα"
 
msgstr[1] "%d ημέρες"
 

	
 
msgid "%d hour"
 
msgid_plural "%d hours"
 
msgstr[0] "%d ώρα"
 
msgstr[1] "%d ώρες"
 

	
 
msgid "%d minute"
 
msgid_plural "%d minutes"
 
msgstr[0] "%d λεπτό"
 
msgstr[1] "%d λεπτά"
 
@@ -914,51 +975,72 @@ msgstr "Δεν έχει ελεγχθεί"
 
msgid "Under review"
 
msgstr "Υπό εξέταση"
 

	
 
msgid "Not approved"
 
msgstr "Δεν έχει εγκριθεί"
 

	
 
msgid "Approved"
 
msgstr "Εγκρίθηκε"
 

	
 
msgid "Please enter a login"
 
msgstr "Παρακαλώ εισάγετε ένα όνομα χρήστη"
 

	
 
msgid "Enter a value %(min)i characters long or more"
 
msgstr "Εισαγάγετε μια τιμή με μήκος %(min)i χαρακτήρες ή περισσότερους"
 

	
 
msgid "Please enter a password"
 
msgstr "Παρακαλώ εισάγετε έναν κωδικό πρόσβασης"
 

	
 
msgid "Enter %(min)i characters or more"
 
msgstr "Εισαγάγετε %(min)i χαρακτήρες ή περισσότερους"
 

	
 
msgid "Name must not contain only digits"
 
msgstr "Το όνομα δεν πρέπει να περιέχει μόνο ψηφία"
 

	
 
msgid ""
 
"[Comment] %(repo_name)s changeset %(short_id)s \"%(message_short)s\" on "
 
"%(branch)s by %(cs_author_username)s"
 
msgstr ""
 
"[Σχόλιο] %(repo_name)s changeset %(short_id)s \"%(message_short)s\" στο "
 
"%(branch)s από %(cs_author_username)s"
 

	
 
msgid "New user %(new_username)s registered"
 
msgstr "Καταχωρήθηκε νέος χρήστης %(new_username)s"
 

	
 
msgid ""
 
"[Review] %(repo_name)s PR %(pr_nice_id)s \"%(pr_title_short)s\" from "
 
"%(pr_source_branch)s by %(pr_owner_username)s"
 
msgstr ""
 
"[Κριτική] %(repo_name)s PR %(pr_nice_id)s \"%(pr_title_short)s\" στο "
 
"%(pr_source_branch)s από %(pr_owner_username)s"
 

	
 
msgid ""
 
"[Comment] %(repo_name)s PR %(pr_nice_id)s \"%(pr_title_short)s\" from "
 
"%(pr_source_branch)s by %(pr_owner_username)s"
 
msgstr ""
 
"[Σχόλιο] %(repo_name)s PR %(pr_nice_id)s \"%(pr_title_short)s\" στο "
 
"%(pr_source_branch)s από %(pr_owner_username)s"
 

	
 
msgid "Closing"
 
msgstr "Κλείσιμο"
 

	
 
msgid "Cannot create empty pull request"
 
msgstr "Δεν είναι δυνατή η δημιουργία κενής αίτησης έλξης"
 

	
 
msgid ""
 
"Cannot create pull request - criss cross merge detected, please merge a "
 
"later %s revision to %s"
 
msgstr ""
 
"Δεν είναι δυνατή η δημιουργία αίτησης έλξης - εντοπίστηκε διασταυρούμενη "
 
"συγχώνευση, παρακαλώ συγχωνεύστε μια μεταγενέστερη αναθεώρηση %s στο %s"
 

	
 
msgid "You are not authorized to create the pull request"
 
msgstr "Δεν έχετε εξουσιοδότηση για τη δημιουργία του αιτήματος έλξης"
 

	
 
msgid "Missing changesets since the previous iteration:"
 
msgstr "Λείπουν σετ αλλαγών από την προηγούμενη επανάληψη:"
 

	
 
msgid "New changesets on %s %s since the previous iteration:"
 
msgstr "Νέα σετ αλλαγών στο %s %s από την προηγούμενη επανάληψη:"
 

	
 
msgid "Ancestor didn't change - diff since previous iteration:"
 
msgstr "Ο πρόγονος δεν άλλαξε - διαφορά από την προηγούμενη επανάληψη:"
 
@@ -1082,48 +1164,53 @@ msgstr "Μη έγκυροι χαρακτήρες (μη ascii) στον κωδικό πρόσβασης"
 
msgid "Invalid old password"
 
msgstr "Ο παλιός κωδικός πρόσβασης δεν είναι έγκυρος"
 

	
 
msgid "Passwords do not match"
 
msgstr "Οι κωδικοί πρόσβασης δεν ταιριάζουν"
 

	
 
msgid "Invalid username or password"
 
msgstr "Το όνομα χρήστη ή ο κωδικός πρόσβασης δεν είναι έγκυρος"
 

	
 
msgid "Repository name %(repo)s is not allowed"
 
msgstr "Δεν επιτρέπεται το %(repo)s ως όνομα του αποθετηρίου"
 

	
 
msgid "Repository named %(repo)s already exists"
 
msgstr "Το αποθετήριο με το όνομα %(repo)s υπάρχει ήδη"
 

	
 
msgid "Repository \"%(repo)s\" already exists in group \"%(group)s\""
 
msgstr "Το αποθετήριο \"%(repo)s\" υπάρχει ήδη στην ομάδα \"%(group)s\""
 

	
 
msgid "Repository group with name \"%(repo)s\" already exists"
 
msgstr "Η ομάδα αποθετηρίου με το όνομα \"%(repo)s\" υπάρχει ήδη"
 

	
 
msgid "Invalid repository URL"
 
msgstr "Μη έγκυρη διεύθυνση URL αποθετηρίου"
 

	
 
msgid "Invalid repository URL. It must be a valid http, https, or ssh URL"
 
msgstr ""
 
"Μη έγκυρο αποθετήριο URL. Πρέπει να είναι μια έγκυρη http, https ή ssh "
 
"διεύθυνση URL"
 

	
 
msgid "Fork has to be the same type as parent"
 
msgstr "Ο κλώνος πρέπει να έχει τον ίδιο τύπο με τον γονέα του"
 

	
 
msgid "You don't have permissions to create repository in this group"
 
msgstr "Δεν έχετε δικαιώματα δημιουργίας αποθετηρίου σε αυτήν την ομάδα"
 

	
 
msgid "no permission to create repository in root location"
 
msgstr "Δεν υπάρχει δικαίωμα δημιουργίας αποθετηρίου στη ριζική τοποθεσία"
 

	
 
msgid "You don't have permissions to create a group in this location"
 
msgstr "Δεν έχετε δικαιώματα δημιουργίας ομάδας σε αυτήν την τοποθεσία"
 

	
 
msgid "This username or user group name is not valid"
 
msgstr "Αυτό το όνομα χρήστη ή το όνομα ομάδας χρηστών δεν είναι έγκυρο"
 

	
 
msgid "This is not a valid path"
 
msgstr "Αυτή η διαδρομή δεν είναι έγκυρη"
 

	
 
msgid "This email address is already in use"
 
msgstr "Αυτή η διεύθυνση ηλεκτρονικού ταχυδρομείου χρησιμοποιείται ήδη"
 

	
 
msgid "Email address \"%(email)s\" not found"
 
msgstr "Η διεύθυνση ηλεκτρονικού ταχυδρομείου \"%(email)s\" δεν βρέθηκε"
 

	
 
@@ -1802,86 +1889,92 @@ msgstr "Χρήστης / Ομάδα χρηστών"
 

	
 
msgid "Default"
 
msgstr "Προεπιλογή"
 

	
 
msgid "Revoke"
 
msgstr "Ανακάλεσε"
 

	
 
msgid "Add new"
 
msgstr "Προσθήκη νέου"
 

	
 
msgid "Apply to children"
 
msgstr "Εφαρμογή στα θυγατρικά"
 

	
 
msgid "Both"
 
msgstr "Και τα δυο"
 

	
 
msgid ""
 
"Set or revoke permission to all children of that group, including non-"
 
"private repositories and other groups if selected."
 
msgstr ""
 
"Ορίστε ή ανακαλέστε τα θυγατρικά δικαιώματα αυτής της ομάδας, "
 
"συμπεριλαμβανομένων των μη ιδιωτικών αποθετηρίων και άλλων ομάδων, εάν "
 
"επιλεγεί."
 

	
 
msgid "Type name of user"
 
msgstr "Πληκτρολογήστε το όνομα του χρήστη"
 

	
 
msgid "Remove this group"
 
msgstr "Κατάργηση αυτής της ομάδας"
 

	
 
msgid "Confirm to delete this group"
 
msgstr "Επιβεβαιώστε για να διαγράψετε αυτή την ομάδα"
 

	
 
msgid "Repository group %s"
 
msgstr "Ομάδα αποθετηρίων %s"
 

	
 
msgid "Repository Groups Administration"
 
msgstr "Διαχείριση Ομάδων Αποθετηρίου"
 

	
 
msgid "Number of Top-level Repositories"
 
msgstr "Αριθμός αποθετηρίων ανώτατου επιπέδου"
 

	
 
msgid "Type of repository to create."
 
msgstr "Τύπος αποθετηρίου προς δημιουργία."
 

	
 
msgid "Clone remote repository"
 
msgstr "Κλωνοποίηση απομακρυσμένου αποθετηρίου"
 

	
 
msgid "Repository URL"
 
msgstr "URL Αποθετηρίου"
 

	
 
msgid ""
 
"Optional: URL of a remote repository. If set, the repository will be "
 
"created as a clone from this URL."
 
msgstr ""
 
"Προαιρετικό: Διεύθυνση URL ενός απομακρυσμένου αποθετηρίου. Εάν οριστεί, "
 
"το αποθετήριο θα δημιουργηθεί ως κλώνος από αυτήν τη διεύθυνση URL."
 

	
 
msgid ""
 
"Keep it short and to the point. Use a README file for longer descriptions."
 
msgstr ""
 
"Κρατήστε τη σύντομη και περιεκτική. Χρησιμοποιήστε ένα αρχείο README για "
 
"μεγαλύτερες περιγραφές."
 

	
 
msgid "Optionally select a group to put this repository into."
 
msgstr ""
 
"Προαιρετικά, επιλέξτε μια ομάδα για να τοποθετήσετε αυτό το αποθετήριο."
 

	
 
msgid "Type of repository to create."
 
msgstr "Τύπος αποθετηρίου προς δημιουργία."
 

	
 
msgid "Landing revision"
 
msgstr "Αναθεώρηση εκφόρτωσης"
 

	
 
msgid ""
 
"Default revision for files page, downloads, full text search index and "
 
"readme generation"
 
msgstr ""
 
"Προεπιλεγμένη αναθεώρηση για τη σελίδα αρχείων, λήψεων, ευρετήριο "
 
"αναζήτησης πλήρους κειμένου και δημιουργία readme"
 

	
 
msgid "%s Creating Repository"
 
msgstr "%s Δημιουργία Αποθετηρίου"
 

	
 
msgid "Creating repository"
 
msgstr "Δημιουργία αποθετηρίου"
 

	
 
msgid ""
 
"Repository \"%(repo_name)s\" is being created, you will be redirected "
 
"when this process is finished.repo_name"
 
msgstr ""
 
"Δημιουργείται το αποθετήριο \"%(repo_name)s\", θα ανακατευθυνθείτε όταν "
 
"ολοκληρωθεί αυτή η διαδικασία."
 

	
 
msgid ""
 
@@ -1987,85 +2080,58 @@ msgstr "Τα επιπλέον πεδία είναι απενεργοποιημένα."
 
msgid "Private Repository"
 
msgstr "Ιδιωτικό Αποθετήριο"
 

	
 
msgid "Fork of repository"
 
msgstr "Κλώνος αποθετηρίου"
 

	
 
msgid "Remote repository URL"
 
msgstr "Διεύθυνση URL απομακρυσμένου αποθετηρίου"
 

	
 
msgid "Pull Changes from Remote Repository"
 
msgstr "Τραβήξτε τις αλλαγές από το απομακρυσμένο αποθετήριο"
 

	
 
msgid "Confirm to pull changes from remote repository."
 
msgstr ""
 
"Επιβεβαιώστε ότι θα τραβήξετε αλλαγές από το απομακρυσμένο αποθετήριο "
 
"δεδομένων."
 

	
 
msgid "This repository does not have a remote repository URL."
 
msgstr ""
 
"Αυτό το αποθετήριο δεν έχει διεύθυνση URL απομακρυσμένου αποθετηρίου."
 

	
 
msgid "Permanent URL"
 
msgstr "Μόνιμη διεύθυνση URL"
 

	
 
msgid ""
 
"In case this repository is renamed or moved into another group the "
 
"repository URL changes.\n"
 
"                               Using the above permanent URL guarantees "
 
"that this repository always will be accessible on that URL.\n"
 
"                               This is useful for CI systems, or any "
 
"other cases that you need to hardcode the URL into a 3rd party service."
 
msgstr ""
 
"Η διεύθυνση URL του αποθετηρίου αλλάζει όταν αυτό μετονομαστεί ή "
 
"μετακινηθεί σε άλλη ομάδα.\n"
 
"                               Η χρήση της παραπάνω μόνιμης διεύθυνσης "
 
"URL εγγυάται ότι αυτό το αποθετήριο θα είναι πάντα προσβάσιμο σε αυτήν τη "
 
"διεύθυνση URL.\n"
 
"                               Αυτό είναι χρήσιμο για συστήματα CI ή για "
 
"άλλες περιπτώσεις που χρειάζεστε να κωδικοποιήσετε τη διεύθυνση URL σε "
 
"κάποια υπηρεσία τρίτου μέρους."
 

	
 
msgid "Remote repository"
 
msgstr "Απομακρυσμένο αποθετήριο"
 

	
 
msgid "Repository URL"
 
msgstr "URL Αποθετηρίου"
 

	
 
msgid ""
 
"Optional: URL of a remote repository. If set, the repository can be "
 
"pulled from this URL."
 
msgstr ""
 
"Προαιρετικό: Διεύθυνση URL ενός απομακρυσμένου αποθετηρίου. Εάν οριστεί, "
 
"το αποθετήριο μπορεί να τραβηχτεί από αυτήν τη διεύθυνση URL."
 

	
 
msgid "Default revision for files page, downloads, whoosh and readme"
 
msgstr ""
 
"Προεπιλεγμένη αναθεώρηση για τη σελίδα αρχείων, λήψεων, Whoosh και readme"
 

	
 
msgid "Type name of user"
 
msgstr "Πληκτρολογήστε το όνομα του χρήστη"
 

	
 
msgid "Change owner of this repository."
 
msgstr "Αλλάξτε τον κάτοχο αυτού του αποθετηρίου."
 

	
 
msgid "Processed commits"
 
msgstr "Επεξεργασμένα commits"
 

	
 
msgid "Processed progress"
 
msgstr "Επεξεργασμένη πρόοδος"
 

	
 
msgid "Reset Statistics"
 
msgstr "Επαναφορά Στατιστικών"
 

	
 
msgid "Confirm to remove current statistics."
 
msgstr "Επιβεβαιώστε την κατάργηση των τρεχόντων στατιστικών στοιχείων."
 

	
 
msgid "Repositories Administration"
 
msgstr "Διαχείριση Αποθετηρίων"
 

	
 
msgid "State"
 
msgstr "Κατάσταση"
 

	
 
msgid "Settings Administration"
 
msgstr "Διαχείριση Ρυθμίσεων"
 

	
 
@@ -2115,76 +2181,91 @@ msgstr ""
 
"HTML (ενδεχομένως με JavaScript ή / και CSS) που θα προστεθούν στο κάτω "
 
"μέρος της κάθε σελίδας. Αυτό μπορεί να χρησιμοποιηθεί για web analytics, "
 
"αλλά και για την προσαρμογή της εμφάνισης, όπως η προσθήκη ενός banner "
 
"στο επάνω μέρος κάθε σελίδας."
 

	
 
msgid "ReCaptcha public key"
 
msgstr "Δημόσιο κλειδί ReCaptcha"
 

	
 
msgid "Public key for reCaptcha system."
 
msgstr "Δημόσιο κλειδί για το σύστημα reCaptcha."
 

	
 
msgid "ReCaptcha private key"
 
msgstr "Ιδιωτικό κλειδί ReCaptcha"
 

	
 
msgid ""
 
"Private key for reCaptcha system. Setting this value will enable captcha "
 
"on registration."
 
msgstr ""
 
"Ιδιωτικό κλειδί για το σύστημα reCaptcha. Ο καθορισμός αυτής της τιμής θα "
 
"ενεργοποιήσει το captcha κατά την εγγραφή."
 

	
 
msgid "Save Settings"
 
msgstr "Αποθήκευση Ρυθμίσεων"
 

	
 
msgid "Custom Hooks are not enabled"
 
msgstr "Τα προσαρμοσμένα άγκιστρα δεν είναι ενεργά"
 

	
 
msgid "Failed to remove hook"
 
msgstr "Απέτυχε η αφαίρεση γάντζου"
 

	
 
msgid "Rescan options"
 
msgstr "Επιλογές Επανασάρωσης"
 

	
 
msgid "Delete records of missing repositories"
 
msgstr "Διαγραφή εγγραφών αποθετηρίων που λείπουν"
 

	
 
msgid ""
 
"Check this option to remove all comments, pull requests and other records "
 
"related to repositories that no longer exist in the filesystem."
 
msgstr ""
 
"Επιλέξτε αυτήν την επιλογή για να καταργήσετε όλα τα σχόλια, να αιτήματα "
 
"έλξης και άλλες εγγραφές που σχετίζονται με αποθετήρια που δεν υπάρχουν "
 
"πλέον στο σύστημα αρχείων."
 

	
 
msgid "Invalidate cache for all repositories"
 
msgstr "Ακυρώνει την προσωρινή αποθήκευση για όλα τα αποθετήρια"
 

	
 
msgid "Check this to reload data and clear cache keys for all repositories."
 
msgstr ""
 
"Επιλέξτε αυτό για να φορτώσετε ξανά τα δεδομένα και να καταργήστε την "
 
"cache για όλα τα αποθετήρια."
 

	
 
msgid "Install Git hooks"
 
msgstr "Εγκατάσταση Git hooks"
 

	
 
msgid "Install and overwrite Git hooks"
 
msgstr "Εγκατάσταση και επανεγγραφή Git hooks"
 

	
 
msgid ""
 
"Install Kallithea's internal hooks for all Git repositories. Existing "
 
"hooks that don't seem to come from Kallithea will be disabled by renaming "
 
"to .bak extension."
 
msgstr ""
 
"Εγκαταστήστε τα εσωτερικά hooks της Kallithea για όλα τα αποθετήρια Git. "
 
"Τα υπάρχοντα hooks που δεν φαίνεται να προέρχονται από την Kallithea θα "
 
"απενεργοποιηθούν με τη μετονομασία σε επέκταση .bak."
 

	
 
msgid "Rescan Repositories"
 
msgstr "Επανασάρωση αποθετηρίων"
 

	
 
msgid "Index build option"
 
msgstr "Επιλογή δημιουργίας ευρετηρίου"
 

	
 
msgid "Build from scratch"
 
msgstr "Κατασκευή από το μηδέν"
 

	
 
msgid ""
 
"This option completely reindexes all of the repositories for proper "
 
"fulltext search capabilities."
 
msgstr ""
 
"Αυτή η επιλογή ξαναδημιουργεί πλήρως τα ευρετήρια σε όλα τα αποθετήρια "
 
"για δυνατότητα αναζήτησης πλήρους κειμένου."
 

	
 
msgid "Reindex"
 
msgstr "Αναδημιουργία ευρετηρίου"
 

	
 
msgid "Checking for updates..."
 
msgstr "Έλεγχος για ενημερώσεις..."
 

	
 
msgid "Kallithea version"
 
msgstr "Έκδοση Καλλιθέας"
 
@@ -2644,53 +2725,53 @@ msgstr "Προσθήκη και άλλου Σχολίου"
 
msgid "Stop following this repository"
 
msgstr "Διακοπή παρακολούθησης αυτού του αποθετηρίου"
 

	
 
msgid "Start following this repository"
 
msgstr "Έναρξη παρακολούθησης αυτού του αποθετηρίου"
 

	
 
msgid "Group"
 
msgstr "Ομάδα"
 

	
 
msgid "Loading ..."
 
msgstr "Φόρτωση..."
 

	
 
msgid "loading ..."
 
msgstr "φόρτωση ..."
 

	
 
msgid "Search truncated"
 
msgstr "Περικομμένη αναζήτηση"
 

	
 
msgid "No matching files"
 
msgstr "Δεν υπάρχουν αρχεία που να ταιριάζουν"
 

	
 
msgid "Open New Pull Request from {0}"
 
msgstr "Άνοιγμα νέας αίτησης έλξης από {0}"
 

	
 
msgid "Open New Pull Request for {0} &rarr; {1}"
 
msgstr "Άνοιγμα νέου αιτήματος έλξης για {0} &rarr; {1}"
 

	
 
msgid "Show Selected Changesets {0} &rarr; {1}"
 
msgstr "Εμφάνιση Επιλεγμένων Σετ Αλλαγών {0} &rarr; {1}"
 
msgid "Open New Pull Request for {0}"
 
msgstr "Άνοιγμα νέου αιτήματος έλξης για {0}"
 

	
 
msgid "Show Selected Changesets {0}"
 
msgstr "Εμφάνιση Επιλεγμένων Σετ Αλλαγών {0}"
 

	
 
msgid "Selection Link"
 
msgstr "Σύνδεσμος Επιλογής"
 

	
 
msgid "Collapse Diff"
 
msgstr "Σύμπτυξη Διαφοράς"
 

	
 
msgid "Expand Diff"
 
msgstr "Ανάπτυξη Διαφοράς"
 

	
 
msgid "No revisions"
 
msgstr "Χωρίς αναθεωρήσεις"
 

	
 
msgid "Type name of user or member to grant permission"
 
msgstr ""
 
"Πληκτρολογήστε το όνομα του χρήστη ή του μέλους για την εκχώρηση "
 
"δικαιωμάτων"
 

	
 
msgid "Failed to revoke permission"
 
msgstr "Απέτυχε η ανάκληση του δικαιωμάτος"
 

	
 
msgid "Confirm to revoke permission for {0}: {1}?"
 
msgstr "Επιβεβαιώστε την ανάκληση του δικαιώματος για {0}: {1};"
 

	
 
@@ -2751,48 +2832,51 @@ msgid "Added"
 
msgstr "Προστέθηκε"
 

	
 
msgid "Affected %s files"
 
msgstr "Επηρεάστηκαν %s αρχεία"
 

	
 
msgid "First (oldest) changeset in this list"
 
msgstr "Πρώτο (παλαιότερο) σετ αλλαγών σε αυτήν τη λίστα"
 

	
 
msgid "Last (most recent) changeset in this list"
 
msgstr "Τελευταίο (πιο πρόσφατο) σετ αλλαγών σε αυτήν τη λίστα"
 

	
 
msgid "Position in this list of changesets"
 
msgstr "Θέση σε αυτήν τη λίστα των αλλαγών"
 

	
 
msgid ""
 
"Changeset status: %s by %s\n"
 
"Click to open associated pull request %s"
 
msgstr ""
 
"Κατάσταση συνόλου αλλαγών: %s από %s\n"
 
"Κάντε κλικ για να ανοίξετε το συσχετισμένο αίτημα έλξης %s"
 

	
 
msgid "Changeset status: %s by %s"
 
msgstr "Κατάσταση σετ αλλαγών: %s από %s"
 

	
 
msgid "(No commit message)"
 
msgstr "(Χωρίς κείμενο commit)"
 

	
 
msgid "Expand commit message"
 
msgstr "Ανάπτυξη μηνύματος commit"
 

	
 
msgid "%s comments"
 
msgstr "%s σχόλια"
 

	
 
msgid "Bookmark %s"
 
msgstr "Σελιδοδείκτης %s"
 

	
 
msgid "Tag %s"
 
msgstr "Ετικέτα %s"
 

	
 
msgid "Branch %s"
 
msgstr "Κλάδος %s"
 

	
 
msgid "%s Changeset"
 
msgstr "Σετ αλλαγών %s"
 

	
 
msgid "Changeset status"
 
msgstr "Κατάσταση σετ αλλαγών"
 

	
 
msgid "Raw diff"
 
msgstr "Ακατέργαστη διαφορά"
 

	
 
@@ -2913,48 +2997,54 @@ msgstr "Αρχείο πριν"
 
msgid "Modified"
 
msgstr "Τροποποιημένο"
 

	
 
msgid "Deleted"
 
msgstr "Διαγράφηκε"
 

	
 
msgid "Renamed"
 
msgstr "Μετονομάστηκε"
 

	
 
msgid "Unknown operation: %r"
 
msgstr "Άγνωστη λειτουργία: %r"
 

	
 
msgid "No file after"
 
msgstr "Δεν υπάρχει αρχείο μετά"
 

	
 
msgid "File after"
 
msgstr "Αρχείο μετά"
 

	
 
msgid "Show full diff for this file"
 
msgstr "Εμφάνιση πλήρους διαφοράς για αυτό το αρχείο"
 

	
 
msgid "Show full side-by-side diff for this file"
 
msgstr "Εμφάνιση πλήρους διαφοράς δίπλα-δίπλα για αυτό το αρχείο"
 

	
 
msgid "Raw diff for this file"
 
msgstr "Διαφορές για αυτό το αρχείο"
 

	
 
msgid "Download diff for this file"
 
msgstr "Μεταφόρτωση διαφοράς για αυτό το αρχείο"
 

	
 
msgid "Show inline comments"
 
msgstr "Εμφάνιση ενσωματωμένων σχολίων"
 

	
 
msgid "No changesets"
 
msgstr "Χωρίς σετ αλλαγών"
 

	
 
msgid "Criss cross merge situation with multiple merge ancestors detected!"
 
msgstr ""
 
"Εντοπίστηκε κατάσταση διασταυρούμενης συγχώνευσης με πολλούς προγόνους "
 
"συγχώνευσης!"
 

	
 
msgid ""
 
"Please merge the target branch to your branch before creating a pull "
 
"request."
 
msgstr ""
 
"Παρακαλώ συγχωνεύστε τον κλάδο-στόχο στον κλάδο σας πριν δημιουργήσετε "
 
"ένα αίτημα έλξης."
 

	
 
msgid "Merge Ancestor"
 
msgstr "Πρόγονος Συγχώνευσης"
 

	
 
msgid "Show merge diff"
 
msgstr "Εμφάνιση διαφοράς συγχώνευσης"
 

	
 
@@ -3599,29 +3689,26 @@ msgstr "Λήψη ως zip"
 
msgid "Check this to download archive with subrepos"
 
msgstr "Επιλέξτε αυτό για τη λήψη του αρχείου με τα υπο-αποθετήρια"
 

	
 
msgid "With subrepos"
 
msgstr "Με υπο-αποθετήρια"
 

	
 
msgid "Feed"
 
msgstr "Ροή"
 

	
 
msgid "Latest Changes"
 
msgstr "Τελευταίες Αλλαγές"
 

	
 
msgid "Quick Start"
 
msgstr "Γρήγορη Εκκίνηση"
 

	
 
msgid "Add or upload files directly via Kallithea"
 
msgstr "Προσθέστε ή ανεβάστε αρχεία απευθείας μέσω Καλλιθέας"
 

	
 
msgid "Push new repository"
 
msgstr "Ώθηση νέου αποθετηρίου"
 

	
 
msgid "Existing repository?"
 
msgstr "Υπάρχον αποθετήριο;"
 

	
 
msgid "Readme file from revision %s:%s"
 
msgstr "Αρχείο Readme από την αναθεώρηση %s:%s"
 

	
 
msgid "Download %s as %s"
 
msgstr "Λήψη %s ως %s"
kallithea/i18n/es/LC_MESSAGES/kallithea.po
Show inline comments
 
# Copyright (C) 2016 Various authors, licensing as GPLv3
 
# This file is distributed under the same license as the Kallithea project.
 

	
 
msgid ""
 
msgstr ""
 
"Report-Msgid-Bugs-To: translations@kallithea-scm.org\n"
 
"Language: es\n"
 
"MIME-Version: 1.0\n"
 
"Content-Type: text/plain; charset=UTF-8\n"
 
"Content-Transfer-Encoding: 8bit\n"
 
"Plural-Forms: nplurals=2; plural=n != 1;\n"
 

	
 
msgid "There are no changesets yet"
 
msgstr "Aún no hay cambios"
 

	
 
msgid "SSH access is disabled."
 
msgstr "El acceso mediante SSH está desactivado."
 

	
 
msgid "None"
 
msgstr "Ninguno"
 

	
 
msgid "(closed)"
 
msgstr "(cerrado)"
 

	
 
msgid "Successfully deleted pull request %s"
 
msgstr "Petición de pull %s eliminada correctamente"
 

	
 
msgid "Such revision does not exist for this repository"
 
msgstr "La revisión no existe en este repositorio"
 

	
 
msgid "Could not find other repository %s"
 
msgstr "No se puede encontrar otro repositorio %s"
 

	
 
msgid "Cannot compare repositories of different types"
 
msgstr "No se pueden comparar repositorios de diferentes tipos"
 

	
 
msgid "Cannot show empty diff"
 
msgstr "No se puede mostrar diff vacio"
 

	
 
msgid "Cannot compare repositories without using common ancestor"
 
msgstr "No se pueden comparar repositorios sin usar un ancestro común"
 

	
 
@@ -56,48 +59,51 @@ msgid "You don't have permission to view
 
msgstr "No tiene permiso para ver esta página"
 

	
 
msgid "The resource could not be found"
 
msgstr "No se ha encontrado el recurso"
 

	
 
msgid ""
 
"The server encountered an unexpected condition which prevented it from "
 
"fulfilling the request."
 
msgstr ""
 
"La petición no se ha podido completar debido a que el servidor encontró "
 
"un problema inesperado."
 

	
 
msgid "%s committed on %s"
 
msgstr "%s anotó en %s"
 

	
 
msgid "Changeset was too big and was cut off..."
 
msgstr "El cambio era demasiado grande y se redució..."
 

	
 
msgid "%s %s feed"
 
msgstr "%s%s canal"
 

	
 
msgid "Click here to add new file"
 
msgstr "Haga clic aquí para añadir un archivo nuevo"
 

	
 
msgid "There are no files yet."
 
msgstr "Aún no hay archivos."
 

	
 
msgid "%s at %s"
 
msgstr "%s en %s"
 

	
 
msgid "You can only delete files with revision being a valid branch"
 
msgstr ""
 
"Sólo puede borrar archivos si la revisión pertenece a una rama válida"
 

	
 
msgid "Deleted file %s via Kallithea"
 
msgstr "Archivo %s eliminado mediante Kallithea"
 

	
 
msgid "Successfully deleted file %s"
 
msgstr "El archivo %s se eliminó correctamente"
 

	
 
msgid "Error occurred during commit"
 
msgstr "Ocurrió un error al anotar los cambios"
 

	
 
msgid "You can only edit files with revision being a valid branch"
 
msgstr ""
 
"Sólo puede editar archivos si la revisión pertenece a una rama válida"
 

	
 
msgid "Edited file %s via Kallithea"
 
msgstr "Archivo %s editado mediante Kallithea"
 

	
 
msgid "No changes"
 
@@ -190,48 +196,51 @@ msgstr "Cambio"
 
msgid "Special"
 
msgstr "Especial"
 

	
 
msgid "Bookmarks"
 
msgstr "Marcadores"
 

	
 
msgid "Error creating pull request: %s"
 
msgstr "Error al crear la petición de pull: %s"
 

	
 
msgid "Error occurred while creating pull request"
 
msgstr "Ocurrió un error al crear la petición de pull"
 

	
 
msgid "Successfully opened new pull request"
 
msgstr "La petición de pull se ha creado correctamente"
 

	
 
msgid "No description"
 
msgstr "No hay descripción"
 

	
 
msgid "Pull request updated"
 
msgstr "Petición pull actualizada"
 

	
 
msgid "Successfully deleted pull request"
 
msgstr "Petición pull eliminada correctamente"
 

	
 
msgid "Revision %s not found in %s"
 
msgstr "No se ha encontrado la revisión %s en %s"
 

	
 
msgid "This pull request has already been merged to %s."
 
msgstr "La petición pull ya ha sido incluida a %s."
 

	
 
msgid "This pull request has been closed and can not be updated."
 
msgstr "La petición pull esta cerrada y no se puede actualizar."
 

	
 
msgid "Invalid search query. Try quoting it."
 
msgstr "Consulta de búsqueda inválida. Inténtelo entre comillas."
 

	
 
msgid "An error occurred during search operation."
 
msgstr "Ocurrió un error mientras se ejecutaba la búsqueda."
 

	
 
msgid "No data ready yet"
 
msgstr "Todavía no hay datos disponibles"
 

	
 
msgid "Statistics are disabled for this repository"
 
msgstr "Las estadísticas están deshabilitadas en este repositorio"
 

	
 
msgid "Auth settings updated successfully"
 
msgstr "Los ajustes de autentificación se han actualizado correctamente"
 

	
 
msgid "error occurred during update of auth settings"
 
msgstr "ocurrió un error al actualizar los ajustes de autentificación"
 

	

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)