comparison mercurial/commands.py @ 18796:fa6d5c62f3bd

pathcomplete: complete directories more conservatively Suppose we want to perform a single-level completion (i.e. without --full) of "fi" in a repo containing "fee", "fie/dead", "fie/live", and "foe". If we give back "fie/" as the only answer, the shell will consider the completion to be unambiguous, and will append a space after the completion. We can't complete "fie/live" or "fie/dead" without first backspacing over that space. We used to thus create two fake names, "fie/a" and "fie/b", to force the shell to consider the completion to be ambiguous. It would then stop at "fie/" without appending a space, allowing us to hit tab again to complete "fie/live" or "fie/dead". The change here arises from realising that we only need to force the shell to consider a completion as ambiguous if we have exactly one directory and zero files as possible completions. This prevents spurious names from showing up as possible completions when they don't need to be invented in the first place.
author Bryan O'Sullivan <bryano@fb.com>
date Thu, 21 Mar 2013 22:10:54 -0700
parents 10669e24eb6c
children 0ed95fe674a8
comparison
equal deleted inserted replaced
18795:704229c06dcf 18796:fa6d5c62f3bd
2196 files, dirs = set(), set() 2196 files, dirs = set(), set()
2197 for spec in specs: 2197 for spec in specs:
2198 f, d = complete(spec, acceptable or 'nmar') 2198 f, d = complete(spec, acceptable or 'nmar')
2199 files.update(f) 2199 files.update(f)
2200 dirs.update(d) 2200 dirs.update(d)
2201 for d in dirs: 2201 if not files and len(dirs) == 1:
2202 files.add(d + 'a') 2202 # force the shell to consider a completion that matches one
2203 files.add(d + 'b') 2203 # directory and zero files to be ambiguous
2204 dirs.add(iter(dirs).next() + '.')
2205 files.update(dirs)
2204 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files))) 2206 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2205 ui.write('\n') 2207 ui.write('\n')
2206 2208
2207 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]')) 2209 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
2208 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts): 2210 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):