• Safely changing history

    How exactly does Mercurial manage to keep you from getting in trouble while changing history?

    Mercurial actually keeps track of something called phases. Every time you push changesets to another repository, Mercurial analyses the phases for those changesets and adapts them if necessary.

    There are three phases, each resulting in different behaviour:

    • secret: This phase indicates that a changeset should not be shared with others. If someone else pulls from your repository, or you push to another repository, these changesets will not be pushed along.
    • draft: This is the default phase for any new changeset you create. It indicates that the changeset has not yet been pushed to another repository. Pushing this changeset to another repository will change its phase to public.
    • public: This phase indicates that a changeset was already shared with others. This means changing history should not be allowed if it includes this changeset.

    Mercurial uses this information to determine which changesets are allowed to be changed. It also determines how to select changes to rebase or histedit automatically. For example: using histedit without any arguments will only show draft and secret changesets for you to change.

    You can not change history for any published changes - like I said, doing so makes your repository incompatible with any other clone.

    • squaresinger@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      2 days ago

      You can not change history for any published changes - like I said, doing so makes your repository incompatible with any other clone.

      That’s the same on Git.