Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26637

Should I run hg revert?

I'm running hg 1.7.5 and I had a similar problem earlier on the mercurial mailing list and we could solve it by running hg revert -a. Now I did run hg revert and it didn't solve the problem. I had problems with my filesystems and I had to interrupt a transaction now when I ran `hg commit' I get a new head

$ hg commit -m 'changes'
skapade ett nytt huvud
ubuntu@ubuntu:/media/Lexar/montao/montaoproject$ 

The localized message means hg created a new head. hg diff shows nothing. Could you say what I can do?

$ hg heads
ändring:     322:d74d7e14fe44
märke:       tip
förälder:    -1:000000000000
användare:   niklasro
datum:       Fri Dec 02 02:22:31 2011 +0000
kortfattat:  changes

ändring:     321:470a570041e0
användare:   niklasro
datum:       Sat Nov 26 22:38:16 2011 +0000
kortfattat:  bug fixes for insert

ubuntu@ubuntu:/media/Lexar/montao/montaoproject$ 

Update

I had to do a merge which it could do, then I could commit and push so now there is only one head like it should be:

$ hg heads
ändring:     324:eccc83b75b58
märke:       tip
förälder:    323:5842204042f5
förälder:    322:d74d7e14fe44
användare:   niklasro
datum:       Fri Dec 02 09:01:35 2011 +0000
kortfattat:  changes

ubuntu@ubuntu:/media/Lexar/montao/montaoproject$ 

Upvotes: 0

Views: 382

Answers (1)

Pavel Gatilov
Pavel Gatilov

Reputation: 7661

If you want to keep your recent changes, try this:

  1. Copy the whole working folder to some other place
  2. run hg update -r 321 --clean
  3. Copy the working folder backup back (do not copy .hg folder from the backup)
  4. run hg commit -m 'changes'

If you don't need your changes, you may just update to the rev 321 and then strip rev 322 using patch queue. I'm not used to work with hg in console, so I'll write how to do this in TortoiseHg.

First, enable the 'mq' extension:

  1. Open 'HG Workbench'
  2. Go to 'File->Settings'
  3. Select 'Extensions' from the list of features
  4. Check 'mq'
  5. Save changes
  6. Close 'HG Workbench'

Strip revision:

  1. Open 'HG Workbench'
  2. Select rev 322
  3. right-click on it
  4. select 'Modify history'->'Strip'
  5. click 'Strip'

Upvotes: 2

Related Questions