1

I know it is strange but I was updating my testcases and thought of removing all the untracked files from the testcase so ran hg purge, but apart from deleting untracked file it deleted tracked files for 230+ testcases too.

Is there any way to revert back to original or can I get the files back? These files are on the server so I can get it by pulling it from server, but this is not helpful as I have to update it again.

BitMask
  • 314
  • 2
  • 9
  • 1
    It definitely *should not* delete tracked files, whether modified in the working directory or not. Note that "tracked-ness" depends on the commit you have out, though. – torek Nov 25 '19 at 22:55
  • I ran few script(old scripts) it must have messed up with few test cases. otherwise why it would delete for only 230 testcases out of 2700. Anyway Thanks! – BitMask Nov 27 '19 at 13:24

1 Answers1

2

If you have modified Working Directory ("modified" by any way) you can easy discard changes and return to the state of clean "."-changeset using

hg up -C -r .

And yes, follow-up to @torek, hg purge must not touch tracked files, because, according to its wiki

extension purges all files and directories not being tracked by Mercurial in the current repository

but I can see one possible case, why its may happen. Next para in description sheds some light on topic:

With the --all option, it will also remove ignored files

(and some pure speculation below...)

If you had files in .hgignore and added these files into repository by hand (you can hg add ignored files), purge probably may delete these files.

You can (rather easy) verify my idea after returning to good state of repo

  1. Install|add hg-isignored extension (Bitbucket, will disapper soon due to BB-refugee from HG) and check ignorance state of versioned, but deleted by extension files (at least some of) - you'll see result and used pattern from .hgignore
  2. Try (again) hg purge --print in order to get list of purged files. If lists (deleted and ignored versoned files) will have intersections, then you'll get answer on question "Why?"

I can't see any other reasons for such behavior of the extension.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110