Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 20136:1df77035c814
pathcomplete: remove ambiguous entries for sole completion on a directory
Previously, directories were added with the trailing slash and, if there was
only one completion, then another ambiguous entry was created using '.', as
follows:
$ hg rm mer<TAB>
mercurial/./ mercurial//
This was added in fa6d5c62f3bd (though, some logic existed before that) to work
around bash completion adding a space after the sole entry because we treated
directories and files the same. We no longer do that now so we remove this
unneeded code.
Tests have been updated to match this new behavior.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 25 Nov 2013 12:12:42 -0500 |
parents | af12f58e2aa0 |
children | 28fe5abc906f |
comparison
equal
deleted
inserted
replaced
20135:e39bd4b7be78 | 20136:1df77035c814 |
---|---|
2243 if fullpaths: | 2243 if fullpaths: |
2244 addfile(f) | 2244 addfile(f) |
2245 continue | 2245 continue |
2246 s = f.find(os.sep, speclen) | 2246 s = f.find(os.sep, speclen) |
2247 if s >= 0: | 2247 if s >= 0: |
2248 adddir(f[:s + 1]) | 2248 adddir(f[:s]) |
2249 else: | 2249 else: |
2250 addfile(f) | 2250 addfile(f) |
2251 return files, dirs | 2251 return files, dirs |
2252 | 2252 |
2253 acceptable = '' | 2253 acceptable = '' |
2264 files, dirs = set(), set() | 2264 files, dirs = set(), set() |
2265 for spec in specs: | 2265 for spec in specs: |
2266 f, d = complete(spec, acceptable or 'nmar') | 2266 f, d = complete(spec, acceptable or 'nmar') |
2267 files.update(f) | 2267 files.update(f) |
2268 dirs.update(d) | 2268 dirs.update(d) |
2269 if not files and len(dirs) == 1: | |
2270 # force the shell to consider a completion that matches one | |
2271 # directory and zero files to be ambiguous | |
2272 dirs.add(iter(dirs).next() + '.') | |
2273 files.update(dirs) | 2269 files.update(dirs) |
2274 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) | 2270 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) |
2275 ui.write('\n') | 2271 ui.write('\n') |
2276 | 2272 |
2277 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) | 2273 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) |