remove command goes walkies
Chris Mason
mason at suse.com
Thu Sep 1 13:10:50 CDT 2005
On Thu, 01 Sep 2005 10:11:16 -0700
Bryan O'Sullivan <bos at serpentine.com> wrote:
> On Thu, 2005-09-01 at 13:01 -0400, Chris Mason wrote:
>
> > You could just drop the warning. You're seeing it because the
> > directory isn't in the map.
>
> It's not quite that simple. I put that warning in there so that
> commands like:
>
> hg dosomething file-that-never-existed
>
> wouldn't simply exit silently without telling you you've done
> something wrong.
>
> What needs to happen is a little trickier. We want to warn about an
> exact name foo that is not in the filesystem, not in the dirstate map,
> and not a directory-like prefix of entries in the dirstate map (i.e.
> there are no files matching the regexp "foo/.*").
Ok, the patch below is entirely untested but should be the right
general idea.
Index: crew/mercurial/dirstate.py
===================================================================
--- crew.orig/mercurial/dirstate.py 2005-09-01 08:43:59.000000000 -0400
+++ crew/mercurial/dirstate.py 2005-09-01 13:57:51.000000000 -0400
@@ -173,34 +173,34 @@ class dirstate:
st.write(e + f)
self.dirty = 0
- def filterfiles(self, files):
+ def filterfiles(self, files, map=self.map):
ret = {}
unknown = []
for x in files:
if x is '.':
- return self.map.copy()
- if x not in self.map:
+ return map.copy()
+ if x not in map:
unknown.append(x)
else:
- ret[x] = self.map[x]
+ ret[x] = map[x]
if not unknown:
return ret
- b = self.map.keys()
+ b = map.keys()
b.sort()
blen = len(b)
for x in unknown:
bs = bisect.bisect(b, x)
if bs != 0 and b[bs-1] == x:
- ret[x] = self.map[x]
+ ret[x] = map[x]
continue
while bs < blen:
s = b[bs]
if len(s) > len(x) and s.startswith(x) and s[len(x)] == '/':
- ret[s] = self.map[s]
+ ret[s] = map[s]
else:
break
bs += 1
@@ -271,9 +271,12 @@ class dirstate:
try:
st = os.stat(f)
except OSError, inst:
- if ff not in dc: self.ui.warn('%s: %s\n' % (
- util.pathto(self.getcwd(), ff),
- inst.strerror))
+ if ff not in dc:
+ filtered = self.filterfiles([ff], dc)
+ if not filtered:
+ self.ui.warn('%s: %s\n' % (
+ util.pathto(self.getcwd(), ff),
+ inst.strerror))
continue
if stat.S_ISDIR(st.st_mode):
sorted = [ x for x in findfiles(f) ]
More information about the Mercurial
mailing list