[PATCH 00 of 13] Cleanup of the purge extension
Alexis S. L. Carvalho
alexis at cecm.usp.br
Tue Mar 13 12:13:46 CDT 2007
Sorry for the huge latency...
Thus spake Emanuele Aina:
> Alexis S. L. Carvalho evidenziò:
> >>>I'd really like to put at least some safety net before moving purge.py
> >>>to hgext.
> >>What kind of safety net?
> >
> >For example, refusing to run if there are missing files (I think it
> >should be enough, if we assume that the filesystem doesn't return 2
> >aliases to the same file[1] on a single os.listdir - which I hope is not
> >much to ask... But I wouldn't mind somebody thinking a bit more about
> >this).
> >
> >Maybe this could be done only for name-mangling filesystems. And we
> >probably could use a --force flag to allow users to shoot their feet.
>
> Do you think that this code will be enough?
>
> if missing and not (util.checkfolding(repo.wjoin('.hg/Foo') or force):
> util.Abort("purging on name mangling fs is not yet fully supported")
Well, that could be a simpler "util.checkfolding(repo.path)".
But I think I'm leaning towards something like trying to lstat every
missing file. If we find any of them, abort (unconditionally).
Otherwise, abort if --force was not specified. Something like
this (completely untested):
found = []
for f in missing:
try:
os.lstat(f)
except OSError, inst:
if inst.errno != errno.ENOENT:
raise
continue
found.append(f)
if found:
if not ui.quiet:
ui.warn(_("The following tracked files weren't listed by the "
"filesystem, but could still be found:\n"))
for f in found:
ui.warn("%s\n" % f)
ui.warn(_("Is this a case-insensitive filesystem?\n"))
raise util.Abort(_("purging on name mangling filesystems is not "
"yet fully supported"))
if missing and not force:
raise util.Abort(_("some nice message that mentions missing files "
"and --force"))
I think that should be safe enough - we really want to abort in the
"if found:" case; OTOH the second conditional is probably not strictly
necessary.
Alexis
More information about the Mercurial-devel
mailing list