I'm new with Mercurial and I'm still trying to establish a workflow.
I clone a remote repository. I then make changes and commits to my local repository. I would like to push a clean revision history. I don't want to push some revisions that may only muddy the remote repository (e.g. typo rename of methods, adding of javadoc, removing whitespaces, etc). Is this possible?
Thank you!
Indeed there are cases when it makes sense to prune/strip/polish changesets or to separate private/in-progress and public/ready changes. Here are some suggestion how to handle this with Mercurial:
If you made a series of small commits (which is a good thing), but you prefer to publish them as one changeset (which makes sense if you committed - possibly contradicting - snapshot changesets), use the collapse extension:
$ hg collapse -r <first-ref>:<last-ref> # both revs including
If you just have changes you want to keep private while others you want to publish, either (a) use mercurial queues for you private changes or (b) commit you private-only changes in an own branch (named, bookmarked, or cloned) and regularly merge it with the public branch. The latter requires you to switch between branches quite often if you commit private and public changes alternating.
UPDATE
To illustrate option 2.b, consider this graph of changesets:
0--1--4--5---8--9 <= public/stable branch
\ \
2--3--6--7 <= private/dev branch
This means you've made changes 2
and 3
on the dev branch. Then you did some work on the stable branch (revisions 4
and 5
). These changes also make sense in dev, so you merge them into dev (revision 6
). Finally you make another experimental change in dev (revision 7
) and some ready-to-publish improvements in stable (revisions 8
and 9
). You can now publish (i.e. push to the remote repository) the changes made in stable, by running
$ hg push -r 9 # or `-r stable` if the branch is named or bookmarked as such
All private changes will stay local!
Note that if you plan to polish your private commits later (e.g. collapse them to one changeset), you must not merge in the stable branch (collapse cannot work across merges). Instead, rebase you private changes whenever you want them to be in sync with the latest changes in stable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With