From 79cfdbf681059746d611d76e0dd2a7ee04c5d072 Mon Sep 17 00:00:00 2001 From: atsy Date: Mon, 30 May 2016 22:51:11 +0300 Subject: [PATCH] #234, fix diff per file (not per object) --- zabapgit.prog.abap | 152 ++++++++++++++++++++++++++------------------- 1 file changed, 89 insertions(+), 63 deletions(-) diff --git a/zabapgit.prog.abap b/zabapgit.prog.abap index 3828011a1..9fe9ff865 100644 --- a/zabapgit.prog.abap +++ b/zabapgit.prog.abap @@ -18390,14 +18390,18 @@ CLASS lcl_gui_page_main DEFINITION FINAL INHERITING FROM lcl_gui_page_super. METHODS lif_gui_page~render REDEFINITION. PRIVATE SECTION. + TYPES: BEGIN OF ty_repo_file, + path TYPE string, + filename TYPE string, + is_changed TYPE abap_bool, + END OF ty_repo_file. + TYPES tt_repo_files TYPE STANDARD TABLE OF ty_repo_file WITH DEFAULT KEY. TYPES: BEGIN OF ty_repo_item, obj_type TYPE tadir-object, obj_name TYPE tadir-obj_name, - is_changed TYPE abap_bool, - files TYPE ty_string_tt, is_first TYPE abap_bool, - result TYPE lcl_file_status=>ty_result, "TODO, remove, clutch + files TYPE tt_repo_files, END OF ty_repo_item. TYPES tt_repo_items TYPE STANDARD TABLE OF ty_repo_item WITH DEFAULT KEY. @@ -18489,19 +18493,19 @@ CLASS lcl_gui_page_main DEFINITION FINAL INHERITING FROM lcl_gui_page_super. RAISING lcx_exception. CLASS-METHODS diff - IMPORTING is_result TYPE lcl_file_status=>ty_result + IMPORTING is_file TYPE ty_repo_file iv_key TYPE lcl_persistence_repo=>ty_repo-key RAISING lcx_exception. CLASS-METHODS file_encode IMPORTING iv_key TYPE lcl_persistence_repo=>ty_repo-key - is_file TYPE lcl_file_status=>ty_result + is_file TYPE ty_repo_file RETURNING VALUE(rv_string) TYPE string. CLASS-METHODS file_decode IMPORTING iv_string TYPE clike EXPORTING ev_key TYPE lcl_persistence_repo=>ty_repo-key - es_file TYPE lcl_file_status=>ty_result + es_file TYPE ty_repo_file RAISING lcx_exception. CLASS-METHODS abapgit_installation @@ -19410,22 +19414,20 @@ CLASS lcl_gui_page_main IMPLEMENTATION. LIKE LINE OF lt_local. - lo_repo ?= lcl_repo_srv=>get( iv_key ). - + lo_repo ?= lcl_repo_srv=>get( iv_key ). lt_remote = lo_repo->get_files_remote( ). - - lt_local = lo_repo->get_files_local( ). + lt_local = lo_repo->get_files_local( ). READ TABLE lt_remote ASSIGNING - WITH KEY filename = is_result-filename - path = is_result-path. + WITH KEY filename = is_file-filename + path = is_file-path. IF sy-subrc <> 0. _raise 'file not found remotely'. ENDIF. READ TABLE lt_local ASSIGNING - WITH KEY file-filename = is_result-filename - file-path = is_result-path. + WITH KEY file-filename = is_file-filename + file-path = is_file-path. IF sy-subrc <> 0. _raise 'file not found locally'. ENDIF. @@ -19507,27 +19509,36 @@ CLASS lcl_gui_page_main IMPLEMENTATION. DATA: lt_fields TYPE tihttpnvp, lv_string TYPE string. - FIELD-SYMBOLS: LIKE LINE OF lt_fields, - TYPE any. + FIELD-SYMBOLS: LIKE LINE OF lt_fields. +* TYPE any. lv_string = iv_string. " type conversion lt_fields = cl_http_utility=>if_http_utility~string_to_fields( lv_string ). - LOOP AT lt_fields ASSIGNING . - ASSIGN COMPONENT -name OF STRUCTURE es_file TO . - IF sy-subrc <> 0. - CONTINUE. " more structures might be encoded in same string - ENDIF. - - = -value. - ENDLOOP. +* LOOP AT lt_fields ASSIGNING . +* ASSIGN COMPONENT -name OF STRUCTURE es_file TO . +* IF sy-subrc <> 0. +* CONTINUE. " more structures might be encoded in same string +* ENDIF. +* +* = -value. +* ENDLOOP. + CLEAR: ev_key, es_file. READ TABLE lt_fields ASSIGNING WITH KEY name = 'KEY'. IF sy-subrc = 0. ev_key = -value. - ELSE. - CLEAR ev_key. + ENDIF. + + READ TABLE lt_fields ASSIGNING WITH KEY name = 'PATH'. + IF sy-subrc = 0. + es_file-path = -value. + ENDIF. + + READ TABLE lt_fields ASSIGNING WITH KEY name = 'FILENAME'. + IF sy-subrc = 0. + es_file-filename = -value. ENDIF. ENDMETHOD. "struct_decode @@ -19553,29 +19564,37 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD file_encode. DATA: lt_fields TYPE tihttpnvp, - lo_descr_ref TYPE REF TO cl_abap_structdescr, +* lo_descr_ref TYPE REF TO cl_abap_structdescr, ls_field LIKE LINE OF lt_fields. - FIELD-SYMBOLS: LIKE LINE OF lo_descr_ref->components, - TYPE any. - - - lo_descr_ref ?= cl_abap_typedescr=>describe_by_data( is_file ). - - LOOP AT lo_descr_ref->components ASSIGNING . - - ASSIGN COMPONENT -name OF STRUCTURE is_file TO . - ASSERT sy-subrc = 0. - - ls_field-name = -name. - ls_field-value = . - APPEND ls_field TO lt_fields. - ENDLOOP. +* FIELD-SYMBOLS: LIKE LINE OF lo_descr_ref->components, +* TYPE any. +* +* +* lo_descr_ref ?= cl_abap_typedescr=>describe_by_data( is_file ). +* +* LOOP AT lo_descr_ref->components ASSIGNING . +* +* ASSIGN COMPONENT -name OF STRUCTURE is_file TO . +* ASSERT sy-subrc = 0. +* +* ls_field-name = -name. +* ls_field-value = . +* APPEND ls_field TO lt_fields. +* ENDLOOP. ls_field-name = 'KEY'. ls_field-value = iv_key. APPEND ls_field TO lt_fields. + ls_field-name = 'PATH'. + ls_field-value = is_file-path. + APPEND ls_field TO lt_fields. + + ls_field-name = 'FILENAME'. + ls_field-value = is_file-filename. + APPEND ls_field TO lt_fields. + rv_string = cl_http_utility=>if_http_utility~fields_to_string( lt_fields ). ENDMETHOD. "encode_struct @@ -19932,6 +19951,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION. ro_html->add('.repo_tab tr.unsupported { color: lightgrey; }'). ro_html->add('.repo_tab tr.firstrow td { border-top: 0px; } ' ). ro_html->add('.repo_tab td.files span { display: block; }'). + ro_html->add('.repo_tab td.cmd span { display: block; }'). + ro_html->add('.repo_tab td.cmd a { display: block; }'). ENDMETHOD. @@ -20062,7 +20083,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. DATA: lo_repo_online TYPE REF TO lcl_repo_online, lt_tadir TYPE lcl_tadir=>ty_tadir_tt, ls_repo_item TYPE ty_repo_item, - lv_file TYPE string, + ls_file TYPE ty_repo_file, lt_results TYPE lcl_file_status=>ty_results_tt. FIELD-SYMBOLS: LIKE LINE OF lt_results, @@ -20095,12 +20116,10 @@ CLASS lcl_gui_page_main IMPLEMENTATION. ENDAT. IF -filename IS NOT INITIAL. - lv_file = -path && -filename. - APPEND lv_file TO ls_repo_item-files. - ENDIF. - IF -match = abap_false. - ls_repo_item-is_changed = abap_true. - ls_repo_item-result = . "TODO remove, clutch + ls_file-path = -path. + ls_file-filename = -filename. + ls_file-is_changed = boolc( NOT -match = abap_true ). + APPEND ls_file TO ls_repo_item-files. ENDIF. AT END OF obj_name. "obj_type + obj_name @@ -20115,8 +20134,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION. DATA: lv_link TYPE string, lv_icon TYPE string, - lv_file TYPE string, - lv_cmd TYPE string, + lv_difflink TYPE string, + ls_file TYPE ty_repo_file, lv_trclass TYPE string. CREATE OBJECT ro_html. @@ -20156,23 +20175,30 @@ CLASS lcl_gui_page_main IMPLEMENTATION. ENDIF. IF io_repo->is_offline( ) = abap_false. " Files for online repos only + ro_html->add( '' ). - LOOP AT is_item-files INTO lv_file. - ro_html->add( |{ lv_file }| ). + LOOP AT is_item-files INTO ls_file. + ro_html->add( |{ ls_file-path && ls_file-filename }| ). ENDLOOP. ro_html->add( '' ). + ro_html->add( '' ). IF lines( is_item-files ) = 0. - lv_cmd = 'new'. - ELSEIF is_item-is_changed = abap_true. - lv_cmd = 'get_key( ) - is_file = is_item-result ) - && '">diff'. + ro_html->add( 'new' ). + ELSE. + LOOP AT is_item-files INTO ls_file. + IF ls_file-is_changed = abap_true. + lv_difflink = file_encode( iv_key = io_repo->get_key( ) is_file = ls_file ). + ro_html->add( |diff| ). + ELSE. + ro_html->add( | | ). + ENDIF. + ENDLOOP. ENDIF. + ro_html->add( '' ). + ENDIF. - ro_html->add( |{ lv_cmd }| ). ro_html->add( '' ). ENDMETHOD. @@ -20292,7 +20318,7 @@ CLASS lcl_gui_page_main IMPLEMENTATION. METHOD lif_gui_page~on_event. - DATA: ls_result TYPE lcl_file_status=>ty_result, + DATA: ls_file TYPE ty_repo_file, lv_url TYPE string, lv_key TYPE lcl_persistence_repo=>ty_repo-key, ls_item TYPE ty_item, @@ -20335,8 +20361,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION. WHEN 'diff'. file_decode( EXPORTING iv_string = iv_getdata IMPORTING ev_key = lv_key - es_file = ls_result ). - diff( is_result = ls_result + es_file = ls_file ). + diff( is_file = ls_file iv_key = lv_key ). WHEN 'jump'. CLEAR ls_item.