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