bversion/server.py
def find_changed(request: Request, context: ConnectionContext) -> Responce: # pylint: disable=W0613
    """ Find changes since the revision it is currently holding """

    session_token = request.headers['session_token'].encode('utf8')
    repository    = request.headers['repository']

    #===
    current_user = have_authenticated_user(request.remote_addr, repository, session_token)
    if current_user is False: return fail(user_auth_fail_msg)

    #===
    repository_path = config['repositories'][repository]['path']
    body_data = request.get_json()

    #===
    data_store = versioned_storage(repository_path,
                                   path_override = config['repositories'][repository]['transient_db_path_override'])

    head = data_store.get_head()
    if head == 'root': return success({}, {'head' : 'root', 'sorted_changes' : {'none' : []}})

    # Find changed items
    client_changes = json.loads(body_data['client_changes'])
    server_changes = data_store.get_changes_since(request.headers["previous_revision"], head)

    # Figure out which files have not been changed
    if bool(int(request.headers['include_unchanged'])):
        unchanged = data_store.get_commit_files(head)

        for path, info in server_changes.items():
            if path in unchanged:
                unchanged.pop(path)

        for path, info in unchanged.items():
            info['status'] = 'unchanged'
            server_changes[path] = info

    # ==================
    sorted_changes = merge_client_and_server_changes(server_changes, client_changes)

    commit_details = data_store.read_commit_index_object(head)

    return success({}, {
        'head'           : head,
        'commit_by'      : commit_details['commit_by'],
        'commit_time'    : commit_details['utc_date_time'],
        'commit_msg'     : commit_details['commit_message'],
        'sorted_changes' : sorted_changes
    })
 Find changes since the revision it is currently holding 
Find changes since the revision it is currently holding
Find changes since the revision it is currently holding
def find_changed(request: Request, context: ConnectionContext) -> Responce: 
    session_token = request.headers['session_token'].encode('utf8')
    repository    = request.headers['repository']
    current_user = have_authenticated_user(request.remote_addr, repository, session_token)
    if current_user is False: return fail(user_auth_fail_msg)
    repository_path = config['repositories'][repository]['path']
    body_data = request.get_json()
    data_store = versioned_storage(repository_path,
                                   path_override = config['repositories'][repository]['transient_db_path_override'])
    head = data_store.get_head()
    if head == 'root': return success({}, {'head' : 'root', 'sorted_changes' : {'none' : []}})
    client_changes = json.loads(body_data['client_changes'])
    server_changes = data_store.get_changes_since(request.headers["previous_revision"], head)
    if bool(int(request.headers['include_unchanged'])):
        unchanged = data_store.get_commit_files(head)
        for path, info in server_changes.items():
            if path in unchanged:
                unchanged.pop(path)
        for path, info in unchanged.items():
            info['status'] = 'unchanged'
            server_changes[path] = info
    sorted_changes = merge_client_and_server_changes(server_changes, client_changes)
    commit_details = data_store.read_commit_index_object(head)
    return success({}, {
        'head'           : head,
        'commit_by'      : commit_details['commit_by'],
        'commit_time'    : commit_details['utc_date_time'],
        'commit_msg'     : commit_details['commit_message'],
        'sorted_changes' : sorted_changes
    })
def find_changed ( request : Request , context : ConnectionContext ) -> Responce : session_token = request . headers [ 'session_token' ] . encode ( 'utf8' ) repository = request . headers [ 'repository' ] current_user = have_authenticated_user ( request . remote_addr , repository , session_token ) if current_user is False : return fail ( user_auth_fail_msg ) repository_path = config [ 'repositories' ] [ repository ] [ 'path' ] body_data = request . get_json ( ) data_store = versioned_storage ( repository_path , path_override = config [ 'repositories' ] [ repository ] [ 'transient_db_path_override' ] ) head = data_store . get_head ( ) if head == 'root' : return success ( { } , { 'head' : 'root' , 'sorted_changes' : { 'none' : [ ] } } ) client_changes = json . loads ( body_data [ 'client_changes' ] ) server_changes = data_store . get_changes_since ( request . headers [ "previous_revision" ] , head ) if bool ( int ( request . headers [ 'include_unchanged' ] ) ) : unchanged = data_store . get_commit_files ( head ) for path , info in server_changes . items ( ) : if path in unchanged : unchanged . pop ( path ) for path , info in unchanged . items ( ) : info [ 'status' ] = 'unchanged' server_changes [ path ] = info sorted_changes = merge_client_and_server_changes ( server_changes , client_changes ) commit_details = data_store . read_commit_index_object ( head ) return success ( { } , { 'head' : head , 'commit_by' : commit_details [ 'commit_by' ] , 'commit_time' : commit_details [ 'utc_date_time' ] , 'commit_msg' : commit_details [ 'commit_message' ] , 'sorted_changes' : sorted_changes } )
Find changes since the revision it is currently holding
Find changes since the revision it is currently holding
# pylint: disable=W0613 """ Find changes since the revision it is currently holding """ #=== #=== #=== # Find changed items # Figure out which files have not been changed # ==================
request
Request
context
ConnectionContext