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

后端 未结 12 663
刺人心
刺人心 2020-12-13 08:34

During merges mercurial leaves .orig file for any unresolved file. But after manually resolving problems and marking a file correct it does not delete the .orig file. Can it

12条回答
  •  Happy的楠姐
    2020-12-13 08:59

    This is not an automatic way of removing extra files, but it's simple enough to run manually.

    The hg st can show unknown or not tracked files. You can use this output as an argument to the system rm command. Here's an actual example I just performed:

    $ # 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 behind, the -r and -d flags for rm might help.

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

提交回复
热议问题