mergin/merginproject.py
def update_with_rebase(self, path, src, dest, basefile, temp_dir, user_name):
        """
        Update a versioned file with rebase.

        Try to peform automatic rebase, create conflict file if failed.pyt

        .. seealso:: self.update_without_rebase

        :param path: path to geodiff file
        :type path: str
        :param src: path to the server version of the file
        :type src: str
        :param dest: path to the local version of the file
        :type dest: str
        :param basefile: path to a file in meta dir
        :type basefile: str
        :param temp_dir: directory with downloaded files from server
        :type temp_dir: str
        :returns: path to conflict file if rebase fails, empty string on success
        :rtype: str
        """
        self.log.info("updating file with rebase: " + path)

        server_diff = self.fpath(f'{path}-server_diff', temp_dir)  # diff between server file and local basefile
        local_diff = self.fpath(f'{path}-local_diff', temp_dir)

        # temporary backup of file pulled from server for recovery
        f_server_backup = self.fpath(f'{path}-server_backup', temp_dir)
        self.geodiff.make_copy_sqlite(src, f_server_backup)

        # create temp backup (ideally with geodiff) of locally modified file if needed later
        f_conflict_file = self.fpath(f'{path}-local_backup', temp_dir)

        try:
            self.geodiff.create_changeset(basefile, dest, local_diff)
            self.geodiff.make_copy_sqlite(basefile, f_conflict_file)
            self.geodiff.apply_changeset(f_conflict_file, local_diff)
        except (pygeodiff.GeoDiffLibError, pygeodiff.GeoDiffLibConflictError):
            self.log.info("backup of local file with geodiff failed - need to do hard copy")
            self.geodiff.make_copy_sqlite(dest, f_conflict_file)

        # in case there will be any conflicting operations found during rebase,
        # they will be stored in a JSON file - if there are no conflicts, the file
        # won't even be created
        rebase_conflicts = unique_path_name(
                edit_conflict_file_name(self.fpath(path), user_name, int_version(self.metadata['version'])))

        # try to do rebase magic
        try:
            self.geodiff.create_changeset(basefile, src, server_diff)
            self.geodiff.rebase(basefile, src, dest, rebase_conflicts)
            # make sure basefile is in the same state as remote server file (for calc of push changes)
            self.geodiff.apply_changeset(basefile, server_diff)
            self.log.info("rebase successful!")
        except (pygeodiff.GeoDiffLibError, pygeodiff.GeoDiffLibConflictError) as err:
            self.log.warning("rebase failed! going to create conflict file")
            try:
                # it would not be possible to commit local changes, they need to end up in new conflict file
                self.geodiff.make_copy_sqlite(f_conflict_file, dest)
                conflict = self.create_conflicted_copy(path, user_name)
                # original file synced with server
                self.geodiff.make_copy_sqlite(f_server_backup, basefile)
                self.geodiff.make_copy_sqlite(f_server_backup, dest)
                return conflict
            except pygeodiff.GeoDiffLibError as err:
                self.log.warning("creation of conflicted copy failed! going to create an unfinished pull")
                f_server_unfinished = self.fpath_unfinished_pull(path)
                self.geodiff.make_copy_sqlite(f_server_backup, f_server_unfinished)

        return ''

        Update a versioned file with rebase.

        Try to peform automatic rebase, create conflict file if failed.pyt

        .. seealso:: self.update_without_rebase

        :param path: path to geodiff file
        :type path: str
        :param src: path to the server version of the file
        :type src: str
        :param dest: path to the local version of the file
        :type dest: str
        :param basefile: path to a file in meta dir
        :type basefile: str
        :param temp_dir: directory with downloaded files from server
        :type temp_dir: str
        :returns: path to conflict file if rebase fails, empty string on success
        :rtype: str
        
Update a versioned file with rebase.
Try to peform automatic rebase, create conflict file if failed.pyt


