hgext/purge.py
author Daniel Holth <dholth@fastmail.fm>
Wed, 16 May 2007 01:07:27 -0400
changeset 4446 1b75e0eff532
parent 4308 1043e4b27ab9
child 4462 a73cf208b2a0
permissions -rw-r--r--
document conversion interface
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
     1
# Copyright (C) 2006 - Marco Barisione <marco@barisione.org>
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
     2
#
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
     3
# This is a small extension for Mercurial (http://www.selenic.com/mercurial)
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
     4
# that removes files not known to mercurial
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
     5
#
4154
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
     6
# This program was inspired by the "cvspurge" script contained in CVS utilities
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
     7
# (http://www.red-bean.com/cvsutils/).
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
     8
#
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
     9
# To enable the "purge" extension put these lines in your ~/.hgrc:
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
    10
#  [extensions]
4308
1043e4b27ab9 Move back the purge extension in hgext
Emanuele Aina <em@nerd.ocracy.org>
parents: 4307
diff changeset
    11
#  hgext.purge =
4154
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
    12
#
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
    13
# For help on the usage of "hg purge" use:
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
    14
#  hg help purge
15cd36db4230 Delete the README for purge, putting the useful informations in comments
Emanuele Aina <em@nerd.ocracy.org>
parents: 4153
diff changeset
    15
#
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    16
# This program is free software; you can redistribute it and/or modify
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    17
# it under the terms of the GNU General Public License as published by
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    18
# the Free Software Foundation; either version 2 of the License, or
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    19
# (at your option) any later version.
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    20
#
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    21
# This program is distributed in the hope that it will be useful,
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    24
# GNU General Public License for more details.
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    25
#
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    26
# You should have received a copy of the GNU General Public License
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    27
# along with this program; if not, write to the Free Software
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    28
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    29
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    30
from mercurial import hg, util
4121
d250076824e3 Use the mercurial i18n infrastructure in the purge extension
Emanuele Aina <em@nerd.ocracy.org>
parents: 4120
diff changeset
    31
from mercurial.i18n import _
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    32
import os
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    33
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    34
def dopurge(ui, repo, dirs=None, act=True, abort_on_err=False, eol='\n',
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    35
            force=False):
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    36
    def error(msg):
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    37
        if abort_on_err:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    38
            raise util.Abort(msg)
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    39
        else:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    40
            ui.warn(_('warning: %s\n') % msg)
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    41
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    42
    def remove(remove_func, name):
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    43
        if act:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    44
            try:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    45
                remove_func(os.path.join(repo.root, name))
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    46
            except OSError, e:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    47
                error(_('%s cannot be removed') % name)
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    48
        else:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    49
            ui.write('%s%s' % (name, eol))
4151
337010e50dcd Use nested functions instead of object methods
Emanuele Aina <faina.mail@tiscali.it>
parents: 4150
diff changeset
    50
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    51
    directories = []
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    52
    files = []
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    53
    missing = []
4155
4c714ed245d6 purge.py: fix invocation of statwalk
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4154
diff changeset
    54
    roots, match, anypats = util.cmdmatcher(repo.root, repo.getcwd(), dirs)
4c714ed245d6 purge.py: fix invocation of statwalk
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4154
diff changeset
    55
    for src, f, st in repo.dirstate.statwalk(files=roots, match=match,
4c714ed245d6 purge.py: fix invocation of statwalk
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4154
diff changeset
    56
                                             ignored=True, directories=True):
4c714ed245d6 purge.py: fix invocation of statwalk
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4154
diff changeset
    57
        if src == 'd':
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    58
            directories.append(f)
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    59
        elif src == 'm':
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    60
            missing.append(f)
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    61
        elif src == 'f' and f not in repo.dirstate:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    62
            files.append(f)
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    63
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    64
    _check_missing(ui, repo, missing, force)
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    65
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    66
    directories.sort()
4147
691f9168a815 Make the purge extension use the statwalk walker from the dirstate object
Emanuele Aina <faina.mail@tiscali.it>
parents: 4121
diff changeset
    67
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    68
    for f in files:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    69
        if f not in repo.dirstate:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    70
            ui.note(_('Removing file %s\n') % f)
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    71
            remove(os.remove, f)
4147
691f9168a815 Make the purge extension use the statwalk walker from the dirstate object
Emanuele Aina <faina.mail@tiscali.it>
parents: 4121
diff changeset
    72
4153
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    73
    for f in directories[::-1]:
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    74
        if not os.listdir(repo.wjoin(f)):
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    75
            ui.note(_('Removing directory %s\n') % f)
