##// END OF EJS Templates
exec: add execfunc to simplify exec flag support on non-exec filesystems
Matt Mackall -
r3996:c190df14 default
parent child Browse files
Show More
@@ -378,13 +378,14 b' class workingctx(changectx):'
378 378 """generate a manifest corresponding to the working directory"""
379 379
380 380 man = self._parents[0].manifest().copy()
381 is_exec = util.execfunc(self._repo.root, man.execf)
381 382 copied = self._repo.dirstate.copies()
382 383 modified, added, removed, deleted, unknown = self._status[:5]
383 384 for i, l in (("a", added), ("m", modified), ("u", unknown)):
384 385 for f in l:
385 386 man[f] = man.get(copied.get(f, f), nullid) + i
386 387 try:
387 man.set(f, util.is_exec(self._repo.wjoin(f), man.execf(f)))
388 man.set(f, is_exec(f))
388 389 except OSError:
389 390 pass
390 391
@@ -712,11 +712,12 b' class localrepository(repo.repository):'
712 712 new = {}
713 713 linkrev = self.changelog.count()
714 714 commit.sort()
715 is_exec = util.execfunc(self.root, m1.execf)
715 716 for f in commit:
716 717 self.ui.note(f + "\n")
717 718 try:
718 719 new[f] = self.filecommit(f, m1, m2, linkrev, tr, changed)
719 m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f)))
720 m1.set(f, is_exec(f))
720 721 except IOError:
721 722 if use_dirstate:
722 723 self.ui.warn(_("trouble committing %s!\n") % f)
@@ -877,9 +878,10 b' class localrepository(repo.repository):'
877 878 # generate a pseudo-manifest for the working dir
878 879 # XXX: create it in dirstate.py ?
879 880 mf2 = mfmatches(self.dirstate.parents()[0])
881 is_exec = util.execfunc(self.root, mf2.execf)
880 882 for f in lookup + modified + added:
881 883 mf2[f] = ""
882 mf2.set(f, execf=util.is_exec(self.wjoin(f), mf2.execf(f)))
884 mf2.set(f, is_exec(f))
883 885 for f in removed:
884 886 if f in mf2:
885 887 del mf2[f]
@@ -524,6 +524,7 b' def diff(repo, node1=None, node2=None, f'
524 524 all = modified + added + removed
525 525 all.sort()
526 526 gone = {}
527
527 528 for f in all:
528 529 to = None
529 530 tn = None
@@ -707,6 +707,12 b' def checkexec(path):'
707 707 os.unlink(fn)
708 708 return r
709 709
710 def execfunc(path, fallback):
711 '''return an is_exec() function with default to fallback'''
712 if checkexec(path):
713 return lambda x: is_exec(os.path.join(path, x), False)
714 return fallback
715
710 716 # Platform specific variants
711 717 if os.name == 'nt':
712 718 import msvcrt
General Comments 0
You need to be logged in to leave comments. Login now