# HG changeset patch # User Matt Mackall # Date 1167444270 21600 # Node ID c190df14338cee2fee25fd8b63f7ab20ea60d280 # Parent a4e79f86d3047f29998104e1bae82f7d90fc3900 exec: add execfunc to simplify exec flag support on non-exec filesystems diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -378,13 +378,14 @@ class workingctx(changectx): """generate a manifest corresponding to the working directory""" man = self._parents[0].manifest().copy() + is_exec = util.execfunc(self._repo.root, man.execf) copied = self._repo.dirstate.copies() modified, added, removed, deleted, unknown = self._status[:5] for i, l in (("a", added), ("m", modified), ("u", unknown)): for f in l: man[f] = man.get(copied.get(f, f), nullid) + i try: - man.set(f, util.is_exec(self._repo.wjoin(f), man.execf(f))) + man.set(f, is_exec(f)) except OSError: pass diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -712,11 +712,12 @@ class localrepository(repo.repository): new = {} linkrev = self.changelog.count() commit.sort() + is_exec = util.execfunc(self.root, m1.execf) for f in commit: self.ui.note(f + "\n") try: new[f] = self.filecommit(f, m1, m2, linkrev, tr, changed) - m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) + m1.set(f, is_exec(f)) except IOError: if use_dirstate: self.ui.warn(_("trouble committing %s!\n") % f) @@ -877,9 +878,10 @@ class localrepository(repo.repository): # generate a pseudo-manifest for the working dir # XXX: create it in dirstate.py ? mf2 = mfmatches(self.dirstate.parents()[0]) + is_exec = util.execfunc(self.root, mf2.execf) for f in lookup + modified + added: mf2[f] = "" - mf2.set(f, execf=util.is_exec(self.wjoin(f), mf2.execf(f))) + mf2.set(f, is_exec(f)) for f in removed: if f in mf2: del mf2[f] diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -524,6 +524,7 @@ def diff(repo, node1=None, node2=None, f all = modified + added + removed all.sort() gone = {} + for f in all: to = None tn = None diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -707,6 +707,12 @@ def checkexec(path): os.unlink(fn) return r +def execfunc(path, fallback): + '''return an is_exec() function with default to fallback''' + if checkexec(path): + return lambda x: is_exec(os.path.join(path, x), False) + return fallback + # Platform specific variants if os.name == 'nt': import msvcrt