// // rcs-aid.mac // $Id: rcs-aid.mac,v 1.3 2016-04-12 23:34:51+09 nzawa Exp nzawa $ // // author : nzawa // created : 2016-04-11 // modified : 2016-04-12 // revision : 1.2 // $CMD_PATH = getenv("COMSPEC"); $CI_PATH = "ci"; $CO_PATH = "co"; $RCS_PATH = "rcs"; $RLOG_PATH = "rlog"; $RDIFF_PATH = "rcsdiff"; $MSGPRE = "** RCS-aid **\n "; $YES = "する"; $NO = "しない"; $OPT_CIEDIT = "する"; $OPT_CIFORCE = "しない"; $OPT_CIREV = "しない"; $OPT_COEDIT = "しない"; $OPT_COFORCE = "しない"; $OPT_CODISP = "しない"; $OPT_COREV = "しない"; while(1) { menu "チェックイン(&I)", // 1 " チェックイン後に編集(&L):" + $OPT_CIEDIT, // 2 " 変更無しでもチェックイン(&F):" + $OPT_CIFORCE, // 3 " リビジョン指定(&R):" + $OPT_CIREV, // 4 "----------------------------------------", // 5----- "チェックアウト(&O)", // 6 " チェックアウト後に編集(&E):" + $OPT_COEDIT, // 7 " ワークファイルを上書き(&W):" + $OPT_COFORCE, // 8 " 表示用にチェックアウト(&D):" + $OPT_CODISP, // 9 " リビジョン指定(&V):" + $OPT_COREV, // 10 "----------------------------------------", // 11----- "ログ表示(&G)", // 12 "リビジョン比較(&C)", // 13 "----------------------------------------", // 14----- "ロック(&K)", // 15 "アンロック(&U)", // 16 "登録のみ実行(&T)"; // 17 if ( !result ) { endmacro; } else if ( result == 1 ) { call ci; endmacro; } else if ( result == 2 ) { if ( $OPT_CIEDIT == $YES ) $OPT_CIEDIT = $NO; else $OPT_CIEDIT = $YES; } else if ( result == 3 ) { if ( $OPT_CIFORCE == $YES ) $OPT_CIFORCE = $NO; else $OPT_CIFORCE = $YES; } else if ( result == 4 ) { if ( $OPT_CIREV == $YES ) $OPT_CIREV = $NO; else $OPT_CIREV = $YES; } else if ( result == 6 ) { call co; endmacro; } else if ( result == 7 ) { if ( $OPT_COEDIT == $YES ) $OPT_COEDIT = $NO; else $OPT_COEDIT = $YES; } else if ( result == 8 ) { if ( $OPT_COFORCE == $YES ) { $OPT_COFORCE = $NO; } else { $OPT_COFORCE = $YES; $OPT_CODISP = $NO; } } else if ( result == 9 ) { if ( $OPT_CODISP == $YES ) { $OPT_CODISP = $NO; } else { $OPT_CODISP = $YES; $OPT_COFORCE = $NO; } } else if ( result == 10 ) { if ( $OPT_COREV == $YES ) $OPT_COREV = $NO; else $OPT_COREV = $YES; } else if ( result == 12 ) { call rlog; endmacro; } else if ( result == 13 ) { call rcsdiff; endmacro; } else if ( result == 15 ) { call rcsl; endmacro; } else if ( result == 16 ) { call rcsu; endmacro; } else if ( result == 17 ) { call rcsi; endmacro; } } //----------------------------------------------------------------------------// // カレントディレクトリのパスを取得 // // $$return: パス(末尾に\記号あり) //----------------------------------------------------------------------------// getPWD: if ( wcsrightstr(directory2, 1) == "\\" ) return directory2; return directory2 + "\\"; //----------------------------------------------------------------------------// // ワークファイルのパスを取得 // // $$return: パス //----------------------------------------------------------------------------// getWorkFilePath: if ( wcsrightstr(basename, 2) == ",v" ) { $$wfname = wcsleftstr(basename2, wcslen(basename2) - 2); } else { $$wfname = basename2; } call getPWD; $$pwd = $$return; $$pwdlow = tolower($$pwd); if ( wcsrightstr($$pwdlow, 4) == "rcs\\" ) { $$dirname = wcsleftstr($$pwd, wcslen($$pwd) - 4); } else { $$dirname = $$pwd; } return $$dirname + $$wfname; //----------------------------------------------------------------------------// // RCSファイルのパスを取得 // // $$return: パス(ファイルが存在しない場合は空文字列) //----------------------------------------------------------------------------// getRCSFilePath: call getPWD; $$pwd = $$return; $$path = $$pwd + "RCS\\" + basename2 + ",v"; if ( existfile($$path) ) return $$path; $$path = $$pwd + "RCS\\" + basename2; if ( existfile($$path) ) return $$path; $$path = $$pwd + basename2 + ",v"; if ( existfile($$path) ) return $$path; return ""; //----------------------------------------------------------------------------// // RCSフォルダを作成 //----------------------------------------------------------------------------// makeRCSDir: call getPWD; $$pwd = $$return; $$rcsdir = $$pwd + "RCS"; if ( existfile($$rcsdir, 1) & 0x00000010 != 0 ) return; question $MSGPRE + "RCSフォルダがありません。作成して良いですか?"; if ( !result ) endmacro; runex $CMD_PATH + " /C mkdir \"" + $$rcsdir + "\"" , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 0, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; if ( existfile($$rcsdir, 1) & 0x00000010 == 0 ) { message $MSGPRE + "RCSフォルダの作成に失敗しました。"; endmacro; } return; //----------------------------------------------------------------------------// // \と"をエスケープ // // $$1: 処理対象文字列 // $$return: 処理後の文字列 //----------------------------------------------------------------------------// strEscape: ##i = 0; $$str = ""; while( ##i < wcslen($$1) ) { if ( wcsmidstr($$1, ##i, 1) == "\\" ) { $$str = $$str + "\\\\"; } else if ( wcsmidstr($$1, ##i, 1) == "\"" ) { $$str = $$str + "\\\""; } else { $$str = $$str + wcsmidstr($$1, ##i, 1); } ##i = ##i + 1; } return $$str; //----------------------------------------------------------------------------// // 編集中のファイルを保存する //----------------------------------------------------------------------------// saveCurrentFile: if ( updated ) { question $MSGPRE + "ファイルが変更されています。上書きして良いですか?"; if ( !result ) endmacro; } else if ( filename == "" ) { question $MSGPRE + "ファイルが保存されていません。保存して良いですか?"; if ( !result ) endmacro; } else { return; } save; return; //----------------------------------------------------------------------------// // ロック //----------------------------------------------------------------------------// rcsl: $$rev = input($MSGPRE + "リビジョン番号を指定してください。(空欄可)"); if ( !result ) endmacro; call strEscape $$rev; $$rev = $$return; if ( $$rev == "" ) $$command = $RCS_PATH + " -l \"%f\""; else $$command = $RCS_PATH + " -l" + $$rev + " \"%f\""; runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 8, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 8, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; return; //----------------------------------------------------------------------------// // アンロック //----------------------------------------------------------------------------// rcsu: $$rev = input($MSGPRE + "リビジョン番号を指定してください。(空欄可)"); if ( !result ) endmacro; call strEscape $$rev; $$rev = $$return; if ( $$rev == "" ) $$command = $RCS_PATH + " -u \"%f\""; else $$command = $RCS_PATH + " -u" + $$rev + " \"%f\""; runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 8, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 8, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; return; //----------------------------------------------------------------------------// // RCS登録 //----------------------------------------------------------------------------// rcsi: call saveCurrentFile; call getRCSFilePath; if ( $$return != "" ) { message $MSGPRE + "このファイルは既に登録されています。"; return; } call makeRCSDir; $$msg = input($MSGPRE + "RCSへ登録します。ファイルの説明を入力してください。"); if ( !result ) endmacro; if ( $$msg == "" ) $$msg = "*** empty description ***"; call strEscape $$msg; $$msg = $$return; runex $RCS_PATH + " -t-" + "\"" + $$msg + "\"" + " -i " + "\"" + "%f" + "\"" , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 8, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 8, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; call getRCSFilePath; if ( $$return == "" ) { message $MSGPRE + "ファイルの登録に失敗しました。"; endmacro; } return; //----------------------------------------------------------------------------// // RCSチェックイン //----------------------------------------------------------------------------// ci: call getRCSFilePath; if ( $$return == "" ) call rcsi; if ( $OPT_CIREV == $YES ) { $$rev = input($MSGPRE + "リビジョン番号を指定してください。"); if ( !result ) endmacro; } call strEscape $$rev; $$rev = $$return; $$msg = input($MSGPRE + "チェックインします。ログを入力してください。"); if ( !result ) endmacro; if ( $$msg == "" ) $$msg = "*** empty log message ***"; call strEscape $$msg; $$msg = $$return; $$command = $CI_PATH + " -m" + "\"" + $$msg + "\""; if ( $OPT_CIFORCE == $YES ) $$command = $$command + " -f"; if ( $OPT_CIEDIT == $YES ) $$command = $$command + " -l" + $$rev + " \"%f\""; else $$command = $$command + " -u" + $$rev + " \"%f\""; runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 8, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 8, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; reopen; return; //----------------------------------------------------------------------------// // RCSチェックアウト //----------------------------------------------------------------------------// co: call getWorkFilePath; $$wf = $$return; if ( $OPT_COREV == $YES ) { $$rev = input($MSGPRE + "リビジョン番号を指定してください。"); if ( !result ) endmacro; } call strEscape $$rev; $$rev = $$return; $$command = $CO_PATH; if ( $OPT_CODISP == $YES ) { $$command = $$command + " -p" + $$rev + " \"" + $$wf + "\""; runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 1, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 1, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; return; } else { if ( $OPT_COFORCE == $YES ) $$command = $$command + " -f"; if ( $OPT_COEDIT == $YES ) $$command = $$command + " -l" + $$rev + " \"" + $$wf + "\""; else $$command = $$command + " -u" + $$rev + " \"" + $$wf + "\""; } runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 8, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 8, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; openfile $$wf; return; //----------------------------------------------------------------------------// // ログ表示 //----------------------------------------------------------------------------// rlog: runex $RLOG_PATH + " \"%f\"" , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 4, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 4, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; return; //----------------------------------------------------------------------------// // リビジョン比較 //----------------------------------------------------------------------------// rcsdiff: $$rev1 = input($MSGPRE + "1つ目のリビジョン番号を指定してください。(空欄可)"); if ( !result ) endmacro; call strEscape $$rev1; $$rev1 = $$return; $$command = $RDIFF_PATH; if ( $$rev1 != "" ) { $$rev2 = input($MSGPRE + "2つ目のリビジョン番号を指定してください。(空欄可)"); if ( !result ) endmacro; call strEscape $$rev2; $$rev2 = $$return; $$command = $$command + " -r" + $$rev1; if ( $$rev2 != "" ) $$command = $$command + " -r" + $$rev2; } call getWorkFilePath; $$wf = $$return; $$command = $$command + " \"" + $$wf + "\""; runex $$command , 1 //sync 0:async 1:sync , 0, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select , 4, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 4, "" //stderr 0:none 1:=out/auto 2:file 3:add file 4:new 5:insert 6:replace 7:output 8:add output , 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder , 2 //show 0:auto 1:show 2:hide , 1 //nodraw 0:draw 1:no draw , 0 //unicode 0:ansi 2:utf-16 6:utf-8 ; return;