hgext/purge.py
changeset 6754 0b700faaef32
parent 6746 1dca460e7d1e
child 6757 55c71226eceb
equal deleted inserted replaced
6753:ed5ffb2c12f3 6754:0b700faaef32
    54     Be careful with purge, you could irreversibly delete some files you
    54     Be careful with purge, you could irreversibly delete some files you
    55     forgot to add to the repository. If you only want to print the list of
    55     forgot to add to the repository. If you only want to print the list of
    56     files that this program would delete use the --print option.
    56     files that this program would delete use the --print option.
    57     '''
    57     '''
    58     act = not opts['print']
    58     act = not opts['print']
    59     ignored = bool(opts['all'])
       
    60     abort_on_err = bool(opts['abort_on_err'])
    59     abort_on_err = bool(opts['abort_on_err'])
    61     eol = opts['print0'] and '\0' or '\n'
    60     eol = opts['print0'] and '\0' or '\n'
    62     if eol == '\0':
    61     if eol == '\0':
    63         # --print0 implies --print
    62         # --print0 implies --print
    64         act = False
    63         act = False
    84 
    83 
    85     directories = []
    84     directories = []
    86     files = []
    85     files = []
    87     match = cmdutil.match(repo, dirs, opts)
    86     match = cmdutil.match(repo, dirs, opts)
    88     match.dir = directories.append
    87     match.dir = directories.append
    89     for src, f, st in repo.dirstate.statwalk(match, ignored=ignored):
    88     status = repo.status(match=match, ignored=opts['all'], unknown=True)
    90         if src == 'f' and f not in repo.dirstate:
    89     files = status[4] + status[5]
    91             files.append(f)
    90     files.sort()
    92 
       
    93     directories.sort()
    91     directories.sort()
    94 
    92 
    95     for f in files:
    93     for f in files:
    96         if f not in repo.dirstate:
    94         ui.note(_('Removing file %s\n') % f)
    97             ui.note(_('Removing file %s\n') % f)
    95         remove(os.remove, f)
    98             remove(os.remove, f)
       
    99 
    96 
   100     for f in directories[::-1]:
    97     for f in directories[::-1]:
   101         if match(f) and not os.listdir(repo.wjoin(f)):
    98         if match(f) and not os.listdir(repo.wjoin(f)):
   102             ui.note(_('Removing directory %s\n') % f)
    99             ui.note(_('Removing directory %s\n') % f)
   103             remove(os.rmdir, f)
   100             remove(os.rmdir, f)