As part of our platform consolidation, this content will be moving to Unity.com by March 31st, 2025.
Preview the new location and updated resources here.
Plastic SCM 是一個視覺化版本控制系統。但該系統也應能透過命令列使用。
本指南會逐步引導您瞭解常見的命令列介面 (CLI) 案例,協助您熟悉如何使用 Plastic。
請記住,您可以隨時使用 cm help command_name 來取得有關所有命令的詳細資訊。
執行 cm help objectspec 命令,以瞭解 Plastic 支援的不同物件規格的定義。
若要建立新的工作區,您唯一要做的就是使用 cm workspace create 命令。
>cm workspace create quakewk quake_path --repository=quake@localhost:6060 Workspace quakewk has been correctly created然後,我會移至新建立的目錄:
>cd quake_path >cm status /main@quake@localhost:6060 (cs:0 - head)這表示我仍在變更集 0 上,因為我尚未執行更新。根據預設,此工作區會設定為使用分支 [主要]。
我可以藉由執行 cm status --head 來查看分支上的最新變更集:
>cm status --head cs:573@quake@localhost:6060只需輸入下列命令,即可更新至最新狀態:
>cm update然後,此命令將開始傾印複製的檔案的所有相關資訊,直到我更新到最新狀態為止。
>cm status /main@quake@localhost:6060 (cs:573 - head)現在我已在最新的變更集上:我的案例為 573。
建立新分支只需執行 cm branch (或 cm branch create) 命令:
> cm branch main/fix-1342請注意,我剛建立了新分支,但我尚未切換至該分支,如 cm status 所示:
>cm status /main@quake@localhost:6060 (cs:573 - head)因此,我並未指定起點,新分支會直接從上層分支上的最新變更集開始,在我的案例中就是 main 分支的 cset 573。我可以使用 --changeset 和 --label 修飾詞,指定要從哪個特定變更集或標籤開始我的分支。
現在,我要使用切換命令來將工作區切換至分支:
> cm switch main/fix-1342 Performing switch operation... Searching for changed items in the workspace... Setting the new selector... Plastic is updating your workspace. Wait a moment, please... The workspace c:\Users\pablo\wkspaces\quake_path is up-to-date (cset:573@quake@localhost:6060)新分支仍為空白狀態,因此,Plastic 實際上並未在工作區上更新任何內容以進行切換,因為此時 fix-1342 指向同一個 cset 573。
我要在我的工作區編輯檔案,然後搜尋變更來找出該檔案:
>vim code\FileSystem-renamed.cs >cm status /main/fix-1342@quake@localhost:8084 (cs:573 - head) 已變更 Status Size Last Modified Path Changed 80 bytes 6 seconds ago code\FileSystem-renamed.csstatus 不僅會顯示 wk 設定 (如同之前所示),也會顯示已變更、簽出、移動、刪除的檔案。
現在,我要將 FileSystem-renamed.cs
移至新位置:
我會執行 status 尋找己移動的檔案:
>cm status /main/fix-1342@quake@localhost:8084 (cs:573 - head) 已移動 Status Size Similarity Path Moved locally 86 bytes 99% code\FileSystem-renamed.cs -> code\lib\FileSystem.cs其中 [在本機移動] 是指我已將檔案移至 Plastic 控制範圍之外,但它能夠找出已移動的檔案,因為它與先前版本之間仍具有 99% 的相似性。
然後,我可以輕鬆簽入我的變更:
>cm ci --all The selected items are about to be checked in. Please wait ... Assembling checkin data Validating checkin data Uploading file data Uploaded 0 bytes of 2.77 KB (0%) Confirming checkin operation Modified c:\Users\pablo\wkspaces\quake_path\code Modified c:\Users\pablo\wkspaces\quake_path\code\lib Modified and moved from c:\Users\pablo\wkspaces\quake_path\code\FileSystem-renamed.cs to c:\Users\pablo\wkspaces\quake_path\code\lib\FileSystem.cs Created changeset cs:575@br:/main/fix-1342@quake@localhost:6060 (mount:'/')預設的 ci 命令會簽入所有新增的檔案。透過 ci --all,我基本上是在告訴 Plastic:偵測已變更的所有內容,並執行簽入。all 表示:已變更、刪除或移動的檔案。我們也可以使用 ci --all --private 來包含私人檔案。
Plastic SCM 也支援簽出-編輯-簽入工作流程。
cm log 命令會顯示在指定 cset 上或特定 cset 範圍內所做的變更:
>cm log cs:575 Changeset number: 575 Branch: /main/fix-1342 Owner: pablo Date: 7/18/2015 19:41:29 Comment: Changes: C code\lib\FileSystem.cs M code\lib\FileSystem.cs
在這裡可以看到其顯示我在簽入的最後一個變更集中修改和移動檔案 FileSystem.cs
的過程。
cm diff 命令會執行類似的動作,但始終限定於指定的 cset:
>cm diff cs:575 C "code\lib\FileSystem.cs" M "code\FileSystem-renamed.cs" "code\lib\FileSystem.cs"工作一段時間後,在嘗試一些實驗性質變更的同時,我決定捨棄所有暫止的變更,並從頭開始。該如何進行?
現在檢查我的目前狀態:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 49.23 KB 2 hours ago code\bsp-renamed.c Changed 23.42 KB 2 hours ago code\cgame\cg_drawtools.c Changed 61.23 KB 8 minutes ago libs\cmdlib.h Changed 398 bytes 7 minutes ago libs\str.h我只想要復原所有變更。為了這樣做,我只是以遞迴方式執行 undo 命令:
>cm undo -r c:\Users\pablo\wkspaces\quake_path\libs\str.h unchecked out correctly c:\Users\pablo\wkspaces\quake_path\libs\cmdlib.h unchecked out correctly c:\Users\pablo\wkspaces\quake_path\code\cgame\cg_drawtools.c unchecked out correctly c:\Users\pablo\wkspaces\quake_path\code\bsp-renamed.c unchecked out correctly現在我的狀態是:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head)這表示我處於全新狀態。
一個備註:
如先前所述,我可以將復原限制到特定變更類型。我可使用篩選選項來執行此操作:
假設我有與上述相同的變更,但這次我已新增和刪除幾個檔案:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 49.23 KB 2 hours ago code\bsp-renamed.c Changed 23.42 KB 2 hours ago code\cgame\cg_drawtools.c Changed 61.23 KB 9 minutes ago libs\cmdlib.h Changed 398 bytes 8 minutes ago libs\str.h 已刪除 Status Size Path Removed 12.41 KB code\bsp-temp.c 已新增 Status Size Last Modified Path Added 4.42 KB 17 seconds ago code\bsp-experimental.c這次我要復原 [新增] 和 [移除],但會將變更保留原狀:我使用篩選來執行此操作:
>cm undo --added --deleted -r c:\Users\pablo\wkspaces\quake_path\code\bsp-experimental.c unchecked out correctly c:\Users\pablo\wkspaces\quake_path\code\bsp-temp.c unchecked out correctly現在我的狀態是:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 49.23 KB 2 hours ago code\bsp-renamed.c Changed 23.42 KB 2 hours ago code\cgame\cg_drawtools.c Changed 61.23 KB 10 minutes ago libs\cmdlib.h Changed 398 bytes 9 minutes ago libs\str.h正符合我的需要。
如果您只想要復原單一已變更的檔案,該怎麼做?
我修改了幾個檔案:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 15.83 KB 50 seconds ago code\cgame\cg_ents.c Changed 35.27 KB 30 seconds ago code\cgame\cg_main.c
但我只想要復原對 cg_main.c
所做的變更。我將執行下列命令:
現在,假設我只需要復原某些路徑底下的一些變更:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 15.83 KB 50 seconds ago code\lib\be_aas_cluster.c Changed 35.27 KB 5 minutes ago code\cgame\cg_ents.c Changed 73.15 KB 5 minutes ago code\cgame\cg_localents.c Changed 62.62 KB 5 minutes ago code\renderer\tr_cmds.c Changed 12.26 KB 5 minutes ago merge\Socket.cs
我只要復原 code
底下的變更,但保留 merge
底下的變更:
現在狀態如同預期:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 12.26 KB 5 minutes ago merge\Socket.cs我可以將目標鎖定在復原,甚至可以使用萬用字元提高精確度:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 15.83 KB 4 minutes ago code\lib\be_aas_cluster.c Changed 3.14 KB 4 minutes ago code\lib\be_aas_cluster.h Changed 35.27 KB 8 minutes ago code\cgame\cg_ents.c Changed 3.24 KB 2 minutes ago code\cgame\cg_ents.h Changed 73.15 KB 8 minutes ago code\cgame\cg_localents.c Changed 6.14 KB 2 minutes ago code\cgame\cg_localents.h Changed 62.62 KB 8 minutes ago code\renderer\tr_cmds.c Changed 1.98 KB 2 minutes ago code\renderer\tr_cmds.h Changed 12.26 KB 8 minutes ago merge\Socket.cs
這次我只要復原 code
底下的標題檔案,但保留原始檔案:
現在狀態如同預期:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 15.83 KB 5 minutes ago code\lib\be_aas_cluster.c Changed 35.27 KB 9 minutes ago code\cgame\cg_ents.c Changed 73.15 KB 9 minutes ago code\cgame\cg_localents.c Changed 62.62 KB 9 minutes ago code\renderer\tr_cmds.c Changed 12.26 KB 9 minutes ago merge\Socket.cs現在,假設我只要在指定路徑簽入某些檔案。我有許多已修改的檔案,如下所示:
>cm status /main/fix-1342@quake@localhost:8084 (cs:575 - head) 已變更 Status Size Last Modified Path Changed 12.26 KB 5 minutes ago merge\Socket.cs Changed 42.26 KB 5 minutes ago q3radiant\alpha\osf\tst\sort.sbk Changed 86.27 KB 5 minutes ago q3radiant\alpha\osf\tst\spill.2bk Changed 85.27 KB 5 minutes ago q3radiant\alpha\osf\tst\spill.sbk Changed 34.26 KB 5 minutes ago q3radiant\alpha\osf\tst\stdarg.1bk Changed 34.26 KB 5 minutes ago q3radiant\alpha\osf\tst\stdarg.2bk Changed 34.26 KB 5 minutes ago q3radiant\alpha\osf\tst\stdarg.sbk
但我只想要簽入 q3radiant\alpha
內的檔案,因此我執行 checkin 命令,如下所示:
在 Plastic SCM 中,可以只變更檔案,也可以將其簽出。因此,您可以遵循按照兩個工作流程:編輯-簽入或簽出-編輯-簽入。
簽出檔案表示告訴 Plastic:「嘿,我要修改檔案了」,因此,它會將檔案新增至已簽出檔案的內部清單。
使用簽出有 3 個主要原因:
以簽出-編輯-簽入的方式工作非常簡單:只需要在編輯任何檔案前執行 cm co 命令即可。
>cm co q3radiant\Bmp.cpp The selected items are about to be checked out. Please wait ... Item q3radiant\Bmp.cpp was correctly checked out >cm status /main/fix-1342@quake@localhost:8084 (cs:576 - head) 已變更 Status Size Last Modified Path Changed 12.26 KB 5 minutes ago merge\Socket.cs Checked-out 12.21 KB 65 minutes ago q3radiant\Bmp.cpp
現在您可以看到,Bmp.cpp
已標示為已簽出,而不只是已變更。
使用 cm mv 命令移動的檔案會視為另一種形式的已簽出,如下列範例所示:
>cm mv common\aselib.c q3asm common\aselib.c has been moved to q3asm >cm status /main/fix-1342@quake@localhost:8084 (cs:576 - head) 已變更 Status Size Last Modified Path Changed 12.26 KB 5 minutes ago merge\Socket.cs Checked-out 12.21 KB 65 minutes ago q3radiant\Bmp.cpp 已移動 Status Size Similarity Path Moved 88 bytes common\aselib.c -> q3asm\aselib.c
您會看到 aselib.c
並非「在本機移動」,而只是已移動。
我可以簽入兩個已簽出的檔案,如下所示:
>cm ci -c "changed bmp and moved aselib" The selected items are about to be checked in. Please wait ... Assembling checkin data Validating checkin data Uploading file data Uploaded 0 bytes of 9.26 KB (0%) Confirming checkin operation Modified c:\Users\pablo\wkspaces\quake_path\q3radiant\Bmp.cpp Modified c:\Users\pablo\wkspaces\quake_path\common Modified c:\Users\pablo\wkspaces\quake_path\q3asm Move from c:\Users\pablo\wkspaces\quake_path\common\aselib.c to c:\Users\pablo\wkspaces\quake_path\q3asm\aselib.c Created changeset cs:577@br:/main/fix-1342@quake@localhost:6060 (mount:'/')
因為我並未在 checkin 中指定 --all 修飾詞,因此只簽入了已簽出的檔案,且 Socket.cs
檔案仍為暫止的變更:
從 CLI 進行合併的方法相當簡單,只要執行 cm merge 命令即可。
到目前為止,我在 main/fix-1342 分支中進行所有變更,因此我將切換至 main 分支以合併我的變更。我目前的情況如下:
我將切換至 main:
>cm switch main Performing switch operation... Searching for changed items in the workspace... Cannot perform the switch to branch/label/changeset since there are pending changes. Please review the pending changes and retry the operation again.
抱歉,目前還無法切換,因為我忘了我的 Socket.cs
...我將先復原變更,再嘗試重新切換:
切換命令會更新我的工作區,使用 main 分支中的版本取代我已在分支上變更的所有檔案。
現在,我的狀態如下所示:
>cm status /main@quake@localhost:6060 (cs:573 - head)這也會反映在分支瀏覽器中:
我現在要執行 merge 命令:
>cm merge main/fix-1342 The file /q3radiant/Bmp.cpp#cs:577 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/sort.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.1bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.sbk#cs:576 was modified on source and will replace the destination version The file /code/lib/FileSystem.cs#cs:575 was modified on source and will replace the destination version The item /common/aselib.c has been moved to /q3asm/aselib.c on source and will be moved as result of the merge The item /code/FileSystem-renamed.cs has been moved to /code/lib/FileSystem.cs on source and will be moved as result of the merge不含任何修飾詞的合併只會列印即將合併內容的預覽,這樣有助於瞭解即將發生的情況。
為了讓合併更加有趣,我將修改 FileSystem-renamed.cs
(別忘了,它已在分支上移動和重新命名):
現在,我將重新執行合併,並新增註解:
>cm merge main/fix-1342 -c="Added changes and fixes to the interface" The file /q3radiant/Bmp.cpp#cs:577 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/sort.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.1bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.sbk#cs:576 was modified on source and will replace the destination version The item /common/aselib.c has been moved to /q3asm/aselib.c on source and will be moved as result of the merge The item /code/FileSystem-renamed.cs has been moved to /code/lib/FileSystem.cs on source and will be moved as result of the merge The file /code/FileSystem-renamed.cs needs to be merged from cs:575 to cs:578 base cs:573. Changed by both contributors.
如最後一行所示,FileSystem-renamed.cs
現在需要 3 向合併,因為兩位貢獻者已做過修改。
現在,我將執行合併,將 --merge (實際執行合併) 和 --commentsfile (從檔案內容設定新變更集的註解) 修飾詞新增至 merge 命令:
>cm merge main/fix-1342 --merge --commentsfile=comment-merge-fix-1342.txt The file /q3radiant/Bmp.cpp#cs:577 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/sort.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/spill.sbk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.1bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.2bk#cs:576 was modified on source and will replace the destination version The file /q3radiant/alpha/osf/tst/stdarg.sbk#cs:576 was modified on source and will replace the destination version The item /common/aselib.c has been moved to /q3asm/aselib.c on source and will be moved as result of the merge The item /code/FileSystem-renamed.cs has been moved to /code/lib/FileSystem.cs on source and will be moved as result of the merge The file /code/FileSystem-renamed.cs needs to be merged from cs:575 to cs:578 base cs:573. Changed by both contributors. Merging c:\Users\pablo\wkspaces\quake_path\q3asm\aselib.c c:\Users\pablo\wkspaces\quake_path\common\aselib.c has been moved to c:\Users\pablo\wkspaces\quake_path\q3asm\aselib.c Merging c:\Users\pablo\wkspaces\quake_path\code\lib\FileSystem.cs c:\Users\pablo\wkspaces\quake_path\code\FileSystem-renamed.cs has been moved to c:\Users\pablo\wkspaces\quake_path\code\lib\FileSystem.cs Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\Bmp.cpp The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\Bmp.cpp@cs:577 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\sort.sbk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\sort.sbk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.2bk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.2bk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.sbk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.sbk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.1bk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.1bk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.2bk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.2bk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.sbk The revision c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.sbk@cs:576 has been loaded Merging c:\Users\pablo\wkspaces\quake_path\code\lib\FileSystem.cs Merge done
如您所見,它會將所有合併套用至工作區,並啟動您已設定的 3 向合併工具 (預設為 Plastic 的 Xmerge),以解決 FileSystem.cs
中的衝突。請注意 FileSystem.cs
如何正確移動和重新命名,且檔案內容已正確合併。
現在,如果執行 status 命令,所有已合併的檔案都會處於已簽出狀態:
>cm status /main@quake@localhost:6060 (cs:578 - head) Pending merge links Merge from cs:577 at /main/fix-1432@test@localhost:8084 已變更 Status Size Last Modified Path Checked-out (Merge from 577) 41.32 KB 6 hours ago code\lib\FileSystem.cs Replaced (Merge from 577) 42.26 KB 6 hours ago q3radiant\alpha\osf\tst\sort.sbk Replaced (Merge from 577) 86.27 KB 6 hours ago q3radiant\alpha\osf\tst\spill.2bk Replaced (Merge from 577) 85.27 KB 6 hours ago q3radiant\alpha\osf\tst\spill.sbk Replaced (Merge from 577) 34.26 KB 6 hours ago q3radiant\alpha\osf\tst\stdarg.1bk Replaced (Merge from 577) 34.26 KB 6 hours ago q3radiant\alpha\osf\tst\stdarg.2bk Replaced (Merge from 577) 34.26 KB 6 hours ago q3radiant\alpha\osf\tst\stdarg.sbk Replaced (Merge from 577) 12.21 KB 6 hours ago q3radiant\Bmp.cpp 已移動 Status Size Similarity Path Moved 14.41 KB code\FileSystem-renamed.cs -> code\lib\FileSystem.cs Moved 88 bytes common\aselib.c -> q3asm\aselib.c
您現在會看到使用中的新狀態:已取代,這表示,為提高效率會儲存指向分支上原始位置的指標 (而不是複製版本控制中的檔案),然後 FileSystem.cs
檔案在合併後標示為真正的已簽出。
此時,我的分支瀏覽器如下所示:
虛線表示合併仍在進行中,尚未簽入。
現在,我只需直接使用 cm ci 命令簽入:
>cm ci -m "merged from fix-1342" The selected items are about to be checked in. Please wait ... Assembling checkin data Validating checkin data Uploading file data Uploaded 0 bytes of 2.80 KB (0%) Confirming checkin operation Modified c:\Users\pablo\wkspaces\quake_path\common Modified c:\Users\pablo\wkspaces\quake_path\q3asm Move from c:\Users\pablo\wkspaces\quake_path\common\aselib.c to c:\Users\pablo\wkspaces\quake_path\q3asm\aselib.c Modified c:\Users\pablo\wkspaces\quake_path\code Modified c:\Users\pablo\wkspaces\quake_path\code\lib Modified and moved from c:\Users\pablo\wkspaces\quake_path\code\FileSystem-renamed.cs to c:\Users\pablo\wkspaces\quake_path\code\lib\FileSystem.cs Modified c:\Users\pablo\wkspaces\quake_path\q3radiant Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\Bmp.cpp Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\sort.sbk Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.2bk Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\spill.sbk Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.1bk Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.2bk Replaced c:\Users\pablo\wkspaces\quake_path\q3radiant\alpha\osf\tst\stdarg.sbk Created changeset cs:579@br:/main@quake@localhost:6060 (mount:'/')為新合併的程式碼加上標籤需要執行 cm label 命令,如下所示:
>cm label BL612 cs:579分支瀏覽器現在顯示如下:
列出指定伺服器上的儲存庫輕而易舉,只要使用 repository [list] 命令即可:
>cm repository codice@localhost:6060 pnunit@localhost:6060 nervathirdparty@localhost:6060 quake@localhost:6060
根據預設,repository 會顯示預設伺服器中的儲存庫,該伺服器是您在設定精靈中設定的伺服器,並且已寫入 client.conf
中:
repository list 命令非常實用,可診斷與伺服器的連線問題,因為您也可以輸入不同伺服器,如下所示:
>cm repository list tube:dianaserver@codice.es --format=TABLE 4 codice tube:dianaserver@codice.es 4_1 codice/unitymerge tube:dianaserver@codice.es 5 pnunit tube:dianaserver@codice.es 6 nervathirdparty tube:dianaserver@codice.es 6_1 nervathirdparty/yamldotnet tube:dianaserver@codice.es 6_2 nervathirdparty/yamldotnet_buildutils tube:dianaserver@codice.es 35 licensetools tube:dianaserver@codice.es 55 plasticscm.com tube:dianaserver@codice.es 64 indexertest tube:dianaserver@codice.es 1741 tts tube:dianaserver@codice.esPlastic SCM 會保留您機器上擁有的工作區清單 (至少會有它知道的工作區,因為您可以隨時從某個位置複製工作區,而 Plastic 的清單上不會有該工作區)。
>cm workspace list codebase@MODOK c:\Users\pablo\wkspaces\four doc@MODOK c:\Users\pablo\wkspaces\doc mkt@MODOK c:\Users\pablo\wkspaces\marketing quakecode@MODOK c:\Users\pablo\wkspaces\testwkspaces\quakewk codicediana@MODOK c:\Users\pablo\wkspaces\codicediana本指南僅簡介您可以透過 CLI 進行的所有操作。如需瞭解其他可用命令,您可以執行 cm showcommands。
此外,所有命令均隨附於其選項 cm <command> --usage 的內建文件,以及更完整且包含範例的說明 cm <command> --help
偶爾可能會發生 CLI 運作不如預期的情況,這時候您便需要與我們的專業支援團隊聯絡。為了協助他們診斷您的問題,您可以使用如下所示的 cm support 命令來產生一個 zip 檔案,然後再將這個滿載實用診斷資訊的檔案傳送給他們。
>cm support bundle c:\supportbundle.zip Creating a new support bundle... Adding clientinfo.txt... Adding clientprocessinfo.txt... Adding client.conf... Adding filetypes.conf... Adding guiclient.conf... Adding mergetool.conf... Adding plastic.uisettings.conf... Adding plasticgui.conf... Adding syncviews.conf... Adding logs\plastic.debug.log.txt... Adding logs\plastic.relevant.log.txt... Support bundle created at c:\supportbundle.zip CommandResult 0我剛執行了對原始檔案做出大量變更的指令碼,包括本地移動和刪除。我的 status 現在如下所示:
>cm status /main@quake@localhost:6060 (cs:578 - head) 已刪除 Status Size Path Removed locally 34.26 KB q3radiant\alpha\osf\tst\stdarg.sbk 已移動 Status Size Similarity Path Moved locally 88 bytes 100% q3asm\aselib.c -> q3asm\aselib_fixed.c既然這些檔案都已經移動或刪除,如何讓這些變更受到原始檔控制?這不是問題。我們可以直接執行 move 或 remove 命令,並建立受控變更:
>cm remove q3radiant\alpha\osf\tst\stdarg.sbk Item q3radiant\alpha\osf\tst\stdarg.sbk has been removed. >cm move q3asm\aselib.c -> q3asm\aselib_fixed.c q3asm\aselib.c has been moved to q3asm\aselib_fixed.c >cm status /main@quake@localhost:6060 (cs:578 - head) 已刪除 Status Size Path Removed 34.26 KB q3radiant\alpha\osf\tst\stdarg.sbk 已移動 Status Size Similarity Path Moved 88 bytes q3asm\aselib.c -> q3asm\aselib_fixed.c我正在處理某些實驗性質的程式碼變更,我想要將它們儲存在原始檔控制中,而且可能會與我的同事進行共用,但我不想將其簽入任何分支,因為它們只是我正在嘗試的構想。
在此情況下,我實際上使用 shelveset 命令來認可未與任何分支相關聯的變更集。
>cm shelveset src\experimental_changes Uploading file data Confirming checkin operation Modified src\experimental_changes Created shelve sh:25@myrepo@localhost:8080 (mount:'/')我已將本地變更擱置在儲存庫上。我將我的分支切換至另一個工作區,並繼續像平常一樣使用。之後,我要回到我之前處理的這些實驗性質變更。為此,我使用 apply 子命令來將擱置集套用至我的工作區。
>cm shelveset apply sh:25 The item /newtonraphson.cs#sh:25 has been added on source and will be added as result of the merge Merging \src\experimental_changes\newtonraphson.cs The revision \src\experimental_changes\newtonraphson.cs@sh:25 has been loadedPlastic CLI 的一項經常遭到忽略的功能是使用 - 選項逐一從 stdin 讀取引數,如下所示:
>cm add - a.txt b.txt c.txt The selected items are about to be added. Please wait ... Item c:\Users\pablo\wkspaces\mcga\a.txt was correctly added Item c:\Users\pablo\wkspaces\mcga\b.txt was correctly added Item c:\Users\pablo\wkspaces\mcga\c.txt was correctly added >cm ci - a.txt b.txt c.txt The selected items are about to be checked in. Please wait ... \ Checkin finished 12 bytes/12 bytes [##################################] 100 % Modified c:\mcga Added c:\Users\pablo\wkspaces\mcga\a.txt Added c:\Users\pablo\wkspaces\mcga\b.txt Added c:\Users\pablo\wkspaces\mcga\c.txt Created changeset cs:22@br:/main@test@localhost:8084 (mount:'/') >cm rm - a.txt Item a.txt has been removed. b.txt Item b.txt has been removed. c.txt Item c.txt has been removed.這為何很實用?因為這表示我們可以透過管道將輸出從其他命令傳送至 cm。
下列命令可接受管道路徑:
我們來看一些範例!
現在,您可以盡量搭配使用管道和 cm 來建置酷炫的指令碼!