82 Be careful with purge, as you could irreversibly delete some files |
82 Be careful with purge, as you could irreversibly delete some files |
83 you forgot to add to the repository. If you only want to print the |
83 you forgot to add to the repository. If you only want to print the |
84 list of files that this program would delete, use the --print |
84 list of files that this program would delete, use the --print |
85 option. |
85 option. |
86 ''' |
86 ''' |
87 act = not opts['print'] |
87 act = not opts.get('print') |
88 eol = '\n' |
88 eol = '\n' |
89 if opts['print0']: |
89 if opts.get('print0'): |
90 eol = '\0' |
90 eol = '\0' |
91 act = False # --print0 implies --print |
91 act = False # --print0 implies --print |
92 removefiles = opts['files'] |
92 removefiles = opts.get('files') |
93 removedirs = opts['dirs'] |
93 removedirs = opts.get('dirs') |
94 if not removefiles and not removedirs: |
94 if not removefiles and not removedirs: |
95 removefiles = True |
95 removefiles = True |
96 removedirs = True |
96 removedirs = True |
97 |
97 |
98 def remove(remove_func, name): |
98 def remove(remove_func, name): |
99 if act: |
99 if act: |
100 try: |
100 try: |
101 remove_func(repo.wjoin(name)) |
101 remove_func(repo.wjoin(name)) |
102 except OSError: |
102 except OSError: |
103 m = _('%s cannot be removed') % name |
103 m = _('%s cannot be removed') % name |
104 if opts['abort_on_err']: |
104 if opts.get('abort_on_err'): |
105 raise error.Abort(m) |
105 raise error.Abort(m) |
106 ui.warn(_('warning: %s\n') % m) |
106 ui.warn(_('warning: %s\n') % m) |
107 else: |
107 else: |
108 ui.write('%s%s' % (name, eol)) |
108 ui.write('%s%s' % (name, eol)) |
109 |
109 |
110 match = scmutil.match(repo[None], dirs, opts) |
110 match = scmutil.match(repo[None], dirs, opts) |
111 if removedirs: |
111 if removedirs: |
112 directories = [] |
112 directories = [] |
113 match.explicitdir = match.traversedir = directories.append |
113 match.explicitdir = match.traversedir = directories.append |
114 status = repo.status(match=match, ignored=opts['all'], unknown=True) |
114 status = repo.status(match=match, ignored=opts.get('all'), unknown=True) |
115 |
115 |
116 if removefiles: |
116 if removefiles: |
117 for f in sorted(status.unknown + status.ignored): |
117 for f in sorted(status.unknown + status.ignored): |
118 if act: |
118 if act: |
119 ui.note(_('removing file %s\n') % f) |
119 ui.note(_('removing file %s\n') % f) |