Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 7643:9a1ea6587557
error: move UnknownCommand and AmbiguousCommand
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 12 Jan 2009 11:39:38 -0600 |
parents | 07cb58b8c843 |
children | bd5c37d792e6 |
comparison
equal
deleted
inserted
replaced
7642:84346894def8 | 7643:9a1ea6587557 |
---|---|
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 from node import hex, nullid, nullrev, short | 8 from node import hex, nullid, nullrev, short |
9 from i18n import _ | 9 from i18n import _ |
10 import os, sys, bisect, stat | 10 import os, sys, bisect, stat |
11 import mdiff, bdiff, util, templater, templatefilters, patch, errno | 11 import mdiff, bdiff, util, templater, templatefilters, patch, errno, error |
12 import match as _match | 12 import match as _match |
13 | 13 |
14 revrangesep = ':' | 14 revrangesep = ':' |
15 | |
16 class UnknownCommand(Exception): | |
17 """Exception raised if command is not in the command table.""" | |
18 class AmbiguousCommand(Exception): | |
19 """Exception raised if command shortcut matches more than one command.""" | |
20 | 15 |
21 def findpossible(cmd, table, strict=False): | 16 def findpossible(cmd, table, strict=False): |
22 """ | 17 """ |
23 Return cmd -> (aliases, command table entry) | 18 Return cmd -> (aliases, command table entry) |
24 for each matching command. | 19 for each matching command. |
55 return choice[cmd] | 50 return choice[cmd] |
56 | 51 |
57 if len(choice) > 1: | 52 if len(choice) > 1: |
58 clist = choice.keys() | 53 clist = choice.keys() |
59 clist.sort() | 54 clist.sort() |
60 raise AmbiguousCommand(cmd, clist) | 55 raise error.AmbiguousCommand(cmd, clist) |
61 | 56 |
62 if choice: | 57 if choice: |
63 return choice.values()[0] | 58 return choice.values()[0] |
64 | 59 |
65 raise UnknownCommand(cmd) | 60 raise error.UnknownCommand(cmd) |
66 | 61 |
67 def bail_if_changed(repo): | 62 def bail_if_changed(repo): |
68 if repo.dirstate.parents()[1] != nullid: | 63 if repo.dirstate.parents()[1] != nullid: |
69 raise util.Abort(_('outstanding uncommitted merge')) | 64 raise util.Abort(_('outstanding uncommitted merge')) |
70 modified, added, removed, deleted = repo.status()[:4] | 65 modified, added, removed, deleted = repo.status()[:4] |