mercurial(Hg) Server 搭建 过程记录

1、  环境说明

只是测试搭建,环境为本机开发环境:win 8.1 + IIS8.5

软件准备:

2、  软件安装

先安装Python2.7, 然后安装Mercurial的Python package, 然后安装TortoiseHg, 最后安装url rewrite组件。

3、 在D盘建一个数据仓库总目录, 例如D:\Mercurial\ hgweb, 所有的repositories都将位于这个目录之下。

(Repositories是仓库文件夹,下面存放多个代码仓库。这里为了方便放入D:\Mercurial\ hgweb路径下,其实也可放在别的路径,只要在配置文件中配置对就行了)

4、  IIS下建立网站hg

双击Handlers Mappings, 右侧会出现一个actions列表, 点击Add Managed Handler, 会弹出一个新建窗口, 按如下图所示填写这个新建窗口:

5、 在D:\Mercurial\ hgweb路径下建立hgweb.cgi文件,内容如下:

#!D:/Python27/python.exe

#

# An example FastCGI script for use with flup, edit as necessary

# Path to repo or hgweb config to serve (see 'hg help hgweb')

config = "D:/Mercurial/hgweb/hgweb.config"

# Uncomment and adjust if Mercurial is not installed system-wide

# (consult "installed modules" path from 'hg debuginstall'):

import sys; sys.path.insert(0, "D:\\Python27\\Lib\\site-packages\\mercurial")

# Uncomment to send python tracebacks to the browser if an error occurs:

from mercurial import demandimport;

demandimport.enable()

import cgitb

cgitb.enable()

#import os

#os.environ["HGENCODING"] = "UTF-8"

from mercurial.hgweb.hgwebdir_mod import hgwebdir

import mercurial.hgweb.wsgicgi as wsgicgi

application = hgwebdir(config)

wsgicgi.launch(application)

其中D:/Python27/python.exe为python安装路径,

config = "D:/Mercurial/hgweb/hgweb.config" (下一步将建立的文件)

D:\\Python27\\Lib\\site-packages\\mercurial 为安装Mercurial的Python package路径。

6、 再在D:\Mercurial\ hgweb下新建一个文本文件, 重命名为hgweb.config,内容为:

[paths]

