Using Mercurial, how can I bundle all changesets not known to be in another repository, including secret changesets?
I know bundle's --base option happens to include secret changesets, but I don't want the --base behavior. (And it seems unusually weird that secret changesets are always included with --base but are never included without it. Shouldn't there be a separate option?)
FYI, I commonly want to make a backup of all changesets which are only in my local repo before attempting a potentially dangerous history rewrite.
You are correct that
hg bundlewill normally exclude secret changesets. This is because it's just running the equivalent ofhg outgoingand bundling these changesets.So some work-arounds:
If you know that you have at least one draft or public outgoing changeset as an ancestor of your secret changesets, then you can use
to get what you want. The
outgoing()revset will pick the missing draft and public changesets andparents(outgoing()will be suitable bases. Since you use--baseyou get all descendants (public, draft, and secret) from these bases.You could temporarily make your secret changesets draft, bundle, and then mark them secret again:
(I use Zsh and there I had to use
${=secret}instead of$secretbecause Zsh doesn't do word splitting on parameter expansion by default.)It's important to chain the commands with
;instead of&&since you'll want to reset the phases regardless of what happens in thehg bundlecall — passing wrong parameters tohg bundleshould not mean that you lose all the information about the secret changesets. Note also that since secret changesets only have secret descendants, there's no information loss with this technique.You can turn this into a shell alias:
The
$@is expanded by Mercurial before the alias is invoked and this lets you insert the necessary arguments forhg bundle.Note that phase information cannot be stored in bundles — the bundle format has not been changed to accommodate it.