Managing local changes I don't want to push?
Patrick Mézard
pmezard at gmail.com
Thu Aug 9 04:03:15 CDT 2007
Martin Sjögren a écrit :
> We use it in a more or less centralized style, having an "official
> repository" that everybody pull from and push to, but people set up
> other repositories too. Now, what I want to do is have some local
> changes (e.g. an extra target in a Makefile) that I want to be applied
> whenever the "official" Makefile changes, but I don't want these changes
> to tag along when I push my changes back to the official repo.
>
> I tried out MQ, but either I don't understand how to make it work for
> me, or it can't do what I want to do...
You can do that with MQ. First, you have to setup an hg repository
tracking the sources you want to edit and keep it in sync with your
source repository. Everytime you update you main repository you have to
add files to hg and commit the changes as well (I assume the hg
repository will share your svn/whatever working copy).
Now, you change "Makefile". To keep it somewhere (assuming it is already
tracked in hg), just:
"""
hg qnew -f edit_makefile.diff
"""
This stores your change in MQ as a patch, applied as an hg revision.
Before you refresh your working copy using svn/whatever:
"""
hg qpop -a
"""
This will unapply the patch and restore the original working copy. Then:
"""
svn update
# Sync hg again with svn working copy
hg ci -m upstream
# Apply your patch again
hg qpush -a
"""
Use guards to apply patches conditionally, first mark the patch:
"""
hg qguard edit_makefile.diff +local
"""
To activate it:
"""
hg qpop -a
hg qselect local
hg qpush -a
"""
To deactive it, remove all guards:
"""
hg qpop -a
hg qselect -n
hg qpush -a
"""
Finally, if you want to push one of your applied patch, instead of qpop:
"""
# Commit whatever changes are applied
# It basically sync snv with hg
svn ci
# Convert the patch revisions as real hg revisions
hg qdel -r qbase:
"""
Then hg and svn are in sync again (modulo conflicting upstream changes).
--
Patrick Mézard
More information about the Mercurial
mailing list