af72395580e8 Delete the Purge class, refactoring Purge.purge() in dopurge()
Emanuele Aina <faina.mail@tiscali.it>
parents: 4152
diff changeset
    76
            remove(os.rmdir, f)
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
    77
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    78
def _check_missing(ui, repo, missing, force=False):
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    79
    """Abort if there is the chance of having problems with name-mangling fs
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    80
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    81
    In a name mangling filesystem (e.g. a case insensitive one)
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    82
    dirstate.walk() can yield filenames different from the ones
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    83
    stored in the dirstate. This already confuses the status and
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    84
    add commands, but with purge this may cause data loss.
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    85
    
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    86
    To prevent this, _check_missing will abort if there are missing
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    87
    files. The force option will let the user skip the check if he 
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    88
    knows it is safe.
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    89
    
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    90
    Even with the force option this function will check if any of the 
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    91
    missing files is still available in the working dir: if so there
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    92
    may be some problem with the underlying filesystem, so it
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    93
    aborts unconditionally."""
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    94
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    95
    found = [f for f in missing if util.lexists(repo.wjoin(f))]
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    96
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    97
    if found:
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    98
        if not ui.quiet:
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
    99
            ui.warn(_("The following tracked files weren't listed by the "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   100
                      "filesystem, but could still be found:\n"))
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   101
            for f in found:
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   102
                ui.warn("%s\n" % f)
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   103
            if util.checkfolding(repo.path):
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   104
                ui.warn(_("This is probably due to a case-insensitive "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   105
                          "filesystem\n"))
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   106
        raise util.Abort(_("purging on name mangling filesystems is not "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   107
                           "yet fully supported"))
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   108
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   109
    if missing and not force:
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   110
        raise util.Abort(_("there are missing files in the working dir and "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   111
                           "purge still has problems with them due to name "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   112
                           "mangling filesystems. "
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   113
                           "Use --force if you know what you are doing"))
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   114
2369
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   115
2377
626779aba9bb The meaning of the directories on the command line is now explained correctly
Marco Barisione <marco@barisione.org>
parents: 2376
diff changeset
   116
def purge(ui, repo, *dirs, **opts):
2369
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   117
    '''removes files not tracked by mercurial
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   118
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   119
    Delete files not known to mercurial, this is useful to test local and
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   120
    uncommitted changes in the otherwise clean source tree.
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   121
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   122
    This means that purge will delete:
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   123
     - Unknown files: files marked with "?" by "hg status"
2377
626779aba9bb The meaning of the directories on the command line is now explained correctly
Marco Barisione <marco@barisione.org>
parents: 2376
diff changeset
   124
     - Ignored files: files usually ignored by Mercurial because they match
626779aba9bb The meaning of the directories on the command line is now explained correctly
Marco Barisione <marco@barisione.org>
parents: 2376
diff changeset
   125
       a pattern in a ".hgignore" file
2381
ab7a438294fc Rewritten install instructions for hg-purge to match new situation, fixed typos.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2379
diff changeset
   126
     - Empty directories: in fact Mercurial ignores directories unless they
2369
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   127
       contain files under source control managment
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   128
    But it will leave untouched:
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   129
     - Unmodified tracked files
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   130
     - Modified tracked files
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   131
     - New files added to the repository (with "hg add")
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   132
2377
626779aba9bb The meaning of the directories on the command line is now explained correctly
Marco Barisione <marco@barisione.org>
parents: 2376
diff changeset
   133
    If directories are given on the command line, only files in these
626779aba9bb The meaning of the directories on the command line is now explained correctly
Marco Barisione <marco@barisione.org>
parents: 2376
diff changeset
   134
    directories are considered.
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   135
2369
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   136
    Be careful with purge, you could irreversibly delete some files you
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   137
    forgot to add to the repository. If you only want to print the list of
2381
ab7a438294fc Rewritten install instructions for hg-purge to match new situation, fixed typos.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2379
diff changeset
   138
    files that this program would delete use the --print option.
2369
9da3dd62c827 Purge.from_command is now a function called purge
demian@gaudron.lan
parents: 2364
diff changeset
   139
    '''
2378
6e5d40ec862d Removed --nothing, added --print and --print0
Marco Barisione <marco@barisione.org>
parents: 2377
diff changeset
   140
    act = not opts['print']
2370
de893ad6bd17 Command line options are read in a saner way
demian@gaudron.lan
parents: 2369
diff changeset
   141
    abort_on_err = bool(opts['abort_on_err'])
2378
6e5d40ec862d Removed --nothing, added --print and --print0
Marco Barisione <marco@barisione.org>
parents: 2377
diff changeset
   142
    eol = opts['print0'] and '\0' or '\n'
6e5d40ec862d Removed --nothing, added --print and --print0
Marco Barisione <marco@barisione.org>
parents: 2377
diff changeset
   143
    if eol == '\0':
6e5d40ec862d Removed --nothing, added --print and --print0
Marco Barisione <marco@barisione.org>
parents: 2377
diff changeset
   144
        # --print0 implies --print
6e5d40ec862d Removed --nothing, added --print and --print0
Marco Barisione <marco@barisione.org>
parents: 2377
diff changeset
   145
        act = False
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   146
    force = bool(opts['force'])
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   147
    dopurge(ui, repo, dirs, act, abort_on_err, eol, force)
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   148
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   149
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   150
cmdtable = {
2382
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   151
    'purge':
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   152
        (purge,
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   153
         [('a', 'abort-on-err', None, _('abort if an error occurs')),
4307
c8919eb0f315 purge: abort with missing files avoiding problems with name-mangling fs
Emanuele Aina <em@nerd.ocracy.org>
parents: 4155
diff changeset
   154
          ('f', 'force', None, _('purge even when missing files are detected')),
2382
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   155
          ('p', 'print', None, _('print the file names instead of deleting them')),
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   156
          ('0', 'print0', None, _('end filenames with NUL, for use with xargs'
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   157
                                  ' (implies -p)'))],
b429566d1994 Make indentation of purge's cmdtable match to mercurial/commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2381
diff changeset
   158
         _('hg purge [OPTION]... [DIR]...'))
2364
f368a1c302d5 Initial commit
demian@gaudron.lan
parents:
diff changeset
   159
}