Update a versioned file with rebase . Try to peform automatic rebase create conflict file if failed . pyt
def update_with_rebase(self, path, src, dest, basefile, temp_dir, user_name):
        self.log.info("updating file with rebase: " + path)
        server_diff = self.fpath(f'{path}-server_diff', temp_dir)  
        local_diff = self.fpath(f'{path}-local_diff', temp_dir)
        f_server_backup = self.fpath(f'{path}-server_backup', temp_dir)
        self.geodiff.make_copy_sqlite(src, f_server_backup)
        f_conflict_file = self.fpath(f'{path}-local_backup', temp_dir)
        try:
            self.geodiff.create_changeset(basefile, dest, local_diff)
            self.geodiff.make_copy_sqlite(basefile, f_conflict_file)
            self.geodiff.apply_changeset(f_conflict_file, local_diff)
        except (pygeodiff.GeoDiffLibError, pygeodiff.GeoDiffLibConflictError):
            self.log.info("backup of local file with geodiff failed - need to do hard copy")
            self.geodiff.make_copy_sqlite(dest, f_conflict_file)
        rebase_conflicts = unique_path_name(
                edit_conflict_file_name(self.fpath(path), user_name, int_version(self.metadata['version'])))
        try:
            self.geodiff.create_changeset(basefile, src, server_diff)
            self.geodiff.rebase(basefile, src, dest, rebase_conflicts)
            self.geodiff.apply_changeset(basefile, server_diff)
            self.log.info("rebase successful!")
        except (pygeodiff.GeoDiffLibError, pygeodiff.GeoDiffLibConflictError) as err:
            self.log.warning("rebase failed! going to create conflict file")
            try:
                self.geodiff.make_copy_sqlite(f_conflict_file, dest)
                conflict = self.create_conflicted_copy(path, user_name)
                self.geodiff.make_copy_sqlite(f_server_backup, basefile)
                self.geodiff.make_copy_sqlite(f_server_backup, dest)
                return conflict
            except pygeodiff.GeoDiffLibError as err:
                self.log.warning("creation of conflicted copy failed! going to create an unfinished pull")
                f_server_unfinished = self.fpath_unfinished_pull(path)
                self.geodiff.make_copy_sqlite(f_server_backup, f_server_unfinished)
        return ''
def update_with_rebase ( self , path , src , dest , basefile , temp_dir , user_name ) : self . log . info ( "updating file with rebase: " + path ) server_diff = self . fpath ( f'{path}-server_diff' , temp_dir ) local_diff = self . fpath ( f'{path}-local_diff' , temp_dir ) f_server_backup = self . fpath ( f'{path}-server_backup' , temp_dir ) self . geodiff . make_copy_sqlite ( src , f_server_backup ) f_conflict_file = self . fpath ( f'{path}-local_backup' , temp_dir ) try : self . geodiff . create_changeset ( basefile , dest , local_diff ) self . geodiff . make_copy_sqlite ( basefile , f_conflict_file ) self . geodiff . apply_changeset ( f_conflict_file , local_diff ) except ( pygeodiff . GeoDiffLibError , pygeodiff . GeoDiffLibConflictError ) : self . log . info ( "backup of local file with geodiff failed - need to do hard copy" ) self . geodiff . make_copy_sqlite ( dest , f_conflict_file ) rebase_conflicts = unique_path_name ( edit_conflict_file_name ( self . fpath ( path ) , user_name , int_version ( self . metadata [ 'version' ] ) ) ) try : self . geodiff . create_changeset ( basefile , src , server_diff ) self . geodiff . rebase ( basefile , src , dest , rebase_conflicts ) self . geodiff . apply_changeset ( basefile , server_diff ) self . log . info ( "rebase successful!" ) except ( pygeodiff . GeoDiffLibError , pygeodiff . GeoDiffLibConflictError ) as err : self . log . warning ( "rebase failed! going to create conflict file" ) try : self . geodiff . make_copy_sqlite ( f_conflict_file , dest ) conflict = self . create_conflicted_copy ( path , user_name ) self . geodiff . make_copy_sqlite ( f_server_backup , basefile ) self . geodiff . make_copy_sqlite ( f_server_backup , dest ) return conflict except pygeodiff . GeoDiffLibError as err : self . log . warning ( "creation of conflicted copy failed! going to create an unfinished pull" ) f_server_unfinished = self . fpath_unfinished_pull ( path ) self . geodiff . make_copy_sqlite ( f_server_backup , f_server_unfinished ) return ''
Update a versioned file with rebase.
Update a versioned file with rebase .
"""
        Update a versioned file with rebase.

        Try to peform automatic rebase, create conflict file if failed.pyt

        .. seealso:: self.update_without_rebase

        :param path: path to geodiff file
        :type path: str
        :param src: path to the server version of the file
        :type src: str
        :param dest: path to the local version of the file
        :type dest: str
        :param basefile: path to a file in meta dir
        :type basefile: str
        :param temp_dir: directory with downloaded files from server
        :type temp_dir: str
        :returns: path to conflict file if rebase fails, empty string on success
        :rtype: str
        """ # diff between server file and local basefile # temporary backup of file pulled from server for recovery # create temp backup (ideally with geodiff) of locally modified file if needed later # in case there will be any conflicting operations found during rebase, # they will be stored in a JSON file - if there are no conflicts, the file # won't even be created # try to do rebase magic # make sure basefile is in the same state as remote server file (for calc of push changes) # it would not be possible to commit local changes, they need to end up in new conflict file # original file synced with server
path to conflict file if rebase fails, empty string on success
path to conflict file if rebase fails empty string on success
str
self
path
path to geodiff file
path to geodiff file
src
path to the server version of the file
path to the server version of the file
dest
path to the local version of the file
path to the local version of the file
basefile
path to a file in meta dir
path to a file in meta dir
temp_dir
directory with downloaded files from server
directory with downloaded files from server
user_name