repo attach/detach (#343)

* #319, refactor render_repo_menu

* #319, btw: decrease short list size, fix db exept

* #319, small text fixes, preparations for remotes

* #319 preparations 2

* #319 refactor popup_to_confirm

* #319 detach logic DRAFT

* #319, btw: decrease short list size, fix db exept

* #319 refactor popup_to_confirm

* #319, part 2

* #338 small fixes

* #338 lcl_services_repo, part1

* #338, remove files_commit action logic
Removes files_commit action handling 
and lcl_zip->files_commit
and modifies interface of lcl_zip->export

* #338, services_repo fixes and improvements

* #338, lcl_services_abapgit

* #338, small improvements

* #338 adopt render_repo_menu from #319

* #338 lcx_cancel

* #338 zip services

* #338 abapgit services finetune

* #338 lcx_cancel finetune

* #338 zip finetune

* fix repo_menu

* #388 small adj

* #338 lcl_services_git part1

* #338 lcl_services_db, html_actions features

* #338, services_repo=>new_offline

* #338, delete/switch branch to lcl_services_git

* #338, improvements in switch_branch

* #338, switch_branch more improvements

* #319 attach, detach, change - complete

* #319, fine tuning - repo_popup title

* #319 linter fixes
This commit is contained in:
atsy 2016-09-17 12:01:39 +03:00 committed by Lars Hvam
parent ca34395b98
commit 2fbe413d77
8 changed files with 246 additions and 51 deletions

View File

@ -142,6 +142,9 @@ CONSTANTS: BEGIN OF gc_action,
repo_remove TYPE string VALUE 'repo_remove', repo_remove TYPE string VALUE 'repo_remove',
repo_purge TYPE string VALUE 'repo_purge', repo_purge TYPE string VALUE 'repo_purge',
repo_newoffline TYPE string VALUE 'repo_newoffline', repo_newoffline TYPE string VALUE 'repo_newoffline',
repo_remote_attach TYPE string VALUE 'repo_remote_attach',
repo_remote_detach TYPE string VALUE 'repo_remote_detach',
repo_remote_change TYPE string VALUE 'repo_remote_change',
abapgit_home TYPE string VALUE 'abapgit_home', abapgit_home TYPE string VALUE 'abapgit_home',
abapgit_install TYPE string VALUE 'abapgit_install', abapgit_install TYPE string VALUE 'abapgit_install',
zip_import TYPE string VALUE 'zip_import', zip_import TYPE string VALUE 'zip_import',

View File

@ -147,6 +147,17 @@ CLASS lcl_gui_router IMPLEMENTATION.
lcl_transport=>zip( ). lcl_transport=>zip( ).
ev_state = gc_event_state-no_more_act. ev_state = gc_event_state-no_more_act.
" Remote origin manipulations
WHEN gc_action-repo_remote_attach.
lcl_services_repo=>remote_attach( lv_key ).
ev_state = gc_event_state-re_render.
WHEN gc_action-repo_remote_detach.
lcl_services_repo=>remote_detach( lv_key ).
ev_state = gc_event_state-re_render.
WHEN gc_action-repo_remote_change.
lcl_services_repo=>remote_change( lv_key ).
ev_state = gc_event_state-re_render.
" Git actions " Git actions
WHEN gc_action-git_pull. WHEN gc_action-git_pull.
lcl_services_git=>pull( lv_key ). lcl_services_git=>pull( lv_key ).
@ -219,7 +230,7 @@ CLASS lcl_gui_router IMPLEMENTATION.
ri_page = lo_page. ri_page = lo_page.
ENDMETHOD. ENDMETHOD. "get_page_branch_overview
METHOD get_page_diff. METHOD get_page_diff.
@ -262,7 +273,7 @@ CLASS lcl_gui_router IMPLEMENTATION.
ri_page = lo_page. ri_page = lo_page.
ENDMETHOD. ENDMETHOD. "get_page_diff
METHOD get_page_stage. METHOD get_page_stage.
@ -281,7 +292,7 @@ CLASS lcl_gui_router IMPLEMENTATION.
ri_page = lo_stage_page. ri_page = lo_stage_page.
ENDMETHOD. ENDMETHOD. "get_page_stage
METHOD get_page_background. METHOD get_page_background.

View File

@ -207,7 +207,6 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
lv_pull_opt LIKE gc_html_opt-crossout, lv_pull_opt LIKE gc_html_opt-crossout,
lo_repo_online TYPE REF TO lcl_repo_online. lo_repo_online TYPE REF TO lcl_repo_online.
CREATE OBJECT ro_html. CREATE OBJECT ro_html.
CREATE OBJECT lo_toolbar. CREATE OBJECT lo_toolbar.
CREATE OBJECT lo_tb_branch. CREATE OBJECT lo_tb_branch.
@ -245,6 +244,13 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
iv_opt = lv_wp_opt ). iv_opt = lv_wp_opt ).
lo_tb_advanced->add( iv_txt = 'Background mode' lo_tb_advanced->add( iv_txt = 'Background mode'
iv_act = |background?{ lv_key }| ). iv_act = |background?{ lv_key }| ).
lo_tb_advanced->add( iv_txt = 'Change remote'
iv_act = |{ gc_action-repo_remote_change }?{ lv_key }| ).
lo_tb_advanced->add( iv_txt = 'Make off-line'
iv_act = |{ gc_action-repo_remote_detach }?{ lv_key }| ).
ELSE.
lo_tb_advanced->add( iv_txt = 'Make on-line'
iv_act = |{ gc_action-repo_remote_attach }?{ lv_key }| ).
ENDIF. ENDIF.
lo_tb_advanced->add( iv_txt = 'Remove' lo_tb_advanced->add( iv_txt = 'Remove'
iv_act = |{ gc_action-repo_remove }?{ lv_key }| ). iv_act = |{ gc_action-repo_remove }?{ lv_key }| ).

