##// END OF EJS Templates
purge: simplify safety net for case mangling filesystems...
Alexis S. L. Carvalho -
r5517:98d5f9b9 default
parent child Browse files
Show More
@@ -49,6 +49,9 b' def dopurge(ui, repo, dirs=None, act=Tru'
49 49 else:
50 50 ui.write('%s%s' % (name, eol))
51 51
52 if not force:
53 _check_fs(ui, repo)
54
52 55 directories = []
53 56 files = []
54 57 missing = []
@@ -63,8 +66,6 b' def dopurge(ui, repo, dirs=None, act=Tru'
63 66 elif src == 'f' and f not in repo.dirstate:
64 67 files.append(f)
65 68
66 _check_missing(ui, repo, missing, force)
67
68 69 directories.sort()
69 70
70 71 for f in files:
@@ -77,7 +78,7 b' def dopurge(ui, repo, dirs=None, act=Tru'
77 78 ui.note(_('Removing directory %s\n') % f)
78 79 remove(os.rmdir, f)
79 80
80 def _check_missing(ui, repo, missing, force=False):
81 def _check_fs(ui, repo):
81 82 """Abort if there is the chance of having problems with name-mangling fs
82 83
83 84 In a name mangling filesystem (e.g. a case insensitive one)
@@ -85,34 +86,18 b' def _check_missing(ui, repo, missing, fo'
85 86 stored in the dirstate. This already confuses the status and
86 87 add commands, but with purge this may cause data loss.
87 88
88 To prevent this, _check_missing will abort if there are missing
89 files. The force option will let the user skip the check if he
90 knows it is safe.
91
92 Even with the force option this function will check if any of the
93 missing files is still available in the working dir: if so there
94 may be some problem with the underlying filesystem, so it
95 aborts unconditionally."""
96
97 found = [f for f in missing if util.lexists(repo.wjoin(f))]
89 To prevent this, this function will abort if there are uncommitted
90 changes.
91 """
98 92
99 if found:
100 if not ui.quiet:
101 ui.warn(_("The following tracked files weren't listed by the "
102 "filesystem, but could still be found:\n"))
103 for f in found:
104 ui.warn("%s\n" % f)
105 if util.checkfolding(repo.path):
106 ui.warn(_("This is probably due to a case-insensitive "
107 "filesystem\n"))
108 raise util.Abort(_("purging on name mangling filesystems is not "
109 "yet fully supported"))
110
111 if missing and not force:
112 raise util.Abort(_("there are missing files in the working dir and "
113 "purge still has problems with them due to name "
114 "mangling filesystems. "
115 "Use --force if you know what you are doing"))
93 # We can't use (files, match) to do a partial walk here - we wouldn't
94 # notice a modified README file if the user ran "hg purge readme"
95 modified, added, removed, deleted = repo.status()[:4]
96 if modified or added or removed or deleted:
97 if not util.checkfolding(repo.path) and not ui.quiet:
98 ui.warn(_("Purging on name mangling filesystems is not "
99 "fully supported.\n"))
100 raise util.Abort(_("outstanding uncommitted changes"))
116 101
117 102
118 103 def purge(ui, repo, *dirs, **opts):
@@ -158,7 +143,7 b' cmdtable = {'
158 143 (purge,
159 144 [('a', 'abort-on-err', None, _('abort if an error occurs')),
160 145 ('', 'all', None, _('purge ignored files too')),
161 ('f', 'force', None, _('purge even when missing files are detected')),
146 ('f', 'force', None, _('purge even when there are uncommitted changes')),
162 147 ('p', 'print', None, _('print the file names instead of deleting them')),
163 148 ('0', 'print0', None, _('end filenames with NUL, for use with xargs'
164 149 ' (implies -p)')),
@@ -101,6 +101,13 b' hg purge -v --force'
101 101 hg revert --all --quiet
102 102 ls
103 103
104 echo '% tracked file in ignored directory (issue621)'
105 echo directory >> .hgignore
106 hg ci -m 'ignore directory'
107 touch untracked_file
108 hg purge -p
109 hg purge -v
110
104 111 echo % skip excluded files
105 112 touch excluded_file
106 113 hg purge -p -X excluded_file
@@ -59,6 +59,9 b' untracked_file still around'
59 59 Removing file untracked_file
60 60 directory
61 61 r1
62 % tracked file in ignored directory (issue621)
63 untracked_file
64 Removing file untracked_file
62 65 % skip excluded files
63 66 directory
64 67 excluded_file
General Comments 0
You need to be logged in to leave comments. Login now