4

The closest answer is this one, and here's a line from it:

hg revert -r <oneRevBack> fileName

The last thing is to get <oneRevBack> other than using hash. I would dream of just typing <-1>.

Community
  • 1
  • 1
Dan
  • 55,715
  • 40
  • 116
  • 154

1 Answers1

7

The hg syntax for "one rev back" is tip^, where tip is the latest revision and ^ means "parent". If your working directory is not at tip, use .^, where the dot means "current revision".

You can use hg revert -r tip~n file to revert to the nth ancestor of the tip (using the first parent if a commit has two parents). You can use -(n+1) only if there's only a single branch. -1 refers to the last revision, -2 the penultimate revision, and so forth, in order of revision numbering and not following the branch structure. (See hg help revsets for more details.)

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Peter Westlake
  • 4,894
  • 1
  • 26
  • 35