View File

@ -146,6 +146,11 @@ CLASS lcl_persistence_repo DEFINITION FINAL.
iv_head_branch TYPE ty_repo_xml-head_branch iv_head_branch TYPE ty_repo_xml-head_branch
RAISING lcx_exception. RAISING lcx_exception.
METHODS update_offline
IMPORTING iv_key TYPE ty_repo-key
iv_offline TYPE ty_repo_xml-offline
RAISING lcx_exception.
METHODS add METHODS add
IMPORTING iv_url TYPE string IMPORTING iv_url TYPE string
iv_branch_name TYPE string iv_branch_name TYPE string
@ -815,10 +820,6 @@ CLASS lcl_persistence_repo IMPLEMENTATION.
ls_repo TYPE ty_repo. ls_repo TYPE ty_repo.
IF iv_branch_name IS INITIAL.
lcx_exception=>raise( 'update, branch name empty' ).
ENDIF.
ASSERT NOT iv_key IS INITIAL. ASSERT NOT iv_key IS INITIAL.
TRY. TRY.
@ -843,10 +844,6 @@ CLASS lcl_persistence_repo IMPLEMENTATION.
ls_repo TYPE ty_repo. ls_repo TYPE ty_repo.
IF iv_head_branch IS INITIAL.
lcx_exception=>raise( 'update, head branch empty' ).
ENDIF.
ASSERT NOT iv_key IS INITIAL. ASSERT NOT iv_key IS INITIAL.
TRY. TRY.
@ -864,6 +861,29 @@ CLASS lcl_persistence_repo IMPLEMENTATION.
ENDMETHOD. "update_head_branch ENDMETHOD. "update_head_branch
METHOD update_offline.
DATA: lt_content TYPE lcl_persistence_db=>tt_content,
ls_content LIKE LINE OF lt_content,
ls_repo TYPE ty_repo.
ASSERT NOT iv_key IS INITIAL.
TRY.
ls_repo = read( iv_key ).
CATCH lcx_not_found.
lcx_exception=>raise( 'key not found' ).
ENDTRY.
ls_repo-offline = iv_offline.
ls_content-data_str = to_xml( ls_repo ).
mo_db->update( iv_type = c_type_repo
iv_value = iv_key
iv_data = ls_content-data_str ).
ENDMETHOD. "update_offline
METHOD update_sha1. METHOD update_sha1.
DATA: lt_content TYPE lcl_persistence_db=>tt_content, DATA: lt_content TYPE lcl_persistence_db=>tt_content,
@ -871,10 +891,6 @@ CLASS lcl_persistence_repo IMPLEMENTATION.
ls_repo TYPE ty_repo. ls_repo TYPE ty_repo.
IF iv_branch_sha1 IS INITIAL.
lcx_exception=>raise( 'update, sha empty' ).
ENDIF.
ASSERT NOT iv_key IS INITIAL. ASSERT NOT iv_key IS INITIAL.
TRY. TRY.

View File

