Svn keyword and setprops

จาก WikiBall

ข้ามไปที่: นำทาง, ค้นหา

เนื้อหา

Command

propset

ใช้คำสั่ง propset เพื่อทำการสร้างค่า properties ใหม่ให้กับ file ตังตัวอย่างการ set ในส่วนของ copyright โดยชื่อ file สามารถใช้ regular expression ได้ด้วย ซึ่งการใช้ regular expression ใน svn แบบ UI เป็นเรื่องที่ทำยากมาก

$ svn propset copyright '(c) 2003 Red-Bean Software' calc/button.c
property 'copyright' set on 'calc/button.c'

ด้วอย่างด้านล่าง จะเป็นการเปลี่ยนหมดทุกไฟล์ ใน directory

$ svn propset svn:keywords 'Author Date Id Revision HeadURL' *

propedit

proplist

proplist ใช้สำหรับแสดง properties ใน file ในตัวอย่างต้านล่างเป็นการดู properties ทีละหลายๆ ไฟล์ โดยสามารถเลือกดูทีละ file โดยเปลี่ยนจาก * เป็นชื่อ เราใช้ --verbose สำหรับแสดง value ใน properties ต่างๆ ซึ่งถ้าเราไม่ใส่ เอาพุตที่ออกมานั้นจะเป็นเฉพาะชื่อ properties ที่ทำการตั้งไว้เท่านั้น

$ svn proplist --verbose *
Properties on 'gcp_addressbook.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_all.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_compose.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_list.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_login.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_mail.ext.php':
  svn:keywords : Author Date Id Revision HeadURL
Properties on 'gcp_settings.ext.php':
  svn:keywords : Author Date Id Revision HeadURL

Keywords

การใส่ keyword ใน file นั้น สามารถทำได้โดยการใส่ข้อความตามรูปแบบ ชื่อ keyword ที่ต้องการระหว่าง $ ดังต่อไปนี้

$Revision$
$Id$

ไม่ต้องใส่ค่าสงไป เพราะค่าที่ได้จะถูกใส่โดยอัตโนมัติ

Date

สำหรับใส่วันที่ที่การเปลี่ยนแปลงไฟล์ ใน revision นั้นๆ หรือใช้ LastChangedDate. แทนก็ได้ ซึ่งจะให้ผลดังตัวอย่าง

$Date: 2002-07-22 21:42:37 -0700 (Mon, 22 Jul 2002) $ 

Revision

สำหรับใส่เลข revision หรือใช้ LastChangedRevision หรือ Rev แทนก็ได้

$Revision: 144 $

Author

สำหรับใส่ชื่อผู้เขียนข้อมูลนี้ขึ้น หรือใช้ LastChangedBy แทนก็ได้

$Author: harry $

HeadURL

สำหรับใส่ URL หรือที่อยู่ไฟล์ (ในตำแหน่งสุดท้าย ไม่ขึ้นอยู่กับว่าจะย้ายหรือคัดลอกมาจากไหน) หรือใช้ URL แทนก็ได้

$HeadURL: http://svn.collab.net/repos/trunk/README $

Id

ใส่ทุกอย่างที่จำเป็นต้องมี ดูได้ดังตัวอย่าง คือ ชื่อไฟล์ Revision วันที่และเวลาที่ทำการเปลี่ยนแปลง และผู้เขียน ตามลำดับ

$Id: calc.c 148 2002-07-28 21:30:43Z sally $


ขอบคุณข้อมูลดีๆ จาก ref

รับข้อมูลจาก "http://wiki.memoball.info/index.php/Svn_keyword_and_setprops"
เครื่องมือส่วนตัว