Mercurial > hg
annotate mercurial/manifest.py @ 4198:9e3121017fb2
Optimize return value of util._matcher for common command line case
This will trigger every time somebody runs something like "hg diff"
or "hg status" without any arguments.
The important part here is returning util.always as the match function,
which is a much simpler (and faster) function than the usual return
value, and allows other code to just skip the filtering if it knows
all files will match.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 10 Mar 2007 23:01:00 -0300 |
parents | f4c9bb4ad7b1 |
children | abaee83ce0a6 |
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 # |
2859 | 3 # Copyright 2005, 2006 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 * |
1400
cf9a1233738a
i18n first part: make '_' available for files who need it
Benoit Boissinot <benoit.boissinot@ens-lyon.org
parents:
1098
diff
changeset
|
9 from i18n import gettext as _ |
262 | 10 from demandload import * |
2470
fe1689273f84
use demandload more.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2320
diff
changeset
|
11 demandload(globals(), "array bisect struct") |
3196
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
12 demandload(globals(), "mdiff") |
79 | 13 |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
14 class manifestdict(dict): |
2857
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2841
diff
changeset
|
15 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:
2841
diff
changeset
|
16 if mapping is None: mapping = {} |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2841
diff
changeset
|
17 if flags is None: flags = {} |
2831 | 18 dict.__init__(self, mapping) |
2839
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
19 self._flags = flags |
2834
35af2e56f15a
manifestflags: eliminate remaining users of direct dict access
Matt Mackall <mpm@selenic.com>
parents:
2833
diff
changeset
|
20 def flags(self, f): |
2839
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
21 return self._flags.get(f, "") |
2831 | 22 def execf(self, f): |
23 "test for executable in manifest flags" | |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
24 return "x" in self.flags(f) |
2831 | 25 def linkf(self, f): |
26 "test for symlink in manifest flags" | |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
27 return "l" in self.flags(f) |
2839
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
28 def rawset(self, f, entry): |
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
29 self[f] = bin(entry[:40]) |
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
30 fl = entry[40:-1] |
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
31 if fl: self._flags[f] = fl |
2831 | 32 def set(self, f, execf=False, linkf=False): |
2857
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2841
diff
changeset
|
33 if linkf: self._flags[f] = "l" |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2841
diff
changeset
|
34 elif execf: self._flags[f] = "x" |
18cf5349a361
Fix some bugs introduced during the manifest refactoring
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2841
diff
changeset
|
35 else: self._flags[f] = "" |
2831 | 36 def copy(self): |
2839
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
37 return manifestdict(dict.copy(self), dict.copy(self._flags)) |
2831 | 38 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
39 class manifest(revlog): |
2142
8a1e2a9c7013
Replaced 0 with REVLOGV0 where this meaning is used.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2072
diff
changeset
|
40 def __init__(self, opener, defversion=REVLOGV0): |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
41 self.mapcache = None |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
42 self.listcache = None |
2072 | 43 revlog.__init__(self, opener, "00manifest.i", "00manifest.d", |
44 defversion) | |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
45 |
3196
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
46 def parselines(self, lines): |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
47 for l in lines.splitlines(1): |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
48 yield l.split('\0') |
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): |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
51 delta = mdiff.patchtext(self.delta(node)) |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
52 deltamap = manifestdict() |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
53 for f, n in self.parselines(delta): |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
54 deltamap.rawset(f, n) |
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
55 return deltamap |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3196
diff
changeset
|
56 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
57 def read(self, node): |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
58 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
|
59 if self.mapcache and self.mapcache[0] == node: |
561 | 60 return self.mapcache[1] |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
61 text = self.revision(node) |
1534 | 62 self.listcache = array.array('c', text) |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
63 mapping = manifestdict() |
3196
f3b939444c72
Abstract manifest block parsing.
Brendan Cully <brendan@kublai.com>
parents:
3148
diff
changeset
|
64 for f, n in self.parselines(text): |
2839
b4f05ecf4ee8
Switch to simpler manifestdict
Matt Mackall <mpm@selenic.com>
parents:
2835
diff
changeset
|
65 mapping.rawset(f, n) |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
66 self.mapcache = (node, mapping) |
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
67 return mapping |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
68 |
2320
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
69 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
|
70 '''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
|
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 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 # 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
|
95 # 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
|
96 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
|
97 else: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
98 # 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 # 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
|
104 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
|
105 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
|
106 else: |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
107 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
|
108 |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
109 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
|
110 '''look up entry for a single file efficiently. |
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 (node, flag) pair if found, (None, None) if not.''' |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
112 if self.mapcache and node == self.mapcache[0]: |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 f, n = l.split('\0') |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
120 return bin(n[:40]), n[40:-1] == 'x' |
dbdce3b99988
fix parsing of tags. make parse errors useful. add new tag tests.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2142
diff
changeset
|
121 |
2841 | 122 def add(self, map, transaction, link, p1=None, p2=None, |
741 | 123 changed=None): |
644 | 124 # apply the changes collected during the bisect loop to our addlist |
1534 | 125 # return a delta suitable for addrevision |
126 def addlistdelta(addlist, x): | |
127 # start from the bottom up | |
644 | 128 # so changes to the offsets don't mess things up. |
1534 | 129 i = len(x) |
644 | 130 while i > 0: |
131 i -= 1 | |
1534 | 132 start = x[i][0] |
133 end = x[i][1] | |
134 if x[i][2]: | |
135 addlist[start:end] = array.array('c', x[i][2]) | |
644 | 136 else: |
137 del addlist[start:end] | |
1534 | 138 return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2] \ |
139 for d in x ]) | |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
140 |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
141 def checkforbidden(f): |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
142 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:
3223
diff
changeset
|
143 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:
3223
diff
changeset
|
144 |
644 | 145 # if we're using the listcache, make sure it is valid and |
146 # parented by the same node we're diffing against | |
741 | 147 if not changed or not self.listcache or not p1 or \ |
148 self.mapcache[0] != p1: | |
644 | 149 files = map.keys() |
150 files.sort() | |
151 | |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
152 for f in files: |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
153 checkforbidden(f) |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
154 |
1651 | 155 # if this is changed to support newlines in filenames, |
156 # be sure to check the templates/ dir again (especially *-raw.tmpl) | |
2841 | 157 text = ["%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) for f in files] |
1534 | 158 self.listcache = array.array('c', "".join(text)) |
644 | 159 cachedelta = None |
160 else: | |
1534 | 161 addlist = self.listcache |
644 | 162 |
3607
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
163 for f in changed[0]: |
f4c9bb4ad7b1
issue352: disallow '\n' and '\r' in filenames (dirstate and manifest)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3223
diff
changeset
|
164 checkforbidden(f) |
644 | 165 # combine the changed lists into one list for sorting |
166 work = [[x, 0] for x in changed[0]] | |
167 work[len(work):] = [[x, 1] for x in changed[1]] | |
168 work.sort() | |
169 | |
170 delta = [] | |
1534 | 171 dstart = None |
172 dend = None | |
173 dline = [""] | |
174 start = 0 | |
175 # zero copy representation of addlist as a buffer | |
176 addbuf = buffer(addlist) | |
644 | 177 |
1534 | 178 # start with a readonly loop that finds the offset of |
179 # each line and creates the deltas | |
644 | 180 for w in work: |
181 f = w[0] | |
741 | 182 # 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
|
183 start, end = self._search(addbuf, f, start) |
644 | 184 if w[1] == 0: |
2841 | 185 l = "%s\000%s%s\n" % (f, hex(map[f]), map.flags(f)) |
644 | 186 else: |
1534 | 187 l = "" |
188 if start == end and w[1] == 1: | |
189 # item we want to delete was not found, error out | |
190 raise AssertionError( | |
3148
adb246ce6736
fix newline in error message
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3140
diff
changeset
|
191 _("failed to remove %s from manifest") % f) |
1534 | 192 if dstart != None and dstart <= start and dend >= start: |
193 if dend < end: | |
194 dend = end | |
195 if l: | |
196 dline.append(l) | |
644 | 197 else: |
1534 | 198 if dstart != None: |
199 delta.append([dstart, dend, "".join(dline)]) | |
200 dstart = start | |
201 dend = end | |
202 dline = [l] | |
644 | 203 |
1534 | 204 if dstart != None: |
205 delta.append([dstart, dend, "".join(dline)]) | |
206 # apply the delta to the addlist, and get a delta for addrevision | |
207 cachedelta = addlistdelta(addlist, delta) | |
644 | 208 |
1534 | 209 # the delta is only valid if we've been processing the tip revision |
210 if self.mapcache[0] != self.tip(): | |
211 cachedelta = None | |
212 self.listcache = addlist | |
213 | |
214 n = self.addrevision(buffer(self.listcache), transaction, link, p1, \ | |
215 p2, cachedelta) | |
2835
a9f5d4149123
Combine manifest dict and flags dict into a single object
Matt Mackall <mpm@selenic.com>
parents:
2834
diff
changeset
|
216 self.mapcache = (n, map) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
217 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
218 return n |