I have about 100 Mercurial repositories served by hgweb. The repositories are stored in a folder hierarchy, but hgweb displays the structure in a "flat" manner. This doesn't scale. Is there a way to display the repositories in a tree-like hierarchy instead?
I like to organize my repos by type, this is what my hgweb config looks like:
[web]
baseurl =
[paths]
/apps = /var/hg/apps/*
/config = /var/hg/config/*
/design = /var/hg/design/*
/music = /var/hg/music/*
/projects = /var/hg/projects/*
/scripts = /var/hg/scripts/*
You can also use ** to make it display directories recursively.
[paths]
/ = /var/hg/**
Check out the docs for other details/options: http://www.selenic.com/mercurial/hgrc.5.html#web.
You might also be interested in RhodeCode which is a more feature-rich web interface for mercurial.
I'm not sure if this was an option at the time of the question, but there's now an option that enables descending into directories.
[web]
descend = True
You then have two options for how to configure your paths. If you specify a path with a single asterisk, it will descend into subdirectories until it finds repositories.
[paths]
/ = /var/hg/*
If you specify a path with two asterisks, it will also descend into repositories to see if there are nested repositories or subrepositories.
[paths]
/ = /var/hg/**
You can find more details on the Mercurial wiki at PublishingRepositories.
(It sounds as if you may also be looking to have the hierarchy displayed in a tree-like fashion. This solution only impacts which repositories will be detected. It will not change how they are displayed. I'm not aware of any built-in way to accomplish a hierarchical display.)
I had the same problem, and I solved by enabling the collapse option:
[web]
collapse = yes
Related
I'm trying to use 2 set of rules for the ACL of my repos. I was thinking that maybe the action name could be useful from the hooks section but that not the case.
The rules are :
1) Only be able to commit on a specific branch (ex: acceptance)
2) Only be able to pull a specific branch. (Ex: bigNewFeature)
The second rule can look strange for a repo. We are in middle of releasing a big project where all the branches related to it had been merge under bigNewFeature for months on it. We are pushing it on our acceptance server and want to freeze the repos of any new branches except for bigNewFeature. That pretty much to avoid any mistake from one of the dev.
[extensions]
hgext.acl=
[hooks]
pretxncommit.acl = python:hgext.acl.hook
# Was expecting to be able to use any action name
pretxncommit.aclpull = python:hgext.acl.hook
# OR
pretxnchangegroup.aclpull = python:hgext.acl.hook
[acl]
sources = commit
[acl.allow.branches]
acceptance = *
[aclpull]
sources = pull
[aclpull.allow.branches]
bigNewFeature = *
My first rule work like usual but the second one don't look to be run at all. I have no error or what ever.
I'm trying to set up subrepo remapping in Mercurial (2.1.1) to account for subrepo paths that may change in the future. I've been able to get the [subpaths] key to be read and processed properly when it is specified in the .hgrc file. However, when I clone or pull from that repository, the .hgrc file is not copied and thus the subrepo remaps are not brought over to the destination repository.
My first thought after looking at the SubrepoRemappingPlan was to put the [subpaths] in a .hg/subpaths file, which is supposed to be copied on clones/pulls. However, it turns out this functionality has been obsoleted, and the subpaths file has been replaced with a more general configuration-sharing mechanism via the Projrc extension.
The problems with the Projrc solution, though, are:
it's a separate extension that all team members need to have installed and enabled
additional configuration needs to be done to tell Projrc where it is allowed to pull from (and what it is allowed to pull), for security reasons
So, my question is, is there any built-in mechanism in Mercurial for implementing subrepo mapping that is preserved across clones/pulls?
Generally, the best method is to use relative paths for subrepos (see http://mercurial.aragost.com/kick-start/en/subrepositories/) so they never have to be remapped at all.
Example:
+ main repo
+ subrepo
+ .hgsub
.hgsub:
subrepo = subrepo
Adding the subpaths mapping to your .hgsub file should do the trick (as described in the mercurial wiki).
I am setting up a central mercurial server, and want to host multiple repositories. Every web page I look at about this says to set up a config file that looks like this:
[collections]
repos/ = repos/
Where /repos is the folder and /repos is the path to use in the URL.
My question is which /repos is which??? I may want to use a name that is not the same as the path, as in:
[collections]
A/ = B/
Is A the physical path or the url path? Such a simple question you would think would have been answered, but I could not find any nontrivial examples.
Ok, I got it. This is on Windows, and here is everything that I need in the hg.conf file:
[paths]
foo = C:\Data\repositories-hg/foo-hg
bar = C:\Data\repositories-hg/bar-hg
This lets met access the repo at the location C:\Data\repositories-hg/foo-hg as:
http://server:8000/foo
Therefore A is the url alias and B is the physical path. There's of course more to set up, but this accomplishes what need for now.
NOTE: Since I'm new they won't let me post links, which means all the config files will have improperly formatted URLs. This is simply to get around stackoverflow's limitations, I have used the correct URL in practice.
I tried to setup a subrepo, let's call it A/B. So that cloning works properly, I wanted a normal relative path to put it inside the repository, so logically I had .hgsub:
A/B = A/B
However when trying to push this into bitbucket I get the usual 404 (NOT FOUND) error because on bitbucket B cannot be local, and is actually another project (http s://username#bitbucket.org/username/B)
So then I said, OK just to make bitbucket work I can put .hgsub:
A/B = https://username#bitbucket.org/username/B
However, I recently found out that supposedly there was a workaround here: https://www.mercurial-scm.org/wiki/Subrepository where you use the [subpaths] section so that cloning locally works normal, but bitbucket will request the special path for the project.
So I tried copying their instructions. .hgsub:
A/B = A/B
[subpaths]
https://username#bitbucket.org/username/project/A/B = https://username#bitbucket.org/username/B
But I get the same 404 error. Supposedly whenever it sees https://username#bitbucket.org/username/project/A/B, it will instead remap to the latter https://username#bitbucket.org/username/B which will work. However, this doesn't appear to be the case. I have also tried without putting the username# at the beginning.
Any help would be much appreciated. :)
Turns out I think I was testing at a different repo so it wasn't grabbing the match. Here's the working config for all those interested:
.hgsub:
A/B = A/B
[subpaths]
bitbucket\.org/username/projectname/A/B = bitbucket.org/username/B
It looks like your subpaths config is incorrect. The string on the left side must be a pattern that matches an entry in your .hgsub. I think you want something like:
[subpaths]
A/B = https://username#bitbucket.org/username/B
More info may be found in:
SubrepoRemappingPlan
The subpaths section of hg help hgrc:
Here is an excerpt from the hgrc help:
Defines subrepositories source locations rewriting rules of the form:
<pattern> = <replacement>
Where "pattern" is a regular expression matching the source and
"replacement" is the replacement string used to rewrite it. Groups can be
matched in "pattern" and referenced in "replacements". For instance:
http://server/(.*)-hg/ = http://hg.server/\1/
rewrites "http://server/foo-hg/" into "http://hg.server/foo/".
I'm offline a lot.
So normally, I use one local clone as a "hub" for features, bugs, etc.
hg clone local-hub bug-123
Works offline. Cool.
Can I use a similar workflow if that project contains remote subrepositories?
Because, if .hgsub says
sub/shared = http://server/hg/shared
hg clone says
abort: error: getaddrinfo failed
Note that once the clone is created (while connected), push and pull will use the path in the subrepo's hgrc (instead of the location in .hgsub). So I can point this to a local clone and everything is cool.
But clone looks at .hgsub (as it's supposed to). So if the "blessed" subrepo is on a server, I can't create new clones offline, even though the files I need are right there.
This is a problem, right?
Ideally whomever set up the project uses relative URLs in their .hgsub file like this:
sub/shared = ../shared
and then, of course, actually makes shared a sibling of the main repo. Then as long as you have cloned down the main repo and the subs (as siblings) then everything will work out.
If they've used absolute URLs in their .hgsub file you can work around it using the subpaths section in your .hgrc like this:
[subpaths]
http://server/hg/shared = ../shared
which provides a translation layer in your client.
The canonical way to use subrepositories is to have X = X paths in the .hgsub file:
sub/shared = sub/shared
That way a clone will structurally look just like the original -- and so you can use the clone to make further (local!) clones.
However, this is not always possible, for example, Bitbucket wont let you create the nested repositories on their server. In that case, the ../X style paths in the .hgsub file is better, and you can use the subpaths configuration section to translate these paths into paths you can use locally.