From patchwork Tue Nov 26 19:54:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [15, of, 15, V5] pathcomplete: remove ambiguous entries for sole completion on a directory From: Sean Farley X-Patchwork-Id: 3169 Message-Id: To: mercurial-devel@selenic.com Date: Tue, 26 Nov 2013 14:54:54 -0500 # HG changeset patch # User Sean Farley # Date 1385399562 18000 # Mon Nov 25 12:12:42 2013 -0500 # Node ID f9d326693c8880f88f0fea1478db6bd88e75c3b4 # Parent 7908c45ed714ef93803c7fdd7cf408be84d1d3f7 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 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 @@ -2243,11 +2243,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 = '' @@ -2264,14 +2264,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