# HG changeset patch # User Bryan O'Sullivan # Date 1156222769 25200 # Node ID 63c3a1921a67b1860dcee4a3c76f0ec549d0054c # Parent 12d1475b48df2bc1390c32152340883e368994f5 Add ui.strict config item. This turns off command matching by unambiguous prefix, and is a good thing if you want to write future-proof scripts. This fixes issue 314. diff -r 12d1475b48df -r 63c3a1921a67 doc/hgrc.5.txt --- a/doc/hgrc.5.txt Mon Aug 21 17:47:02 2006 -0700 +++ b/doc/hgrc.5.txt Mon Aug 21 21:59:29 2006 -0700 @@ -377,6 +377,9 @@ remote command to use for clone/push/pull operations. Default is 'hg'. ssh;; command to use for SSH connections. Default is 'ssh'. + strict;; + Require exact command names, instead of allowing unambiguous + abbreviations. True or False. Default is False. timeout;; The timeout used when a lock is held (in seconds), a negative value means no timeout. Default is 600. diff -r 12d1475b48df -r 63c3a1921a67 mercurial/commands.py --- a/mercurial/commands.py Mon Aug 21 17:47:02 2006 -0700 +++ b/mercurial/commands.py Mon Aug 21 21:59:29 2006 -0700 @@ -507,7 +507,7 @@ if with_version: show_version(ui) ui.write('\n') - aliases, i = findcmd(name) + aliases, i = findcmd(ui, name) # synopsis ui.write("%s\n\n" % i[2]) @@ -1154,7 +1154,7 @@ options = [] otables = [globalopts] if cmd: - aliases, entry = findcmd(cmd) + aliases, entry = findcmd(ui, cmd) otables.append(entry[1]) for t in otables: for o in t: @@ -1164,7 +1164,7 @@ ui.write("%s\n" % "\n".join(options)) return - clist = findpossible(cmd).keys() + clist = findpossible(ui, cmd).keys() clist.sort() ui.write("%s\n" % "\n".join(clist)) @@ -3149,7 +3149,7 @@ " debugindex debugindexdot") optionalrepo = ("paths serve debugconfig") -def findpossible(cmd): +def findpossible(ui, cmd): """ Return cmd -> (aliases, command table entry) for each matching command. @@ -3162,7 +3162,7 @@ found = None if cmd in aliases: found = cmd - else: + elif not ui.config("ui", "strict"): for a in aliases: if a.startswith(cmd): found = a @@ -3178,9 +3178,9 @@ return choice -def findcmd(cmd): +def findcmd(ui, cmd): """Return (aliases, command table entry) for command string.""" - choice = findpossible(cmd) + choice = findpossible(ui, cmd) if choice.has_key(cmd): return choice[cmd] @@ -3215,7 +3215,7 @@ if args: cmd, args = args[0], args[1:] - aliases, i = findcmd(cmd) + aliases, i = findcmd(ui, cmd) cmd = aliases[0] defaults = ui.config("defaults", cmd) if defaults: diff -r 12d1475b48df -r 63c3a1921a67 tests/test-strict --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-strict Mon Aug 21 21:59:29 2006 -0700 @@ -0,0 +1,19 @@ +#!/bin/sh + +hg init + +echo a > a +hg ci -d '0 0' -Ama + +hg an a + +HGRCPATH=$HGTMP/.hgrc; export HGRCPATH +echo "[ui]" >> $HGTMP/.hgrc +echo "strict=True" >> $HGTMP/.hgrc + +hg an a +hg annotate a + +echo % should succeed - up is an alias, not an abbreviation + +hg up diff -r 12d1475b48df -r 63c3a1921a67 tests/test-strict.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-strict.out Mon Aug 21 21:59:29 2006 -0700 @@ -0,0 +1,26 @@ +adding a +0: a +hg: unknown command 'an' +Mercurial Distributed SCM + +basic commands (use "hg help" for the full list or option "-v" for details): + + add add the specified files on the next commit + annotate show changeset information per file line + clone make a copy of an existing repository + commit commit the specified files or all outstanding changes + diff diff repository (or selected files) + export dump the header and diffs for one or more changesets + init create a new repository in the given directory + log show revision history of entire repository or files + parents show the parents of the working dir or revision + pull pull changes from the specified source + push push changes to the specified destination + remove remove the specified files on the next commit + revert revert files or dirs to their states as of some revision + serve export the repository via HTTP + status show changed files in the working directory + update update or merge working directory +0: a +% should succeed - up is an alias, not an abbreviation +0 files updated, 0 files merged, 0 files removed, 0 files unresolved