comparison mercurial/localrepo.py @ 4006:67982d3ee76c

symlinks: add flags param to wwrite Now wwrite can set symlink and exec for files
author Matt Mackall <mpm@selenic.com>
date Fri, 29 Dec 2006 20:04:31 -0600
parents 656e06eebda7
children 20da40cc1c73
comparison
equal deleted inserted replaced
4005:656e06eebda7 4006:67982d3ee76c
503 data = os.readlink(self.wjoin(filename)) 503 data = os.readlink(self.wjoin(filename))
504 else: 504 else:
505 data = self.wopener(filename, 'r').read() 505 data = self.wopener(filename, 'r').read()
506 return self._filter("encode", filename, data) 506 return self._filter("encode", filename, data)
507 507
508 def wwrite(self, filename, data): 508 def wwrite(self, filename, data, flags):
509 data = self._filter("decode", filename, data) 509 data = self._filter("decode", filename, data)
510 return self.wopener(filename, 'w').write(data) 510 if "l" in flags:
511 os.unlink(self.wjoin(filename))
512 os.symlink(data, self.wjoin(filename))
513 else:
514 try:
515 if self._link(filename):
516 os.unlink(self.wjoin(filename))
517 except OSError:
518 pass
519 self.wopener(filename, 'w').write(data)
520 util.set_exec(self.wjoin(filename), "x" in flags)
511 521
512 def wwritedata(self, filename, data): 522 def wwritedata(self, filename, data):
513 return self._filter("decode", filename, data) 523 return self._filter("decode", filename, data)
514 524
515 def transaction(self): 525 def transaction(self):
969 for f in list: 979 for f in list:
970 if self.dirstate.state(f) not in "r": 980 if self.dirstate.state(f) not in "r":
971 self.ui.warn("%s not removed!\n" % f) 981 self.ui.warn("%s not removed!\n" % f)
972 else: 982 else:
973 t = self.file(f).read(m[f]) 983 t = self.file(f).read(m[f])
974 self.wwrite(f, t) 984 self.wwrite(f, t, m.flags(f))
975 util.set_exec(self.wjoin(f), m.execf(f))
976 self.dirstate.update([f], "n") 985 self.dirstate.update([f], "n")
977 986
978 def copy(self, source, dest, wlock=None): 987 def copy(self, source, dest, wlock=None):
979 p = self.wjoin(dest) 988 p = self.wjoin(dest)
980 if not os.path.exists(p): 989 if not os.path.exists(p):