Mercurial > hg
changeset 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 |
files | contrib/convert-repo mercurial/localrepo.py mercurial/merge.py mercurial/patch.py |
diffstat | 4 files changed, 21 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/convert-repo Fri Dec 29 20:04:31 2006 -0600 +++ b/contrib/convert-repo Fri Dec 29 20:04:31 2006 -0600 @@ -351,12 +351,10 @@ return [ hg.hex(x) for x in h ] def putfile(self, f, e, data): - self.repo.wfile(f, "w").write(data) + self.repo.wwrite(f, data, e and 'x' or '') if self.repo.dirstate.state(f) == '?': self.repo.dirstate.update([f], "a") - util.set_exec(self.repo.wjoin(f), e) - def delfile(self, f): try: os.unlink(self.repo.wjoin(f))
--- a/mercurial/localrepo.py Fri Dec 29 20:04:31 2006 -0600 +++ b/mercurial/localrepo.py Fri Dec 29 20:04:31 2006 -0600 @@ -505,9 +505,19 @@ data = self.wopener(filename, 'r').read() return self._filter("encode", filename, data) - def wwrite(self, filename, data): + def wwrite(self, filename, data, flags): data = self._filter("decode", filename, data) - return self.wopener(filename, 'w').write(data) + if "l" in flags: + os.unlink(self.wjoin(filename)) + os.symlink(data, self.wjoin(filename)) + else: + try: + if self._link(filename): + os.unlink(self.wjoin(filename)) + except OSError: + pass + self.wopener(filename, 'w').write(data) + util.set_exec(self.wjoin(filename), "x" in flags) def wwritedata(self, filename, data): return self._filter("decode", filename, data) @@ -971,8 +981,7 @@ self.ui.warn("%s not removed!\n" % f) else: t = self.file(f).read(m[f]) - self.wwrite(f, t) - util.set_exec(self.wjoin(f), m.execf(f)) + self.wwrite(f, t, m.flags(f)) self.dirstate.update([f], "n") def copy(self, source, dest, wlock=None):
--- a/mercurial/merge.py Fri Dec 29 20:04:31 2006 -0600 +++ b/mercurial/merge.py Fri Dec 29 20:04:31 2006 -0600 @@ -346,7 +346,7 @@ merged += 1 if f != fd: repo.ui.debug(_("copying %s to %s\n") % (f, fd)) - repo.wwrite(fd, repo.wread(f)) + repo.wwrite(fd, repo.wread(f), flag and 'x' or '') if move: repo.ui.debug(_("removing %s\n") % f) os.unlink(repo.wjoin(f)) @@ -355,22 +355,19 @@ flag = a[2] repo.ui.note(_("getting %s\n") % f) t = mctx.filectx(f).data() - repo.wwrite(f, t) - util.set_exec(repo.wjoin(f), flag) + repo.wwrite(f, t, flag and 'x' or '') updated += 1 elif m == "d": # directory rename f2, fd, flag = a[2:] if f: repo.ui.note(_("moving %s to %s\n") % (f, fd)) t = wctx.filectx(f).data() - repo.wwrite(fd, t) - util.set_exec(repo.wjoin(fd), flag) + repo.wwrite(fd, t, flag and 'x' or '') util.unlink(repo.wjoin(f)) if f2: repo.ui.note(_("getting %s to %s\n") % (f2, fd)) t = mctx.filectx(f2).data() - repo.wwrite(fd, t) - util.set_exec(repo.wjoin(fd), flag) + repo.wwrite(fd, t, flag and 'x' or '') updated += 1 elif m == "e": # exec flag = a[2]
--- a/mercurial/patch.py Fri Dec 29 20:04:31 2006 -0600 +++ b/mercurial/patch.py Fri Dec 29 20:04:31 2006 -0600 @@ -377,8 +377,9 @@ dst = os.path.join(repo.root, gp.path) # patch won't create empty files if ctype == 'ADD' and not os.path.exists(dst): - repo.wwrite(gp.path, '') - util.set_exec(dst, x) + repo.wwrite(gp.path, '', x and 'x' or '') + else: + util.set_exec(dst, x) cmdutil.addremove(repo, cfiles, wlock=wlock) files = patches.keys() files.extend([r for r in removes if r not in files])