Show More
@@ -182,10 +182,21 b' def _runcatch(ui, args):' | |||||
182 |
|
182 | |||
183 | return -1 |
|
183 | return -1 | |
184 |
|
184 | |||
185 | def aliasargs(fn): |
|
185 | def aliasargs(fn, givenargs): | |
186 |
|
|
186 | args = getattr(fn, 'args', []) | |
187 | return fn.args |
|
187 | if args and givenargs: | |
188 | return [] |
|
188 | cmd = ' '.join(map(util.shellquote, args)) | |
|
189 | ||||
|
190 | nums = [] | |||
|
191 | def replacer(m): | |||
|
192 | num = int(m.group(1)) - 1 | |||
|
193 | nums.append(num) | |||
|
194 | return givenargs[num] | |||
|
195 | cmd = re.sub(r'\$(\d+|\$)', replacer, cmd) | |||
|
196 | givenargs = [x for i, x in enumerate(givenargs) | |||
|
197 | if i not in nums] | |||
|
198 | args = shlex.split(cmd) | |||
|
199 | return args + givenargs | |||
189 |
|
200 | |||
190 | class cmdalias(object): |
|
201 | class cmdalias(object): | |
191 | def __init__(self, name, definition, cmdtable): |
|
202 | def __init__(self, name, definition, cmdtable): | |
@@ -263,7 +274,7 b' class cmdalias(object):' | |||||
263 | else: |
|
274 | else: | |
264 | self.fn, self.opts = tableentry |
|
275 | self.fn, self.opts = tableentry | |
265 |
|
276 | |||
266 |
self.args = aliasargs(self.fn |
|
277 | self.args = aliasargs(self.fn, args) | |
267 | if cmd not in commands.norepo.split(' '): |
|
278 | if cmd not in commands.norepo.split(' '): | |
268 | self.norepo = False |
|
279 | self.norepo = False | |
269 | if self.help.startswith("hg " + cmd): |
|
280 | if self.help.startswith("hg " + cmd): | |
@@ -330,7 +341,7 b' def _parse(ui, args):' | |||||
330 | aliases, entry = cmdutil.findcmd(cmd, commands.table, |
|
341 | aliases, entry = cmdutil.findcmd(cmd, commands.table, | |
331 | ui.config("ui", "strict")) |
|
342 | ui.config("ui", "strict")) | |
332 | cmd = aliases[0] |
|
343 | cmd = aliases[0] | |
333 |
args = aliasargs(entry[0] |
|
344 | args = aliasargs(entry[0], args) | |
334 | defaults = ui.config("defaults", cmd) |
|
345 | defaults = ui.config("defaults", cmd) | |
335 | if defaults: |
|
346 | if defaults: | |
336 | args = map(util.expandpath, shlex.split(defaults)) + args |
|
347 | args = map(util.expandpath, shlex.split(defaults)) + args |
@@ -17,6 +17,7 b'' | |||||
17 | > mylog = log |
|
17 | > mylog = log | |
18 | > lognull = log -r null |
|
18 | > lognull = log -r null | |
19 | > shortlog = log --template '{rev} {node|short} | {date|isodate}\n' |
|
19 | > shortlog = log --template '{rev} {node|short} | {date|isodate}\n' | |
|
20 | > positional = log --template '{\$2} {\$1} | {date|isodate}\n' | |||
20 | > dln = lognull --debug |
|
21 | > dln = lognull --debug | |
21 | > nousage = rollback |
|
22 | > nousage = rollback | |
22 | > put = export -r 0 -o "\$FOO/%R.diff" |
|
23 | > put = export -r 0 -o "\$FOO/%R.diff" | |
@@ -127,6 +128,10 b' with opts and whitespace' | |||||
127 | $ hg shortlog |
|
128 | $ hg shortlog | |
128 | 0 e63c23eaa88a | 1970-01-01 00:00 +0000 |
|
129 | 0 e63c23eaa88a | 1970-01-01 00:00 +0000 | |
129 |
|
130 | |||
|
131 | positional arguments | |||
|
132 | ||||
|
133 | $ hg positional 'node|short' rev | |||
|
134 | 0 e63c23eaa88a | 1970-01-01 00:00 +0000 | |||
130 |
|
135 | |||
131 | interaction with defaults |
|
136 | interaction with defaults | |
132 |
|
137 |
General Comments 0
You need to be logged in to leave comments.
Login now