Mercurial > hg > mercurial-crew-with-dirclash
annotate mercurial/manifest.py @ 5049:41284ad94852
Merge with stable
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Wed, 01 Aug 2007 14:32:53 -0700 |
parents | e45fc5d03798 |
children | 8d00788ca578 |
rev | line source |
---|---|
1089 | 1 # manifest.py - manifest revision class for mercurial |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 # |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4633
diff
changeset
|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 # |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
262 | 8 from revlog import * |
3893 | 9 from i18n import _ |
3886
abaee83ce0a6
Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents:
3607
diff
changeset
|
10 import array, bisect, struct, mdiff |
79 | 11 |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
12 class manifestdict(dict): |
2856
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
13 def __init__(self, mapping=None, flags=None): |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
14 if mapping is None: mapping = {} |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
15 if flags is None: flags = {} |
2843 | 16 dict.__init__(self, mapping) |
2851
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2847
diff
changeset
|
17 self._flags = flags |
2846
35af2e56f15a
manifestflags: eliminate remaining users of direct dict access
Matt Mackall <mpm@selenic.com>
parents:
2845
diff
changeset
|
18 def flags(self, f): |
2851
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2847
diff
changeset
|
19 return self._flags.get(f, "") |
2843 | 20 def execf(self, f): |
21 "test for executable in manifest flags" | |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
22 return "x" in self.flags(f) |
2843 | 23 def linkf(self, f): |
24 "test for symlink in manifest flags" | |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
25 return "l" in self.flags(f) |
2843 | 26 def set(self, f, execf=False, linkf=False): |
2856
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
27 if linkf: self._flags[f] = "l" |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
28 elif execf: self._flags[f] = "x" |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2853
diff
changeset
|
29 else: self._flags[f] = "" |
2843 | 30 def copy(self): |
2851
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2847
diff
changeset
|
31 return manifestdict(dict.copy(self), dict.copy(self._flags)) |
2843 | 32 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
33 class manifest(revlog): |
4267
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4266
diff
changeset
|
34 def __init__(self, opener): |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
35 self.mapcache = None |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
36 self.listcache = None |
4267
b11a2fb59cf5
revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents:
4266
diff
changeset
|
37 revlog.__init__(self, opener, "00manifest.i") |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
38 |
4995
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
39 def parse(self, lines): |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
40 mfdict = manifestdict() |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
41 for l in lines.splitlines(): |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
42 f, n = l.split('\0') |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
43 if len(n) > 40: |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
44 mfdict._flags[f] = n[40:] |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
45 mfdict[f] = bin(n[:40]) |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
46 else: |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
47 mfdict[f] = bin(n) |
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
48 return mfdict |
3189
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
49 |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
50 def readdelta(self, node): |
4995
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
51 return self.parse(mdiff.patchtext(self.delta(node))) |
3215
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3189
diff
changeset
|
52 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
53 def read(self, node): |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
54 if node == nullid: return manifestdict() # don't upset local cache |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
55 if self.mapcache and self.mapcache[0] == node: |
561 | 56 return self.mapcache[1] |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
57 text = self.revision(node) |
1534 | 58 self.listcache = array.array('c', text) |
4995
e45fc5d03798
manifest: speed up creation of the manifestdict
Matt Mackall <mpm@selenic.com>
parents:
4635
diff
changeset
|
59 mapping = self.parse(text) |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
60 self.mapcache = (node, mapping) |
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
61 return mapping |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
62 |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
63 def _search(self, m, s, lo=0, hi=None): |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
64 '''return a tuple (start, end) that says where to find s within m. |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
65 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
66 If the string is found m[start:end] are the line containing |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
67 that string. If start == end the string was not found and |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
68 they indicate the proper sorted insertion point. This was |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
69 taken from bisect_left, and modified to find line start/end as |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
70 it goes along. |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
71 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
72 m should be a buffer or a string |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
73 s is a string''' |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
74 def advance(i, c): |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
75 while i < lenm and m[i] != c: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
76 i += 1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
77 return i |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
78 lenm = len(m) |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
79 if not hi: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
80 hi = lenm |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
81 while lo < hi: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
82 mid = (lo + hi) // 2 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
83 start = mid |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
84 while start > 0 and m[start-1] != '\n': |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
85 start -= 1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
86 end = advance(start, '\0') |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
87 if m[start:end] < s: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
88 # we know that after the null there are 40 bytes of sha1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
89 # this translates to the bisect lo = mid + 1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
90 lo = advance(end + 40, '\n') + 1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
91 else: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
92 # this translates to the bisect hi = mid |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
93 hi = start |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
94 end = advance(lo, '\0') |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
95 found = m[lo:end] |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
96 if cmp(s, found) == 0: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
97 # we know that after the null there are 40 bytes of sha1 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
98 end = advance(end + 40, '\n') |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
99 return (lo, end+1) |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
100 else: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
101 return (lo, lo) |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
102 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
103 def find(self, node, f): |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
104 '''look up entry for a single file efficiently. |
4159
a896607d3ec3
fix manifest.find
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3893
diff
changeset
|
105 return (node, flags) pair if found, (None, None) if not.''' |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
106 if self.mapcache and node == self.mapcache[0]: |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
107 return self.mapcache[1].get(f), self.mapcache[1].flags(f) |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
108 text = self.revision(node) |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
109 start, end = self._search(text, f) |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
110 if start == end: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
111 return None, None |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
112 l = text[start:end] |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
113 f, n = l.split('\0') |
4159
a896607d3ec3
fix manifest.find
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3893
diff
changeset
|
114 return bin(n[:40]), n[40:-1] |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
115 |
2853 | 116 def add(self, map, transaction, link, p1=None, p2=None, |
741 | 117 changed=None): |
644 | 118 # apply the changes collected during the bisect loop to our addlist |
1534 | 119 # return a delta suitable for addrevision |
120 def addlistdelta(addlist, x): | |
121 # start from the bottom up | |
644 | 122 # so changes to the offsets don't mess things up. |
1534 | 123 i = len(x) |
644 | 124 while i > 0: |
125 i -= 1 | |
1534 | 126 start = x[i][0] |
127 end = x[i][1] | |
128 if x[i][2]: | |
129 addlist[start:end] = array.array('c', x[i][2]) | |
644 | 130 else: |
131 del addlist[start:end] | |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
132 return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2] |
1534 | 133 for d in x ]) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
134 |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
135 def checkforbidden(f): |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
136 if '\n' in f or '\r' in f: |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
137 raise RevlogError(_("'\\n' and '\\r' disallowed in filenames")) |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
138 |
644 | 139 # if we're using the listcache, make sure it is valid and |
140 # parented by the same node we're diffing against | |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
141 if not (changed and self.listcache and p1 and self.mapcache[0] == p1): |
644 | 142 files = map.keys() |
143 files.sort() | |
144 | |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
145 for f in files: |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
146 checkforbidden(f) |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
147 |
1651 | 148 # if this is changed to support newlines in filenames, |
149 # be sure to check the templates/ dir again (especially *-raw.tmpl) | |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
150 text = ["%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) |
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
151 for f in files] |
1534 | 152 self.listcache = array.array('c', "".join(text)) |
644 | 153 cachedelta = None |
154 else: | |
1534 | 155 addlist = self.listcache |
644 | 156 |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
157 for f in changed[0]: |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3215
diff
changeset
|
158 checkforbidden(f) |
644 | 159 # combine the changed lists into one list for sorting |
160 work = [[x, 0] for x in changed[0]] | |
161 work[len(work):] = [[x, 1] for x in changed[1]] | |
162 work.sort() | |
163 | |
164 delta = [] | |
1534 | 165 dstart = None |
166 dend = None | |
167 dline = [""] | |
168 start = 0 | |
169 # zero copy representation of addlist as a buffer | |
170 addbuf = buffer(addlist) | |
644 | 171 |
1534 | 172 # start with a readonly loop that finds the offset of |
173 # each line and creates the deltas | |
644 | 174 for w in work: |
175 f = w[0] | |
741 | 176 # bs will either be the index of the item or the insert point |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
177 start, end = self._search(addbuf, f, start) |
644 | 178 if w[1] == 0: |
2853 | 179 l = "%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) |
644 | 180 else: |
1534 | 181 l = "" |
182 if start == end and w[1] == 1: | |
183 # item we want to delete was not found, error out | |
184 raise AssertionError( | |
3148
adb246ce6736
fix newline in error message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3140
diff
changeset
|
185 _("failed to remove %s from manifest") % f) |
1534 | 186 if dstart != None and dstart <= start and dend >= start: |
187 if dend < end: | |
188 dend = end | |
189 if l: | |
190 dline.append(l) | |
644 | 191 else: |
1534 | 192 if dstart != None: |
193 delta.append([dstart, dend, "".join(dline)]) | |
194 dstart = start | |
195 dend = end | |
196 dline = [l] | |
644 | 197 |
1534 | 198 if dstart != None: |
199 delta.append([dstart, dend, "".join(dline)]) | |
200 # apply the delta to the addlist, and get a delta for addrevision | |
201 cachedelta = addlistdelta(addlist, delta) | |
644 | 202 |
1534 | 203 # the delta is only valid if we've been processing the tip revision |
204 if self.mapcache[0] != self.tip(): | |
205 cachedelta = None | |
206 self.listcache = addlist | |
207 | |
4633
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
208 n = self.addrevision(buffer(self.listcache), transaction, link, |
ff7253a0d1da
Cleanup of whitespace, indentation and line continuation.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4267
diff
changeset
|
209 p1, p2, cachedelta) |
2847
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2846
diff
changeset
|
210 self.mapcache = (n, map) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
211 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
212 return n |