[PATCH]OpenVMS patches

Matt Mackall mpm at selenic.com
Sat Jun 9 12:00:35 CDT 2007


On Sat, Jun 09, 2007 at 04:27:49PM +0200, Jean-François Piéronne wrote:
> Hi,
> 
> I have attach the necessary patches for OpenVMS.

These aren't too bad. But we really do want to isolate platform
changes to util.py.

> # HG changeset patch
> # User Jean-Francois PIERONNE <jf.pieronne at laposte.net>
> # Date 1181312683 -7200
> # Node ID b67a2dbcab04571d11b35d8b52ab9352639fbeed
> # Parent  3e4aa4c9efe4fc8516c267a980b08ea3739023f9
> OpenVMS patches
> 
> diff -r 3e4aa4c9efe4 -r b67a2dbcab04 mercurial/patch.py
> --- a/mercurial/patch.py	Thu Jun 07 12:41:12 2007 +0200
> +++ b/mercurial/patch.py	Fri Jun 08 16:24:43 2007 +0200
> @@ -308,8 +308,14 @@ def patch(patchname, ui, strip=1, cwd=No
>  
>          if cwd:
>              args.append('-d %s' % util.shellquote(cwd))
> -        fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
> -                                           util.shellquote(patchname)))
> +        if sys.platform == 'OpenVMS':
> +            cmd = '%s %s -p%d -i %s' % (patcher, ' '.join(args), strip,
> +                                       util.shellquote(patchname))
> +            print cmd

We never use 'print'.

> +            fp = os.popen(cmd)
> +        else:
> +            fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
> +                                               util.shellquote(patchname)))

Seems we could use -i everywhere easily enough?

>          for line in fp:
>              line = line.rstrip()
> diff -r 3e4aa4c9efe4 -r b67a2dbcab04 mercurial/revlog.py
> --- a/mercurial/revlog.py	Thu Jun 07 12:41:12 2007 +0200
> +++ b/mercurial/revlog.py	Fri Jun 08 16:24:43 2007 +0200
> @@ -957,8 +957,10 @@ class revlog(object):
>              start = self.start(r) + (r + 1) * calc
>              length = self.length(r)
>              fp.seek(start)
> -            d = fp.read(length)
> -            df.write(d)
> +            # on OpenVMS read a 0 length buffer may return an error
> +            if length > 0:
> +                d = fp.read(length)
> +                df.write(d)

That's sad (and a litte strange). I'd prefer to hack opener to hide
this misfeature. Something like:

  fp = open(...)
  if "VMS":
    class vmsfile(file):
      ...
      def read(self, length):
        if length == 0:
          ...
        return file.read(self, length)

    fp = vmsfile(fp)

> --- a/mercurial/ui.py	Thu Jun 07 12:41:12 2007 +0200
> +++ b/mercurial/ui.py	Fri Jun 08 16:24:43 2007 +0200
> @@ -436,9 +436,15 @@ class ui(object):
>                      self.config("ui", "editor") or
>                      os.environ.get("EDITOR", "vi"))
>  
> -            util.system("%s \"%s\"" % (editor, name),
> -                        environ={'HGUSER': user},
> -                        onerr=util.Abort, errprefix=_("edit failed"))
> +            if sys.platform == 'OpenVMS':
> +                from vms.crtl import to_vms
> +                util.system("%s %s" % (editor, to_vms(name)),
> +                            environ={'HGUSER': user},
> +                            onerr=util.Abort, errprefix=_("edit failed"))

This should be hidden in util.system().

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list