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