/Repositories/ = D:/Mercurial/hgweb/Repositories/*

[web]

encoding = UTF-8

push_ssl = false

allow_read = *

allow_push = *

baseurl = /

即可尝试浏览http://localhost/hgweb.cgi . 应该能看到如下界面:

(由于80端口有其他网站,此处用的83端口,内部使用,所以安全问题不大关注 设置push_ssl = false)

7、 创建网站时会自动生成个web.config文件,用任意文本编辑器打开此文件, 在System.webServer节下的handlers节下面增加一个rewrite节

 <?xml version="1.0" encoding="UTF-8"?>

 <configuration>

     <system.webServer>

        <handlers>

             <add name="CGIHandler" path="*.cgi" verb="*" modules="CgiModule" scriptProcessor="D:\Python27\python.exe -u &quot;%s&quot;" resourceType="Unspecified" requireAccess="Script" />

        </handlers>

       <rewrite>

         <rules>

           <clear />

           <rule name="hgweb.cgi" enabled="true" patternSyntax="Wildcard">

             <match url="*" />

             <conditions logicalGrouping="MatchAll" trackAllCaptures="false">

               <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

             </conditions>

             <action type="Rewrite" url="hgweb.cgi/{R:1}" />

           </rule>

         </rules>

       </rewrite>

         <security>

             <authorization>

                 <remove users="*" roles="" verbs="" />

                 <add accessType="Allow" users="?" />

             </authorization>

         </security>

     </system.webServer>

 </configuration>

这样直接用http://localhost/ 就可访问和http://localhost/hgweb.cgi一样的效果。

8、 用Hg在Repositories中创建仓库

然后就可以在客户端clone仓库、以及push到服务器了。

在push时可能会遇到权限问题,解决方法:

1)         确定IIS_IUSERS有读写D:/Mercurial/hgweb文件夹的权限;

2)         修改仓库中的.hg/hgrc文件

添加如下内容

[web]

allow_read = *

allow_push = *

push_ssl = false

(也没太弄明白为什么,hgweb.config中也有这些配置,和这里有啥区别?但是在这里添加后确实可以PUSH了)

参考网址:

http://www.cnblogs.com/Moosdau/archive/2012/03/06/2382769.html

http://blog.csdn.net/delphinew/article/details/5440723

http://bz.selenic.com/show_bug.cgi?id=2954

mercurial(Hg) Server 搭建 过程记录的更多相关文章

  1. Java Web项目搭建过程记录(struts2)

    开发工具:eclipse 搭建环境:jdk1.7   tomcat 8.0 基础的java开发环境搭建过程不再赘述,下面从打开eclipse 之后的操作开始 第一步: 创建项目,File -> ...

  2. iRedMail的搭建过程记录

    iRedMail的搭建和注意事项 经过一段时间的折腾,终于将iRedMail搭建起来了,下面介绍一下搭建的过程,以及注意事项. 注意事项:  1. iRedMail不支持重复安装,如果安装错误,请重置 ...

  3. mongo 集群(副本)搭建过程记录

    最近搭建mongo集群,回忆总结,作以记录.整个过程主要参考以下两篇文章,但是过程并不顺利,有些问题需要记录.https://www.cnblogs.com/dba-devops/p/7130710. ...

  4. mongodb集群搭建过程记录

    mongodb集群搭建花费比较长的时间,在此记录下过程,方便以后使用 一 软件环境 系统:ubuntu 18.04,mongodb 社区版4.2 https://docs.mongodb.com/ma ...

  5. Linux下kafka集群搭建过程记录

    环境准备 zookeeper集群环境kafka是依赖于zookeeper注册中心的一款分布式消息对列,所以需要有zookeeper单机或者集群环境. 三台服务器: 172.16.18.198 k8s- ...

  6. JDK+Tomcat+Eclipse环境搭建过程记录

    这学期选了一门公选课叫网络开发工具与技术,主要学习用JSP语言构建网站.在配置环境的过程中遇到不少的坑,于是记录下来,希望能帮到大家. 系统环境:Win10 JDK版本:8u121, JAVA版本1. ...

  7. linux 编程环境搭建过程记录

    1, 安装centos 7 最小版  过程略 ...... 2, 安装桌面安装yum groupinstall "GNOME Desktop" 更新系统运行级别ln -sf /li ...

  8. MAPR 开发环境搭建过程记录

    我下载了MAPR 官方提供的virtualbox 和 vmware版本的sandbox进行试用. 开始试用了一会vmware版的,因为不太熟悉vmware的操作,而且vmplayer经常没有反应,后来 ...

  9. Python 语言搭建SELENIUM测试环境,搭建过程记录。

    第一步,安装Python: 第二步,安装SetupTools: 第三步,安装Pip: 第四步,安装selenium(for python) 第五步,新建第一个基于Firefox的测试用例 上述 只是步 ...

随机推荐

  1. dbutils的使用Demo

    首先了解一下 Queryrunner.query    —————只可以执行select语句. Queryrunner.update  —————只可以接收update,delte,insert语句 ...

  2. Html5 学习之 Html5功能判断插件 Modernizr

    ---恢复内容开始--- Modernizr 浏览器对HTML5和CSS3开发的功能检测类库 由于当前用户使用的浏览器版本较多,对H5和CSS3的支持也各不相同.前端的开发者,在使用一些新的特性的时候 ...

  3. css3画苹果logo

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  4. brew 更换国内源(镜像)

    cd /usr/local git remote set-url origin git://mirrors.tuna.tsinghua.edu.cn/homebrew.git brew update ...

  5. Membership修改密码

    MembershipUser mu = Membership.GetUser(labelUserName.Text.Trim());//获取资格用户 try { bool flat = mu.Chan ...

  6. 【好程序员笔记分享】——UIView与CALayer详解

    -iOS培训,iOS学习-------型技术博客.期待与您交流!------------ UIView与CALayer详解 研究Core Animation已经有段时间了,关于Core Animati ...

  7. Swift中数组集合-b

    数组(Array)是一串有序的由相同类型元素构成的集合.数组中的集合元素是有序的,可以重复出现. 声明一个Array类型的时候可以使用下面的语句之一. var studentList1:Array&l ...

  8. CentOS7配置Nodejs环境安装记录

    今天购买了阿里云服务器,系统选的是CentOS7,下面记录下在它上面安装Nodejs环境的过程,本次操作是直接连接的阿里云服务器的管理终端. 1.由于是纯净的环境,先通过以下命令安装nodejs编译及 ...

  9. 【转】const的用法,特别是用在函数前面与后面的区别!

    在普通的非 const成员函数中,this的类型是一个指向类类型的 const指针.可以改变this所指向的值,但不能改变 this所保存的地址. 在 const成员函数中,this的类型是一个指向 ...

  10. LeetCode_Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2-& ...