[PATCH 11 of 11 V3] pathcomplete: remove ambiguous entries for sole completion on a directory
Sean Farley
sean.michael.farley at gmail.com
Mon Nov 25 17:42:24 UTC 2013
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1385399562 18000
# Mon Nov 25 12:12:42 2013 -0500
# Node ID 9fc5da5c2b25588861ffb30bc26d4c06a404122d
# Parent 069222d00ab0940e2afce45a7c9bfcd907e7ca44
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.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2241,11 +2241,11 @@
if fullpaths:
addfile(f)
continue
s = f.find(os.sep, speclen)
if s >= 0:
- adddir(f[:s + 1])
+ adddir(f[:s])
else:
addfile(f)
return files, dirs
acceptable = ''
@@ -2262,14 +2262,10 @@
files, dirs = set(), set()
for spec in specs:
f, d = complete(spec, acceptable or 'nmar')
files.update(f)
dirs.update(d)
- if not files and len(dirs) == 1:
- # force the shell to consider a completion that matches one
- # directory and zero files to be ambiguous
- dirs.add(iter(dirs).next() + '.')
files.update(dirs)
ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
ui.write('\n')
@command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -303,11 +303,11 @@
Test debugpathcomplete
$ hg debugpathcomplete f
fee
- fie/
+ fie
fo
$ hg debugpathcomplete -f f
fee
fie/dead
fie/live
@@ -315,16 +315,10 @@
$ hg rm Fum
$ hg debugpathcomplete -r F
Fum
-If one directory and no files match, give an ambiguous answer
-
- $ hg debugpathcomplete fi
- fie/
- fie/.
-
Test debuglabelcomplete
$ hg debuglabelcomplete
Fum
default
More information about the Mercurial-devel
mailing list