[PATCH 4 of 5 RFC] various hacks to make some tests pass

Matt Mackall mpm at selenic.com
Fri Jun 3 16:20:43 CDT 2011


On Fri, 2011-06-03 at 23:04 +0300, Idan Kamara wrote:
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1307131444 -10800
> # Node ID 1a75ec54cf1092c2e3690511b54d2bf941c974de
> # Parent  629b46ad35e63f5217ae782d950dfb5c5835380e
> various hacks to make some tests pass
> 
> the problem is the commandserver replaces stdout/err, so after dup'ing them
> output no longer goes through the redirected ones.

General note: this sort of thing should go -before- the thing that
introduces the breakage. That way at every point in history, tests still
pass.

Specific note: these hacks are a little unfortunate. Also seems like the
actual issue is you can't dup a channel?

> diff -r 629b46ad35e6 -r 1a75ec54cf10 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py	Fri Jun 03 17:34:54 2011 +0300
> +++ b/mercurial/cmdutil.py	Fri Jun 03 23:04:04 2011 +0300
> @@ -161,7 +161,7 @@
>  
>      if not pat or pat == '-':
>          fp = writable and sys.stdout or sys.stdin
> -        return os.fdopen(os.dup(fp.fileno()), mode)
> +        return fp
>      if hasattr(pat, 'write') and writable:
>          return pat
>      if hasattr(pat, 'read') and 'r' in mode:
> @@ -503,7 +503,7 @@
>          if not fp:
>              fp = makefileobj(repo, template, node, total=total, seqno=seqno,
>                               revwidth=revwidth, mode='ab')
> -            if fp != template:
> +            if fp != template and fp not in (sys.stdout, sys.stderr):
>                  shouldclose = True
>          if fp != sys.stdout and hasattr(fp, 'name'):
>              repo.ui.note("%s\n" % fp.name)
> diff -r 629b46ad35e6 -r 1a75ec54cf10 mercurial/commands.py
> --- a/mercurial/commands.py	Fri Jun 03 17:34:54 2011 +0300
> +++ b/mercurial/commands.py	Fri Jun 03 23:04:04 2011 +0300
> @@ -946,7 +946,8 @@
>          if opts.get('decode'):
>              data = repo.wwritedata(abs, data)
>          fp.write(data)
> -        fp.close()
> +        if fp not in (sys.stdout, sys.stderr):
> +            fp.close()
>          err = 0
>      return err
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list