Mercurial > hg > mercurial-crew-with-dirclash
annotate hgext/alias.py @ 5377:756a43a30e34
convert: readd --filemap
To handle merges correctly, this revision adds a filemap_source class
that wraps a converter_source and does the work necessary to calculate
the subgraph we're interested in.
The wrapped converter_source must provide a new getchangedfiles method
that, given a revision rev, and an index N, returns the list of files
that are different in rev and its Nth parent.
The implementation depends on the ability to skip some revisions and to
change the parents field of the commit objects that we returned earlier.
To make the conversion restartable, we assume the revisons in the
revmapfile are topologically sorted.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Thu, 04 Oct 2007 23:21:37 -0300 |
parents | 18a9fbb5cd78 |
children |
rev | line source |
---|---|
4800 | 1 # Copyright (C) 2007 Brendan Cully <brendan@kublai.com> |
2 # This file is published under the GNU GPL. | |
3 | |
4 '''allow user-defined command aliases | |
5 | |
6 To use, create entries in your hgrc of the form | |
7 | |
8 [alias] | |
9 mycmd = cmd --args | |
10 ''' | |
11 | |
12 from mercurial.cmdutil import findcmd, UnknownCommand, AmbiguousCommand | |
13 from mercurial import commands | |
14 | |
15 cmdtable = {} | |
16 | |
17 class RecursiveCommand(Exception): pass | |
18 | |
19 class lazycommand(object): | |
20 '''defer command lookup until needed, so that extensions loaded | |
21 after alias can be aliased''' | |
22 def __init__(self, ui, name, target): | |
23 self._ui = ui | |
24 self._name = name | |
25 self._target = target | |
26 self._cmd = None | |
27 | |
28 def __len__(self): | |
29 self._resolve() | |
30 return len(self._cmd) | |
31 | |
32 def __getitem__(self, key): | |
33 self._resolve() | |
34 return self._cmd[key] | |
35 | |
36 def __iter__(self): | |
37 self._resolve() | |
38 return self._cmd.__iter__() | |
39 | |
40 def _resolve(self): | |
41 if self._cmd is not None: | |
42 return | |
43 | |
44 try: | |
5185
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
4946
diff
changeset
|
45 self._cmd = findcmd(self._ui, self._target, commands.table)[1] |
4800 | 46 if self._cmd == self: |
47 raise RecursiveCommand() | |
48 if self._target in commands.norepo.split(' '): | |
49 commands.norepo += ' %s' % self._name | |
50 return | |
51 except UnknownCommand: | |
52 msg = '*** [alias] %s: command %s is unknown' % \ | |
53 (self._name, self._target) | |
54 except AmbiguousCommand: | |
55 msg = '*** [alias] %s: command %s is ambiguous' % \ | |
56 (self._name, self._target) | |
57 except RecursiveCommand: | |
58 msg = '*** [alias] %s: circular dependency on %s' % \ | |
59 (self._name, self._target) | |
60 def nocmd(*args, **opts): | |
61 self._ui.warn(msg + '\n') | |
62 return 1 | |
63 nocmd.__doc__ = msg | |
64 self._cmd = (nocmd, [], '') | |
65 commands.norepo += ' %s' % self._name | |
66 | |
67 def uisetup(ui): | |
68 for cmd, target in ui.configitems('alias'): | |
69 if not target: | |
70 ui.warn('*** [alias] %s: no definition\n' % cmd) | |
71 continue | |
72 args = target.split(' ') | |
73 tcmd = args.pop(0) | |
74 if args: | |
4946
a28661788f2f
test-alias: Removed fallback to parentui, no longer needed since 10afa3fab6b4
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4807
diff
changeset
|
75 ui.setconfig('defaults', cmd, ' '.join(args)) |
4800 | 76 cmdtable[cmd] = lazycommand(ui, cmd, tcmd) |