Mercurial动态用户名扩展
mercurial_dynamic_username的Python项目详细描述
每个目录树使用不同的提交用户名。
使用此扩展,您可以在~/work下面的存储库中提交为John Smith <john.smith@serious.com>,在~/hobby下面的代码中提交为Johny <fastjohny@fantasy.net>,并设置此 规则一次,在~/.hgrc中。
1 Example
按照以下说明安装延长件。
写下你的~/.hgrc:
[extensions] mercurial_dynamic_username = [dynamic_username] work.location = ~/work work.username = John Smith <john.smith@serious.com> hobby.location = ~/hobby ~/blogging hobby.username = Johny <fastjohny@fantasy.net>
然后承诺。在~/work下面的任何存储库中,您将提交 John Smith,在~/hobby以下的回购协议中,作为Johny,其他地方默认 将使用设置(username来自[ui])。
2 Configuration syntax
所有设置都在[dynamic_username]节中定义,并具有 以下表格:
«somelabel».location = «list of directory names» «somelabel».username = «username used there»
标签仅用于将这些设置的对连接在一起。
在.location中指定的目录名是空格或冒号 分开,可以引用。如果存储库与规则匹配 属于此处指定的目录树。tildas(~/..和 ~john/...)已正确展开。
用户名的语法与标准的username相同。
定义不带配对的.location要求扩展到 还原为标准用户名,例如:
[ui] username = Jake <jake@loose.net> [dynamic_username] work.location = ~/work work.username = John Smith <john.smith@serious.com> open.location = ~/work/open-source
将在~/work/libs/veryimportant中提交为John Smith,但是 将在~/work/open-source/libshared中还原为默认的Jake。
3 Match priority
如果多个位置与存储库匹配,则使用最长的位置 (类似于上面的open-source示例)。longest被选中 在tilda扩展后使用实际规范路径(~/work/sthis 长于/home/littlejohny/work)。
动态用户名当前总是战胜[ui]-部分 username,即使后者是在每个存储库中定义的 .hg/hgrc。我很乐意优先考虑后者,但我已经 不知道如何在不重新解析配置的情况下检测到这一点。
4 Testing configuration
您可以通过调用来测试配置:
hg showconfig ui.username
(结果应根据当前工作目录而有所不同)。 方便的比较方法:
hg --cwd ~/work/libs/acme showconfig ui.username hg --cwd ~/hobby/blogging showconfig ui.username
5 Installation
5.1 Linux/Unix (from PyPI)
如果您有工作pip或easy_install:
pip install --user mercurial_dynamic_username
或者:
sudo pip install mercurial_dynamic_username
(或者使用easy_install而不是pip)。然后激活:
[extensions] mercurial_dynamic_username =
要升级,请使用--upgrade选项重复相同的命令 示例:
pip install --user --upgrade mercurial_dynamic_username
5.2 Linux/Unix (from source)
如果您没有pip,或者希望更密切地关注开发:
克隆此存储库和mercurial_extension_utils并将 它们位于同一目录中,例如:
cd ~/sources hg clone https://bitbucket.org/Mekk/mercurial-extension_utils/ hg clone https://bitbucket.org/Mekk/mercurial-dynamic_username/
更新到最新标签,
激活方式:
[extensions] mercurial_dynamic_username = ~/sources/mercurial-dynamic_username/mercurial_dynamic_username.py
升级,拉和更新。
注意目录名很重要。参见mercurial_extension_utils了解 这类安装的详细说明。
5.3 Windows
如果您安装了任何python,则可以使用pip:
pip install mercurial_dynamic_username
但是,作为mercurial(无论是从TortoiseHg,还是自己的包中获取) 使用它自己的捆绑python,必须通过指定路径来激活:
[extensions] mercurial_dynamic_username = C:/Python27/Lib/site-packages/mercurial_dynamic_username.py ;; Or wherever pip installed it
升级到新版本:
pip --upgrade mercurial_dynamic_username
如果没有任何python,请克隆存储库:
cd c:\hgplugins hg clone https://bitbucket.org/Mekk/mercurial-extension_utils/ hg clone https://bitbucket.org/Mekk/mercurial-dynamic_username/
更新到标记的版本并按路径激活:
[extensions] mercurial_dynamic_username = C:/hgplugins/mercurial-dynamic_username/mercurial_dynamic_username.py ;; Or wherever you cloned
有关详细信息,请参见mercurial_extension_utils文档 Windows安装。
注意
目录名很重要。如果mercurial_dynamic_username.py找不到 mercurial_extension_utils.py在系统路径中,它在 它自己的目录,在../mercurial_extension_utils和 ../extension_utils。
7 Development, bug reports, enhancement suggestions
在Bitbucket上跟踪开发,请参见 http://bitbucket.org/Mekk/mercurial-dynamic_username/
使用Bitbucket问题跟踪程序进行错误报告和增强 建议。
8 Additional notes
有关的信息此分机也可用 在Mercurial Wiki上:http://mercurial.selenic.com/wiki/DynamicUsernameExtension