@ -36,6 +36,9 @@ CLASS lcl_popups DEFINITION.
IMPORTING iv_url TYPE string IMPORTING iv_url TYPE string
iv_package TYPE devclass OPTIONAL iv_package TYPE devclass OPTIONAL
iv_branch TYPE string DEFAULT 'refs/heads/master' iv_branch TYPE string DEFAULT 'refs/heads/master'
iv_freeze_package TYPE abap_bool OPTIONAL
iv_freeze_url TYPE abap_bool OPTIONAL
iv_title TYPE clike DEFAULT 'Clone repository ...'
RETURNING VALUE(rs_popup) TYPE ty_popup RETURNING VALUE(rs_popup) TYPE ty_popup
RAISING lcx_exception ##NO_TEXT, RAISING lcx_exception ##NO_TEXT,
popup_to_confirm popup_to_confirm
@ -253,34 +256,37 @@ CLASS lcl_popups IMPLEMENTATION.
lv_icon_ok TYPE icon-name, lv_icon_ok TYPE icon-name,
lv_icon_br TYPE icon-name, lv_icon_br TYPE icon-name,
lt_fields TYPE TABLE OF sval, lt_fields TYPE TABLE OF sval,
lv_uattr TYPE spo_fattr,
lv_pattr TYPE spo_fattr, lv_pattr TYPE spo_fattr,
lv_battr TYPE spo_fattr,
lv_button2 TYPE svalbutton-buttontext, lv_button2 TYPE svalbutton-buttontext,
lv_icon2 TYPE icon-name. lv_icon2 TYPE icon-name.
FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields. FIELD-SYMBOLS: <ls_field> LIKE LINE OF lt_fields.
IF iv_freeze_url = abap_true.
lv_uattr = '05'.
ENDIF.
IF NOT iv_package IS INITIAL. IF iv_freeze_package = abap_true.
lv_pattr = '05'. lv_pattr = '05'.
lv_battr = '03'. ENDIF.
ELSE.
lv_battr = '05'. IF iv_package IS INITIAL. " Empty package -> can be created
lv_button2 = 'Create package' ##NO_TEXT. lv_button2 = 'Create package' ##NO_TEXT.
lv_icon2 = icon_msg. lv_icon2 = icon_msg.
ENDIF. ENDIF.
* TAB FLD LABEL DEF ATTR * TAB FLD LABEL DEF ATTR
_add_dialog_fld 'ABAPTXT255' 'LINE' 'Git Clone Url' iv_url lv_pattr. _add_dialog_fld 'ABAPTXT255' 'LINE' 'Git clone URL' iv_url lv_uattr.
_add_dialog_fld 'TDEVC' 'DEVCLASS' 'Target Package' iv_package lv_pattr. _add_dialog_fld 'TDEVC' 'DEVCLASS' 'Target package' iv_package lv_pattr.
_add_dialog_fld 'TEXTL' 'LINE' 'Branch' iv_branch lv_battr. _add_dialog_fld 'TEXTL' 'LINE' 'Branch' iv_branch '05'.
lv_icon_ok = icon_okay. lv_icon_ok = icon_okay.
lv_icon_br = icon_workflow_fork. lv_icon_br = icon_workflow_fork.
CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS' CALL FUNCTION 'POPUP_GET_VALUES_USER_BUTTONS'
EXPORTING EXPORTING
popup_title = 'Repository' popup_title = iv_title
programname = sy-repid programname = sy-repid
formname = 'BRANCH_POPUP' formname = 'BRANCH_POPUP'
ok_pushbuttontext = 'OK' ok_pushbuttontext = 'OK'

View File

