How to automatically delete all .orig files in the Mercurial working tree?

During merge, merurial leaves an .orig file for any unresolved file. But after correctly resolving the problems and correctly marking the file, it does not delete the .orig file. Can it be automatically deleted by some command?

I work on a Mac, so I can use something like:

find . -iname '*.orig' -exec rm '{}' ';' 

and an alias is this or something, but I would rather use something like cleaning hg ...

UPDATE:

Since some time, the Purge Extension has been bundled with Mercurial and perfectly solves this problem.

+52
dvcs mercurial
Jul 01 '09 at 7:10
source share
11 answers

I personally use

 $ rm **/*.orig 

if I get tired of .orig files. This works in Zsh and Bash 4 after running shopt -s globstar .

But if you use a different shell or want a built-in solution, you might like the extension (link updated 2016-08-25). This allows you to delete all unprocessed files using

 $ hg purge 

You can delete all unsolicited and ignored files with

 $ hg purge --all 

The advantage of using hg purge is that it will also clean directories that become empty after files are deleted. The rm command line will simply leave empty directories.

+64
Jul 01 '09 at 8:19
source share

by the way. find The utility has a -delete action so you can print only:

find <path-to-files> -name '*.orig' -delete

+31
Nov 12 '12 at 11:18
source share

If you just want to delete the .orig files and you end up on a Windows machine, it looks like this works well:

 D:\workspace>hg purge -I **/*.orig --all 

This will delete all unprocessed files that end in .orig, but will not delete other unnecessary files, as other answers will be.

You can verify this before starting it by adding the --print flag.

+12
Nov 14 '12 at 21:35
source share

Below .orig files will be deleted in the entire hierarchy of the working copy, and also works for paths containing spaces:

 find . -name *.orig | while read -d $'\n' file; do rm -v "$file"; done; 

I use an alias in my .bash_profile:

 alias clearorig='echo "Removing .orig files..."; find . -name *.orig | \ while read -d $'\''\n'\'' file; do rm -v "$file"; done;' 
+4
Mar 11 '12 at 21:15
source share

I posted this answer before . But this is the right place for this answer.

I myself made this batch file.

 IF "%1%" == "d" ( del /s *.orig del /s *.rej ) ELSE ( del /s /p *.rej del /s /p *.orig ) 

Help: Save this content as orig.bat

  • Run orig d to delete all rejects and orig files at once without confirmation.
  • Run orig to delete confirmation files [Security Engine]

Hope this will be helpful.

+1
Nov 23 '12 at 12:40
source share

I personally use the following from the repo root:

 hg purge -p -I **/*.orig | xargs rm -f 

This is slightly better than using only "hg purge" or "hg purge -all", because you can filter out the specific file types that you want to include.

For an explanation:

  • The -p argument prints a list of files to be cleaned.
  • -I Argument whitelist filters files to include
  • The resulting list is piped to xargs and executed using the rm -f command
+1
Jul 11 '13 at
source share

I work in Powershell and cannot see the answer here:

 # NOTE: be in the root of your repository # fetch all .orig files recursively $orig = (dir *.orig -recurse) ; # remove each .orig file foreach ($item in $orig) { del $($item.FullName) ; } # afterwards I make sure to remove the references to the .orig files in the repo # then commit & push hg addremove ; hg commit -m "remove .orig" ; hg push ; 
+1
Jul 09 '15 at 21:50
source share

you must use update binding

update: this is done after the update is completed or the working directory is merged

0
Jul 01 '09 at 7:31
source share

This is not an automatic way to delete additional files, but it is simple enough to start manually.

hg st may show unknown or not tracked files. You can use this output as an argument to the rm command. Here is the actual example that I just completed:

 $ # SHOW ONLY THE CRUFT $ hg status --unknown ? config/settings.rb.orig ? lib/helpers.rb.orig ? routes/main.rb.orig $ # THE CRUFT WITHOUT THE "?" PREFIX $ hg status --unknown --no-status config/settings.rb.orig lib/helpers.rb.orig routes/main.rb.orig $ # SAFELY REMOVE ALL CRUFT $ rm -- `hg st -un` 

If you have empty directories left, the -r and -d flags for rm may help.

As a bonus , hg status --ignored can be used to clear all those ignored temp files, as well as swap files from your editor (e.g. Vim).

0
Sep 29 '14 at 0:12
source share

The command that I use for Linux to clean up eliminates the need to perform a new search with find.

They need to be run from the root directory of the Mercurial project.

hg status | grep ".orig" | cut -d ' ' -f 2- | xargs rm -f

Or if you want to delete all unknown files.

hg status | cut -d ' ' -f 2- | xargs rm -f

0
Dec 01 '15 at 22:02
source share

I do not like the selected answer. It does not delete everything at all levels of the project. I use this:

 for f in `find . | grep .orig$`; do rm "$f"; done 

Works on both Mac and * nix

-one
Jan 19 '12 at 20:02
source share



All Articles