mercurial-hook

precommit mercurial hook to stop commits to the wrong branch

浪尽此生 提交于 2019-12-11 01:16:17
问题 I have a piece of software in a Mercurial repository. I'm packaging my software project as a Debian package. It seems the standard way to do this is to have a separate branch for the Debian package files, which live in the debian sub-directory. One problem I keep having is that I forget which branch I am on and accidentally commit to the wrong branch. This happens frequently, and is really annoying. When this happens I usually push to remote before realising the problem, and then have to fix

Mercurial hook to set policy on tag names

倾然丶 夕夏残阳落幕 提交于 2019-12-11 00:44:18
问题 I write (in-process) hook to prevent add BAD tag name locally: .hg/hgrc : pretag.badtagname = python:.hg/hgcheck.py:localbadtag .hg/hgcheck.py : goodtag_re = r'(ver-\d+\.\d+\.\d+|tip)$' def localbadtag(ui, repo, hooktype, node, **kwargs): assert(hooktype == 'pretag') re_ = re.compile(goodtag_re) if not re_.match(tag): ui.warn('Invalid tag name "%s".\n' % tag) ui.warn('Use one of tip, ver-xx.xx.xx\n') return True return False How make this check for pretxnchangegroup hook? I try write this

Mercurial - How to disable push

余生长醉 提交于 2019-12-10 23:45:46
问题 I am trying to find if there is an easy way to make a mercurial repository read-only. The user should be able to clone, but no pushes should be allowed. I need to do this for all my repositories which is more than 100. 回答1: You can do this like this in .hg/hgrc: [hooks] prechangegroup = false 回答2: This depends on how you're publishing your repositories but here's a few things you can try, depending on this: If you're publishing your repositories on network shares or mounted volumes, simply

mercurial: including precommit-changed file

霸气de小男生 提交于 2019-12-08 03:37:59
问题 On commit to repository I have a hook defined in Mercurial: [hooks] precommit.exportDB=exportDB.bat This creates/updates a SQL-dump from my database, which should be included in the commit. BUT: although this works, the Sql is marked as new, but not part of the now commiting changeset. How can I automatically include it so it gets into the set of changed files? Hope this makes sense... Thx Reinhard 回答1: This'll sound crazy, but you can do it in two steps. First change your precommit hook to a

Mercurial hooks — pass information between hooks?

こ雲淡風輕ζ 提交于 2019-12-08 01:30:21
问题 I currently have a pre-commit hook in my mercurial project that gives the user the option to update the version number of the project if they wish (e.g. 1.0 to 1.0.1 or 1.1 or 2.0 ). They select one of these options, and the hook updates the version number in one of the project's files prior to the commit taking place. When I run hg commit , this hook runs and updates the relevant file with the new version number, and then performs the commit. I'd like to add to the hook such that it calls hg

Call a mercurial command (“hg update”) from a python hook

≯℡__Kan透↙ 提交于 2019-12-07 11:23:58
问题 I have Mercurial hgweb set up on Windows 2008 64 bit and IIS. The location of the repositories is a network share. I want to create a hook on the repository to issue an "hg update" command on a changeroup. I cannot use the external hook as this would start cmd.exe with the network share as the working directory (and cmd.exe does not support network shares). Therefore, I'm looking to find an example of a python hook that calls a mercurial command. I notice that there is a mercurial.commands

Mercurial pre-push hook scanning the working copy

南楼画角 提交于 2019-12-06 10:48:45
问题 I need to setup a hook on a repository where people can push, that would run some validation (the goal is to reject the push if validation fails). I already have some hooks setup to auto-update after a successful push, and prevent multiple heads. I have no problem writing a validation script (for example a shell script that runs unit tests), but it needs to run on the full working copy. My problem is that, if I just put it in a pretxnchangegroup hook, it does not operate on updated files. If

Let Jenkins build project from a Mercurial commit

混江龙づ霸主 提交于 2019-12-06 00:36:44
问题 Is there a way to specify a hook in the single repository? Now we have specified the hook in the "/etc/mercurial/hgrc" file, but every time it builds twice, and it builds for each commit in each repository. So we want to specify a build per repository. This is how we implemented the hook: [hooks] changegroup = curl --silent http://jenkins:8080/job/ourProject/build It's on a Ubuntu server. 回答1: Select the Poll SCM option under Build Triggers . Make sure that schedule form is empty. You should

Call a mercurial command (“hg update”) from a python hook

白昼怎懂夜的黑 提交于 2019-12-05 17:37:13
I have Mercurial hgweb set up on Windows 2008 64 bit and IIS. The location of the repositories is a network share. I want to create a hook on the repository to issue an "hg update" command on a changeroup. I cannot use the external hook as this would start cmd.exe with the network share as the working directory (and cmd.exe does not support network shares). Therefore, I'm looking to find an example of a python hook that calls a mercurial command. I notice that there is a mercurial.commands module, but I cannot find any examples on the webs and I'm not very experienced with Python. Are there

Mercurial pre-push hook scanning the working copy

泄露秘密 提交于 2019-12-04 15:58:34
I need to setup a hook on a repository where people can push, that would run some validation (the goal is to reject the push if validation fails). I already have some hooks setup to auto-update after a successful push, and prevent multiple heads. I have no problem writing a validation script (for example a shell script that runs unit tests), but it needs to run on the full working copy. My problem is that, if I just put it in a pretxnchangegroup hook, it does not operate on updated files. If I try to hg update inside the hook, this leads to repository corruption whenever validation fails and