本週開始將利用 Fossil SCM 伺服器管理各組所寫的 C 與 Python3 程式. 課程中將使用 C 程式設計語言基礎 研習 ANSI C 程式, 並採用 Lean Python 研習 Python3 程式, 透過 http://www.c4learn.com/c-programs/ 中的範例進行練習.

首先, 從課本中找出, 以 C 程式, 利用 for 迴圈與格式化列印所完成的 99 乘法計算程式, 存為 99.c

/* ====================
99 multiplication table
==================== */
#include 
int main()
{
    int x, y;
    for( x = 1; x <= 9; x++ )
    {
        for( y = 1; y <= 9; y++ )
        {
            printf("%d", x*y );
        }
        printf("\n");
    }
    return 0;
}

接下來以 Python3 編寫能夠執行相同功能的程式:

for i in range(1, 10):
   for j in range(1, 10):
      print(i*j, end="")
   print()

同時找出先前所寫的 hello.c 與 hello.py:

hello.c:

/* ====================
 Say Hello World!.
==================== */
#include 
void main()
{
 /* 印出 Hello */
printf("Hello World!");
}

hello.py:

print("hello world")

接下來我們將要先利用各學員近端的 Fossil SCM Server 練習如何對上述4個檔案進行版次管理:

Fossil SCM autosync on 改版

  1. fossil clone https://username@192.168.1.68 vcp.fossil

  2. 輸入與 username 對應的密碼.

  3. 在工作目錄中開啟倉儲檔案.

fossil open vcp.fossil

  1. 在倉儲對應的工作目錄中進行改版.

  2. 納入所有的改版內容

fossil add .

  1. 提交, 並讓 Fossil SCM 自動完成推送

fossil commit -m "message"

Fossil SCM autosync off 改版

  1. fossil clone https://192.168.1.68 vcp.fossil

  2. 輸入與 username 對應的密碼.

  3. 在工作目錄中開啟倉儲檔案.

fossil open vcp.fossil

  1. 在倉儲對應的工作目錄中進行改版.

  2. 納入所有的改版內容

fossil add .

  1. 利用 fossil remote-url off 切斷內建的帳號綁定

  2. 提交, 並以手動完成推送

fossil commit -m "message"

  1. 手動推送

fossil push https://username@192.168.1.68

輸入與 username 對應的密碼後完成推送, 並回應是否要將推送權限資料儲存在近端.

其他說明

假設當使用者啟動近端隨身碟中的 start.bat 時, Fossil SCM Server 在 https://192.168.1.68 中啟動 vcp.fossil 倉儲, 接下來則要利用:

fossil clone https://yen@192.168.1.68 vcp.fossil

將 URL 中的倉儲克隆到近端的 vcp.fossil 倉儲檔中.

接著則要在近端 vcp.fossil 所在目錄下, 建立一個名稱為 wd 的工作目錄.

以 cd wd 進入工作目錄之後, 可以利用 fossil open ./../vcp.fossil 將倉儲解開.

因為當使用者在不指定用戶的情況下進行 fossil clone, Fossil SCM 會以內定的 autosync 用戶作為指定使用者, 同時會在完成克隆後顯示在命令列中.

接下來, 使用者將上述兩個 .c 與 兩個 .py 程式, 從原本的儲存位置, 複製到 wd 工作目錄中.

意即原本 vcp.fossil 倉儲中並沒有任何納管的資料內容, 透過操作系統的檔案複製, 將四個程式檔案放入工作目錄後, 必須利用 fossil add . 納入所有的改版內容.

接下來則要進行倉儲改版提交與推送的流程.

所謂的改版提交, 表示要在倉儲資料庫中對改版內容進行"註記", 也就是改版標記, 並且輸入對應的提交訊息, 以便讓協同者, 可以透過提交註記, 分辨每一次的改版大要.

由於 Fossil SCM 的設定中, 內建 autosync 為 on, 也就是改版的提交會自動與推送同步進行, 假如接下來, 使用者採用 fossil clone 時系統內建的使用者, 則只要完成改版提交, Fossil 會自動進行推送的動作.

但是, 假如使用者要使用其他俱備提交推送權限的帳號執行後續的動作, 則需要利用:

fossil remote-url off

抹除 autosync 為 on 所綁定的使用者帳號, 但是提交之後 ,必須手動進行推送.

Fossil SCM 提交:

fossil commit -m "add four demo program files"

Fossil SCM 推送

fossil push https://username@192.168.1.68

接著輸入與 username 對應的密碼, 即可完成改版推送的流程.

完成之後的結果 https://mde2a1.kmol.info/dir?ci=tip