Wednesday, April 18, 2012

Using Mercurial: Backing out changeset(s)

Backing out changeset is the process of applying the inverse patch of that changeset.  By extension, you can backout a range of changesets by applying the inverse of patch of all the changesets.  This should be the default methodology of "reverting" a change or set of changes as it will maintain the consistency and completeness of the repository.

  • hg pull
  • hg up # Now your working directory and local repo are up to date
  • hg up -r revLast # Update to the latest revision you want to backout
  • hg revert -a -r revFirst-1 # Creates an inverse patch of revFirst to revLast
  • hg ci -m "Backed out revFirst - revLast" # Commit inverse patch
  • hg merge # Merge inverse patch to tip in my working directory
  • hg ci -m "Merged change back into the tip" # Commit inverse patch to tip in local repo
  • hg push # Push to master

Reference iWhether i9-09/backing-out-multiple-consecutive-changesets-mercurial


No comments:

Post a Comment