view mercurial/util.py @ 437:5b38a5af4019

Commands cleanup -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Commands cleanup move patch function to import_ strip underbars from function names in help remove debugaddchangegroup and debugchangegroup remove -q option from import remove some aliases: ann, dump, dumpmanifest, merge, resolve add rm alias manifest hash: a3259c52d69be93e272b336098ab8549ec1922bb -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCulc9ywK+sNU5EO8RAvLqAJ0fIvuSCYZgXUBubBREL7dfg5y/yQCglYte AwWOEQJoLGHXbpvPYI1uljo= =hQeO -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 22 Jun 2005 22:31:25 -0800
parents 10c43444a38e
children e8af362cfb01
line wrap: on
line source

# util.py - utility functions and platform specfic implementations
#
# Copyright 2005 K. Thananchayan <thananck@yahoo.com>
#
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.

import os

def rename(src, dst):
    try:
        os.rename(src, dst)
    except:
        os.unlink(dst)
        os.rename(src, dst)

# Platfor specific varients
if os.name == 'nt':
    def pconvert(path):
        return path.replace("\\", "/")

    def makelock(info, pathname):
        ld = os.open(pathname, os.O_CREAT | os.O_WRONLY | os.O_EXCL)
        os.write(ld, info)
        os.close(ld)

    def readlock(pathname):
        return file(pathname).read()
else:
    def pconvert(path):
        return path

    def makelock(info, pathname):
        os.symlink(info, pathname)

    def readlock(pathname):
        return os.readlink(pathname)