3

I have file/directory structure:

main/.hg
main/subrepo/.hg
main/subrepo1/.hg

I have .hgignore file with such content

.hg

Finally, I want to make a commit in 'main' repository that will include all files in it, including all files from main/subrepo and main/subrepo1 and excluding folders main/subrepo/.hg and main/subrepo1/.hg (so all files from main folder, excluding .hg folders in it will be commited). But Mercurial skips main/subrepo/* and main/subrepo1/*. It does not include this subfolders/subrepos to commit fully. How can I fix this?

Gangnus
  • 24,044
  • 16
  • 90
  • 149
freento
  • 2,939
  • 4
  • 29
  • 53
  • are you sub repositories properly linked to the main repository or do you just have nested repositories? In other words, does the main folder have a .hgsub file in it? – Jason Down Dec 13 '13 at 23:45
  • main, main/subrepo, main/subrepo1 should be independant repositories, for example, main and main/subrepo should track filechanges from main/subrepo/test.txt independantly, main and main/subrepo1 should track filechanges from main/subrepo1/test.txt independantly, etc – freento Dec 14 '13 at 11:02
  • 2
    A subrepository is independent, yes. However, the purpose of a subrepository is to take that independent repository and reuse it within another repository. The parent repository has the option of pulling down changes that were done in the remote/central location for the subrepository, or to keep it at a particular version (prevents being forced into importing a breaking change). In essence, a subrepository is an alternative strategy to keeping a 3rd party library in your project, without having to keep an external reference to the subrepo or to a compiled version of the library (for e.g.). – Jason Down Dec 14 '13 at 17:39

1 Answers1

3

I'm going to guess that you have simply created some nested repositories, but not properly linked them as subrepositories.

Make sure that the root of the main repository has a file called .hgsub. You create the file, add the following and then add + commit the file to the main repository:

subrepo = https://path-to-subrepo/
subrepo1 = https://path-to-subrepo1

If the subrepos do not point to some remote server, you would use the local path of course.

Jason Down
  • 21,731
  • 12
  • 83
  • 117
  • Some subrepos pointed to remote server, some not. My goal is to use main repository as backup of all files/folders in it (excluding .hg folders, because where are no need to backup it). Once a day I want to do hg commit; hg push; by cron. I don't want to use any backup software, because hg has all that I need. Solution that I did is to rename all .hg files to .hg_gg files, add .hg_gg to .hgignore and after commit and push rename all back. But I hope to find the way without folders rename. – freento Dec 14 '13 at 10:47
  • 2
    Sounds like a slight misuse (abuse?) of what subrepositories are for. The .hg files are necessary to keep a history of the subrepositories in case you ever decide to pull down changes for them. They are really designed to allow a repository to be shared with others so that cloning the parent repository ensures that the subrepositories are also cloned, and at the level the parent repository expects them to be at. – Jason Down Dec 14 '13 at 17:43