pathcomplete: remove ambiguous entries for sole completion on a directory
authorSean Farley <sean.michael.farley@gmail.com>
Mon, 25 Nov 2013 12:12:42 -0500
changeset 20136 1df77035c814
parent 20135 e39bd4b7be78
child 20137 9f1d4323c749
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.
mercurial/commands.py
tests/test-completion.t
--- a/mercurial/commands.py	Tue Nov 26 14:33:18 2013 -0600
+++ b/mercurial/commands.py	Mon Nov 25 12:12:42 2013 -0500
@@ -2245,7 +2245,7 @@
                     continue
                 s = f.find(os.sep, speclen)
                 if s >= 0:
-                    adddir(f[:s + 1])
+                    adddir(f[:s])
                 else:
                     addfile(f)
         return files, dirs
@@ -2266,10 +2266,6 @@
         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')
--- a/tests/test-completion.t	Tue Nov 26 14:33:18 2013 -0600
+++ b/tests/test-completion.t	Mon Nov 25 12:12:42 2013 -0500
@@ -305,7 +305,7 @@
 
   $ hg debugpathcomplete f
   fee
-  fie/
+  fie
   fo
   $ hg debugpathcomplete -f f
   fee
@@ -317,12 +317,6 @@
   $ 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