@ -5,7 +5,7 @@
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
* CLASS lcl_repo DEFINITION * CLASS lcl_repo DEFINITION
*----------------------------------------------------------------------* *----------------------------------------------------------------------*
CLASS lcl_repo DEFINITION ABSTRACT. CLASS lcl_repo DEFINITION ABSTRACT FRIENDS lcl_repo_srv.
PUBLIC SECTION. PUBLIC SECTION.
METHODS: METHODS:
@ -62,6 +62,7 @@ CLASS lcl_repo DEFINITION ABSTRACT.
iv_url TYPE lcl_persistence_repo=>ty_repo-url OPTIONAL iv_url TYPE lcl_persistence_repo=>ty_repo-url OPTIONAL
iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name OPTIONAL iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name OPTIONAL
iv_head_branch TYPE lcl_persistence_repo=>ty_repo-head_branch OPTIONAL iv_head_branch TYPE lcl_persistence_repo=>ty_repo-head_branch OPTIONAL
iv_offline TYPE lcl_persistence_repo=>ty_repo-offline OPTIONAL
RAISING lcx_exception. RAISING lcx_exception.
ENDCLASS. "lcl_repo DEFINITION ENDCLASS. "lcl_repo DEFINITION
@ -92,6 +93,10 @@ CLASS lcl_repo_online DEFINITION INHERITING FROM lcl_repo FINAL.
set_branch_name set_branch_name
IMPORTING iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name IMPORTING iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name
RAISING lcx_exception, RAISING lcx_exception,
set_new_remote
IMPORTING iv_url TYPE lcl_persistence_repo=>ty_repo-url
iv_branch_name TYPE lcl_persistence_repo=>ty_repo-branch_name
RAISING lcx_exception,
get_sha1_local get_sha1_local
RETURNING VALUE(rv_sha1) TYPE lcl_persistence_repo=>ty_repo-sha1, RETURNING VALUE(rv_sha1) TYPE lcl_persistence_repo=>ty_repo-sha1,
get_sha1_remote get_sha1_remote
@ -186,6 +191,11 @@ CLASS lcl_repo_srv DEFINITION FINAL CREATE PRIVATE FRIENDS lcl_app.
RETURNING VALUE(rv_installed) TYPE abap_bool RETURNING VALUE(rv_installed) TYPE abap_bool
RAISING lcx_exception. RAISING lcx_exception.
METHODS switch_repo_type
IMPORTING iv_key TYPE lcl_persistence_db=>ty_value
iv_offline TYPE abap_bool
RAISING lcx_exception.
PRIVATE SECTION. PRIVATE SECTION.
METHODS constructor. METHODS constructor.

View File

@ -135,6 +135,10 @@ CLASS lcl_repo_online IMPLEMENTATION.
METHOD set_url. METHOD set_url.
IF ms_data-write_protect = abap_true.
lcx_exception=>raise( 'Cannot change URL. Local code is write-protected by repo config' ).
ENDIF.
mv_initialized = abap_false. mv_initialized = abap_false.
set( iv_url = iv_url ). set( iv_url = iv_url ).
@ -151,6 +155,20 @@ CLASS lcl_repo_online IMPLEMENTATION.
ENDMETHOD. ENDMETHOD.
METHOD set_new_remote.
IF ms_data-write_protect = abap_true.
lcx_exception=>raise( 'Cannot change remote. Local code is write-protected by repo config' ).
ENDIF.
mv_initialized = abap_false.
set( iv_url = iv_url
iv_branch_name = iv_branch_name
iv_head_branch = ''
iv_sha1 = '' ).
ENDMETHOD. "set_new_remote
METHOD get_sha1_local. METHOD get_sha1_local.
rv_sha1 = ms_data-sha1. rv_sha1 = ms_data-sha1.
ENDMETHOD. "get_sha1_local ENDMETHOD. "get_sha1_local
@ -252,7 +270,8 @@ CLASS lcl_repo IMPLEMENTATION.
OR it_checksums IS SUPPLIED OR it_checksums IS SUPPLIED
OR iv_url IS SUPPLIED OR iv_url IS SUPPLIED
OR iv_branch_name IS SUPPLIED OR iv_branch_name IS SUPPLIED
OR iv_head_branch IS SUPPLIED. OR iv_head_branch IS SUPPLIED
OR iv_offline IS SUPPLIED.
CREATE OBJECT lo_persistence. CREATE OBJECT lo_persistence.
@ -291,6 +310,13 @@ CLASS lcl_repo IMPLEMENTATION.
ms_data-head_branch = iv_head_branch. ms_data-head_branch = iv_head_branch.
ENDIF. ENDIF.
IF iv_offline IS SUPPLIED.
lo_persistence->update_offline(
iv_key = ms_data-key
iv_offline = iv_offline ).
ms_data-offline = iv_offline.
ENDIF.
ENDMETHOD. "set_sha1 ENDMETHOD. "set_sha1
METHOD build_local_checksums. METHOD build_local_checksums.
@ -529,7 +555,8 @@ CLASS lcl_repo_srv IMPLEMENTATION.
lv_key = mo_persistence->add( lv_key = mo_persistence->add(
iv_url = iv_url iv_url = iv_url
iv_branch_name = iv_branch_name iv_branch_name = iv_branch_name
iv_package = iv_package ). iv_package = iv_package
iv_offline = abap_false ).
TRY. TRY.
ls_repo = mo_persistence->read( lv_key ). ls_repo = mo_persistence->read( lv_key ).
@ -663,4 +690,34 @@ CLASS lcl_repo_srv IMPLEMENTATION.
ENDMETHOD. "is_repo_installed ENDMETHOD. "is_repo_installed
METHOD switch_repo_type.
DATA lo_repo TYPE REF TO lcl_repo.
FIELD-SYMBOLS <repo> LIKE LINE OF mt_list.
lo_repo = get( iv_key ).
READ TABLE mt_list ASSIGNING <repo> FROM lo_repo.
ASSERT sy-subrc IS INITIAL.
ASSERT iv_offline <> lo_repo->ms_data-offline.
IF iv_offline = abap_true. " On-line -> OFFline
lo_repo->set(
iv_url = lcl_url=>name( lo_repo->ms_data-url )
iv_branch_name = ''
iv_sha1 = ''
iv_head_branch = ''
iv_offline = abap_true ).
CREATE OBJECT <repo> TYPE lcl_repo_offline
EXPORTING
is_data = lo_repo->ms_data.
ELSE. " OFFline -> On-line
lo_repo->set( iv_offline = abap_false ).
CREATE OBJECT <repo> TYPE lcl_repo_online
EXPORTING
is_data = lo_repo->ms_data.
ENDIF.
ENDMETHOD. "switch_repo_type
ENDCLASS. "lcl_repo_srv IMPLEMENTATION ENDCLASS. "lcl_repo_srv IMPLEMENTATION

