# HG changeset patch # User Matt Mackall # Date 2008-08-11 02:55:06 # Node ID 1d38f3605b205b5c1b22e8e82b551a05ebe799da # Parent 0d714a48ab53eb5352374ebadaf2e5a70eb75ff6 util: set_flags shouldn't know about repo flag formats diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -999,7 +999,7 @@ class svn_sink(converter_sink, commandli fp = open(hook, 'w') fp.write(pre_revprop_change) fp.close() - util.set_flags(hook, "x") + util.set_flags(hook, False, True) xport = transport.SvnRaTransport(url=geturl(path)) self.uuid = svn.ra.get_uuid(xport.ra) @@ -1026,7 +1026,7 @@ class svn_sink(converter_sink, commandli # systematically is just as expensive and much simpler. was_exec = 'x' not in flags - util.set_flags(self.wjoin(filename), flags) + util.set_flags(self.wjoin(filename), False, 'x' in flags) if was_exec: if 'x' not in flags: self.delexec.append(filename) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -562,8 +562,12 @@ class localrepository(repo.repository): os.unlink(self.wjoin(filename)) except OSError: pass - self.wopener(filename, 'w').write(data) - util.set_flags(self.wjoin(filename), flags) + if 'l' in flags: + self.wopener.symlink(data, filename) + else: + self.wopener(filename, 'w').write(data) + if 'x' in flags: + util.set_flags(self.wjoin(filename), False, True) def wwritedata(self, filename, data): return self._filter("decode", filename, data) diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -237,7 +237,7 @@ def applyupdates(repo, action, wctx, mct updated += 1 else: merged += 1 - util.set_flags(repo.wjoin(fd), flags) + util.set_flags(repo.wjoin(fd), 'l' in flags, 'x' in flags) if f != fd and move and util.lexists(repo.wjoin(f)): repo.ui.debug(_("removing %s\n") % f) os.unlink(repo.wjoin(f)) @@ -266,7 +266,7 @@ def applyupdates(repo, action, wctx, mct repo.ui.warn(" %s\n" % nf) elif m == "e": # exec flags = a[2] - util.set_flags(repo.wjoin(f), flags) + util.set_flags(repo.wjoin(f), 'l' in flags, 'x' in flags) return updated, merged, removed, unresolved diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1109,7 +1109,7 @@ def updatedir(ui, repo, patches): if ctype == 'ADD' and not os.path.exists(dst): repo.wwrite(gp.path, '', flags) else: - util.set_flags(dst, flags) + util.set_flags(dst, 'l' in flags, 'x' in flags) cmdutil.addremove(repo, cfiles) files = patches.keys() files.extend([r for r in removes if r not in files]) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -996,7 +996,7 @@ if os.name == 'nt': '''return False if pid dead, True if running or not known''' return True - def set_flags(f, flags): + def set_flags(f, l, x): pass def set_binary(fd): @@ -1143,10 +1143,8 @@ else: """check whether a file is executable""" return (os.lstat(f).st_mode & 0100 != 0) - def set_flags(f, flags): + def set_flags(f, l, x): s = os.lstat(f).st_mode - x = "x" in flags - l = "l" in flags if l: if not stat.S_ISLNK(s): # switch file to link