Using hg revert in Mercurial

53,925

Solution 1

Yes, you can delete them. It's a safety feature in case you reverted something you didn't mean to revert.

Solution 2

You can also use the flag --no-backup and the .orig files will not be created

hg revert --no-backup filename.java

As of Mercurial 2.0, you can instead use the flag -C to supress the .orig files from being created

hg revert -C filename.java

Solution 3

I find the purge extension handy. Usage:

hg purge

"This extension purges all files and directories not being tracked by Mercurial"

...including the .orig files but excluding ignored files (unless you use --all).

Solution 4

As other's have pointed out, you can safely delete these files.

You can remove them by executing this command from the root of your repo:

rm `hg st -un | grep orig`

If you want to revert, and don't care at all about backing up the original files, the command you want is:

hg update -C

Solution 5

Those are copies of the files from before you reverted them. If you don't need those, you can delete them, either by hand or by using the Purge extension:

hg clean
Share:
53,925
user246114
Author by

user246114

Updated on July 08, 2022

Comments

  • user246114
    user246114 almost 2 years

    I'm using Mercurial. I made a clone of a repository. For debugging, I changed a few lines of code in a java file. I did not commit those changes though. I just want to revert them back to their original state, as found in the repository. I tried hg revert filename.java, which did revert it, but now when I do hg status, I see additional files added in my folder now like:

    ? filename.java.orig
    

    Can I just delete those files, and why does Mercurial make them when I use revert?

  • Martin Geisler
    Martin Geisler over 14 years
    There is "clean" command in standard Mercurial -- perhaps you are thinking of the purge extension and hg purge?
  • Casebash
    Casebash almost 14 years
    @Martin: Typing hg clean says that clean is provided by the purge extension
  • Martin Geisler
    Martin Geisler almost 14 years
    Casebash: ah, right -- the purge extension provides the command under both names: hg purge and hg clean.
  • jbranchaud
    jbranchaud about 11 years
    Save some typing with: hg revert -C filename.java
  • Fooman
    Fooman about 11 years
    The -C shortcut was introduced with mercurial 2.0 see mercurial.selenic.com/wiki/WhatsNew
  • TOMKA
    TOMKA about 11 years
    I'm not sure I understand how -C is short for --no-backup... is it a Courageous revert?
  • Florian Pilz
    Florian Pilz over 10 years
    I guess it stands for clean, since it has the same effect as calling hg revert FILE && hg clean.