comparison mercurial/util.py @ 29367:4e6e280e238f

doc: describe detail about checkambig optional argument This is followup for patches below, which add checkambig argument to existing function. - 731ced087a4b - 76f1ea360c7e - ce2d81aafbae - a109bf7e0dc2
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 13 Jun 2016 05:11:56 +0900
parents c27dc3c31222
children 50269a4dce61
comparison
equal deleted inserted replaced
29366:d269e7db2f55 29367:4e6e280e238f
1008 1008
1009 return check 1009 return check
1010 1010
1011 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False): 1011 def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False):
1012 '''copy a file, preserving mode and optionally other stat info like 1012 '''copy a file, preserving mode and optionally other stat info like
1013 atime/mtime''' 1013 atime/mtime
1014
1015 checkambig argument is used with filestat, and is useful only if
1016 destination file is guarded by any lock (e.g. repo.lock or
1017 repo.wlock).
1018
1019 copystat and checkambig should be exclusive.
1020 '''
1014 assert not (copystat and checkambig) 1021 assert not (copystat and checkambig)
1015 oldstat = None 1022 oldstat = None
1016 if os.path.lexists(dest): 1023 if os.path.lexists(dest):
1017 if checkambig: 1024 if checkambig:
1018 oldstat = checkambig and filestat(dest) 1025 oldstat = checkambig and filestat(dest)
1461 All writes will go to a temporary copy of the original file. Call 1468 All writes will go to a temporary copy of the original file. Call
1462 close() when you are done writing, and atomictempfile will rename 1469 close() when you are done writing, and atomictempfile will rename
1463 the temporary copy to the original name, making the changes 1470 the temporary copy to the original name, making the changes
1464 visible. If the object is destroyed without being closed, all your 1471 visible. If the object is destroyed without being closed, all your
1465 writes are discarded. 1472 writes are discarded.
1473
1474 checkambig argument of constructor is used with filestat, and is
1475 useful only if target file is guarded by any lock (e.g. repo.lock
1476 or repo.wlock).
1466 ''' 1477 '''
1467 def __init__(self, name, mode='w+b', createmode=None, checkambig=False): 1478 def __init__(self, name, mode='w+b', createmode=None, checkambig=False):
1468 self.__name = name # permanent name 1479 self.__name = name # permanent name
1469 self._tempname = mktempcopy(name, emptyok=('w' in mode), 1480 self._tempname = mktempcopy(name, emptyok=('w' in mode),
1470 createmode=createmode) 1481 createmode=createmode)