Skip to content


SVN Keywords และการใช้คำสั่ง set properties (setprops)

วันนี้นั่งเขียน auto-props ของ svn อยู่ ก็เลยเอา keywords ของ svn มาใส่เก็บไว้ใน wiki จะได้ง่ายต่อการค้นหา

มาอัพเดตในส่วนของ keywords (Tue Aug 18,2009) ใหม่ โดยจะเพิ่มส่วนของการใช้งานคำสั่ง เพราะเพิ่งค้นพบว่าตัวเองชอบการใช้ command line มากกว่าการใช้ UI ซึ่งอาจเป็นเพราะใช้ Ubuntu Destop/Server เสียจนชิน อีกทั้งการใช้คำสั่งบางอย่าง สามารถทำงานได้สะดวกกว่าการใช้ UI ดังนั้นในที่นี้ จึงจะกล่างถึงแต่เฉพาะการใช้งาน Set proporties ใน svn เท่านั้น

จาก 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

รับข้อมูลจาก (Reference) :

จาก WikiBall : http://wiki.memoball.info/index.php/Svn_keyword_and_setprops

Posted in Programming, Trac & SVN. Tagged with .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.