I have a project, which is using Mercurial, I work alone on it and often I find myself in the same situation over and over: during working on something, I realize, that other changes should be fixed and committed before I finish my current work. So, I tried to create an “Anonymous branch”
hg update --check PREVIOUS_REVISION
but unfortunately, it doesn’t work with the uncommitted changes (and I really don’t want to commit unfinished work). So, every time, I copy directory with sources, revert to the previous revision, fix, commit, switch back to my working copy, pull the change and continue my work… But it takes too much time, so maybe there are better ways to do it and just with one copy of sources? Thank you.
P.S. Probably, it’s the same question as How do I put a bunch of uncommitted changes aside while working on something else but my idea is “Is it possible just to leave unfinished work in the default branch in ‘as is’ state and then work on it later, without loading external patch?” (anyway, feel free to close it if it’s a duplicate)
Three ways to solve task of “intermitted work”
hg shelve --all, make needed independent changes in clean WC, commit, restore intermediate results of work, saved on step 1hg unshelvehg up <REV>to previous commit, make “must be before” changes, commit, return to older head, merge heads, continue workI’ll prefer (and always use for different tasks) MQ
Addition:
For fans and admirers of “clean history” one possible change in anonymous branching workflow (avoiding merge)
hg commit -m "Unfinished work"(rev M)hg up -r "tip^1"hg commit -m "Base changes"(rev N)hg rebase -r M -d N(linearize history)hg uphg commit --amend -m "Full dependent change"PS: I can’t see anything bad in reversed set of changeset, i.e write
a = something(data)in CSET, andfunction something (int subject) {...}in CSET+1