หลังจากลองใช้ Mercurial ในแบบ Pull-only ได้เวลาลองแบบ Shared-push บ้าง เริ่มเลยดีกว่า
สิ่งที่ต้องมีก่อน
- Web server ผมเลือก Apache 2.2 เพราะคุ้นเคยที่สุด (Apache 2.2.11)
- Mercurial อันนี้ขาดไม่ได้ (Mercurial 1.2.1)
- Python อันนี้ต้องใช้ version เดียวกันกับที่ Mercurial ใช้ด้วย (Python 2.5.4)
- hgwebdir.cgi อันนี้จะอยู่ ใน source distribution ของ Mercurial (Mercurial 1.2.1 Source)
วิธีการติดตั้ง
- Install Apache, Merurial, Python อันนี้ ผมจะข้ามไปเพราะคงหาได้ง่ายใน net อยู่แล้ว (หลายคนเก่งกว่าผมไม่อยากปล่อยไก่ อิอิ)
- แตก library.zip จาก dir ที่ลง Mercurial ไป c:\hg\lib (อันนี้แล้วแต่ path ที่เราจะลงนะ) **ห้ามใ้ช้ unzip ที่มากับ Windows หรือ Winzip ไฟล์อาจเสียได้
- Copy \Templates จาก dir ที่ลง Mercurial ไป c:\hg\lib\Templates
- Copy hgwebdir.cgi จาก root ของ Mercurial Source ไป c:\hg\hgwebdir.cgi
- แก้ hgwebdir.cgi ตามนี้
#!c:/python25/python
#
# An example CGI script to export multiple hgweb repos, edit as necessary# adjust python path if not a system-wide install:
import sys
sys.path.insert(0, “c:/hg/lib”) - สร้าง file c:\hg\hgweb.config
[paths]
/ = c:/hg_repos/*
- สร้าง dir c:\hg_repos\ ไว้ใส่ code repositories ของเรา
- สร้าง repository ใน c:\hg_repos\demo
C:\hg_repos>hg init demo
- สร้าง file c:\hg_repos\demo\.hg\hgrc
- แ้ก้ file httpd.conf ของ Apache โดย เพิ่มที่ท้าย file
ScriptAliasMatch ^/hg(.*) /hg/hgwebdir.cgi$1
Alias /hg C:/hg
<Location /hg>
Allow from all
Options ExecCGI
AuthType Basic
AuthName "Mercurial repositories"
AuthUserFile c:/hg/hgusers
<LimitExcept GET>
Require valid-user
</LimitExcept>
</Location>
- สร้าง passwd file c:\hg\hgusers แล้ว เพิ่ม user ด้วยคำสั่ง (แทน <username> ด้วยชื่อ user ที่ต้องการ)
"C:\Program Files\Apache Software Foundation\Apache2.2\bin\htpasswd" c:\hg\hgusers <username>
[web]
style = gitweb
allow_archive = bz2 gz zip
allow_push = *
push_ssl = false
สำเร็จแล้ว