View File

@ -23,6 +23,18 @@ CLASS lcl_services_repo DEFINITION FINAL.
CLASS-METHODS new_offline CLASS-METHODS new_offline
RAISING lcx_exception lcx_cancel. RAISING lcx_exception lcx_cancel.
CLASS-METHODS remote_attach
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
RAISING lcx_exception lcx_cancel.
CLASS-METHODS remote_detach
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
RAISING lcx_exception lcx_cancel.
CLASS-METHODS remote_change
IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key
RAISING lcx_exception lcx_cancel.
ENDCLASS. "lcl_services_repo ENDCLASS. "lcl_services_repo
CLASS lcl_services_repo IMPLEMENTATION. CLASS lcl_services_repo IMPLEMENTATION.
@ -159,4 +171,78 @@ CLASS lcl_services_repo IMPLEMENTATION.
ENDMETHOD. "new_offline ENDMETHOD. "new_offline
METHOD remote_detach.
DATA: lv_answer TYPE c LENGTH 1.
lv_answer = lcl_popups=>popup_to_confirm(
titlebar = 'Make repository OFF-line'
text_question = 'This will detach the repo from remote and make it OFF-line'
text_button_1 = 'Make OFF-line'
icon_button_1 = 'ICON_WF_UNLINK'
text_button_2 = 'Cancel'
icon_button_2 = 'ICON_CANCEL'
default_button = '2'
display_cancel_button = abap_false
). "#EC NOTEXT
IF lv_answer = '2'.
RAISE EXCEPTION TYPE lcx_cancel.
ENDIF.
lcl_app=>repo_srv( )->switch_repo_type( iv_key = iv_key iv_offline = abap_true ).
COMMIT WORK.
ENDMETHOD. "remote_detach
METHOD remote_attach.
DATA: ls_popup TYPE lcl_popups=>ty_popup,
lo_repo TYPE REF TO lcl_repo_online.
ls_popup = lcl_popups=>repo_popup(
iv_title = 'Attach repo to remote ...'
iv_url = ''
iv_package = lcl_app=>repo_srv( )->get( iv_key )->get_package( )
iv_freeze_package = abap_true ).
IF ls_popup-cancel = abap_true.
RAISE EXCEPTION TYPE lcx_cancel.
ENDIF.
lcl_app=>repo_srv( )->switch_repo_type( iv_key = iv_key iv_offline = abap_false ).
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
lo_repo->set_url( ls_popup-url ).
lo_repo->set_branch_name( ls_popup-branch_name ).
COMMIT WORK.
ENDMETHOD. "remote_attach
METHOD remote_change.
DATA: ls_popup TYPE lcl_popups=>ty_popup,
lo_repo TYPE REF TO lcl_repo_online.
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
ls_popup = lcl_popups=>repo_popup(
iv_title = 'Change repo remote ...'
iv_url = lo_repo->get_url( )
iv_package = lo_repo->get_package( )
iv_freeze_package = abap_true ).
IF ls_popup-cancel = abap_true.
RAISE EXCEPTION TYPE lcx_cancel.
ENDIF.
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
lo_repo->set_new_remote( iv_url = ls_popup-url
iv_branch_name = ls_popup-branch_name ).
COMMIT WORK.
ENDMETHOD. "remote_change
ENDCLASS. "lcl_services_repo ENDCLASS. "lcl_services_repo