mercurial/util.py
author mpm@selenic.com
Wed, 22 Jun 2005 11:23:01 -0800
changeset 432 3b9e3d3d2810
parent 422 10c43444a38e
child 441 e8af362cfb01
permissions -rw-r--r--
Start using bdiff for generating deltas -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Start using bdiff for generating deltas manifest hash: bf6ed7d17d96810b7f40b50811b104b568c64b4b -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCubqVywK+sNU5EO8RAor6AKCm8Zqg0DIhLzaMPp5/GKPKk/GjKwCfbCe+ /CBmpvcTxSJofY9RE08cCVY= =2yu2 -----END PGP SIGNATURE-----

# 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)