4

How can I hinder mercurial from putting changesets to phase “public” on push operations? I want them to stay “draft”.

I rebase and histedit a lot, and the repository I push to is for me only. And having to change the phase all the time is a nuisance.

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94

4 Answers4

11

What the documentation does not clearly reveal is:

The phase-change on push is not a purely local decision. – After “uploading” the changesets, the client asks the server for updates regarding the phases of the commits, and the server is usually telling that they are now “public”.

Thus, the .hgrc-snippet

[phases]
publish = False

has to be put on the server, which inhibits the usual phase-change there. The server will then report the phases back the same way they were pushed.

Bitbucket has an option for this under Settings → Repository details → Phases.

Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
4

The most direct way to keep the phase at draft is to configure the remote server as "non-publishing", as you have already discovered.

But there is a second way, which may be useful to some if the destination server cannot be set to "non-publishing" for any reason: Use pull instead of push. Pulling is read-only, so if you can set up your workflow (e.g. through a local alias) so that the remote pulls changes from your local repo, they'll remain in phase draft.

alexis
  • 48,685
  • 16
  • 101
  • 161
  • you suggestion to use 'pull' worked for me. I tried the "non-publishing" setting listed above but it didn't work for me. Now my 'draft' stays that way on the server. – Jay Shanker Jun 06 '17 at 05:37
  • How do you push in such a way that the remote pulls from you? – binki Jul 27 '17 at 17:25
  • You don't push, you ssh to the remote and pull from there. Interactively or with a script. – alexis Jul 28 '17 at 02:08
  • Most hosts which don’t let you edit the remote’s `.hg/hgrc` also don’t allow you an interactive shell or command other than `hg serve`. I thought there was maybe some trick to make `hg push` operate in pull mode, like how `hg clone` has both a hardlink mode and pull mode. Hmm, too bad. – binki Jul 31 '17 at 18:43
  • Well yeah, you need to have some control over the destination server. My suggestion is useful if you don't _want_ to reconfigure the destination server, e.g. because it should behave as a publishing server except in this one case. (And by the way you know you can also use `hg phase -f --draft` to rewind the phase of some changesets to `draft`, right?) – alexis Jul 31 '17 at 21:45
2

https://www.mercurial-scm.org/wiki/Phases

A repository is "publishing" by default. To make a repository non-publishing, add these lines to its hgrc configuration:


[phases]
publish = False
storm
  • 151
  • 6
-1

Short answer: nohow

If you want rewrite history both locally and on push-target, you have to

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110