1.環境和所需工具安裝
1. 安裝python-2.7.9.exe
2. 安裝mercurial-3.2.3.win32-py2.7.exe
3. 安裝mercurial-3.2.3-x86.msi
4. 安裝tortoisehg-3.3.2-x64或者tortoisehg-3.3.2-x86
5. 安裝windows iis
2.操作步驟
1. 搭建網站,新建文件夾D:/hgweb
2. 在 IIS 中新建一個網站,名稱是 hgweb,物理路徑指向上一步的D:/hgweb
3. 在 IIS 中選擇剛才新建的網站,右側的功能視圖中選擇 “處理程序映射”,如下圖
IIS 7.0以上的寫法
IIS 6.0的寫法
4. 在D:\hgweb下新建一個文本文件, 重命名為test.cgi (注意連同擴展名一起修改) , 編輯其內容如下:
print 'Status: 200 OK'
print 'Content-Type: text/html'
print '<html><body><h1>It Works!</h1></body></html>'
保存, 然后在IIS中瀏覽test.cgi:
url: http://localhost/hg/test.cgi
界面:
如果能看到上述界面, 說明初期配置成功,繼續.
如果提示HTTP 錯誤 404.2 - Not Found
由於 Web 服務器上的“ISAPI 和 CGI 限制”列表設置,無法提供您請求的頁面
打開IIS管理器, 定位到服務器級別, 在其功能列表中找到ISAPI and CGI restrictions, 如圖:
雙擊打開, 里面必須存在如下圖所示的行:
如果不存在則按點擊右側的”add”, 按下圖填寫:
如果已存在, 但是被禁用, 將其啟用即可.
完成后重試打開test.cgi, 應該可以看到it works字樣.
5. 在D:\hgweb目錄下新建一個文本文件, 重命名為hgweb.cgi, 編輯其內容為以下幾句話:
#!/usr/bin/env python # # An example hgweb CGI script, edit as necessary # See also http://mercurial.selenic.com/wiki/PublishingRepositories # Path to repo or hgweb config to serve (see 'hg help hgweb') config = "D:/hgweb/hgweb.config" # Uncomment and adjust if Mercurial is not installed system-wide: #import sys; sys.path.insert(0, "/path/to/python/lib") # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb; cgitb.enable() from mercurial import demandimport; demandimport.enable() from mercurial.hgweb import hgweb, wsgicgi application = hgweb(config) wsgicgi.launch(application) |
然后再在D:\Mercurial下新建一個文本文件, 重命名為hgweb.config, 不需要寫入任何內容, 即可嘗試瀏覽http://localhost:8080 /hgweb.cgi . 應該能看到如下界面:
6. 修改hgweb.config
[paths] /Repositories/ = E:/myweb/* [web] baseurl = /hgweb.cgi allow_push = * push_ssl = false |
7. 創建代碼倉庫
在D:/hgweb下面創建test文件夾,在文件夾中執行創建hg create
再次訪問hgweb.cgi,可以看到如下圖的畫面:
8. 同步
在要同步的電腦上輸入hg clone
9. 提交代碼
修改文件后,在設置中將用戶名設置為提交用戶名