0

my problem is quite simple: there is a folder in my project which I want versioned, but not pushed along with the rest of the project when I push updates. The situation is that I made an Android app stub along with the project, and I don't want to push it until it is actually somewhat functioning. It's a pretty bulky folder.

I do not want to make a separate branch for that folder, because of two problems: firstly, updating that branch whenever I pull from remote will require a merge; secondly, swapping between the two branches requires noticeable waiting time as the thousands of Android files are created/deleted, and this is very annoying to me.

I was thinking about editing .hgignore in some way, but I think it is wrong that the remote repo will then have my local folder as ignored.

Any suggestions?

user1846231
  • 315
  • 3
  • 12
  • Your only option when pushing is which changesets to push. If a folder is committed, you can't really push a partial changeset. Either you push the entire changeset, or you don't push it at all. You can easily do what you want with branches, and there's no need to update back and forth, simply keep two local working folders / repositories, each to their own branch, and push/pull and merge between them. – Lasse V. Karlsen Dec 13 '14 at 21:05

2 Answers2

2

You can add this snippet to your repo's hgrc file:

[ui]
ignore = /path/to/.hg/hgignore

where the point about this hgignore file is that it is non-versioned and local to you. The contents hgignore can be anything that would also be suitable for the (versioned) .hgignore. e.g:

syntax: glob
/directory/to/ignore

The name of the file, hgignore, can be called anything, but it's what I use.

John Jefferies
  • 1,176
  • 7
  • 13
1

You can use the configuration [defaults] section to add some "--exclude" options to usual commands (see my answer to Mercurial hg ignore does not work properly ) for more details. You can even specify which files you do not want to commit in your directory, e.g., stub/**.c for all C files in the hierarchy of directories below stub.

But.. be careful that it is dangerous to silently ignore modifications to files and also that this [defaults] section has been marked as deprecated (it is still present in 2.9.2).

If this is a temporary situation, it would solve your problem though: you would just have to remove the --exclude parts when you feel ready to commit and push your stub.

Community
  • 1
  • 1
Christophe Muller
  • 4,850
  • 1
  • 23
  • 31
  • This looks interesting, I will try it out. Can I add the exclude option to only push, but not commit, commands? – user1846231 Dec 12 '14 at 09:08
  • @user1846231 actually `push` will only push the local changesets (i.e., commits) that are not yet found in the destination, so no you really cannot avoid excluding in the `commit` command.. – Christophe Muller Dec 12 '14 at 14:43