I like Mercurial a lot better for its consistent command line, but git has a feature which I very much miss:
Can Mercurial simply ignore an .hg folder within a subdirectory, in order to track all files below it 'normally'?
With git it is possible and it does not even require a special switch!
Edit: Somewhat sad, that one gets downvoted for simply asking if the feature is present in merc as well.
Details:
Current Behaviour
As soon an .hg directory is created within the tree, Mercurial stops tracking all content from its containers directory, treating it as another independently managed repo by default:
/tmp$ mkdir -p a/b/c/ && touch a/b/c/foo && hg init a && cd a && hg status
? b/c/foo
/tmp/a$ mkdir b/.hg && hg status
/tmp/a$
Merc. thinks now there is another repo tracking all within ./b
, by presence of .hg
folder.
But can I switch this off? Even if I explicitly ignore b/.hg
:
/tmp/a$ echo -e "syntax: glob\nb/.hg*" > .hgignore
/tmp/a$ hg status
? .hgignore
the main repo does not track below ./b
anymore.
I would like to have ALL files below a
tracked within a/.hg
, no matter if someone created a .hg
folder within.
git:
/tmp$ mkdir -p a/b/c/ && touch a/b/c/foo && \
git init a && cd a && git add -A && git status
Initialized empty Git repository in /tmp/a/.git/
# new file: b/c/foo
/tmp/a$ git init b
Initialized empty Git repository in /tmp/a/b/.git/
/tmp/a$ git status
# new file: b/c/foo # <- still tracked.
```
Two Potential Use Cases
Disclaimer: The comments show that the information given in these use cases alone is NOT sufficient to justify the requested feature of my question: For case A as well as B, subrepos COULD be the right answer (definitely not in my specific case though). I still leave the use cases in, in order to demonstrate the directory structure but I pls. mind the main question of this post.
A) Different commit purposes, intervals, periods, policies, skills within one large project:
Juniors/Partners Seniors, Admins
contribute to subdir(s) overlook the whole project
| |
| |
| LargeProject/ |
| ├── .hg <------------ 'official' commits
| ├── conf high quality, customer tracks,
| ├── lib show up in release notes.
| ├── (...)
| └── frontend,contrib,...
└-freq. commits-> └── .hg
of frontend └── js
stuff └── css
└── (...)
- The project is mature and stable in general but at certain periods work in not critical part(s) happens, in subdirectories, which only after contributers give a go, should show up as official commits.
- Which parts are handled like this is changing over time and not known in advance.
- For topological reasons all the work happens on one machine in the DEV or staging zones of the customer.
- From time to time a tagged push to the central repo to transfer to (pre)production.
If another VCS would be used for the partner stuff (with its meta files ignored in the global repo), it would all work like expected - except that I would like to use (and explain & train) Mercurial only for all contributions.
B) Using hg solely as Filesystem change tracking tool only - within a project repo.
Within my hg project directory I have a subdirectory, containing dumped files of an object database as integral part of the project.
Now I would love to use hg within that one directory, for some of its tracking features (basically for tracking transactions within the OODB and being able to push back changes on the filesystem into it, maybe after merges). I need frequent commits here - but don't want to explode the history of the official project repo with those.
Problem is just: As soon I run an hg init there, the main repo outside is stopping to track the directory.
I DON'T want subrepos since I'm really not pushing or pulling anything there, as said it is just for local OODB changes tracking. Also I don't want the caveats of subrepos, just because I require those tracking features within the subdir, incl. automatic commits.
My current work around is to use git like shown, that way the main repo does display any changes of the OODB just like for any other file of the project:
my_project/
├── .hg # Main project repo, 'offical commits'
├── conf # 'Normal' project repo folders
├── lib
└── zodb # Containing OODB dumps
├── .git # Repo to auto track transactions of the OODB,
└── zodb_root # frequently dumped within this directory, and
└── tenant1 # often committed, for diffing / merging reasons.
But I would really love to use .hg as well for the inner 'tracking only' directory as well.
The most simple solution would be if I could configure mercurial to ignore the .hg in the OODB directory. Tried with unshared bindmounts but alone the empty mountpoint directory is enough to make hg refuse to look into the directory.
Any Ideas out there? A simple solution would be if Mercurial would respect *.hg within the global .hgignore, like it does for *.git - but it doesn't.