Show More
@@ -387,7 +387,7 b' def files(ui, repo, *pats, **opts):' | |||
|
387 | 387 | files += unknown |
|
388 | 388 | files.sort() |
|
389 | 389 | wctx = repo.changectx(None) |
|
390 |
islink = lambda p: 'l' in wctx. |
|
|
390 | islink = lambda p: 'l' in wctx.flags(p) | |
|
391 | 391 | kwfiles = [f for f in files if kwt.iskwfile(f, islink)] |
|
392 | 392 | cwd = pats and repo.getcwd() or '' |
|
393 | 393 | kwfstats = not opts.get('ignore') and (('K', kwfiles),) or () |
@@ -2480,7 +2480,7 b' def revert(ui, repo, *pats, **opts):' | |||
|
2480 | 2480 | if not opts.get('dry_run'): |
|
2481 | 2481 | def checkout(f): |
|
2482 | 2482 | fc = ctx[f] |
|
2483 |
repo.wwrite(f, fc.data(), fc. |
|
|
2483 | repo.wwrite(f, fc.data(), fc.flags()) | |
|
2484 | 2484 | |
|
2485 | 2485 | audit_path = util.path_auditor(repo.root) |
|
2486 | 2486 | for f in remove[0]: |
@@ -118,7 +118,7 b' class changectx(object):' | |||
|
118 | 118 | def filenode(self, path): |
|
119 | 119 | return self._fileinfo(path)[0] |
|
120 | 120 | |
|
121 |
def |
|
|
121 | def flags(self, path): | |
|
122 | 122 | try: |
|
123 | 123 | return self._fileinfo(path)[1] |
|
124 | 124 | except revlog.LookupError: |
@@ -237,9 +237,9 b' class filectx(object):' | |||
|
237 | 237 | |
|
238 | 238 | def filerev(self): return self._filerev |
|
239 | 239 | def filenode(self): return self._filenode |
|
240 |
def |
|
|
241 |
def isexec(self): return 'x' in self. |
|
|
242 |
def islink(self): return 'l' in self. |
|
|
240 | def flags(self): return self._changectx.flags(self._path) | |
|
241 | def isexec(self): return 'x' in self.flags() | |
|
242 | def islink(self): return 'l' in self.flags() | |
|
243 | 243 | def filelog(self): return self._filelog |
|
244 | 244 | |
|
245 | 245 | def rev(self): |
@@ -509,16 +509,14 b' class workingctx(changectx):' | |||
|
509 | 509 | |
|
510 | 510 | man = self._parents[0].manifest().copy() |
|
511 | 511 | copied = self._repo.dirstate.copies() |
|
512 | is_exec = util.execfunc(self._repo.root, | |
|
513 | lambda p: man.execf(copied.get(p,p))) | |
|
514 | is_link = util.linkfunc(self._repo.root, | |
|
515 | lambda p: man.linkf(copied.get(p,p))) | |
|
512 | cf = lambda x: man.flags(copied.get(x, x)) | |
|
513 | ff = self._repo.dirstate.flagfunc(cf) | |
|
516 | 514 | modified, added, removed, deleted, unknown = self._status[:5] |
|
517 | 515 | for i, l in (("a", added), ("m", modified), ("u", unknown)): |
|
518 | 516 | for f in l: |
|
519 | 517 | man[f] = man.get(copied.get(f, f), nullid) + i |
|
520 | 518 | try: |
|
521 |
man.set(f, |
|
|
519 | man.set(f, ff(f)) | |
|
522 | 520 | except OSError: |
|
523 | 521 | pass |
|
524 | 522 | |
@@ -555,7 +553,7 b' class workingctx(changectx):' | |||
|
555 | 553 | def children(self): |
|
556 | 554 | return [] |
|
557 | 555 | |
|
558 |
def |
|
|
556 | def flags(self, path): | |
|
559 | 557 | if '_manifest' in self.__dict__: |
|
560 | 558 | try: |
|
561 | 559 | return self._manifest.flags(path) |
@@ -565,12 +563,9 b' class workingctx(changectx):' | |||
|
565 | 563 | pnode = self._parents[0].changeset()[0] |
|
566 | 564 | orig = self._repo.dirstate.copies().get(path, path) |
|
567 | 565 | node, flag = self._repo.manifest.find(pnode, orig) |
|
568 | is_link = util.linkfunc(self._repo.root, | |
|
569 | lambda p: flag and 'l' in flag) | |
|
570 | is_exec = util.execfunc(self._repo.root, | |
|
571 | lambda p: flag and 'x' in flag) | |
|
572 | 566 | try: |
|
573 | return (is_link(path) and 'l' or '') + (is_exec(path) and 'x' or '') | |
|
567 | ff = self._repo.dirstate.flagfunc(lambda x: flag or '') | |
|
568 | return ff(path) | |
|
574 | 569 | except OSError: |
|
575 | 570 | pass |
|
576 | 571 | |
@@ -724,6 +719,7 b' class memctx(object):' | |||
|
724 | 719 | def clean(self): return self._status[5] |
|
725 | 720 | def branch(self): return self._extra['branch'] |
|
726 | 721 | def extra(self): return self._extra |
|
722 | def flags(self, f): return self[f].flags() | |
|
727 | 723 | |
|
728 | 724 | def parents(self): |
|
729 | 725 | """return contexts for each parent changeset""" |
@@ -750,7 +746,7 b' class memfilectx(object):' | |||
|
750 | 746 | def __str__(self): return "%s@%s" % (self.path(), self._changectx) |
|
751 | 747 | def path(self): return self._path |
|
752 | 748 | def data(self): return self._data |
|
753 |
def |
|
|
749 | def flags(self): return self._flags | |
|
754 | 750 | def isexec(self): return 'x' in self._flags |
|
755 | 751 | def islink(self): return 'l' in self._flags |
|
756 | 752 | def renamed(self): return self._copied |
@@ -70,6 +70,9 b' class dirstate(object):' | |||
|
70 | 70 | elif name == '_slash': |
|
71 | 71 | self._slash = self._ui.configbool('ui', 'slash') and os.sep != '/' |
|
72 | 72 | return self._slash |
|
73 | elif name == '_checklink': | |
|
74 | self._checklink = util.checklink(self._root) | |
|
75 | return self._checklink | |
|
73 | 76 | elif name == '_checkexec': |
|
74 | 77 | self._checkexec = util.checkexec(self._root) |
|
75 | 78 | return self._checkexec |
@@ -91,6 +94,34 b' class dirstate(object):' | |||
|
91 | 94 | def folding(self): |
|
92 | 95 | return self._folding |
|
93 | 96 | |
|
97 | def flagfunc(self, fallback): | |
|
98 | if self._checklink: | |
|
99 | if self._checkexec: | |
|
100 | def f(x): | |
|
101 | p = os.path.join(self._root, x) | |
|
102 | if os.path.islink(p): | |
|
103 | return 'l' | |
|
104 | if util.is_exec(p): | |
|
105 | return 'x' | |
|
106 | return '' | |
|
107 | return f | |
|
108 | def f(x): | |
|
109 | if os.path.islink(os.path.join(self._root, x)): | |
|
110 | return 'l' | |
|
111 | if 'x' in fallback(x): | |
|
112 | return 'x' | |
|
113 | return '' | |
|
114 | return f | |
|
115 | if self._checkexec: | |
|
116 | def f(x): | |
|
117 | if 'l' in fallback(x): | |
|
118 | return 'l' | |
|
119 | if util.is_exec(os.path.join(self._root, x)): | |
|
120 | return 'x' | |
|
121 | return '' | |
|
122 | return f | |
|
123 | return fallback | |
|
124 | ||
|
94 | 125 | def getcwd(self): |
|
95 | 126 | cwd = os.getcwd() |
|
96 | 127 | if cwd == self._root: return '' |
@@ -146,7 +146,7 b' def filemerge(repo, mynode, orig, fcd, f' | |||
|
146 | 146 | if tool == "internal:local": |
|
147 | 147 | return 0 |
|
148 | 148 | if tool == "internal:other": |
|
149 |
repo.wwrite(fd, fco.data(), fco. |
|
|
149 | repo.wwrite(fd, fco.data(), fco.flags()) | |
|
150 | 150 | return 0 |
|
151 | 151 | if tool == "internal:fail": |
|
152 | 152 | return 1 |
@@ -837,19 +837,16 b' class localrepository(repo.repository):' | |||
|
837 | 837 | self.ui.note(f + "\n") |
|
838 | 838 | try: |
|
839 | 839 | fctx = wctx.filectx(f) |
|
840 | newflags = fctx.flags() | |
|
840 | 841 | new[f] = self.filecommit(fctx, m1, m2, linkrev, trp, changed) |
|
841 | new_exec = fctx.isexec() | |
|
842 | new_link = fctx.islink() | |
|
843 | 842 | if ((not changed or changed[-1] != f) and |
|
844 | 843 | m2.get(f) != new[f]): |
|
845 | 844 | # mention the file in the changelog if some |
|
846 | 845 | # flag changed, even if there was no content |
|
847 | 846 | # change. |
|
848 |
|
|
|
849 | old_link = m1.linkf(f) | |
|
850 | if old_exec != new_exec or old_link != new_link: | |
|
847 | if m1.flags(f) != newflags: | |
|
851 | 848 | changed.append(f) |
|
852 |
m1.set(f, new |
|
|
849 | m1.set(f, newflags) | |
|
853 | 850 | if use_dirstate: |
|
854 | 851 | self.dirstate.normal(f) |
|
855 | 852 | |
@@ -1009,14 +1006,9 b' class localrepository(repo.repository):' | |||
|
1009 | 1006 | fixup = [] |
|
1010 | 1007 | # do a full compare of any files that might have changed |
|
1011 | 1008 | ctx = self.changectx('') |
|
1012 |
|
|
|
1013 | mlink = lambda f: 'l' in ctx.fileflags(f) | |
|
1014 | is_exec = util.execfunc(self.root, mexec) | |
|
1015 | is_link = util.linkfunc(self.root, mlink) | |
|
1016 | def flags(f): | |
|
1017 | return is_link(f) and 'l' or is_exec(f) and 'x' or '' | |
|
1009 | ff = self.dirstate.flagfunc(ctx.flags) | |
|
1018 | 1010 | for f in lookup: |
|
1019 |
if (f not in ctx or f |
|
|
1011 | if (f not in ctx or ff(f) != ctx.flags(f) | |
|
1020 | 1012 | or ctx[f].cmp(self.wread(f))): |
|
1021 | 1013 | modified.append(f) |
|
1022 | 1014 | else: |
@@ -1042,11 +1034,10 b' class localrepository(repo.repository):' | |||
|
1042 | 1034 | # generate a pseudo-manifest for the working dir |
|
1043 | 1035 | # XXX: create it in dirstate.py ? |
|
1044 | 1036 | mf2 = mfmatches(self.dirstate.parents()[0]) |
|
1045 | is_exec = util.execfunc(self.root, mf2.execf) | |
|
1046 | is_link = util.linkfunc(self.root, mf2.linkf) | |
|
1037 | ff = self.dirstate.flagfunc(mf2.flags) | |
|
1047 | 1038 | for f in lookup + modified + added: |
|
1048 | 1039 | mf2[f] = "" |
|
1049 |
mf2.set(f, |
|
|
1040 | mf2.set(f, ff(f)) | |
|
1050 | 1041 | for f in removed: |
|
1051 | 1042 | if f in mf2: |
|
1052 | 1043 | del mf2[f] |
@@ -24,10 +24,8 b' class manifestdict(dict):' | |||
|
24 | 24 | def linkf(self, f): |
|
25 | 25 | "test for symlink in manifest flags" |
|
26 | 26 | return "l" in self.flags(f) |
|
27 |
def set(self, f, |
|
|
28 |
|
|
|
29 | elif execf: self._flags[f] = "x" | |
|
30 | else: self._flags[f] = "" | |
|
27 | def set(self, f, flags): | |
|
28 | self._flags[f] = flags | |
|
31 | 29 | def copy(self): |
|
32 | 30 | return manifestdict(dict.copy(self), dict.copy(self._flags)) |
|
33 | 31 |
@@ -1193,16 +1193,6 b' def diff(repo, node1=None, node2=None, m' | |||
|
1193 | 1193 | return |
|
1194 | 1194 | |
|
1195 | 1195 | ctx2 = repo.changectx(node2) |
|
1196 | if node2: | |
|
1197 | execf2 = ctx2.manifest().execf | |
|
1198 | linkf2 = ctx2.manifest().linkf | |
|
1199 | else: | |
|
1200 | execf2 = util.execfunc(repo.root, None) | |
|
1201 | linkf2 = util.linkfunc(repo.root, None) | |
|
1202 | if execf2 is None: | |
|
1203 | mc = ctx2.parents()[0].manifest().copy() | |
|
1204 | execf2 = mc.execf | |
|
1205 | linkf2 = mc.linkf | |
|
1206 | 1196 | |
|
1207 | 1197 | if repo.ui.quiet: |
|
1208 | 1198 | r = None |
@@ -1219,6 +1209,8 b' def diff(repo, node1=None, node2=None, m' | |||
|
1219 | 1209 | all.sort() |
|
1220 | 1210 | gone = {} |
|
1221 | 1211 | |
|
1212 | gitmode = {'l': '120000', 'x': '100755', '': '100644'} | |
|
1213 | ||
|
1222 | 1214 | for f in all: |
|
1223 | 1215 | to = None |
|
1224 | 1216 | tn = None |
@@ -1230,18 +1222,16 b' def diff(repo, node1=None, node2=None, m' | |||
|
1230 | 1222 | tn = getfilectx(f, ctx2).data() |
|
1231 | 1223 | a, b = f, f |
|
1232 | 1224 | if opts.git: |
|
1233 | def gitmode(x, l): | |
|
1234 | return l and '120000' or (x and '100755' or '100644') | |
|
1235 | 1225 | def addmodehdr(header, omode, nmode): |
|
1236 | 1226 | if omode != nmode: |
|
1237 | 1227 | header.append('old mode %s\n' % omode) |
|
1238 | 1228 | header.append('new mode %s\n' % nmode) |
|
1239 | 1229 | |
|
1240 | 1230 | if f in added: |
|
1241 |
mode = gitmode |
|
|
1231 | mode = gitmode[ctx2.flags(f)] | |
|
1242 | 1232 | if f in copy: |
|
1243 | 1233 | a = copy[f] |
|
1244 |
omode = gitmode |
|
|
1234 | omode = gitmode[man1.flags(a)] | |
|
1245 | 1235 | addmodehdr(header, omode, mode) |
|
1246 | 1236 | if a in removed and a not in gone: |
|
1247 | 1237 | op = 'rename' |
@@ -1260,11 +1250,11 b' def diff(repo, node1=None, node2=None, m' | |||
|
1260 | 1250 | if f in copy and copy[f] in added and copy[copy[f]] == f: |
|
1261 | 1251 | dodiff = False |
|
1262 | 1252 | else: |
|
1263 | mode = gitmode(man1.execf(f), man1.linkf(f)) | |
|
1264 | header.append('deleted file mode %s\n' % mode) | |
|
1253 | header.append('deleted file mode %s\n' % | |
|
1254 | gitmode[man1.flags(f)]) | |
|
1265 | 1255 | else: |
|
1266 |
omode = gitmode |
|
|
1267 |
nmode = gitmode |
|
|
1256 | omode = gitmode[man1.flags(f)] | |
|
1257 | nmode = gitmode[ctx2.flags(f)] | |
|
1268 | 1258 | addmodehdr(header, omode, nmode) |
|
1269 | 1259 | if util.binary(to) or util.binary(tn): |
|
1270 | 1260 | dodiff = 'binary' |
@@ -933,12 +933,6 b' def checkexec(path):' | |||
|
933 | 933 | return False |
|
934 | 934 | return not (new_file_has_exec or exec_flags_cannot_flip) |
|
935 | 935 | |
|
936 | def execfunc(path, fallback): | |
|
937 | '''return an is_exec() function with default to fallback''' | |
|
938 | if checkexec(path): | |
|
939 | return lambda x: is_exec(os.path.join(path, x)) | |
|
940 | return fallback | |
|
941 | ||
|
942 | 936 | def checklink(path): |
|
943 | 937 | """check whether the given path is on a symlink-capable filesystem""" |
|
944 | 938 | # mktemp is not racy because symlink creation will fail if the |
@@ -951,12 +945,6 b' def checklink(path):' | |||
|
951 | 945 | except (OSError, AttributeError): |
|
952 | 946 | return False |
|
953 | 947 | |
|
954 | def linkfunc(path, fallback): | |
|
955 | '''return an is_link() function with default to fallback''' | |
|
956 | if checklink(path): | |
|
957 | return lambda x: os.path.islink(os.path.join(path, x)) | |
|
958 | return fallback | |
|
959 | ||
|
960 | 948 | _umask = os.umask(0) |
|
961 | 949 | os.umask(_umask) |
|
962 | 950 |
General Comments 0
You need to be logged in to leave comments.
Login now