Show More
@@ -169,6 +169,6 b' def archive(repo, dest, node, kind, deco' | |||
|
169 | 169 | write('.hg_archival.txt', 0644, |
|
170 | 170 | 'repo: %s\nnode: %s\n' % (hex(repo.changelog.node(0)), hex(node))) |
|
171 | 171 | for filename, filenode in mf: |
|
172 |
write(filename, mff |
|
|
172 | write(filename, mff.execf(filename) and 0755 or 0644, | |
|
173 | 173 | repo.file(filename).read(filenode)) |
|
174 | 174 | archiver.done() |
@@ -2151,7 +2151,8 b' def manifest(ui, repo, rev=None):' | |||
|
2151 | 2151 | files.sort() |
|
2152 | 2152 | |
|
2153 | 2153 | for f in files: |
|
2154 |
ui.write("%40s %3s %s\n" % (hex(m[f]), |
|
|
2154 | ui.write("%40s %3s %s\n" % (hex(m[f]), | |
|
2155 | mf.execf(f) and "755" or "644", f)) | |
|
2155 | 2156 | |
|
2156 | 2157 | def merge(ui, repo, node=None, force=None, branch=None): |
|
2157 | 2158 | """Merge working directory with another revision |
@@ -238,8 +238,8 b' class dirstate(object):' | |||
|
238 | 238 | self.clear() |
|
239 | 239 | umask = os.umask(0) |
|
240 | 240 | os.umask(umask) |
|
241 |
for f |
|
|
242 |
if |
|
|
241 | for f in files: | |
|
242 | if files.execf(f): | |
|
243 | 243 | self.map[f] = ('n', ~umask, -1, 0) |
|
244 | 244 | else: |
|
245 | 245 | self.map[f] = ('n', ~umask & 0666, -1, 0) |
@@ -490,9 +490,8 b' class localrepository(repo.repository):' | |||
|
490 | 490 | for f in files: |
|
491 | 491 | try: |
|
492 | 492 | t = self.wread(f) |
|
493 |
|
|
|
493 | mfm.set(f, util.is_exec(self.wjoin(f), mfm.execf(f))) | |
|
494 | 494 | r = self.file(f) |
|
495 | mfm[f] = tm | |
|
496 | 495 | |
|
497 | 496 | (entry, fp1, fp2) = self.checkfilemerge(f, t, r, m1, m2) |
|
498 | 497 | if entry: |
@@ -571,7 +570,7 b' class localrepository(repo.repository):' | |||
|
571 | 570 | for f in commit: |
|
572 | 571 | self.ui.note(f + "\n") |
|
573 | 572 | try: |
|
574 |
mf1 |
|
|
573 | mf1.set(f, util.is_exec(self.wjoin(f), mf1.execf(f))) | |
|
575 | 574 | t = self.wread(f) |
|
576 | 575 | except IOError: |
|
577 | 576 | self.ui.warn(_("trouble committing %s!\n") % f) |
@@ -826,7 +825,7 b' class localrepository(repo.repository):' | |||
|
826 | 825 | else: |
|
827 | 826 | t = self.file(f).read(m[f]) |
|
828 | 827 | self.wwrite(f, t) |
|
829 |
util.set_exec(self.wjoin(f), mf |
|
|
828 | util.set_exec(self.wjoin(f), mf.execf(f)) | |
|
830 | 829 | self.dirstate.update([f], "n") |
|
831 | 830 | |
|
832 | 831 | def copy(self, source, dest, wlock=None): |
@@ -10,6 +10,40 b' from i18n import gettext as _' | |||
|
10 | 10 | from demandload import * |
|
11 | 11 | demandload(globals(), "array bisect struct") |
|
12 | 12 | |
|
13 | class manifestdict(dict): | |
|
14 | def __init__(self, mapping={}): | |
|
15 | dict.__init__(self, mapping) | |
|
16 | def __getitem__(self, f): | |
|
17 | return self.node(f) | |
|
18 | def get(self, f, default=None): | |
|
19 | try: | |
|
20 | return dict.__getitem__(self, f)[:20] | |
|
21 | except KeyError: | |
|
22 | return default | |
|
23 | def __setitem__(self, f, node): | |
|
24 | fl = self.flags(f) | |
|
25 | dict.__setitem__(self, f, node + fl) | |
|
26 | def node(self, f): | |
|
27 | return dict.__getitem__(self, f)[:20] | |
|
28 | def flags(self, f): | |
|
29 | return dict.get(self, f, "")[20:] | |
|
30 | def execf(self, f): | |
|
31 | "test for executable in manifest flags" | |
|
32 | return "x" in self.flags(f) | |
|
33 | def linkf(self, f): | |
|
34 | "test for symlink in manifest flags" | |
|
35 | return "l" in self.flags(f) | |
|
36 | def rawset(self, f, node, flags): | |
|
37 | dict.__setitem__(self, f, node + flags) | |
|
38 | def set(self, f, execf=False, linkf=False): | |
|
39 | n = dict.get(self, f, nullid)[:20] | |
|
40 | fl = "" | |
|
41 | if execf: fl = "x" | |
|
42 | if linkf: fl = "l" | |
|
43 | dict.__setitem__(self, f, n + fl) | |
|
44 | def copy(self): | |
|
45 | return manifestdict(dict.copy(self)) | |
|
46 | ||
|
13 | 47 | class manifest(revlog): |
|
14 | 48 | def __init__(self, opener, defversion=REVLOGV0): |
|
15 | 49 | self.mapcache = None |
@@ -18,26 +52,21 b' class manifest(revlog):' | |||
|
18 | 52 | defversion) |
|
19 | 53 | |
|
20 | 54 | def read(self, node): |
|
21 |
if node == nullid: return |
|
|
55 | if node == nullid: return manifestdict() # don't upset local cache | |
|
22 | 56 | if self.mapcache and self.mapcache[0] == node: |
|
23 | 57 | return self.mapcache[1] |
|
24 | 58 | text = self.revision(node) |
|
25 | map = {} | |
|
26 | flag = {} | |
|
27 | 59 | self.listcache = array.array('c', text) |
|
28 | 60 | lines = text.splitlines(1) |
|
61 | mapping = manifestdict() | |
|
29 | 62 | for l in lines: |
|
30 | 63 | (f, n) = l.split('\0') |
|
31 |
map |
|
|
32 | flag[f] = (n[40:-1] == "x") | |
|
33 | self.mapcache = (node, map, flag) | |
|
34 | return map | |
|
64 | mapping.rawset(f, bin(n[:40]), n[40:-1]) | |
|
65 | self.mapcache = (node, mapping) | |
|
66 | return mapping | |
|
35 | 67 | |
|
36 | 68 | def readflags(self, node): |
|
37 | if node == nullid: return {} # don't upset local cache | |
|
38 | if not self.mapcache or self.mapcache[0] != node: | |
|
39 | self.read(node) | |
|
40 | return self.mapcache[2] | |
|
69 | return self.read(node) | |
|
41 | 70 | |
|
42 | 71 | def diff(self, a, b): |
|
43 | 72 | return mdiff.textdiff(str(a), str(b)) |
@@ -86,7 +115,7 b' class manifest(revlog):' | |||
|
86 | 115 | '''look up entry for a single file efficiently. |
|
87 | 116 | return (node, flag) pair if found, (None, None) if not.''' |
|
88 | 117 | if self.mapcache and node == self.mapcache[0]: |
|
89 |
return self.mapcache[1].get(f), self.mapcache[ |
|
|
118 | return self.mapcache[1].get(f), self.mapcache[1].flags(f) | |
|
90 | 119 | text = self.revision(node) |
|
91 | 120 | start, end = self._search(text, f) |
|
92 | 121 | if start == end: |
@@ -123,9 +152,7 b' class manifest(revlog):' | |||
|
123 | 152 | |
|
124 | 153 | # if this is changed to support newlines in filenames, |
|
125 | 154 | # be sure to check the templates/ dir again (especially *-raw.tmpl) |
|
126 | text = ["%s\000%s%s\n" % | |
|
127 | (f, hex(map[f]), flags[f] and "x" or '') | |
|
128 | for f in files] | |
|
155 | text = ["%s\000%s%s\n" % (f, hex(map[f]), flags.flags(f)) for f in files] | |
|
129 | 156 | self.listcache = array.array('c', "".join(text)) |
|
130 | 157 | cachedelta = None |
|
131 | 158 | else: |
@@ -151,8 +178,7 b' class manifest(revlog):' | |||
|
151 | 178 | # bs will either be the index of the item or the insert point |
|
152 | 179 | start, end = self._search(addbuf, f, start) |
|
153 | 180 | if w[1] == 0: |
|
154 | l = "%s\000%s%s\n" % (f, hex(map[f]), | |
|
155 | flags[f] and "x" or '') | |
|
181 | l = "%s\000%s%s\n" % (f, hex(map[f]), flags.flags(f)) | |
|
156 | 182 | else: |
|
157 | 183 | l = "" |
|
158 | 184 | if start == end and w[1] == 1: |
@@ -183,6 +209,6 b' class manifest(revlog):' | |||
|
183 | 209 | |
|
184 | 210 | n = self.addrevision(buffer(self.listcache), transaction, link, p1, \ |
|
185 | 211 | p2, cachedelta) |
|
186 |
self.mapcache = (n, map |
|
|
212 | self.mapcache = (n, map) | |
|
187 | 213 | |
|
188 | 214 | return n |
@@ -118,7 +118,7 b' def update(repo, node, branchmerge=False' | |||
|
118 | 118 | |
|
119 | 119 | for f in added + modified + unknown: |
|
120 | 120 | mw[f] = "" |
|
121 |
mfw |
|
|
121 | mfw.set(f, util.is_exec(repo.wjoin(f), mfw.execf(f))) | |
|
122 | 122 | |
|
123 | 123 | for f in deleted + removed: |
|
124 | 124 | if f in mw: |
@@ -155,7 +155,7 b' def update(repo, node, branchmerge=False' | |||
|
155 | 155 | repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
|
156 | 156 | # merge executable bits |
|
157 | 157 | # "if we changed or they changed, change in merge" |
|
158 |
a, b, c = mfa. |
|
|
158 | a, b, c = mfa.execf(f), mfw.execf(f), mf2.execf(f) | |
|
159 | 159 | mode = ((a^b) | (a^c)) ^ a |
|
160 | 160 | merge[f] = (m1.get(f, nullid), m2[f], mode) |
|
161 | 161 | s = 1 |
@@ -171,12 +171,12 b' def update(repo, node, branchmerge=False' | |||
|
171 | 171 | # we need to reset the dirstate if the file was added |
|
172 | 172 | get[f] = m2[f] |
|
173 | 173 | |
|
174 |
if not s and mfw |
|
|
174 | if not s and mfw.execf(f) != mf2.execf(f): | |
|
175 | 175 | if overwrite: |
|
176 | 176 | repo.ui.debug(_(" updating permissions for %s\n") % f) |
|
177 |
util.set_exec(repo.wjoin(f), mf2 |
|
|
177 | util.set_exec(repo.wjoin(f), mf2.execf(f)) | |
|
178 | 178 | else: |
|
179 |
a, b, c = mfa. |
|
|
179 | a, b, c = mfa.execf(f), mfw.execf(f), mf2.execf(f) | |
|
180 | 180 | mode = ((a^b) | (a^c)) ^ a |
|
181 | 181 | if mode != b: |
|
182 | 182 | repo.ui.debug(_(" updating permissions for %s\n") |
@@ -259,7 +259,7 b' def update(repo, node, branchmerge=False' | |||
|
259 | 259 | repo.ui.note(_("getting %s\n") % f) |
|
260 | 260 | t = repo.file(f).read(get[f]) |
|
261 | 261 | repo.wwrite(f, t) |
|
262 |
util.set_exec(repo.wjoin(f), mf2 |
|
|
262 | util.set_exec(repo.wjoin(f), mf2.execf(f)) | |
|
263 | 263 | if not partial: |
|
264 | 264 | if branchmerge: |
|
265 | 265 | repo.dirstate.update([f], 'n', st_mtime=-1) |
General Comments 0
You need to be logged in to leave comments.
Login now