Show More
@@ -182,10 +182,21 def _runcatch(ui, args): | |||
|
182 | 182 | |
|
183 | 183 | return -1 |
|
184 | 184 | |
|
185 | def aliasargs(fn): | |
|
186 |
|
|
|
187 | return fn.args | |
|
188 | return [] | |
|
185 | def aliasargs(fn, givenargs): | |
|
186 | args = getattr(fn, 'args', []) | |
|
187 | if args and givenargs: | |
|
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 | 201 | class cmdalias(object): |
|
191 | 202 | def __init__(self, name, definition, cmdtable): |
@@ -263,7 +274,7 class cmdalias(object): | |||
|
263 | 274 | else: |
|
264 | 275 | self.fn, self.opts = tableentry |
|
265 | 276 | |
|
266 |
self.args = aliasargs(self.fn |
|
|
277 | self.args = aliasargs(self.fn, args) | |
|
267 | 278 | if cmd not in commands.norepo.split(' '): |
|
268 | 279 | self.norepo = False |
|
269 | 280 | if self.help.startswith("hg " + cmd): |
@@ -330,7 +341,7 def _parse(ui, args): | |||
|
330 | 341 | aliases, entry = cmdutil.findcmd(cmd, commands.table, |
|
331 | 342 | ui.config("ui", "strict")) |
|
332 | 343 | cmd = aliases[0] |
|
333 |
args = aliasargs(entry[0] |
|
|
344 | args = aliasargs(entry[0], args) | |
|
334 | 345 | defaults = ui.config("defaults", cmd) |
|
335 | 346 | if defaults: |
|
336 | 347 | args = map(util.expandpath, shlex.split(defaults)) + args |
@@ -17,6 +17,7 | |||
|
17 | 17 | > mylog = log |
|
18 | 18 | > lognull = log -r null |
|
19 | 19 | > shortlog = log --template '{rev} {node|short} | {date|isodate}\n' |
|
20 | > positional = log --template '{\$2} {\$1} | {date|isodate}\n' | |
|
20 | 21 | > dln = lognull --debug |
|
21 | 22 | > nousage = rollback |
|
22 | 23 | > put = export -r 0 -o "\$FOO/%R.diff" |
@@ -127,6 +128,10 with opts and whitespace | |||
|
127 | 128 | $ hg shortlog |
|
128 | 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 | 136 | interaction with defaults |
|
132 | 137 |
General Comments 0
You need to be logged in to leave comments.
Login now