hg equivalent of git push -f?
Arne Babenhauserheide
arne_bab at web.de
Mon Mar 6 16:33:50 UTC 2017
Jeremy . writes:
> I've been thinking of what it would take to convert my work place from
> git to hg, and the one thing which doesn't seem to have any equivalent
> is git push -f. hg may also have a push -f, but it leaves dangling
> anonymous heads which have to be stripped on the server. Evolve may
> help, but it doesn't like changing branches which have been pushed to
> a publishing repository, and we don't need or want the overhead of
> keeping obsolete changesets and markers.
One solution is already in there: You can make the remote repository
non-publishing. The obsoletes do not leave that server.
# with evolve
cd /tmp
hg init moo
cd moo
echo 1 > 1
hg ci -Am 1
echo 2 > 1
hg ci --amend -Am 1
hg log --hidden
# three changesets
cd ../
hg clone moo goo
cd goo
hg log --hidden
# only the final changeset
Alternatively you could create a push hook which automatically strips
the old changesets. The following example is for bookmarks, but you
could also just strip away the non-tip head on a force-push.
[hooks]
pushkey.delete-old-history = if test x"$HG_NAMESPACE" = x"bookmarks"; then $HG strip --hidden -r "::$HG_OLD - ::$HG_NEW"; hg update $HG_KEY; fi
Best wishes,
Arne
More information about the Mercurial
mailing list