On Mercurial API
Alexis S. L. Carvalho
alexis at cecm.usp.br
Thu Aug 9 00:52:33 UTC 2007
Thus spake TK Soh:
> On 8/9/07, Thomas Arendsen Hein <thomas at intevation.de> wrote:
> > I call it a bug.
> >
> > Quick and dirty fix (can't do more currently):
> >
> > diff -r dc2e512cb89a mercurial/cmdutil.py
> > --- a/mercurial/cmdutil.py Tue Aug 07 15:56:26 2007 +0200
> > +++ b/mercurial/cmdutil.py Wed Aug 08 18:00:58 2007 +0200
> > @@ -7,7 +7,7 @@
> >
> > from node import *
> > from i18n import _
> > -import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex
> > +import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex, copy
> > import mdiff, bdiff, util, templater, patch, commands, hg, lock, time
> > import fancyopts, revlog, version, extensions, hook
> >
> > @@ -211,7 +211,7 @@ def parse(ui, args):
> > defaults = ui.config("defaults", cmd)
> > if defaults:
> > args = shlex.split(defaults) + args
> > - c = list(i[1])
> > + c = list(copy.deepcopy(i[1]))
> > else:
> > cmd = None
> > c = []
>
> Strange. IIRC, deepcopy wouldn't work due to the func data in the structure.
The function is in i[0], not i[1], so that shouldn't be a problem here.
But I'd rather fix this in fancyopts. Something like:
diff -r 1eb19d57675e mercurial/fancyopts.py
--- a/mercurial/fancyopts.py Wed Aug 08 21:31:31 2007 -0300
+++ b/mercurial/fancyopts.py Wed Aug 08 21:39:29 2007 -0300
@@ -9,7 +9,10 @@ def fancyopts(args, options, state):
for s, l, d, c in options:
pl = l.replace('-', '_')
map['-'+s] = map['--'+l] = pl
- state[pl] = d
+ if isinstance(d, list):
+ state[pl] = d[:]
+ else:
+ state[pl] = d
dt[pl] = type(d)
if (d is not None and d is not True and d is not False and
not callable(d)):
Yeah, we could use the copy module here and avoid the conditional,
but I don't really like it - without demandimport it takes ages to
be imported...
Alexis
More information about the Mercurial
mailing list