1

Is there any way to lock a repository into pull-only mode?

The use case I have in mind is that I own an open-source C# WinForms project on CodePlex. I have a clone of that repository that is for internal distribution - that is, it is the complete public source code, with the addition of changes to the project file from Visual Studio's Publish/ClickOnce feature.

No one else in the world should have or would want these changesets - the file share where the ClickOnce files are stored, for instance.

I have another repository where I would make changes to the underlying source and push them to CodePlex. I want to prevent myself from accidentally pushing in the distribution-only clone. Is there a way in Mercurial do do that?

flag

1 Answer

1

If you really want to have the repository be completely pull-only, that's as easy as overriding the push command on that repository. In the repository's .hg\hgrc file, simply add the lines

[alias]
pull = ! echo No pushing allowed

(probably editing that command slightly for cmd.exe rather than bash).

If you want some more complex behavior, you can [use the preoutgoing hook][http://www.selenic.com/mercurial/hgrc.5.html#hooks] to prevent pushing as well. Again, add the hook in the repository's .hg\hgrc, not your global Mercurial.ini, or you're going to be very unhappy with your pushless DVCS.

link|flag
Thanks Ben! Your example disables pull, not push (typo I'm sure) but other than that, your example worked perfectly even on Windows. I also chose to disable outgoing as I didn't see much point in advertising something that's disallowed. – David Dec 21 2010 at 20:03

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.