Show More
@@ -1,277 +1,239 b'' | |||||
1 | # discovery.py - protocol changeset discovery functions |
|
1 | # discovery.py - protocol changeset discovery functions | |
2 | # |
|
2 | # | |
3 | # Copyright 2010 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2010 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import nullid, short |
|
8 | from node import nullid, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import util, setdiscovery, treediscovery, phases |
|
10 | import util, setdiscovery, treediscovery, phases | |
11 |
|
11 | |||
12 | def findcommonincoming(repo, remote, heads=None, force=False): |
|
12 | def findcommonincoming(repo, remote, heads=None, force=False): | |
13 | """Return a tuple (common, anyincoming, heads) used to identify the common |
|
13 | """Return a tuple (common, anyincoming, heads) used to identify the common | |
14 | subset of nodes between repo and remote. |
|
14 | subset of nodes between repo and remote. | |
15 |
|
15 | |||
16 | "common" is a list of (at least) the heads of the common subset. |
|
16 | "common" is a list of (at least) the heads of the common subset. | |
17 | "anyincoming" is testable as a boolean indicating if any nodes are missing |
|
17 | "anyincoming" is testable as a boolean indicating if any nodes are missing | |
18 | locally. If remote does not support getbundle, this actually is a list of |
|
18 | locally. If remote does not support getbundle, this actually is a list of | |
19 | roots of the nodes that would be incoming, to be supplied to |
|
19 | roots of the nodes that would be incoming, to be supplied to | |
20 | changegroupsubset. No code except for pull should be relying on this fact |
|
20 | changegroupsubset. No code except for pull should be relying on this fact | |
21 | any longer. |
|
21 | any longer. | |
22 | "heads" is either the supplied heads, or else the remote's heads. |
|
22 | "heads" is either the supplied heads, or else the remote's heads. | |
23 |
|
23 | |||
24 | If you pass heads and they are all known locally, the reponse lists justs |
|
24 | If you pass heads and they are all known locally, the reponse lists justs | |
25 | these heads in "common" and in "heads". |
|
25 | these heads in "common" and in "heads". | |
26 |
|
26 | |||
27 | Please use findcommonoutgoing to compute the set of outgoing nodes to give |
|
27 | Please use findcommonoutgoing to compute the set of outgoing nodes to give | |
28 | extensions a good hook into outgoing. |
|
28 | extensions a good hook into outgoing. | |
29 | """ |
|
29 | """ | |
30 |
|
30 | |||
31 | if not remote.capable('getbundle'): |
|
31 | if not remote.capable('getbundle'): | |
32 | return treediscovery.findcommonincoming(repo, remote, heads, force) |
|
32 | return treediscovery.findcommonincoming(repo, remote, heads, force) | |
33 |
|
33 | |||
34 | if heads: |
|
34 | if heads: | |
35 | allknown = True |
|
35 | allknown = True | |
36 | nm = repo.changelog.nodemap |
|
36 | nm = repo.changelog.nodemap | |
37 | for h in heads: |
|
37 | for h in heads: | |
38 | if nm.get(h) is None: |
|
38 | if nm.get(h) is None: | |
39 | allknown = False |
|
39 | allknown = False | |
40 | break |
|
40 | break | |
41 | if allknown: |
|
41 | if allknown: | |
42 | return (heads, False, heads) |
|
42 | return (heads, False, heads) | |
43 |
|
43 | |||
44 | res = setdiscovery.findcommonheads(repo.ui, repo, remote, |
|
44 | res = setdiscovery.findcommonheads(repo.ui, repo, remote, | |
45 | abortwhenunrelated=not force) |
|
45 | abortwhenunrelated=not force) | |
46 | common, anyinc, srvheads = res |
|
46 | common, anyinc, srvheads = res | |
47 | return (list(common), anyinc, heads or list(srvheads)) |
|
47 | return (list(common), anyinc, heads or list(srvheads)) | |
48 |
|
48 | |||
49 | class outgoing(object): |
|
49 | class outgoing(object): | |
50 | '''Represents the set of nodes present in a local repo but not in a |
|
50 | '''Represents the set of nodes present in a local repo but not in a | |
51 | (possibly) remote one. |
|
51 | (possibly) remote one. | |
52 |
|
52 | |||
53 | Members: |
|
53 | Members: | |
54 |
|
54 | |||
55 | missing is a list of all nodes present in local but not in remote. |
|
55 | missing is a list of all nodes present in local but not in remote. | |
56 | common is a list of all nodes shared between the two repos. |
|
56 | common is a list of all nodes shared between the two repos. | |
57 | excluded is the list of missing changeset that shouldn't be sent remotely. |
|
57 | excluded is the list of missing changeset that shouldn't be sent remotely. | |
58 | missingheads is the list of heads of missing. |
|
58 | missingheads is the list of heads of missing. | |
59 | commonheads is the list of heads of common. |
|
59 | commonheads is the list of heads of common. | |
60 |
|
60 | |||
61 | The sets are computed on demand from the heads, unless provided upfront |
|
61 | The sets are computed on demand from the heads, unless provided upfront | |
62 | by discovery.''' |
|
62 | by discovery.''' | |
63 |
|
63 | |||
64 | def __init__(self, revlog, commonheads, missingheads): |
|
64 | def __init__(self, revlog, commonheads, missingheads): | |
65 | self.commonheads = commonheads |
|
65 | self.commonheads = commonheads | |
66 | self.missingheads = missingheads |
|
66 | self.missingheads = missingheads | |
67 | self._revlog = revlog |
|
67 | self._revlog = revlog | |
68 | self._common = None |
|
68 | self._common = None | |
69 | self._missing = None |
|
69 | self._missing = None | |
70 | self.excluded = [] |
|
70 | self.excluded = [] | |
71 |
|
71 | |||
72 | def _computecommonmissing(self): |
|
72 | def _computecommonmissing(self): | |
73 | sets = self._revlog.findcommonmissing(self.commonheads, |
|
73 | sets = self._revlog.findcommonmissing(self.commonheads, | |
74 | self.missingheads) |
|
74 | self.missingheads) | |
75 | self._common, self._missing = sets |
|
75 | self._common, self._missing = sets | |
76 |
|
76 | |||
77 | @util.propertycache |
|
77 | @util.propertycache | |
78 | def common(self): |
|
78 | def common(self): | |
79 | if self._common is None: |
|
79 | if self._common is None: | |
80 | self._computecommonmissing() |
|
80 | self._computecommonmissing() | |
81 | return self._common |
|
81 | return self._common | |
82 |
|
82 | |||
83 | @util.propertycache |
|
83 | @util.propertycache | |
84 | def missing(self): |
|
84 | def missing(self): | |
85 | if self._missing is None: |
|
85 | if self._missing is None: | |
86 | self._computecommonmissing() |
|
86 | self._computecommonmissing() | |
87 | return self._missing |
|
87 | return self._missing | |
88 |
|
88 | |||
89 | def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): |
|
89 | def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): | |
90 | '''Return an outgoing instance to identify the nodes present in repo but |
|
90 | '''Return an outgoing instance to identify the nodes present in repo but | |
91 | not in other. |
|
91 | not in other. | |
92 |
|
92 | |||
93 | If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) |
|
93 | If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) | |
94 | are included. If you already know the local repo's heads, passing them in |
|
94 | are included. If you already know the local repo's heads, passing them in | |
95 | onlyheads is faster than letting them be recomputed here. |
|
95 | onlyheads is faster than letting them be recomputed here. | |
96 |
|
96 | |||
97 | If commoninc is given, it must the the result of a prior call to |
|
97 | If commoninc is given, it must the the result of a prior call to | |
98 | findcommonincoming(repo, other, force) to avoid recomputing it here.''' |
|
98 | findcommonincoming(repo, other, force) to avoid recomputing it here.''' | |
99 | # declare an empty outgoing object to be filled later |
|
99 | # declare an empty outgoing object to be filled later | |
100 | og = outgoing(repo.changelog, None, None) |
|
100 | og = outgoing(repo.changelog, None, None) | |
101 |
|
101 | |||
102 | # get common set if not provided |
|
102 | # get common set if not provided | |
103 | if commoninc is None: |
|
103 | if commoninc is None: | |
104 | commoninc = findcommonincoming(repo, other, force=force) |
|
104 | commoninc = findcommonincoming(repo, other, force=force) | |
105 | og.commonheads, _any, _hds = commoninc |
|
105 | og.commonheads, _any, _hds = commoninc | |
106 |
|
106 | |||
107 | # compute outgoing |
|
107 | # compute outgoing | |
108 | if not repo._phaseroots[phases.secret]: |
|
108 | if not repo._phaseroots[phases.secret]: | |
109 | og.missingheads = onlyheads or repo.heads() |
|
109 | og.missingheads = onlyheads or repo.heads() | |
110 | elif onlyheads is None: |
|
110 | elif onlyheads is None: | |
111 | # use visible heads as it should be cached |
|
111 | # use visible heads as it should be cached | |
112 | og.missingheads = phases.visibleheads(repo) |
|
112 | og.missingheads = phases.visibleheads(repo) | |
113 | og.excluded = [ctx.node() for ctx in repo.set('secret()')] |
|
113 | og.excluded = [ctx.node() for ctx in repo.set('secret()')] | |
114 | else: |
|
114 | else: | |
115 | # compute common, missing and exclude secret stuff |
|
115 | # compute common, missing and exclude secret stuff | |
116 | sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads) |
|
116 | sets = repo.changelog.findcommonmissing(og.commonheads, onlyheads) | |
117 | og._common, allmissing = sets |
|
117 | og._common, allmissing = sets | |
118 | og._missing = missing = [] |
|
118 | og._missing = missing = [] | |
119 | og._excluded = excluded = [] |
|
119 | og._excluded = excluded = [] | |
120 | for node in allmissing: |
|
120 | for node in allmissing: | |
121 | if repo[node].phase() >= phases.secret: |
|
121 | if repo[node].phase() >= phases.secret: | |
122 | excluded.append(node) |
|
122 | excluded.append(node) | |
123 | else: |
|
123 | else: | |
124 | missing.append(node) |
|
124 | missing.append(node) | |
125 | if excluded: |
|
125 | if excluded: | |
126 | # update missing heads |
|
126 | # update missing heads | |
127 | rset = repo.set('heads(%ln)', missing) |
|
127 | rset = repo.set('heads(%ln)', missing) | |
128 | missingheads = [ctx.node() for ctx in rset] |
|
128 | missingheads = [ctx.node() for ctx in rset] | |
129 | else: |
|
129 | else: | |
130 | missingheads = onlyheads |
|
130 | missingheads = onlyheads | |
131 | og.missingheads = missingheads |
|
131 | og.missingheads = missingheads | |
132 |
|
132 | |||
133 | return og |
|
133 | return og | |
134 |
|
134 | |||
135 |
def |
|
135 | def checkheads(repo, remote, outgoing, remoteheads, newbranch=False): | |
136 | '''Analyze the local and remote repositories and determine which |
|
136 | """Check that a push won't add any outgoing head | |
137 | changesets need to be pushed to the remote. Return value depends |
|
|||
138 | on circumstances: |
|
|||
139 |
|
||||
140 | If we are not going to push anything, return a tuple (None, 1, |
|
|||
141 | common) The third element "common" is the list of heads of the |
|
|||
142 | common set between local and remote. |
|
|||
143 |
|
137 | |||
144 | Otherwise, return a tuple (changegroup, remoteheads, futureheads), |
|
138 | raise Abort error and display ui message as needed. | |
145 | where changegroup is a readable file-like object whose read() |
|
139 | """ | |
146 | returns successive changegroup chunks ready to be sent over the |
|
140 | if remoteheads == [nullid]: | |
147 | wire, remoteheads is the list of remote heads and futureheads is |
|
141 | # remote is empty, nothing to check. | |
148 | the list of heads of the common set between local and remote to |
|
142 | return | |
149 | be after push completion. |
|
|||
150 | ''' |
|
|||
151 | commoninc = findcommonincoming(repo, remote, force=force) |
|
|||
152 | outgoing = findcommonoutgoing(repo, remote, onlyheads=revs, |
|
|||
153 | commoninc=commoninc, force=force) |
|
|||
154 | _common, inc, remoteheads = commoninc |
|
|||
155 |
|
143 | |||
156 | cl = repo.changelog |
|
144 | cl = repo.changelog | |
157 | outg = outgoing.missing |
|
145 | if remote.capable('branchmap'): | |
158 | common = outgoing.commonheads |
|
146 | # Check for each named branch if we're creating new remote heads. | |
|
147 | # To be a remote head after push, node must be either: | |||
|
148 | # - unknown locally | |||
|
149 | # - a local outgoing head descended from update | |||
|
150 | # - a remote head that's known locally and not | |||
|
151 | # ancestral to an outgoing head | |||
159 |
|
152 | |||
160 | if not outg: |
|
153 | # 1. Create set of branches involved in the push. | |
161 | if outgoing.excluded: |
|
154 | branches = set(repo[n].branch() for n in outgoing.missing) | |
162 | repo.ui.status(_("no changes to push but %i secret changesets\n") |
|
|||
163 | % len(outgoing.excluded)) |
|
|||
164 | else: |
|
|||
165 | repo.ui.status(_("no changes found\n")) |
|
|||
166 | return None, 1, common |
|
|||
167 |
|
155 | |||
168 | if not force and remoteheads != [nullid]: |
|
156 | # 2. Check for new branches on the remote. | |
169 |
|
|
157 | remotemap = remote.branchmap() | |
170 | # Check for each named branch if we're creating new remote heads. |
|
158 | newbranches = branches - set(remotemap) | |
171 | # To be a remote head after push, node must be either: |
|
159 | if newbranches and not newbranch: # new branch requires --new-branch | |
172 | # - unknown locally |
|
160 | branchnames = ', '.join(sorted(newbranches)) | |
173 | # - a local outgoing head descended from update |
|
161 | raise util.Abort(_("push creates new remote branches: %s!") | |
174 | # - a remote head that's known locally and not |
|
162 | % branchnames, | |
175 | # ancestral to an outgoing head |
|
163 | hint=_("use 'hg push --new-branch' to create" | |
176 |
|
164 | " new remote branches")) | ||
177 | # 1. Create set of branches involved in the push. |
|
165 | branches.difference_update(newbranches) | |
178 | branches = set(repo[n].branch() for n in outg) |
|
|||
179 |
|
166 | |||
180 | # 2. Check for new branches on the remote. |
|
167 | # 3. Construct the initial oldmap and newmap dicts. | |
181 | remotemap = remote.branchmap() |
|
168 | # They contain information about the remote heads before and | |
182 | newbranches = branches - set(remotemap) |
|
169 | # after the push, respectively. | |
183 | if newbranches and not newbranch: # new branch requires --new-branch |
|
170 | # Heads not found locally are not included in either dict, | |
184 | branchnames = ', '.join(sorted(newbranches)) |
|
171 | # since they won't be affected by the push. | |
185 | raise util.Abort(_("push creates new remote branches: %s!") |
|
172 | # unsynced contains all branches with incoming changesets. | |
186 | % branchnames, |
|
173 | oldmap = {} | |
187 | hint=_("use 'hg push --new-branch' to create" |
|
174 | newmap = {} | |
188 | " new remote branches")) |
|
175 | unsynced = set() | |
189 | branches.difference_update(newbranches) |
|
176 | for branch in branches: | |
|
177 | remotebrheads = remotemap[branch] | |||
|
178 | prunedbrheads = [h for h in remotebrheads if h in cl.nodemap] | |||
|
179 | oldmap[branch] = prunedbrheads | |||
|
180 | newmap[branch] = list(prunedbrheads) | |||
|
181 | if len(remotebrheads) > len(prunedbrheads): | |||
|
182 | unsynced.add(branch) | |||
190 |
|
183 | |||
191 | # 3. Construct the initial oldmap and newmap dicts. |
|
184 | # 4. Update newmap with outgoing changes. | |
192 | # They contain information about the remote heads before and |
|
185 | # This will possibly add new heads and remove existing ones. | |
193 | # after the push, respectively. |
|
186 | ctxgen = (repo[n] for n in outgoing.missing) | |
194 | # Heads not found locally are not included in either dict, |
|
187 | repo._updatebranchcache(newmap, ctxgen) | |
195 | # since they won't be affected by the push. |
|
|||
196 | # unsynced contains all branches with incoming changesets. |
|
|||
197 | oldmap = {} |
|
|||
198 | newmap = {} |
|
|||
199 | unsynced = set() |
|
|||
200 | for branch in branches: |
|
|||
201 | remotebrheads = remotemap[branch] |
|
|||
202 | prunedbrheads = [h for h in remotebrheads if h in cl.nodemap] |
|
|||
203 | oldmap[branch] = prunedbrheads |
|
|||
204 | newmap[branch] = list(prunedbrheads) |
|
|||
205 | if len(remotebrheads) > len(prunedbrheads): |
|
|||
206 | unsynced.add(branch) |
|
|||
207 |
|
||||
208 | # 4. Update newmap with outgoing changes. |
|
|||
209 | # This will possibly add new heads and remove existing ones. |
|
|||
210 | ctxgen = (repo[n] for n in outg) |
|
|||
211 | repo._updatebranchcache(newmap, ctxgen) |
|
|||
212 |
|
188 | |||
213 |
|
|
189 | else: | |
214 |
|
|
190 | # 1-4b. old servers: Check for new topological heads. | |
215 |
|
|
191 | # Construct {old,new}map with branch = None (topological branch). | |
216 |
|
|
192 | # (code based on _updatebranchcache) | |
217 |
|
|
193 | oldheads = set(h for h in remoteheads if h in cl.nodemap) | |
218 |
|
|
194 | newheads = oldheads.union(outg) | |
219 |
|
|
195 | if len(newheads) > 1: | |
220 |
|
|
196 | for latest in reversed(outg): | |
221 |
|
|
197 | if latest not in newheads: | |
222 |
|
|
198 | continue | |
223 |
|
|
199 | minhrev = min(cl.rev(h) for h in newheads) | |
224 |
|
|
200 | reachable = cl.reachable(latest, cl.node(minhrev)) | |
225 |
|
|
201 | reachable.remove(latest) | |
226 |
|
|
202 | newheads.difference_update(reachable) | |
227 |
|
|
203 | branches = set([None]) | |
228 |
|
|
204 | newmap = {None: newheads} | |
229 |
|
|
205 | oldmap = {None: oldheads} | |
230 |
|
|
206 | unsynced = inc and branches or set() | |
231 |
|
207 | |||
232 |
|
|
208 | # 5. Check for new heads. | |
233 |
|
|
209 | # If there are more heads after the push than before, a suitable | |
234 |
|
|
210 | # error message, depending on unsynced status, is displayed. | |
235 |
|
|
211 | error = None | |
236 |
|
|
212 | for branch in branches: | |
237 |
|
|
213 | newhs = set(newmap[branch]) | |
238 |
|
|
214 | oldhs = set(oldmap[branch]) | |
239 |
|
|
215 | if len(newhs) > len(oldhs): | |
240 |
|
|
216 | dhs = list(newhs - oldhs) | |
241 |
|
|
217 | if error is None: | |
242 |
|
|
218 | if branch not in ('default', None): | |
243 |
|
|
219 | error = _("push creates new remote head %s " | |
244 |
|
|
220 | "on branch '%s'!") % (short(dhs[0]), branch) | |
245 |
|
|
221 | else: | |
246 |
|
|
222 | error = _("push creates new remote head %s!" | |
247 |
|
|
223 | ) % short(dhs[0]) | |
248 |
|
|
224 | if branch in unsynced: | |
249 |
|
|
225 | hint = _("you should pull and merge or " | |
250 |
|
|
226 | "use push -f to force") | |
251 |
|
|
227 | else: | |
252 |
|
|
228 | hint = _("did you forget to merge? " | |
253 |
|
|
229 | "use push -f to force") | |
254 |
|
|
230 | if branch is not None: | |
255 |
|
|
231 | repo.ui.note(_("new remote heads on branch '%s'\n") % branch) | |
256 |
|
|
232 | for h in dhs: | |
257 |
|
|
233 | repo.ui.note(_("new remote head %s\n") % short(h)) | |
258 |
|
|
234 | if error: | |
259 |
|
|
235 | raise util.Abort(error, hint=hint) | |
260 |
|
236 | |||
261 |
|
|
237 | # 6. Check for unsynced changes on involved branches. | |
262 |
|
|
238 | if unsynced: | |
263 |
|
|
239 | repo.ui.warn(_("note: unsynced remote changes!\n")) | |
264 |
|
||||
265 | if revs is None and not outgoing.excluded: |
|
|||
266 | # push everything, |
|
|||
267 | # use the fast path, no race possible on push |
|
|||
268 | cg = repo._changegroup(outg, 'push') |
|
|||
269 | else: |
|
|||
270 | cg = repo.getlocalbundle('push', outgoing) |
|
|||
271 | # no need to compute outg ancestor. All node in outg have either: |
|
|||
272 | # - parents in outg |
|
|||
273 | # - parents in common |
|
|||
274 | # - nullid parent |
|
|||
275 | rset = repo.set('heads(%ln + %ln)', common, outg) |
|
|||
276 | futureheads = [ctx.node() for ctx in rset] |
|
|||
277 | return cg, remoteheads, futureheads |
|
@@ -1,2254 +1,2283 b'' | |||||
1 | # localrepo.py - read/write repository class for mercurial |
|
1 | # localrepo.py - read/write repository class for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms of the |
|
5 | # This software may be used and distributed according to the terms of the | |
6 | # GNU General Public License version 2 or any later version. |
|
6 | # GNU General Public License version 2 or any later version. | |
7 |
|
7 | |||
8 | from node import bin, hex, nullid, nullrev, short |
|
8 | from node import bin, hex, nullid, nullrev, short | |
9 | from i18n import _ |
|
9 | from i18n import _ | |
10 | import repo, changegroup, subrepo, discovery, pushkey |
|
10 | import repo, changegroup, subrepo, discovery, pushkey | |
11 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases |
|
11 | import changelog, dirstate, filelog, manifest, context, bookmarks, phases | |
12 | import lock, transaction, store, encoding |
|
12 | import lock, transaction, store, encoding | |
13 | import scmutil, util, extensions, hook, error, revset |
|
13 | import scmutil, util, extensions, hook, error, revset | |
14 | import match as matchmod |
|
14 | import match as matchmod | |
15 | import merge as mergemod |
|
15 | import merge as mergemod | |
16 | import tags as tagsmod |
|
16 | import tags as tagsmod | |
17 | from lock import release |
|
17 | from lock import release | |
18 | import weakref, errno, os, time, inspect |
|
18 | import weakref, errno, os, time, inspect | |
19 | propertycache = util.propertycache |
|
19 | propertycache = util.propertycache | |
20 | filecache = scmutil.filecache |
|
20 | filecache = scmutil.filecache | |
21 |
|
21 | |||
22 | class localrepository(repo.repository): |
|
22 | class localrepository(repo.repository): | |
23 | capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey', |
|
23 | capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey', | |
24 | 'known', 'getbundle')) |
|
24 | 'known', 'getbundle')) | |
25 | supportedformats = set(('revlogv1', 'generaldelta')) |
|
25 | supportedformats = set(('revlogv1', 'generaldelta')) | |
26 | supported = supportedformats | set(('store', 'fncache', 'shared', |
|
26 | supported = supportedformats | set(('store', 'fncache', 'shared', | |
27 | 'dotencode')) |
|
27 | 'dotencode')) | |
28 |
|
28 | |||
29 | def __init__(self, baseui, path=None, create=False): |
|
29 | def __init__(self, baseui, path=None, create=False): | |
30 | repo.repository.__init__(self) |
|
30 | repo.repository.__init__(self) | |
31 | self.root = os.path.realpath(util.expandpath(path)) |
|
31 | self.root = os.path.realpath(util.expandpath(path)) | |
32 | self.path = os.path.join(self.root, ".hg") |
|
32 | self.path = os.path.join(self.root, ".hg") | |
33 | self.origroot = path |
|
33 | self.origroot = path | |
34 | self.auditor = scmutil.pathauditor(self.root, self._checknested) |
|
34 | self.auditor = scmutil.pathauditor(self.root, self._checknested) | |
35 | self.opener = scmutil.opener(self.path) |
|
35 | self.opener = scmutil.opener(self.path) | |
36 | self.wopener = scmutil.opener(self.root) |
|
36 | self.wopener = scmutil.opener(self.root) | |
37 | self.baseui = baseui |
|
37 | self.baseui = baseui | |
38 | self.ui = baseui.copy() |
|
38 | self.ui = baseui.copy() | |
39 | self._dirtyphases = False |
|
39 | self._dirtyphases = False | |
40 | # A list of callback to shape the phase if no data were found. |
|
40 | # A list of callback to shape the phase if no data were found. | |
41 | # Callback are in the form: func(repo, roots) --> processed root. |
|
41 | # Callback are in the form: func(repo, roots) --> processed root. | |
42 | # This list it to be filled by extension during repo setup |
|
42 | # This list it to be filled by extension during repo setup | |
43 | self._phasedefaults = [] |
|
43 | self._phasedefaults = [] | |
44 |
|
44 | |||
45 | try: |
|
45 | try: | |
46 | self.ui.readconfig(self.join("hgrc"), self.root) |
|
46 | self.ui.readconfig(self.join("hgrc"), self.root) | |
47 | extensions.loadall(self.ui) |
|
47 | extensions.loadall(self.ui) | |
48 | except IOError: |
|
48 | except IOError: | |
49 | pass |
|
49 | pass | |
50 |
|
50 | |||
51 | if not os.path.isdir(self.path): |
|
51 | if not os.path.isdir(self.path): | |
52 | if create: |
|
52 | if create: | |
53 | if not os.path.exists(path): |
|
53 | if not os.path.exists(path): | |
54 | util.makedirs(path) |
|
54 | util.makedirs(path) | |
55 | util.makedir(self.path, notindexed=True) |
|
55 | util.makedir(self.path, notindexed=True) | |
56 | requirements = ["revlogv1"] |
|
56 | requirements = ["revlogv1"] | |
57 | if self.ui.configbool('format', 'usestore', True): |
|
57 | if self.ui.configbool('format', 'usestore', True): | |
58 | os.mkdir(os.path.join(self.path, "store")) |
|
58 | os.mkdir(os.path.join(self.path, "store")) | |
59 | requirements.append("store") |
|
59 | requirements.append("store") | |
60 | if self.ui.configbool('format', 'usefncache', True): |
|
60 | if self.ui.configbool('format', 'usefncache', True): | |
61 | requirements.append("fncache") |
|
61 | requirements.append("fncache") | |
62 | if self.ui.configbool('format', 'dotencode', True): |
|
62 | if self.ui.configbool('format', 'dotencode', True): | |
63 | requirements.append('dotencode') |
|
63 | requirements.append('dotencode') | |
64 | # create an invalid changelog |
|
64 | # create an invalid changelog | |
65 | self.opener.append( |
|
65 | self.opener.append( | |
66 | "00changelog.i", |
|
66 | "00changelog.i", | |
67 | '\0\0\0\2' # represents revlogv2 |
|
67 | '\0\0\0\2' # represents revlogv2 | |
68 | ' dummy changelog to prevent using the old repo layout' |
|
68 | ' dummy changelog to prevent using the old repo layout' | |
69 | ) |
|
69 | ) | |
70 | if self.ui.configbool('format', 'generaldelta', False): |
|
70 | if self.ui.configbool('format', 'generaldelta', False): | |
71 | requirements.append("generaldelta") |
|
71 | requirements.append("generaldelta") | |
72 | requirements = set(requirements) |
|
72 | requirements = set(requirements) | |
73 | else: |
|
73 | else: | |
74 | raise error.RepoError(_("repository %s not found") % path) |
|
74 | raise error.RepoError(_("repository %s not found") % path) | |
75 | elif create: |
|
75 | elif create: | |
76 | raise error.RepoError(_("repository %s already exists") % path) |
|
76 | raise error.RepoError(_("repository %s already exists") % path) | |
77 | else: |
|
77 | else: | |
78 | try: |
|
78 | try: | |
79 | requirements = scmutil.readrequires(self.opener, self.supported) |
|
79 | requirements = scmutil.readrequires(self.opener, self.supported) | |
80 | except IOError, inst: |
|
80 | except IOError, inst: | |
81 | if inst.errno != errno.ENOENT: |
|
81 | if inst.errno != errno.ENOENT: | |
82 | raise |
|
82 | raise | |
83 | requirements = set() |
|
83 | requirements = set() | |
84 |
|
84 | |||
85 | self.sharedpath = self.path |
|
85 | self.sharedpath = self.path | |
86 | try: |
|
86 | try: | |
87 | s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n')) |
|
87 | s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n')) | |
88 | if not os.path.exists(s): |
|
88 | if not os.path.exists(s): | |
89 | raise error.RepoError( |
|
89 | raise error.RepoError( | |
90 | _('.hg/sharedpath points to nonexistent directory %s') % s) |
|
90 | _('.hg/sharedpath points to nonexistent directory %s') % s) | |
91 | self.sharedpath = s |
|
91 | self.sharedpath = s | |
92 | except IOError, inst: |
|
92 | except IOError, inst: | |
93 | if inst.errno != errno.ENOENT: |
|
93 | if inst.errno != errno.ENOENT: | |
94 | raise |
|
94 | raise | |
95 |
|
95 | |||
96 | self.store = store.store(requirements, self.sharedpath, scmutil.opener) |
|
96 | self.store = store.store(requirements, self.sharedpath, scmutil.opener) | |
97 | self.spath = self.store.path |
|
97 | self.spath = self.store.path | |
98 | self.sopener = self.store.opener |
|
98 | self.sopener = self.store.opener | |
99 | self.sjoin = self.store.join |
|
99 | self.sjoin = self.store.join | |
100 | self.opener.createmode = self.store.createmode |
|
100 | self.opener.createmode = self.store.createmode | |
101 | self._applyrequirements(requirements) |
|
101 | self._applyrequirements(requirements) | |
102 | if create: |
|
102 | if create: | |
103 | self._writerequirements() |
|
103 | self._writerequirements() | |
104 |
|
104 | |||
105 |
|
105 | |||
106 | self._branchcache = None |
|
106 | self._branchcache = None | |
107 | self._branchcachetip = None |
|
107 | self._branchcachetip = None | |
108 | self.filterpats = {} |
|
108 | self.filterpats = {} | |
109 | self._datafilters = {} |
|
109 | self._datafilters = {} | |
110 | self._transref = self._lockref = self._wlockref = None |
|
110 | self._transref = self._lockref = self._wlockref = None | |
111 |
|
111 | |||
112 | # A cache for various files under .hg/ that tracks file changes, |
|
112 | # A cache for various files under .hg/ that tracks file changes, | |
113 | # (used by the filecache decorator) |
|
113 | # (used by the filecache decorator) | |
114 | # |
|
114 | # | |
115 | # Maps a property name to its util.filecacheentry |
|
115 | # Maps a property name to its util.filecacheentry | |
116 | self._filecache = {} |
|
116 | self._filecache = {} | |
117 |
|
117 | |||
118 | def _applyrequirements(self, requirements): |
|
118 | def _applyrequirements(self, requirements): | |
119 | self.requirements = requirements |
|
119 | self.requirements = requirements | |
120 | openerreqs = set(('revlogv1', 'generaldelta')) |
|
120 | openerreqs = set(('revlogv1', 'generaldelta')) | |
121 | self.sopener.options = dict((r, 1) for r in requirements |
|
121 | self.sopener.options = dict((r, 1) for r in requirements | |
122 | if r in openerreqs) |
|
122 | if r in openerreqs) | |
123 |
|
123 | |||
124 | def _writerequirements(self): |
|
124 | def _writerequirements(self): | |
125 | reqfile = self.opener("requires", "w") |
|
125 | reqfile = self.opener("requires", "w") | |
126 | for r in self.requirements: |
|
126 | for r in self.requirements: | |
127 | reqfile.write("%s\n" % r) |
|
127 | reqfile.write("%s\n" % r) | |
128 | reqfile.close() |
|
128 | reqfile.close() | |
129 |
|
129 | |||
130 | def _checknested(self, path): |
|
130 | def _checknested(self, path): | |
131 | """Determine if path is a legal nested repository.""" |
|
131 | """Determine if path is a legal nested repository.""" | |
132 | if not path.startswith(self.root): |
|
132 | if not path.startswith(self.root): | |
133 | return False |
|
133 | return False | |
134 | subpath = path[len(self.root) + 1:] |
|
134 | subpath = path[len(self.root) + 1:] | |
135 | normsubpath = util.pconvert(subpath) |
|
135 | normsubpath = util.pconvert(subpath) | |
136 |
|
136 | |||
137 | # XXX: Checking against the current working copy is wrong in |
|
137 | # XXX: Checking against the current working copy is wrong in | |
138 | # the sense that it can reject things like |
|
138 | # the sense that it can reject things like | |
139 | # |
|
139 | # | |
140 | # $ hg cat -r 10 sub/x.txt |
|
140 | # $ hg cat -r 10 sub/x.txt | |
141 | # |
|
141 | # | |
142 | # if sub/ is no longer a subrepository in the working copy |
|
142 | # if sub/ is no longer a subrepository in the working copy | |
143 | # parent revision. |
|
143 | # parent revision. | |
144 | # |
|
144 | # | |
145 | # However, it can of course also allow things that would have |
|
145 | # However, it can of course also allow things that would have | |
146 | # been rejected before, such as the above cat command if sub/ |
|
146 | # been rejected before, such as the above cat command if sub/ | |
147 | # is a subrepository now, but was a normal directory before. |
|
147 | # is a subrepository now, but was a normal directory before. | |
148 | # The old path auditor would have rejected by mistake since it |
|
148 | # The old path auditor would have rejected by mistake since it | |
149 | # panics when it sees sub/.hg/. |
|
149 | # panics when it sees sub/.hg/. | |
150 | # |
|
150 | # | |
151 | # All in all, checking against the working copy seems sensible |
|
151 | # All in all, checking against the working copy seems sensible | |
152 | # since we want to prevent access to nested repositories on |
|
152 | # since we want to prevent access to nested repositories on | |
153 | # the filesystem *now*. |
|
153 | # the filesystem *now*. | |
154 | ctx = self[None] |
|
154 | ctx = self[None] | |
155 | parts = util.splitpath(subpath) |
|
155 | parts = util.splitpath(subpath) | |
156 | while parts: |
|
156 | while parts: | |
157 | prefix = '/'.join(parts) |
|
157 | prefix = '/'.join(parts) | |
158 | if prefix in ctx.substate: |
|
158 | if prefix in ctx.substate: | |
159 | if prefix == normsubpath: |
|
159 | if prefix == normsubpath: | |
160 | return True |
|
160 | return True | |
161 | else: |
|
161 | else: | |
162 | sub = ctx.sub(prefix) |
|
162 | sub = ctx.sub(prefix) | |
163 | return sub.checknested(subpath[len(prefix) + 1:]) |
|
163 | return sub.checknested(subpath[len(prefix) + 1:]) | |
164 | else: |
|
164 | else: | |
165 | parts.pop() |
|
165 | parts.pop() | |
166 | return False |
|
166 | return False | |
167 |
|
167 | |||
168 | @filecache('bookmarks') |
|
168 | @filecache('bookmarks') | |
169 | def _bookmarks(self): |
|
169 | def _bookmarks(self): | |
170 | return bookmarks.read(self) |
|
170 | return bookmarks.read(self) | |
171 |
|
171 | |||
172 | @filecache('bookmarks.current') |
|
172 | @filecache('bookmarks.current') | |
173 | def _bookmarkcurrent(self): |
|
173 | def _bookmarkcurrent(self): | |
174 | return bookmarks.readcurrent(self) |
|
174 | return bookmarks.readcurrent(self) | |
175 |
|
175 | |||
176 | def _writebookmarks(self, marks): |
|
176 | def _writebookmarks(self, marks): | |
177 | bookmarks.write(self) |
|
177 | bookmarks.write(self) | |
178 |
|
178 | |||
179 | @filecache('phaseroots') |
|
179 | @filecache('phaseroots') | |
180 | def _phaseroots(self): |
|
180 | def _phaseroots(self): | |
181 | self._dirtyphases = False |
|
181 | self._dirtyphases = False | |
182 | phaseroots = phases.readroots(self) |
|
182 | phaseroots = phases.readroots(self) | |
183 | phases.filterunknown(self, phaseroots) |
|
183 | phases.filterunknown(self, phaseroots) | |
184 | return phaseroots |
|
184 | return phaseroots | |
185 |
|
185 | |||
186 | @propertycache |
|
186 | @propertycache | |
187 | def _phaserev(self): |
|
187 | def _phaserev(self): | |
188 | cache = [phases.public] * len(self) |
|
188 | cache = [phases.public] * len(self) | |
189 | for phase in phases.trackedphases: |
|
189 | for phase in phases.trackedphases: | |
190 | roots = map(self.changelog.rev, self._phaseroots[phase]) |
|
190 | roots = map(self.changelog.rev, self._phaseroots[phase]) | |
191 | if roots: |
|
191 | if roots: | |
192 | for rev in roots: |
|
192 | for rev in roots: | |
193 | cache[rev] = phase |
|
193 | cache[rev] = phase | |
194 | for rev in self.changelog.descendants(*roots): |
|
194 | for rev in self.changelog.descendants(*roots): | |
195 | cache[rev] = phase |
|
195 | cache[rev] = phase | |
196 | return cache |
|
196 | return cache | |
197 |
|
197 | |||
198 | @filecache('00changelog.i', True) |
|
198 | @filecache('00changelog.i', True) | |
199 | def changelog(self): |
|
199 | def changelog(self): | |
200 | c = changelog.changelog(self.sopener) |
|
200 | c = changelog.changelog(self.sopener) | |
201 | if 'HG_PENDING' in os.environ: |
|
201 | if 'HG_PENDING' in os.environ: | |
202 | p = os.environ['HG_PENDING'] |
|
202 | p = os.environ['HG_PENDING'] | |
203 | if p.startswith(self.root): |
|
203 | if p.startswith(self.root): | |
204 | c.readpending('00changelog.i.a') |
|
204 | c.readpending('00changelog.i.a') | |
205 | return c |
|
205 | return c | |
206 |
|
206 | |||
207 | @filecache('00manifest.i', True) |
|
207 | @filecache('00manifest.i', True) | |
208 | def manifest(self): |
|
208 | def manifest(self): | |
209 | return manifest.manifest(self.sopener) |
|
209 | return manifest.manifest(self.sopener) | |
210 |
|
210 | |||
211 | @filecache('dirstate') |
|
211 | @filecache('dirstate') | |
212 | def dirstate(self): |
|
212 | def dirstate(self): | |
213 | warned = [0] |
|
213 | warned = [0] | |
214 | def validate(node): |
|
214 | def validate(node): | |
215 | try: |
|
215 | try: | |
216 | self.changelog.rev(node) |
|
216 | self.changelog.rev(node) | |
217 | return node |
|
217 | return node | |
218 | except error.LookupError: |
|
218 | except error.LookupError: | |
219 | if not warned[0]: |
|
219 | if not warned[0]: | |
220 | warned[0] = True |
|
220 | warned[0] = True | |
221 | self.ui.warn(_("warning: ignoring unknown" |
|
221 | self.ui.warn(_("warning: ignoring unknown" | |
222 | " working parent %s!\n") % short(node)) |
|
222 | " working parent %s!\n") % short(node)) | |
223 | return nullid |
|
223 | return nullid | |
224 |
|
224 | |||
225 | return dirstate.dirstate(self.opener, self.ui, self.root, validate) |
|
225 | return dirstate.dirstate(self.opener, self.ui, self.root, validate) | |
226 |
|
226 | |||
227 | def __getitem__(self, changeid): |
|
227 | def __getitem__(self, changeid): | |
228 | if changeid is None: |
|
228 | if changeid is None: | |
229 | return context.workingctx(self) |
|
229 | return context.workingctx(self) | |
230 | return context.changectx(self, changeid) |
|
230 | return context.changectx(self, changeid) | |
231 |
|
231 | |||
232 | def __contains__(self, changeid): |
|
232 | def __contains__(self, changeid): | |
233 | try: |
|
233 | try: | |
234 | return bool(self.lookup(changeid)) |
|
234 | return bool(self.lookup(changeid)) | |
235 | except error.RepoLookupError: |
|
235 | except error.RepoLookupError: | |
236 | return False |
|
236 | return False | |
237 |
|
237 | |||
238 | def __nonzero__(self): |
|
238 | def __nonzero__(self): | |
239 | return True |
|
239 | return True | |
240 |
|
240 | |||
241 | def __len__(self): |
|
241 | def __len__(self): | |
242 | return len(self.changelog) |
|
242 | return len(self.changelog) | |
243 |
|
243 | |||
244 | def __iter__(self): |
|
244 | def __iter__(self): | |
245 | for i in xrange(len(self)): |
|
245 | for i in xrange(len(self)): | |
246 | yield i |
|
246 | yield i | |
247 |
|
247 | |||
248 | def revs(self, expr, *args): |
|
248 | def revs(self, expr, *args): | |
249 | '''Return a list of revisions matching the given revset''' |
|
249 | '''Return a list of revisions matching the given revset''' | |
250 | expr = revset.formatspec(expr, *args) |
|
250 | expr = revset.formatspec(expr, *args) | |
251 | m = revset.match(None, expr) |
|
251 | m = revset.match(None, expr) | |
252 | return [r for r in m(self, range(len(self)))] |
|
252 | return [r for r in m(self, range(len(self)))] | |
253 |
|
253 | |||
254 | def set(self, expr, *args): |
|
254 | def set(self, expr, *args): | |
255 | ''' |
|
255 | ''' | |
256 | Yield a context for each matching revision, after doing arg |
|
256 | Yield a context for each matching revision, after doing arg | |
257 | replacement via revset.formatspec |
|
257 | replacement via revset.formatspec | |
258 | ''' |
|
258 | ''' | |
259 | for r in self.revs(expr, *args): |
|
259 | for r in self.revs(expr, *args): | |
260 | yield self[r] |
|
260 | yield self[r] | |
261 |
|
261 | |||
262 | def url(self): |
|
262 | def url(self): | |
263 | return 'file:' + self.root |
|
263 | return 'file:' + self.root | |
264 |
|
264 | |||
265 | def hook(self, name, throw=False, **args): |
|
265 | def hook(self, name, throw=False, **args): | |
266 | return hook.hook(self.ui, self, name, throw, **args) |
|
266 | return hook.hook(self.ui, self, name, throw, **args) | |
267 |
|
267 | |||
268 | tag_disallowed = ':\r\n' |
|
268 | tag_disallowed = ':\r\n' | |
269 |
|
269 | |||
270 | def _tag(self, names, node, message, local, user, date, extra={}): |
|
270 | def _tag(self, names, node, message, local, user, date, extra={}): | |
271 | if isinstance(names, str): |
|
271 | if isinstance(names, str): | |
272 | allchars = names |
|
272 | allchars = names | |
273 | names = (names,) |
|
273 | names = (names,) | |
274 | else: |
|
274 | else: | |
275 | allchars = ''.join(names) |
|
275 | allchars = ''.join(names) | |
276 | for c in self.tag_disallowed: |
|
276 | for c in self.tag_disallowed: | |
277 | if c in allchars: |
|
277 | if c in allchars: | |
278 | raise util.Abort(_('%r cannot be used in a tag name') % c) |
|
278 | raise util.Abort(_('%r cannot be used in a tag name') % c) | |
279 |
|
279 | |||
280 | branches = self.branchmap() |
|
280 | branches = self.branchmap() | |
281 | for name in names: |
|
281 | for name in names: | |
282 | self.hook('pretag', throw=True, node=hex(node), tag=name, |
|
282 | self.hook('pretag', throw=True, node=hex(node), tag=name, | |
283 | local=local) |
|
283 | local=local) | |
284 | if name in branches: |
|
284 | if name in branches: | |
285 | self.ui.warn(_("warning: tag %s conflicts with existing" |
|
285 | self.ui.warn(_("warning: tag %s conflicts with existing" | |
286 | " branch name\n") % name) |
|
286 | " branch name\n") % name) | |
287 |
|
287 | |||
288 | def writetags(fp, names, munge, prevtags): |
|
288 | def writetags(fp, names, munge, prevtags): | |
289 | fp.seek(0, 2) |
|
289 | fp.seek(0, 2) | |
290 | if prevtags and prevtags[-1] != '\n': |
|
290 | if prevtags and prevtags[-1] != '\n': | |
291 | fp.write('\n') |
|
291 | fp.write('\n') | |
292 | for name in names: |
|
292 | for name in names: | |
293 | m = munge and munge(name) or name |
|
293 | m = munge and munge(name) or name | |
294 | if self._tagscache.tagtypes and name in self._tagscache.tagtypes: |
|
294 | if self._tagscache.tagtypes and name in self._tagscache.tagtypes: | |
295 | old = self.tags().get(name, nullid) |
|
295 | old = self.tags().get(name, nullid) | |
296 | fp.write('%s %s\n' % (hex(old), m)) |
|
296 | fp.write('%s %s\n' % (hex(old), m)) | |
297 | fp.write('%s %s\n' % (hex(node), m)) |
|
297 | fp.write('%s %s\n' % (hex(node), m)) | |
298 | fp.close() |
|
298 | fp.close() | |
299 |
|
299 | |||
300 | prevtags = '' |
|
300 | prevtags = '' | |
301 | if local: |
|
301 | if local: | |
302 | try: |
|
302 | try: | |
303 | fp = self.opener('localtags', 'r+') |
|
303 | fp = self.opener('localtags', 'r+') | |
304 | except IOError: |
|
304 | except IOError: | |
305 | fp = self.opener('localtags', 'a') |
|
305 | fp = self.opener('localtags', 'a') | |
306 | else: |
|
306 | else: | |
307 | prevtags = fp.read() |
|
307 | prevtags = fp.read() | |
308 |
|
308 | |||
309 | # local tags are stored in the current charset |
|
309 | # local tags are stored in the current charset | |
310 | writetags(fp, names, None, prevtags) |
|
310 | writetags(fp, names, None, prevtags) | |
311 | for name in names: |
|
311 | for name in names: | |
312 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
312 | self.hook('tag', node=hex(node), tag=name, local=local) | |
313 | return |
|
313 | return | |
314 |
|
314 | |||
315 | try: |
|
315 | try: | |
316 | fp = self.wfile('.hgtags', 'rb+') |
|
316 | fp = self.wfile('.hgtags', 'rb+') | |
317 | except IOError, e: |
|
317 | except IOError, e: | |
318 | if e.errno != errno.ENOENT: |
|
318 | if e.errno != errno.ENOENT: | |
319 | raise |
|
319 | raise | |
320 | fp = self.wfile('.hgtags', 'ab') |
|
320 | fp = self.wfile('.hgtags', 'ab') | |
321 | else: |
|
321 | else: | |
322 | prevtags = fp.read() |
|
322 | prevtags = fp.read() | |
323 |
|
323 | |||
324 | # committed tags are stored in UTF-8 |
|
324 | # committed tags are stored in UTF-8 | |
325 | writetags(fp, names, encoding.fromlocal, prevtags) |
|
325 | writetags(fp, names, encoding.fromlocal, prevtags) | |
326 |
|
326 | |||
327 | fp.close() |
|
327 | fp.close() | |
328 |
|
328 | |||
329 | self.invalidatecaches() |
|
329 | self.invalidatecaches() | |
330 |
|
330 | |||
331 | if '.hgtags' not in self.dirstate: |
|
331 | if '.hgtags' not in self.dirstate: | |
332 | self[None].add(['.hgtags']) |
|
332 | self[None].add(['.hgtags']) | |
333 |
|
333 | |||
334 | m = matchmod.exact(self.root, '', ['.hgtags']) |
|
334 | m = matchmod.exact(self.root, '', ['.hgtags']) | |
335 | tagnode = self.commit(message, user, date, extra=extra, match=m) |
|
335 | tagnode = self.commit(message, user, date, extra=extra, match=m) | |
336 |
|
336 | |||
337 | for name in names: |
|
337 | for name in names: | |
338 | self.hook('tag', node=hex(node), tag=name, local=local) |
|
338 | self.hook('tag', node=hex(node), tag=name, local=local) | |
339 |
|
339 | |||
340 | return tagnode |
|
340 | return tagnode | |
341 |
|
341 | |||
342 | def tag(self, names, node, message, local, user, date): |
|
342 | def tag(self, names, node, message, local, user, date): | |
343 | '''tag a revision with one or more symbolic names. |
|
343 | '''tag a revision with one or more symbolic names. | |
344 |
|
344 | |||
345 | names is a list of strings or, when adding a single tag, names may be a |
|
345 | names is a list of strings or, when adding a single tag, names may be a | |
346 | string. |
|
346 | string. | |
347 |
|
347 | |||
348 | if local is True, the tags are stored in a per-repository file. |
|
348 | if local is True, the tags are stored in a per-repository file. | |
349 | otherwise, they are stored in the .hgtags file, and a new |
|
349 | otherwise, they are stored in the .hgtags file, and a new | |
350 | changeset is committed with the change. |
|
350 | changeset is committed with the change. | |
351 |
|
351 | |||
352 | keyword arguments: |
|
352 | keyword arguments: | |
353 |
|
353 | |||
354 | local: whether to store tags in non-version-controlled file |
|
354 | local: whether to store tags in non-version-controlled file | |
355 | (default False) |
|
355 | (default False) | |
356 |
|
356 | |||
357 | message: commit message to use if committing |
|
357 | message: commit message to use if committing | |
358 |
|
358 | |||
359 | user: name of user to use if committing |
|
359 | user: name of user to use if committing | |
360 |
|
360 | |||
361 | date: date tuple to use if committing''' |
|
361 | date: date tuple to use if committing''' | |
362 |
|
362 | |||
363 | if not local: |
|
363 | if not local: | |
364 | for x in self.status()[:5]: |
|
364 | for x in self.status()[:5]: | |
365 | if '.hgtags' in x: |
|
365 | if '.hgtags' in x: | |
366 | raise util.Abort(_('working copy of .hgtags is changed ' |
|
366 | raise util.Abort(_('working copy of .hgtags is changed ' | |
367 | '(please commit .hgtags manually)')) |
|
367 | '(please commit .hgtags manually)')) | |
368 |
|
368 | |||
369 | self.tags() # instantiate the cache |
|
369 | self.tags() # instantiate the cache | |
370 | self._tag(names, node, message, local, user, date) |
|
370 | self._tag(names, node, message, local, user, date) | |
371 |
|
371 | |||
372 | @propertycache |
|
372 | @propertycache | |
373 | def _tagscache(self): |
|
373 | def _tagscache(self): | |
374 | '''Returns a tagscache object that contains various tags related caches.''' |
|
374 | '''Returns a tagscache object that contains various tags related caches.''' | |
375 |
|
375 | |||
376 | # This simplifies its cache management by having one decorated |
|
376 | # This simplifies its cache management by having one decorated | |
377 | # function (this one) and the rest simply fetch things from it. |
|
377 | # function (this one) and the rest simply fetch things from it. | |
378 | class tagscache(object): |
|
378 | class tagscache(object): | |
379 | def __init__(self): |
|
379 | def __init__(self): | |
380 | # These two define the set of tags for this repository. tags |
|
380 | # These two define the set of tags for this repository. tags | |
381 | # maps tag name to node; tagtypes maps tag name to 'global' or |
|
381 | # maps tag name to node; tagtypes maps tag name to 'global' or | |
382 | # 'local'. (Global tags are defined by .hgtags across all |
|
382 | # 'local'. (Global tags are defined by .hgtags across all | |
383 | # heads, and local tags are defined in .hg/localtags.) |
|
383 | # heads, and local tags are defined in .hg/localtags.) | |
384 | # They constitute the in-memory cache of tags. |
|
384 | # They constitute the in-memory cache of tags. | |
385 | self.tags = self.tagtypes = None |
|
385 | self.tags = self.tagtypes = None | |
386 |
|
386 | |||
387 | self.nodetagscache = self.tagslist = None |
|
387 | self.nodetagscache = self.tagslist = None | |
388 |
|
388 | |||
389 | cache = tagscache() |
|
389 | cache = tagscache() | |
390 | cache.tags, cache.tagtypes = self._findtags() |
|
390 | cache.tags, cache.tagtypes = self._findtags() | |
391 |
|
391 | |||
392 | return cache |
|
392 | return cache | |
393 |
|
393 | |||
394 | def tags(self): |
|
394 | def tags(self): | |
395 | '''return a mapping of tag to node''' |
|
395 | '''return a mapping of tag to node''' | |
396 | return self._tagscache.tags |
|
396 | return self._tagscache.tags | |
397 |
|
397 | |||
398 | def _findtags(self): |
|
398 | def _findtags(self): | |
399 | '''Do the hard work of finding tags. Return a pair of dicts |
|
399 | '''Do the hard work of finding tags. Return a pair of dicts | |
400 | (tags, tagtypes) where tags maps tag name to node, and tagtypes |
|
400 | (tags, tagtypes) where tags maps tag name to node, and tagtypes | |
401 | maps tag name to a string like \'global\' or \'local\'. |
|
401 | maps tag name to a string like \'global\' or \'local\'. | |
402 | Subclasses or extensions are free to add their own tags, but |
|
402 | Subclasses or extensions are free to add their own tags, but | |
403 | should be aware that the returned dicts will be retained for the |
|
403 | should be aware that the returned dicts will be retained for the | |
404 | duration of the localrepo object.''' |
|
404 | duration of the localrepo object.''' | |
405 |
|
405 | |||
406 | # XXX what tagtype should subclasses/extensions use? Currently |
|
406 | # XXX what tagtype should subclasses/extensions use? Currently | |
407 | # mq and bookmarks add tags, but do not set the tagtype at all. |
|
407 | # mq and bookmarks add tags, but do not set the tagtype at all. | |
408 | # Should each extension invent its own tag type? Should there |
|
408 | # Should each extension invent its own tag type? Should there | |
409 | # be one tagtype for all such "virtual" tags? Or is the status |
|
409 | # be one tagtype for all such "virtual" tags? Or is the status | |
410 | # quo fine? |
|
410 | # quo fine? | |
411 |
|
411 | |||
412 | alltags = {} # map tag name to (node, hist) |
|
412 | alltags = {} # map tag name to (node, hist) | |
413 | tagtypes = {} |
|
413 | tagtypes = {} | |
414 |
|
414 | |||
415 | tagsmod.findglobaltags(self.ui, self, alltags, tagtypes) |
|
415 | tagsmod.findglobaltags(self.ui, self, alltags, tagtypes) | |
416 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) |
|
416 | tagsmod.readlocaltags(self.ui, self, alltags, tagtypes) | |
417 |
|
417 | |||
418 | # Build the return dicts. Have to re-encode tag names because |
|
418 | # Build the return dicts. Have to re-encode tag names because | |
419 | # the tags module always uses UTF-8 (in order not to lose info |
|
419 | # the tags module always uses UTF-8 (in order not to lose info | |
420 | # writing to the cache), but the rest of Mercurial wants them in |
|
420 | # writing to the cache), but the rest of Mercurial wants them in | |
421 | # local encoding. |
|
421 | # local encoding. | |
422 | tags = {} |
|
422 | tags = {} | |
423 | for (name, (node, hist)) in alltags.iteritems(): |
|
423 | for (name, (node, hist)) in alltags.iteritems(): | |
424 | if node != nullid: |
|
424 | if node != nullid: | |
425 | try: |
|
425 | try: | |
426 | # ignore tags to unknown nodes |
|
426 | # ignore tags to unknown nodes | |
427 | self.changelog.lookup(node) |
|
427 | self.changelog.lookup(node) | |
428 | tags[encoding.tolocal(name)] = node |
|
428 | tags[encoding.tolocal(name)] = node | |
429 | except error.LookupError: |
|
429 | except error.LookupError: | |
430 | pass |
|
430 | pass | |
431 | tags['tip'] = self.changelog.tip() |
|
431 | tags['tip'] = self.changelog.tip() | |
432 | tagtypes = dict([(encoding.tolocal(name), value) |
|
432 | tagtypes = dict([(encoding.tolocal(name), value) | |
433 | for (name, value) in tagtypes.iteritems()]) |
|
433 | for (name, value) in tagtypes.iteritems()]) | |
434 | return (tags, tagtypes) |
|
434 | return (tags, tagtypes) | |
435 |
|
435 | |||
436 | def tagtype(self, tagname): |
|
436 | def tagtype(self, tagname): | |
437 | ''' |
|
437 | ''' | |
438 | return the type of the given tag. result can be: |
|
438 | return the type of the given tag. result can be: | |
439 |
|
439 | |||
440 | 'local' : a local tag |
|
440 | 'local' : a local tag | |
441 | 'global' : a global tag |
|
441 | 'global' : a global tag | |
442 | None : tag does not exist |
|
442 | None : tag does not exist | |
443 | ''' |
|
443 | ''' | |
444 |
|
444 | |||
445 | return self._tagscache.tagtypes.get(tagname) |
|
445 | return self._tagscache.tagtypes.get(tagname) | |
446 |
|
446 | |||
447 | def tagslist(self): |
|
447 | def tagslist(self): | |
448 | '''return a list of tags ordered by revision''' |
|
448 | '''return a list of tags ordered by revision''' | |
449 | if not self._tagscache.tagslist: |
|
449 | if not self._tagscache.tagslist: | |
450 | l = [] |
|
450 | l = [] | |
451 | for t, n in self.tags().iteritems(): |
|
451 | for t, n in self.tags().iteritems(): | |
452 | r = self.changelog.rev(n) |
|
452 | r = self.changelog.rev(n) | |
453 | l.append((r, t, n)) |
|
453 | l.append((r, t, n)) | |
454 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] |
|
454 | self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)] | |
455 |
|
455 | |||
456 | return self._tagscache.tagslist |
|
456 | return self._tagscache.tagslist | |
457 |
|
457 | |||
458 | def nodetags(self, node): |
|
458 | def nodetags(self, node): | |
459 | '''return the tags associated with a node''' |
|
459 | '''return the tags associated with a node''' | |
460 | if not self._tagscache.nodetagscache: |
|
460 | if not self._tagscache.nodetagscache: | |
461 | nodetagscache = {} |
|
461 | nodetagscache = {} | |
462 | for t, n in self.tags().iteritems(): |
|
462 | for t, n in self.tags().iteritems(): | |
463 | nodetagscache.setdefault(n, []).append(t) |
|
463 | nodetagscache.setdefault(n, []).append(t) | |
464 | for tags in nodetagscache.itervalues(): |
|
464 | for tags in nodetagscache.itervalues(): | |
465 | tags.sort() |
|
465 | tags.sort() | |
466 | self._tagscache.nodetagscache = nodetagscache |
|
466 | self._tagscache.nodetagscache = nodetagscache | |
467 | return self._tagscache.nodetagscache.get(node, []) |
|
467 | return self._tagscache.nodetagscache.get(node, []) | |
468 |
|
468 | |||
469 | def nodebookmarks(self, node): |
|
469 | def nodebookmarks(self, node): | |
470 | marks = [] |
|
470 | marks = [] | |
471 | for bookmark, n in self._bookmarks.iteritems(): |
|
471 | for bookmark, n in self._bookmarks.iteritems(): | |
472 | if n == node: |
|
472 | if n == node: | |
473 | marks.append(bookmark) |
|
473 | marks.append(bookmark) | |
474 | return sorted(marks) |
|
474 | return sorted(marks) | |
475 |
|
475 | |||
476 | def _branchtags(self, partial, lrev): |
|
476 | def _branchtags(self, partial, lrev): | |
477 | # TODO: rename this function? |
|
477 | # TODO: rename this function? | |
478 | tiprev = len(self) - 1 |
|
478 | tiprev = len(self) - 1 | |
479 | if lrev != tiprev: |
|
479 | if lrev != tiprev: | |
480 | ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1)) |
|
480 | ctxgen = (self[r] for r in xrange(lrev + 1, tiprev + 1)) | |
481 | self._updatebranchcache(partial, ctxgen) |
|
481 | self._updatebranchcache(partial, ctxgen) | |
482 | self._writebranchcache(partial, self.changelog.tip(), tiprev) |
|
482 | self._writebranchcache(partial, self.changelog.tip(), tiprev) | |
483 |
|
483 | |||
484 | return partial |
|
484 | return partial | |
485 |
|
485 | |||
486 | def updatebranchcache(self): |
|
486 | def updatebranchcache(self): | |
487 | tip = self.changelog.tip() |
|
487 | tip = self.changelog.tip() | |
488 | if self._branchcache is not None and self._branchcachetip == tip: |
|
488 | if self._branchcache is not None and self._branchcachetip == tip: | |
489 | return |
|
489 | return | |
490 |
|
490 | |||
491 | oldtip = self._branchcachetip |
|
491 | oldtip = self._branchcachetip | |
492 | self._branchcachetip = tip |
|
492 | self._branchcachetip = tip | |
493 | if oldtip is None or oldtip not in self.changelog.nodemap: |
|
493 | if oldtip is None or oldtip not in self.changelog.nodemap: | |
494 | partial, last, lrev = self._readbranchcache() |
|
494 | partial, last, lrev = self._readbranchcache() | |
495 | else: |
|
495 | else: | |
496 | lrev = self.changelog.rev(oldtip) |
|
496 | lrev = self.changelog.rev(oldtip) | |
497 | partial = self._branchcache |
|
497 | partial = self._branchcache | |
498 |
|
498 | |||
499 | self._branchtags(partial, lrev) |
|
499 | self._branchtags(partial, lrev) | |
500 | # this private cache holds all heads (not just tips) |
|
500 | # this private cache holds all heads (not just tips) | |
501 | self._branchcache = partial |
|
501 | self._branchcache = partial | |
502 |
|
502 | |||
503 | def branchmap(self): |
|
503 | def branchmap(self): | |
504 | '''returns a dictionary {branch: [branchheads]}''' |
|
504 | '''returns a dictionary {branch: [branchheads]}''' | |
505 | self.updatebranchcache() |
|
505 | self.updatebranchcache() | |
506 | return self._branchcache |
|
506 | return self._branchcache | |
507 |
|
507 | |||
508 | def branchtags(self): |
|
508 | def branchtags(self): | |
509 | '''return a dict where branch names map to the tipmost head of |
|
509 | '''return a dict where branch names map to the tipmost head of | |
510 | the branch, open heads come before closed''' |
|
510 | the branch, open heads come before closed''' | |
511 | bt = {} |
|
511 | bt = {} | |
512 | for bn, heads in self.branchmap().iteritems(): |
|
512 | for bn, heads in self.branchmap().iteritems(): | |
513 | tip = heads[-1] |
|
513 | tip = heads[-1] | |
514 | for h in reversed(heads): |
|
514 | for h in reversed(heads): | |
515 | if 'close' not in self.changelog.read(h)[5]: |
|
515 | if 'close' not in self.changelog.read(h)[5]: | |
516 | tip = h |
|
516 | tip = h | |
517 | break |
|
517 | break | |
518 | bt[bn] = tip |
|
518 | bt[bn] = tip | |
519 | return bt |
|
519 | return bt | |
520 |
|
520 | |||
521 | def _readbranchcache(self): |
|
521 | def _readbranchcache(self): | |
522 | partial = {} |
|
522 | partial = {} | |
523 | try: |
|
523 | try: | |
524 | f = self.opener("cache/branchheads") |
|
524 | f = self.opener("cache/branchheads") | |
525 | lines = f.read().split('\n') |
|
525 | lines = f.read().split('\n') | |
526 | f.close() |
|
526 | f.close() | |
527 | except (IOError, OSError): |
|
527 | except (IOError, OSError): | |
528 | return {}, nullid, nullrev |
|
528 | return {}, nullid, nullrev | |
529 |
|
529 | |||
530 | try: |
|
530 | try: | |
531 | last, lrev = lines.pop(0).split(" ", 1) |
|
531 | last, lrev = lines.pop(0).split(" ", 1) | |
532 | last, lrev = bin(last), int(lrev) |
|
532 | last, lrev = bin(last), int(lrev) | |
533 | if lrev >= len(self) or self[lrev].node() != last: |
|
533 | if lrev >= len(self) or self[lrev].node() != last: | |
534 | # invalidate the cache |
|
534 | # invalidate the cache | |
535 | raise ValueError('invalidating branch cache (tip differs)') |
|
535 | raise ValueError('invalidating branch cache (tip differs)') | |
536 | for l in lines: |
|
536 | for l in lines: | |
537 | if not l: |
|
537 | if not l: | |
538 | continue |
|
538 | continue | |
539 | node, label = l.split(" ", 1) |
|
539 | node, label = l.split(" ", 1) | |
540 | label = encoding.tolocal(label.strip()) |
|
540 | label = encoding.tolocal(label.strip()) | |
541 | partial.setdefault(label, []).append(bin(node)) |
|
541 | partial.setdefault(label, []).append(bin(node)) | |
542 | except KeyboardInterrupt: |
|
542 | except KeyboardInterrupt: | |
543 | raise |
|
543 | raise | |
544 | except Exception, inst: |
|
544 | except Exception, inst: | |
545 | if self.ui.debugflag: |
|
545 | if self.ui.debugflag: | |
546 | self.ui.warn(str(inst), '\n') |
|
546 | self.ui.warn(str(inst), '\n') | |
547 | partial, last, lrev = {}, nullid, nullrev |
|
547 | partial, last, lrev = {}, nullid, nullrev | |
548 | return partial, last, lrev |
|
548 | return partial, last, lrev | |
549 |
|
549 | |||
550 | def _writebranchcache(self, branches, tip, tiprev): |
|
550 | def _writebranchcache(self, branches, tip, tiprev): | |
551 | try: |
|
551 | try: | |
552 | f = self.opener("cache/branchheads", "w", atomictemp=True) |
|
552 | f = self.opener("cache/branchheads", "w", atomictemp=True) | |
553 | f.write("%s %s\n" % (hex(tip), tiprev)) |
|
553 | f.write("%s %s\n" % (hex(tip), tiprev)) | |
554 | for label, nodes in branches.iteritems(): |
|
554 | for label, nodes in branches.iteritems(): | |
555 | for node in nodes: |
|
555 | for node in nodes: | |
556 | f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) |
|
556 | f.write("%s %s\n" % (hex(node), encoding.fromlocal(label))) | |
557 | f.close() |
|
557 | f.close() | |
558 | except (IOError, OSError): |
|
558 | except (IOError, OSError): | |
559 | pass |
|
559 | pass | |
560 |
|
560 | |||
561 | def _updatebranchcache(self, partial, ctxgen): |
|
561 | def _updatebranchcache(self, partial, ctxgen): | |
562 | # collect new branch entries |
|
562 | # collect new branch entries | |
563 | newbranches = {} |
|
563 | newbranches = {} | |
564 | for c in ctxgen: |
|
564 | for c in ctxgen: | |
565 | newbranches.setdefault(c.branch(), []).append(c.node()) |
|
565 | newbranches.setdefault(c.branch(), []).append(c.node()) | |
566 | # if older branchheads are reachable from new ones, they aren't |
|
566 | # if older branchheads are reachable from new ones, they aren't | |
567 | # really branchheads. Note checking parents is insufficient: |
|
567 | # really branchheads. Note checking parents is insufficient: | |
568 | # 1 (branch a) -> 2 (branch b) -> 3 (branch a) |
|
568 | # 1 (branch a) -> 2 (branch b) -> 3 (branch a) | |
569 | for branch, newnodes in newbranches.iteritems(): |
|
569 | for branch, newnodes in newbranches.iteritems(): | |
570 | bheads = partial.setdefault(branch, []) |
|
570 | bheads = partial.setdefault(branch, []) | |
571 | bheads.extend(newnodes) |
|
571 | bheads.extend(newnodes) | |
572 | if len(bheads) <= 1: |
|
572 | if len(bheads) <= 1: | |
573 | continue |
|
573 | continue | |
574 | bheads = sorted(bheads, key=lambda x: self[x].rev()) |
|
574 | bheads = sorted(bheads, key=lambda x: self[x].rev()) | |
575 | # starting from tip means fewer passes over reachable |
|
575 | # starting from tip means fewer passes over reachable | |
576 | while newnodes: |
|
576 | while newnodes: | |
577 | latest = newnodes.pop() |
|
577 | latest = newnodes.pop() | |
578 | if latest not in bheads: |
|
578 | if latest not in bheads: | |
579 | continue |
|
579 | continue | |
580 | minbhrev = self[bheads[0]].node() |
|
580 | minbhrev = self[bheads[0]].node() | |
581 | reachable = self.changelog.reachable(latest, minbhrev) |
|
581 | reachable = self.changelog.reachable(latest, minbhrev) | |
582 | reachable.remove(latest) |
|
582 | reachable.remove(latest) | |
583 | if reachable: |
|
583 | if reachable: | |
584 | bheads = [b for b in bheads if b not in reachable] |
|
584 | bheads = [b for b in bheads if b not in reachable] | |
585 | partial[branch] = bheads |
|
585 | partial[branch] = bheads | |
586 |
|
586 | |||
587 | def lookup(self, key): |
|
587 | def lookup(self, key): | |
588 | if isinstance(key, int): |
|
588 | if isinstance(key, int): | |
589 | return self.changelog.node(key) |
|
589 | return self.changelog.node(key) | |
590 | elif key == '.': |
|
590 | elif key == '.': | |
591 | return self.dirstate.p1() |
|
591 | return self.dirstate.p1() | |
592 | elif key == 'null': |
|
592 | elif key == 'null': | |
593 | return nullid |
|
593 | return nullid | |
594 | elif key == 'tip': |
|
594 | elif key == 'tip': | |
595 | return self.changelog.tip() |
|
595 | return self.changelog.tip() | |
596 | n = self.changelog._match(key) |
|
596 | n = self.changelog._match(key) | |
597 | if n: |
|
597 | if n: | |
598 | return n |
|
598 | return n | |
599 | if key in self._bookmarks: |
|
599 | if key in self._bookmarks: | |
600 | return self._bookmarks[key] |
|
600 | return self._bookmarks[key] | |
601 | if key in self.tags(): |
|
601 | if key in self.tags(): | |
602 | return self.tags()[key] |
|
602 | return self.tags()[key] | |
603 | if key in self.branchtags(): |
|
603 | if key in self.branchtags(): | |
604 | return self.branchtags()[key] |
|
604 | return self.branchtags()[key] | |
605 | n = self.changelog._partialmatch(key) |
|
605 | n = self.changelog._partialmatch(key) | |
606 | if n: |
|
606 | if n: | |
607 | return n |
|
607 | return n | |
608 |
|
608 | |||
609 | # can't find key, check if it might have come from damaged dirstate |
|
609 | # can't find key, check if it might have come from damaged dirstate | |
610 | if key in self.dirstate.parents(): |
|
610 | if key in self.dirstate.parents(): | |
611 | raise error.Abort(_("working directory has unknown parent '%s'!") |
|
611 | raise error.Abort(_("working directory has unknown parent '%s'!") | |
612 | % short(key)) |
|
612 | % short(key)) | |
613 | try: |
|
613 | try: | |
614 | if len(key) == 20: |
|
614 | if len(key) == 20: | |
615 | key = hex(key) |
|
615 | key = hex(key) | |
616 | except TypeError: |
|
616 | except TypeError: | |
617 | pass |
|
617 | pass | |
618 | raise error.RepoLookupError(_("unknown revision '%s'") % key) |
|
618 | raise error.RepoLookupError(_("unknown revision '%s'") % key) | |
619 |
|
619 | |||
620 | def lookupbranch(self, key, remote=None): |
|
620 | def lookupbranch(self, key, remote=None): | |
621 | repo = remote or self |
|
621 | repo = remote or self | |
622 | if key in repo.branchmap(): |
|
622 | if key in repo.branchmap(): | |
623 | return key |
|
623 | return key | |
624 |
|
624 | |||
625 | repo = (remote and remote.local()) and remote or self |
|
625 | repo = (remote and remote.local()) and remote or self | |
626 | return repo[key].branch() |
|
626 | return repo[key].branch() | |
627 |
|
627 | |||
628 | def known(self, nodes): |
|
628 | def known(self, nodes): | |
629 | nm = self.changelog.nodemap |
|
629 | nm = self.changelog.nodemap | |
630 | result = [] |
|
630 | result = [] | |
631 | for n in nodes: |
|
631 | for n in nodes: | |
632 | r = nm.get(n) |
|
632 | r = nm.get(n) | |
633 | resp = not (r is None or self._phaserev[r] >= phases.secret) |
|
633 | resp = not (r is None or self._phaserev[r] >= phases.secret) | |
634 | result.append(resp) |
|
634 | result.append(resp) | |
635 | return result |
|
635 | return result | |
636 |
|
636 | |||
637 | def local(self): |
|
637 | def local(self): | |
638 | return self |
|
638 | return self | |
639 |
|
639 | |||
640 | def cancopy(self): |
|
640 | def cancopy(self): | |
641 | return (repo.repository.cancopy(self) |
|
641 | return (repo.repository.cancopy(self) | |
642 | and not self._phaseroots[phases.secret]) |
|
642 | and not self._phaseroots[phases.secret]) | |
643 |
|
643 | |||
644 | def join(self, f): |
|
644 | def join(self, f): | |
645 | return os.path.join(self.path, f) |
|
645 | return os.path.join(self.path, f) | |
646 |
|
646 | |||
647 | def wjoin(self, f): |
|
647 | def wjoin(self, f): | |
648 | return os.path.join(self.root, f) |
|
648 | return os.path.join(self.root, f) | |
649 |
|
649 | |||
650 | def file(self, f): |
|
650 | def file(self, f): | |
651 | if f[0] == '/': |
|
651 | if f[0] == '/': | |
652 | f = f[1:] |
|
652 | f = f[1:] | |
653 | return filelog.filelog(self.sopener, f) |
|
653 | return filelog.filelog(self.sopener, f) | |
654 |
|
654 | |||
655 | def changectx(self, changeid): |
|
655 | def changectx(self, changeid): | |
656 | return self[changeid] |
|
656 | return self[changeid] | |
657 |
|
657 | |||
658 | def parents(self, changeid=None): |
|
658 | def parents(self, changeid=None): | |
659 | '''get list of changectxs for parents of changeid''' |
|
659 | '''get list of changectxs for parents of changeid''' | |
660 | return self[changeid].parents() |
|
660 | return self[changeid].parents() | |
661 |
|
661 | |||
662 | def filectx(self, path, changeid=None, fileid=None): |
|
662 | def filectx(self, path, changeid=None, fileid=None): | |
663 | """changeid can be a changeset revision, node, or tag. |
|
663 | """changeid can be a changeset revision, node, or tag. | |
664 | fileid can be a file revision or node.""" |
|
664 | fileid can be a file revision or node.""" | |
665 | return context.filectx(self, path, changeid, fileid) |
|
665 | return context.filectx(self, path, changeid, fileid) | |
666 |
|
666 | |||
667 | def getcwd(self): |
|
667 | def getcwd(self): | |
668 | return self.dirstate.getcwd() |
|
668 | return self.dirstate.getcwd() | |
669 |
|
669 | |||
670 | def pathto(self, f, cwd=None): |
|
670 | def pathto(self, f, cwd=None): | |
671 | return self.dirstate.pathto(f, cwd) |
|
671 | return self.dirstate.pathto(f, cwd) | |
672 |
|
672 | |||
673 | def wfile(self, f, mode='r'): |
|
673 | def wfile(self, f, mode='r'): | |
674 | return self.wopener(f, mode) |
|
674 | return self.wopener(f, mode) | |
675 |
|
675 | |||
676 | def _link(self, f): |
|
676 | def _link(self, f): | |
677 | return os.path.islink(self.wjoin(f)) |
|
677 | return os.path.islink(self.wjoin(f)) | |
678 |
|
678 | |||
679 | def _loadfilter(self, filter): |
|
679 | def _loadfilter(self, filter): | |
680 | if filter not in self.filterpats: |
|
680 | if filter not in self.filterpats: | |
681 | l = [] |
|
681 | l = [] | |
682 | for pat, cmd in self.ui.configitems(filter): |
|
682 | for pat, cmd in self.ui.configitems(filter): | |
683 | if cmd == '!': |
|
683 | if cmd == '!': | |
684 | continue |
|
684 | continue | |
685 | mf = matchmod.match(self.root, '', [pat]) |
|
685 | mf = matchmod.match(self.root, '', [pat]) | |
686 | fn = None |
|
686 | fn = None | |
687 | params = cmd |
|
687 | params = cmd | |
688 | for name, filterfn in self._datafilters.iteritems(): |
|
688 | for name, filterfn in self._datafilters.iteritems(): | |
689 | if cmd.startswith(name): |
|
689 | if cmd.startswith(name): | |
690 | fn = filterfn |
|
690 | fn = filterfn | |
691 | params = cmd[len(name):].lstrip() |
|
691 | params = cmd[len(name):].lstrip() | |
692 | break |
|
692 | break | |
693 | if not fn: |
|
693 | if not fn: | |
694 | fn = lambda s, c, **kwargs: util.filter(s, c) |
|
694 | fn = lambda s, c, **kwargs: util.filter(s, c) | |
695 | # Wrap old filters not supporting keyword arguments |
|
695 | # Wrap old filters not supporting keyword arguments | |
696 | if not inspect.getargspec(fn)[2]: |
|
696 | if not inspect.getargspec(fn)[2]: | |
697 | oldfn = fn |
|
697 | oldfn = fn | |
698 | fn = lambda s, c, **kwargs: oldfn(s, c) |
|
698 | fn = lambda s, c, **kwargs: oldfn(s, c) | |
699 | l.append((mf, fn, params)) |
|
699 | l.append((mf, fn, params)) | |
700 | self.filterpats[filter] = l |
|
700 | self.filterpats[filter] = l | |
701 | return self.filterpats[filter] |
|
701 | return self.filterpats[filter] | |
702 |
|
702 | |||
703 | def _filter(self, filterpats, filename, data): |
|
703 | def _filter(self, filterpats, filename, data): | |
704 | for mf, fn, cmd in filterpats: |
|
704 | for mf, fn, cmd in filterpats: | |
705 | if mf(filename): |
|
705 | if mf(filename): | |
706 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) |
|
706 | self.ui.debug("filtering %s through %s\n" % (filename, cmd)) | |
707 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) |
|
707 | data = fn(data, cmd, ui=self.ui, repo=self, filename=filename) | |
708 | break |
|
708 | break | |
709 |
|
709 | |||
710 | return data |
|
710 | return data | |
711 |
|
711 | |||
712 | @propertycache |
|
712 | @propertycache | |
713 | def _encodefilterpats(self): |
|
713 | def _encodefilterpats(self): | |
714 | return self._loadfilter('encode') |
|
714 | return self._loadfilter('encode') | |
715 |
|
715 | |||
716 | @propertycache |
|
716 | @propertycache | |
717 | def _decodefilterpats(self): |
|
717 | def _decodefilterpats(self): | |
718 | return self._loadfilter('decode') |
|
718 | return self._loadfilter('decode') | |
719 |
|
719 | |||
720 | def adddatafilter(self, name, filter): |
|
720 | def adddatafilter(self, name, filter): | |
721 | self._datafilters[name] = filter |
|
721 | self._datafilters[name] = filter | |
722 |
|
722 | |||
723 | def wread(self, filename): |
|
723 | def wread(self, filename): | |
724 | if self._link(filename): |
|
724 | if self._link(filename): | |
725 | data = os.readlink(self.wjoin(filename)) |
|
725 | data = os.readlink(self.wjoin(filename)) | |
726 | else: |
|
726 | else: | |
727 | data = self.wopener.read(filename) |
|
727 | data = self.wopener.read(filename) | |
728 | return self._filter(self._encodefilterpats, filename, data) |
|
728 | return self._filter(self._encodefilterpats, filename, data) | |
729 |
|
729 | |||
730 | def wwrite(self, filename, data, flags): |
|
730 | def wwrite(self, filename, data, flags): | |
731 | data = self._filter(self._decodefilterpats, filename, data) |
|
731 | data = self._filter(self._decodefilterpats, filename, data) | |
732 | if 'l' in flags: |
|
732 | if 'l' in flags: | |
733 | self.wopener.symlink(data, filename) |
|
733 | self.wopener.symlink(data, filename) | |
734 | else: |
|
734 | else: | |
735 | self.wopener.write(filename, data) |
|
735 | self.wopener.write(filename, data) | |
736 | if 'x' in flags: |
|
736 | if 'x' in flags: | |
737 | util.setflags(self.wjoin(filename), False, True) |
|
737 | util.setflags(self.wjoin(filename), False, True) | |
738 |
|
738 | |||
739 | def wwritedata(self, filename, data): |
|
739 | def wwritedata(self, filename, data): | |
740 | return self._filter(self._decodefilterpats, filename, data) |
|
740 | return self._filter(self._decodefilterpats, filename, data) | |
741 |
|
741 | |||
742 | def transaction(self, desc): |
|
742 | def transaction(self, desc): | |
743 | tr = self._transref and self._transref() or None |
|
743 | tr = self._transref and self._transref() or None | |
744 | if tr and tr.running(): |
|
744 | if tr and tr.running(): | |
745 | return tr.nest() |
|
745 | return tr.nest() | |
746 |
|
746 | |||
747 | # abort here if the journal already exists |
|
747 | # abort here if the journal already exists | |
748 | if os.path.exists(self.sjoin("journal")): |
|
748 | if os.path.exists(self.sjoin("journal")): | |
749 | raise error.RepoError( |
|
749 | raise error.RepoError( | |
750 | _("abandoned transaction found - run hg recover")) |
|
750 | _("abandoned transaction found - run hg recover")) | |
751 |
|
751 | |||
752 | journalfiles = self._writejournal(desc) |
|
752 | journalfiles = self._writejournal(desc) | |
753 | renames = [(x, undoname(x)) for x in journalfiles] |
|
753 | renames = [(x, undoname(x)) for x in journalfiles] | |
754 |
|
754 | |||
755 | tr = transaction.transaction(self.ui.warn, self.sopener, |
|
755 | tr = transaction.transaction(self.ui.warn, self.sopener, | |
756 | self.sjoin("journal"), |
|
756 | self.sjoin("journal"), | |
757 | aftertrans(renames), |
|
757 | aftertrans(renames), | |
758 | self.store.createmode) |
|
758 | self.store.createmode) | |
759 | self._transref = weakref.ref(tr) |
|
759 | self._transref = weakref.ref(tr) | |
760 | return tr |
|
760 | return tr | |
761 |
|
761 | |||
762 | def _writejournal(self, desc): |
|
762 | def _writejournal(self, desc): | |
763 | # save dirstate for rollback |
|
763 | # save dirstate for rollback | |
764 | try: |
|
764 | try: | |
765 | ds = self.opener.read("dirstate") |
|
765 | ds = self.opener.read("dirstate") | |
766 | except IOError: |
|
766 | except IOError: | |
767 | ds = "" |
|
767 | ds = "" | |
768 | self.opener.write("journal.dirstate", ds) |
|
768 | self.opener.write("journal.dirstate", ds) | |
769 | self.opener.write("journal.branch", |
|
769 | self.opener.write("journal.branch", | |
770 | encoding.fromlocal(self.dirstate.branch())) |
|
770 | encoding.fromlocal(self.dirstate.branch())) | |
771 | self.opener.write("journal.desc", |
|
771 | self.opener.write("journal.desc", | |
772 | "%d\n%s\n" % (len(self), desc)) |
|
772 | "%d\n%s\n" % (len(self), desc)) | |
773 |
|
773 | |||
774 | bkname = self.join('bookmarks') |
|
774 | bkname = self.join('bookmarks') | |
775 | if os.path.exists(bkname): |
|
775 | if os.path.exists(bkname): | |
776 | util.copyfile(bkname, self.join('journal.bookmarks')) |
|
776 | util.copyfile(bkname, self.join('journal.bookmarks')) | |
777 | else: |
|
777 | else: | |
778 | self.opener.write('journal.bookmarks', '') |
|
778 | self.opener.write('journal.bookmarks', '') | |
779 | phasesname = self.sjoin('phaseroots') |
|
779 | phasesname = self.sjoin('phaseroots') | |
780 | if os.path.exists(phasesname): |
|
780 | if os.path.exists(phasesname): | |
781 | util.copyfile(phasesname, self.sjoin('journal.phaseroots')) |
|
781 | util.copyfile(phasesname, self.sjoin('journal.phaseroots')) | |
782 | else: |
|
782 | else: | |
783 | self.sopener.write('journal.phaseroots', '') |
|
783 | self.sopener.write('journal.phaseroots', '') | |
784 |
|
784 | |||
785 | return (self.sjoin('journal'), self.join('journal.dirstate'), |
|
785 | return (self.sjoin('journal'), self.join('journal.dirstate'), | |
786 | self.join('journal.branch'), self.join('journal.desc'), |
|
786 | self.join('journal.branch'), self.join('journal.desc'), | |
787 | self.join('journal.bookmarks'), |
|
787 | self.join('journal.bookmarks'), | |
788 | self.sjoin('journal.phaseroots')) |
|
788 | self.sjoin('journal.phaseroots')) | |
789 |
|
789 | |||
790 | def recover(self): |
|
790 | def recover(self): | |
791 | lock = self.lock() |
|
791 | lock = self.lock() | |
792 | try: |
|
792 | try: | |
793 | if os.path.exists(self.sjoin("journal")): |
|
793 | if os.path.exists(self.sjoin("journal")): | |
794 | self.ui.status(_("rolling back interrupted transaction\n")) |
|
794 | self.ui.status(_("rolling back interrupted transaction\n")) | |
795 | transaction.rollback(self.sopener, self.sjoin("journal"), |
|
795 | transaction.rollback(self.sopener, self.sjoin("journal"), | |
796 | self.ui.warn) |
|
796 | self.ui.warn) | |
797 | self.invalidate() |
|
797 | self.invalidate() | |
798 | return True |
|
798 | return True | |
799 | else: |
|
799 | else: | |
800 | self.ui.warn(_("no interrupted transaction available\n")) |
|
800 | self.ui.warn(_("no interrupted transaction available\n")) | |
801 | return False |
|
801 | return False | |
802 | finally: |
|
802 | finally: | |
803 | lock.release() |
|
803 | lock.release() | |
804 |
|
804 | |||
805 | def rollback(self, dryrun=False, force=False): |
|
805 | def rollback(self, dryrun=False, force=False): | |
806 | wlock = lock = None |
|
806 | wlock = lock = None | |
807 | try: |
|
807 | try: | |
808 | wlock = self.wlock() |
|
808 | wlock = self.wlock() | |
809 | lock = self.lock() |
|
809 | lock = self.lock() | |
810 | if os.path.exists(self.sjoin("undo")): |
|
810 | if os.path.exists(self.sjoin("undo")): | |
811 | return self._rollback(dryrun, force) |
|
811 | return self._rollback(dryrun, force) | |
812 | else: |
|
812 | else: | |
813 | self.ui.warn(_("no rollback information available\n")) |
|
813 | self.ui.warn(_("no rollback information available\n")) | |
814 | return 1 |
|
814 | return 1 | |
815 | finally: |
|
815 | finally: | |
816 | release(lock, wlock) |
|
816 | release(lock, wlock) | |
817 |
|
817 | |||
818 | def _rollback(self, dryrun, force): |
|
818 | def _rollback(self, dryrun, force): | |
819 | ui = self.ui |
|
819 | ui = self.ui | |
820 | try: |
|
820 | try: | |
821 | args = self.opener.read('undo.desc').splitlines() |
|
821 | args = self.opener.read('undo.desc').splitlines() | |
822 | (oldlen, desc, detail) = (int(args[0]), args[1], None) |
|
822 | (oldlen, desc, detail) = (int(args[0]), args[1], None) | |
823 | if len(args) >= 3: |
|
823 | if len(args) >= 3: | |
824 | detail = args[2] |
|
824 | detail = args[2] | |
825 | oldtip = oldlen - 1 |
|
825 | oldtip = oldlen - 1 | |
826 |
|
826 | |||
827 | if detail and ui.verbose: |
|
827 | if detail and ui.verbose: | |
828 | msg = (_('repository tip rolled back to revision %s' |
|
828 | msg = (_('repository tip rolled back to revision %s' | |
829 | ' (undo %s: %s)\n') |
|
829 | ' (undo %s: %s)\n') | |
830 | % (oldtip, desc, detail)) |
|
830 | % (oldtip, desc, detail)) | |
831 | else: |
|
831 | else: | |
832 | msg = (_('repository tip rolled back to revision %s' |
|
832 | msg = (_('repository tip rolled back to revision %s' | |
833 | ' (undo %s)\n') |
|
833 | ' (undo %s)\n') | |
834 | % (oldtip, desc)) |
|
834 | % (oldtip, desc)) | |
835 | except IOError: |
|
835 | except IOError: | |
836 | msg = _('rolling back unknown transaction\n') |
|
836 | msg = _('rolling back unknown transaction\n') | |
837 | desc = None |
|
837 | desc = None | |
838 |
|
838 | |||
839 | if not force and self['.'] != self['tip'] and desc == 'commit': |
|
839 | if not force and self['.'] != self['tip'] and desc == 'commit': | |
840 | raise util.Abort( |
|
840 | raise util.Abort( | |
841 | _('rollback of last commit while not checked out ' |
|
841 | _('rollback of last commit while not checked out ' | |
842 | 'may lose data'), hint=_('use -f to force')) |
|
842 | 'may lose data'), hint=_('use -f to force')) | |
843 |
|
843 | |||
844 | ui.status(msg) |
|
844 | ui.status(msg) | |
845 | if dryrun: |
|
845 | if dryrun: | |
846 | return 0 |
|
846 | return 0 | |
847 |
|
847 | |||
848 | parents = self.dirstate.parents() |
|
848 | parents = self.dirstate.parents() | |
849 | transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn) |
|
849 | transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn) | |
850 | if os.path.exists(self.join('undo.bookmarks')): |
|
850 | if os.path.exists(self.join('undo.bookmarks')): | |
851 | util.rename(self.join('undo.bookmarks'), |
|
851 | util.rename(self.join('undo.bookmarks'), | |
852 | self.join('bookmarks')) |
|
852 | self.join('bookmarks')) | |
853 | if os.path.exists(self.sjoin('undo.phaseroots')): |
|
853 | if os.path.exists(self.sjoin('undo.phaseroots')): | |
854 | util.rename(self.sjoin('undo.phaseroots'), |
|
854 | util.rename(self.sjoin('undo.phaseroots'), | |
855 | self.sjoin('phaseroots')) |
|
855 | self.sjoin('phaseroots')) | |
856 | self.invalidate() |
|
856 | self.invalidate() | |
857 |
|
857 | |||
858 | parentgone = (parents[0] not in self.changelog.nodemap or |
|
858 | parentgone = (parents[0] not in self.changelog.nodemap or | |
859 | parents[1] not in self.changelog.nodemap) |
|
859 | parents[1] not in self.changelog.nodemap) | |
860 | if parentgone: |
|
860 | if parentgone: | |
861 | util.rename(self.join('undo.dirstate'), self.join('dirstate')) |
|
861 | util.rename(self.join('undo.dirstate'), self.join('dirstate')) | |
862 | try: |
|
862 | try: | |
863 | branch = self.opener.read('undo.branch') |
|
863 | branch = self.opener.read('undo.branch') | |
864 | self.dirstate.setbranch(branch) |
|
864 | self.dirstate.setbranch(branch) | |
865 | except IOError: |
|
865 | except IOError: | |
866 | ui.warn(_('named branch could not be reset: ' |
|
866 | ui.warn(_('named branch could not be reset: ' | |
867 | 'current branch is still \'%s\'\n') |
|
867 | 'current branch is still \'%s\'\n') | |
868 | % self.dirstate.branch()) |
|
868 | % self.dirstate.branch()) | |
869 |
|
869 | |||
870 | self.dirstate.invalidate() |
|
870 | self.dirstate.invalidate() | |
871 | parents = tuple([p.rev() for p in self.parents()]) |
|
871 | parents = tuple([p.rev() for p in self.parents()]) | |
872 | if len(parents) > 1: |
|
872 | if len(parents) > 1: | |
873 | ui.status(_('working directory now based on ' |
|
873 | ui.status(_('working directory now based on ' | |
874 | 'revisions %d and %d\n') % parents) |
|
874 | 'revisions %d and %d\n') % parents) | |
875 | else: |
|
875 | else: | |
876 | ui.status(_('working directory now based on ' |
|
876 | ui.status(_('working directory now based on ' | |
877 | 'revision %d\n') % parents) |
|
877 | 'revision %d\n') % parents) | |
878 | self.destroyed() |
|
878 | self.destroyed() | |
879 | return 0 |
|
879 | return 0 | |
880 |
|
880 | |||
881 | def invalidatecaches(self): |
|
881 | def invalidatecaches(self): | |
882 | try: |
|
882 | try: | |
883 | delattr(self, '_tagscache') |
|
883 | delattr(self, '_tagscache') | |
884 | except AttributeError: |
|
884 | except AttributeError: | |
885 | pass |
|
885 | pass | |
886 |
|
886 | |||
887 | self._branchcache = None # in UTF-8 |
|
887 | self._branchcache = None # in UTF-8 | |
888 | self._branchcachetip = None |
|
888 | self._branchcachetip = None | |
889 |
|
889 | |||
890 | def invalidatedirstate(self): |
|
890 | def invalidatedirstate(self): | |
891 | '''Invalidates the dirstate, causing the next call to dirstate |
|
891 | '''Invalidates the dirstate, causing the next call to dirstate | |
892 | to check if it was modified since the last time it was read, |
|
892 | to check if it was modified since the last time it was read, | |
893 | rereading it if it has. |
|
893 | rereading it if it has. | |
894 |
|
894 | |||
895 | This is different to dirstate.invalidate() that it doesn't always |
|
895 | This is different to dirstate.invalidate() that it doesn't always | |
896 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
896 | rereads the dirstate. Use dirstate.invalidate() if you want to | |
897 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
897 | explicitly read the dirstate again (i.e. restoring it to a previous | |
898 | known good state).''' |
|
898 | known good state).''' | |
899 | try: |
|
899 | try: | |
900 | delattr(self, 'dirstate') |
|
900 | delattr(self, 'dirstate') | |
901 | except AttributeError: |
|
901 | except AttributeError: | |
902 | pass |
|
902 | pass | |
903 |
|
903 | |||
904 | def invalidate(self): |
|
904 | def invalidate(self): | |
905 | for k in self._filecache: |
|
905 | for k in self._filecache: | |
906 | # dirstate is invalidated separately in invalidatedirstate() |
|
906 | # dirstate is invalidated separately in invalidatedirstate() | |
907 | if k == 'dirstate': |
|
907 | if k == 'dirstate': | |
908 | continue |
|
908 | continue | |
909 |
|
909 | |||
910 | try: |
|
910 | try: | |
911 | delattr(self, k) |
|
911 | delattr(self, k) | |
912 | except AttributeError: |
|
912 | except AttributeError: | |
913 | pass |
|
913 | pass | |
914 | self.invalidatecaches() |
|
914 | self.invalidatecaches() | |
915 |
|
915 | |||
916 | def _lock(self, lockname, wait, releasefn, acquirefn, desc): |
|
916 | def _lock(self, lockname, wait, releasefn, acquirefn, desc): | |
917 | try: |
|
917 | try: | |
918 | l = lock.lock(lockname, 0, releasefn, desc=desc) |
|
918 | l = lock.lock(lockname, 0, releasefn, desc=desc) | |
919 | except error.LockHeld, inst: |
|
919 | except error.LockHeld, inst: | |
920 | if not wait: |
|
920 | if not wait: | |
921 | raise |
|
921 | raise | |
922 | self.ui.warn(_("waiting for lock on %s held by %r\n") % |
|
922 | self.ui.warn(_("waiting for lock on %s held by %r\n") % | |
923 | (desc, inst.locker)) |
|
923 | (desc, inst.locker)) | |
924 | # default to 600 seconds timeout |
|
924 | # default to 600 seconds timeout | |
925 | l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")), |
|
925 | l = lock.lock(lockname, int(self.ui.config("ui", "timeout", "600")), | |
926 | releasefn, desc=desc) |
|
926 | releasefn, desc=desc) | |
927 | if acquirefn: |
|
927 | if acquirefn: | |
928 | acquirefn() |
|
928 | acquirefn() | |
929 | return l |
|
929 | return l | |
930 |
|
930 | |||
931 | def _afterlock(self, callback): |
|
931 | def _afterlock(self, callback): | |
932 | """add a callback to the current repository lock. |
|
932 | """add a callback to the current repository lock. | |
933 |
|
933 | |||
934 | The callback will be executed on lock release.""" |
|
934 | The callback will be executed on lock release.""" | |
935 | l = self._lockref and self._lockref() |
|
935 | l = self._lockref and self._lockref() | |
936 | if l: |
|
936 | if l: | |
937 | l.postrelease.append(callback) |
|
937 | l.postrelease.append(callback) | |
938 |
|
938 | |||
939 | def lock(self, wait=True): |
|
939 | def lock(self, wait=True): | |
940 | '''Lock the repository store (.hg/store) and return a weak reference |
|
940 | '''Lock the repository store (.hg/store) and return a weak reference | |
941 | to the lock. Use this before modifying the store (e.g. committing or |
|
941 | to the lock. Use this before modifying the store (e.g. committing or | |
942 | stripping). If you are opening a transaction, get a lock as well.)''' |
|
942 | stripping). If you are opening a transaction, get a lock as well.)''' | |
943 | l = self._lockref and self._lockref() |
|
943 | l = self._lockref and self._lockref() | |
944 | if l is not None and l.held: |
|
944 | if l is not None and l.held: | |
945 | l.lock() |
|
945 | l.lock() | |
946 | return l |
|
946 | return l | |
947 |
|
947 | |||
948 | def unlock(): |
|
948 | def unlock(): | |
949 | self.store.write() |
|
949 | self.store.write() | |
950 | if self._dirtyphases: |
|
950 | if self._dirtyphases: | |
951 | phases.writeroots(self) |
|
951 | phases.writeroots(self) | |
952 | for k, ce in self._filecache.items(): |
|
952 | for k, ce in self._filecache.items(): | |
953 | if k == 'dirstate': |
|
953 | if k == 'dirstate': | |
954 | continue |
|
954 | continue | |
955 | ce.refresh() |
|
955 | ce.refresh() | |
956 |
|
956 | |||
957 | l = self._lock(self.sjoin("lock"), wait, unlock, |
|
957 | l = self._lock(self.sjoin("lock"), wait, unlock, | |
958 | self.invalidate, _('repository %s') % self.origroot) |
|
958 | self.invalidate, _('repository %s') % self.origroot) | |
959 | self._lockref = weakref.ref(l) |
|
959 | self._lockref = weakref.ref(l) | |
960 | return l |
|
960 | return l | |
961 |
|
961 | |||
962 | def wlock(self, wait=True): |
|
962 | def wlock(self, wait=True): | |
963 | '''Lock the non-store parts of the repository (everything under |
|
963 | '''Lock the non-store parts of the repository (everything under | |
964 | .hg except .hg/store) and return a weak reference to the lock. |
|
964 | .hg except .hg/store) and return a weak reference to the lock. | |
965 | Use this before modifying files in .hg.''' |
|
965 | Use this before modifying files in .hg.''' | |
966 | l = self._wlockref and self._wlockref() |
|
966 | l = self._wlockref and self._wlockref() | |
967 | if l is not None and l.held: |
|
967 | if l is not None and l.held: | |
968 | l.lock() |
|
968 | l.lock() | |
969 | return l |
|
969 | return l | |
970 |
|
970 | |||
971 | def unlock(): |
|
971 | def unlock(): | |
972 | self.dirstate.write() |
|
972 | self.dirstate.write() | |
973 | ce = self._filecache.get('dirstate') |
|
973 | ce = self._filecache.get('dirstate') | |
974 | if ce: |
|
974 | if ce: | |
975 | ce.refresh() |
|
975 | ce.refresh() | |
976 |
|
976 | |||
977 | l = self._lock(self.join("wlock"), wait, unlock, |
|
977 | l = self._lock(self.join("wlock"), wait, unlock, | |
978 | self.invalidatedirstate, _('working directory of %s') % |
|
978 | self.invalidatedirstate, _('working directory of %s') % | |
979 | self.origroot) |
|
979 | self.origroot) | |
980 | self._wlockref = weakref.ref(l) |
|
980 | self._wlockref = weakref.ref(l) | |
981 | return l |
|
981 | return l | |
982 |
|
982 | |||
983 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
|
983 | def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | |
984 | """ |
|
984 | """ | |
985 | commit an individual file as part of a larger transaction |
|
985 | commit an individual file as part of a larger transaction | |
986 | """ |
|
986 | """ | |
987 |
|
987 | |||
988 | fname = fctx.path() |
|
988 | fname = fctx.path() | |
989 | text = fctx.data() |
|
989 | text = fctx.data() | |
990 | flog = self.file(fname) |
|
990 | flog = self.file(fname) | |
991 | fparent1 = manifest1.get(fname, nullid) |
|
991 | fparent1 = manifest1.get(fname, nullid) | |
992 | fparent2 = fparent2o = manifest2.get(fname, nullid) |
|
992 | fparent2 = fparent2o = manifest2.get(fname, nullid) | |
993 |
|
993 | |||
994 | meta = {} |
|
994 | meta = {} | |
995 | copy = fctx.renamed() |
|
995 | copy = fctx.renamed() | |
996 | if copy and copy[0] != fname: |
|
996 | if copy and copy[0] != fname: | |
997 | # Mark the new revision of this file as a copy of another |
|
997 | # Mark the new revision of this file as a copy of another | |
998 | # file. This copy data will effectively act as a parent |
|
998 | # file. This copy data will effectively act as a parent | |
999 | # of this new revision. If this is a merge, the first |
|
999 | # of this new revision. If this is a merge, the first | |
1000 | # parent will be the nullid (meaning "look up the copy data") |
|
1000 | # parent will be the nullid (meaning "look up the copy data") | |
1001 | # and the second one will be the other parent. For example: |
|
1001 | # and the second one will be the other parent. For example: | |
1002 | # |
|
1002 | # | |
1003 | # 0 --- 1 --- 3 rev1 changes file foo |
|
1003 | # 0 --- 1 --- 3 rev1 changes file foo | |
1004 | # \ / rev2 renames foo to bar and changes it |
|
1004 | # \ / rev2 renames foo to bar and changes it | |
1005 | # \- 2 -/ rev3 should have bar with all changes and |
|
1005 | # \- 2 -/ rev3 should have bar with all changes and | |
1006 | # should record that bar descends from |
|
1006 | # should record that bar descends from | |
1007 | # bar in rev2 and foo in rev1 |
|
1007 | # bar in rev2 and foo in rev1 | |
1008 | # |
|
1008 | # | |
1009 | # this allows this merge to succeed: |
|
1009 | # this allows this merge to succeed: | |
1010 | # |
|
1010 | # | |
1011 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
|
1011 | # 0 --- 1 --- 3 rev4 reverts the content change from rev2 | |
1012 | # \ / merging rev3 and rev4 should use bar@rev2 |
|
1012 | # \ / merging rev3 and rev4 should use bar@rev2 | |
1013 | # \- 2 --- 4 as the merge base |
|
1013 | # \- 2 --- 4 as the merge base | |
1014 | # |
|
1014 | # | |
1015 |
|
1015 | |||
1016 | cfname = copy[0] |
|
1016 | cfname = copy[0] | |
1017 | crev = manifest1.get(cfname) |
|
1017 | crev = manifest1.get(cfname) | |
1018 | newfparent = fparent2 |
|
1018 | newfparent = fparent2 | |
1019 |
|
1019 | |||
1020 | if manifest2: # branch merge |
|
1020 | if manifest2: # branch merge | |
1021 | if fparent2 == nullid or crev is None: # copied on remote side |
|
1021 | if fparent2 == nullid or crev is None: # copied on remote side | |
1022 | if cfname in manifest2: |
|
1022 | if cfname in manifest2: | |
1023 | crev = manifest2[cfname] |
|
1023 | crev = manifest2[cfname] | |
1024 | newfparent = fparent1 |
|
1024 | newfparent = fparent1 | |
1025 |
|
1025 | |||
1026 | # find source in nearest ancestor if we've lost track |
|
1026 | # find source in nearest ancestor if we've lost track | |
1027 | if not crev: |
|
1027 | if not crev: | |
1028 | self.ui.debug(" %s: searching for copy revision for %s\n" % |
|
1028 | self.ui.debug(" %s: searching for copy revision for %s\n" % | |
1029 | (fname, cfname)) |
|
1029 | (fname, cfname)) | |
1030 | for ancestor in self[None].ancestors(): |
|
1030 | for ancestor in self[None].ancestors(): | |
1031 | if cfname in ancestor: |
|
1031 | if cfname in ancestor: | |
1032 | crev = ancestor[cfname].filenode() |
|
1032 | crev = ancestor[cfname].filenode() | |
1033 | break |
|
1033 | break | |
1034 |
|
1034 | |||
1035 | if crev: |
|
1035 | if crev: | |
1036 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) |
|
1036 | self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev))) | |
1037 | meta["copy"] = cfname |
|
1037 | meta["copy"] = cfname | |
1038 | meta["copyrev"] = hex(crev) |
|
1038 | meta["copyrev"] = hex(crev) | |
1039 | fparent1, fparent2 = nullid, newfparent |
|
1039 | fparent1, fparent2 = nullid, newfparent | |
1040 | else: |
|
1040 | else: | |
1041 | self.ui.warn(_("warning: can't find ancestor for '%s' " |
|
1041 | self.ui.warn(_("warning: can't find ancestor for '%s' " | |
1042 | "copied from '%s'!\n") % (fname, cfname)) |
|
1042 | "copied from '%s'!\n") % (fname, cfname)) | |
1043 |
|
1043 | |||
1044 | elif fparent2 != nullid: |
|
1044 | elif fparent2 != nullid: | |
1045 | # is one parent an ancestor of the other? |
|
1045 | # is one parent an ancestor of the other? | |
1046 | fparentancestor = flog.ancestor(fparent1, fparent2) |
|
1046 | fparentancestor = flog.ancestor(fparent1, fparent2) | |
1047 | if fparentancestor == fparent1: |
|
1047 | if fparentancestor == fparent1: | |
1048 | fparent1, fparent2 = fparent2, nullid |
|
1048 | fparent1, fparent2 = fparent2, nullid | |
1049 | elif fparentancestor == fparent2: |
|
1049 | elif fparentancestor == fparent2: | |
1050 | fparent2 = nullid |
|
1050 | fparent2 = nullid | |
1051 |
|
1051 | |||
1052 | # is the file changed? |
|
1052 | # is the file changed? | |
1053 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
|
1053 | if fparent2 != nullid or flog.cmp(fparent1, text) or meta: | |
1054 | changelist.append(fname) |
|
1054 | changelist.append(fname) | |
1055 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
|
1055 | return flog.add(text, meta, tr, linkrev, fparent1, fparent2) | |
1056 |
|
1056 | |||
1057 | # are just the flags changed during merge? |
|
1057 | # are just the flags changed during merge? | |
1058 | if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags(): |
|
1058 | if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags(): | |
1059 | changelist.append(fname) |
|
1059 | changelist.append(fname) | |
1060 |
|
1060 | |||
1061 | return fparent1 |
|
1061 | return fparent1 | |
1062 |
|
1062 | |||
1063 | def commit(self, text="", user=None, date=None, match=None, force=False, |
|
1063 | def commit(self, text="", user=None, date=None, match=None, force=False, | |
1064 | editor=False, extra={}): |
|
1064 | editor=False, extra={}): | |
1065 | """Add a new revision to current repository. |
|
1065 | """Add a new revision to current repository. | |
1066 |
|
1066 | |||
1067 | Revision information is gathered from the working directory, |
|
1067 | Revision information is gathered from the working directory, | |
1068 | match can be used to filter the committed files. If editor is |
|
1068 | match can be used to filter the committed files. If editor is | |
1069 | supplied, it is called to get a commit message. |
|
1069 | supplied, it is called to get a commit message. | |
1070 | """ |
|
1070 | """ | |
1071 |
|
1071 | |||
1072 | def fail(f, msg): |
|
1072 | def fail(f, msg): | |
1073 | raise util.Abort('%s: %s' % (f, msg)) |
|
1073 | raise util.Abort('%s: %s' % (f, msg)) | |
1074 |
|
1074 | |||
1075 | if not match: |
|
1075 | if not match: | |
1076 | match = matchmod.always(self.root, '') |
|
1076 | match = matchmod.always(self.root, '') | |
1077 |
|
1077 | |||
1078 | if not force: |
|
1078 | if not force: | |
1079 | vdirs = [] |
|
1079 | vdirs = [] | |
1080 | match.dir = vdirs.append |
|
1080 | match.dir = vdirs.append | |
1081 | match.bad = fail |
|
1081 | match.bad = fail | |
1082 |
|
1082 | |||
1083 | wlock = self.wlock() |
|
1083 | wlock = self.wlock() | |
1084 | try: |
|
1084 | try: | |
1085 | wctx = self[None] |
|
1085 | wctx = self[None] | |
1086 | merge = len(wctx.parents()) > 1 |
|
1086 | merge = len(wctx.parents()) > 1 | |
1087 |
|
1087 | |||
1088 | if (not force and merge and match and |
|
1088 | if (not force and merge and match and | |
1089 | (match.files() or match.anypats())): |
|
1089 | (match.files() or match.anypats())): | |
1090 | raise util.Abort(_('cannot partially commit a merge ' |
|
1090 | raise util.Abort(_('cannot partially commit a merge ' | |
1091 | '(do not specify files or patterns)')) |
|
1091 | '(do not specify files or patterns)')) | |
1092 |
|
1092 | |||
1093 | changes = self.status(match=match, clean=force) |
|
1093 | changes = self.status(match=match, clean=force) | |
1094 | if force: |
|
1094 | if force: | |
1095 | changes[0].extend(changes[6]) # mq may commit unchanged files |
|
1095 | changes[0].extend(changes[6]) # mq may commit unchanged files | |
1096 |
|
1096 | |||
1097 | # check subrepos |
|
1097 | # check subrepos | |
1098 | subs = [] |
|
1098 | subs = [] | |
1099 | removedsubs = set() |
|
1099 | removedsubs = set() | |
1100 | if '.hgsub' in wctx: |
|
1100 | if '.hgsub' in wctx: | |
1101 | # only manage subrepos and .hgsubstate if .hgsub is present |
|
1101 | # only manage subrepos and .hgsubstate if .hgsub is present | |
1102 | for p in wctx.parents(): |
|
1102 | for p in wctx.parents(): | |
1103 | removedsubs.update(s for s in p.substate if match(s)) |
|
1103 | removedsubs.update(s for s in p.substate if match(s)) | |
1104 | for s in wctx.substate: |
|
1104 | for s in wctx.substate: | |
1105 | removedsubs.discard(s) |
|
1105 | removedsubs.discard(s) | |
1106 | if match(s) and wctx.sub(s).dirty(): |
|
1106 | if match(s) and wctx.sub(s).dirty(): | |
1107 | subs.append(s) |
|
1107 | subs.append(s) | |
1108 | if (subs or removedsubs): |
|
1108 | if (subs or removedsubs): | |
1109 | if (not match('.hgsub') and |
|
1109 | if (not match('.hgsub') and | |
1110 | '.hgsub' in (wctx.modified() + wctx.added())): |
|
1110 | '.hgsub' in (wctx.modified() + wctx.added())): | |
1111 | raise util.Abort( |
|
1111 | raise util.Abort( | |
1112 | _("can't commit subrepos without .hgsub")) |
|
1112 | _("can't commit subrepos without .hgsub")) | |
1113 | if '.hgsubstate' not in changes[0]: |
|
1113 | if '.hgsubstate' not in changes[0]: | |
1114 | changes[0].insert(0, '.hgsubstate') |
|
1114 | changes[0].insert(0, '.hgsubstate') | |
1115 | if '.hgsubstate' in changes[2]: |
|
1115 | if '.hgsubstate' in changes[2]: | |
1116 | changes[2].remove('.hgsubstate') |
|
1116 | changes[2].remove('.hgsubstate') | |
1117 | elif '.hgsub' in changes[2]: |
|
1117 | elif '.hgsub' in changes[2]: | |
1118 | # clean up .hgsubstate when .hgsub is removed |
|
1118 | # clean up .hgsubstate when .hgsub is removed | |
1119 | if ('.hgsubstate' in wctx and |
|
1119 | if ('.hgsubstate' in wctx and | |
1120 | '.hgsubstate' not in changes[0] + changes[1] + changes[2]): |
|
1120 | '.hgsubstate' not in changes[0] + changes[1] + changes[2]): | |
1121 | changes[2].insert(0, '.hgsubstate') |
|
1121 | changes[2].insert(0, '.hgsubstate') | |
1122 |
|
1122 | |||
1123 | if subs and not self.ui.configbool('ui', 'commitsubrepos', False): |
|
1123 | if subs and not self.ui.configbool('ui', 'commitsubrepos', False): | |
1124 | changedsubs = [s for s in subs if wctx.sub(s).dirty(True)] |
|
1124 | changedsubs = [s for s in subs if wctx.sub(s).dirty(True)] | |
1125 | if changedsubs: |
|
1125 | if changedsubs: | |
1126 | raise util.Abort(_("uncommitted changes in subrepo %s") |
|
1126 | raise util.Abort(_("uncommitted changes in subrepo %s") | |
1127 | % changedsubs[0], |
|
1127 | % changedsubs[0], | |
1128 | hint=_("use --subrepos for recursive commit")) |
|
1128 | hint=_("use --subrepos for recursive commit")) | |
1129 |
|
1129 | |||
1130 | # make sure all explicit patterns are matched |
|
1130 | # make sure all explicit patterns are matched | |
1131 | if not force and match.files(): |
|
1131 | if not force and match.files(): | |
1132 | matched = set(changes[0] + changes[1] + changes[2]) |
|
1132 | matched = set(changes[0] + changes[1] + changes[2]) | |
1133 |
|
1133 | |||
1134 | for f in match.files(): |
|
1134 | for f in match.files(): | |
1135 | if f == '.' or f in matched or f in wctx.substate: |
|
1135 | if f == '.' or f in matched or f in wctx.substate: | |
1136 | continue |
|
1136 | continue | |
1137 | if f in changes[3]: # missing |
|
1137 | if f in changes[3]: # missing | |
1138 | fail(f, _('file not found!')) |
|
1138 | fail(f, _('file not found!')) | |
1139 | if f in vdirs: # visited directory |
|
1139 | if f in vdirs: # visited directory | |
1140 | d = f + '/' |
|
1140 | d = f + '/' | |
1141 | for mf in matched: |
|
1141 | for mf in matched: | |
1142 | if mf.startswith(d): |
|
1142 | if mf.startswith(d): | |
1143 | break |
|
1143 | break | |
1144 | else: |
|
1144 | else: | |
1145 | fail(f, _("no match under directory!")) |
|
1145 | fail(f, _("no match under directory!")) | |
1146 | elif f not in self.dirstate: |
|
1146 | elif f not in self.dirstate: | |
1147 | fail(f, _("file not tracked!")) |
|
1147 | fail(f, _("file not tracked!")) | |
1148 |
|
1148 | |||
1149 | if (not force and not extra.get("close") and not merge |
|
1149 | if (not force and not extra.get("close") and not merge | |
1150 | and not (changes[0] or changes[1] or changes[2]) |
|
1150 | and not (changes[0] or changes[1] or changes[2]) | |
1151 | and wctx.branch() == wctx.p1().branch()): |
|
1151 | and wctx.branch() == wctx.p1().branch()): | |
1152 | return None |
|
1152 | return None | |
1153 |
|
1153 | |||
1154 | ms = mergemod.mergestate(self) |
|
1154 | ms = mergemod.mergestate(self) | |
1155 | for f in changes[0]: |
|
1155 | for f in changes[0]: | |
1156 | if f in ms and ms[f] == 'u': |
|
1156 | if f in ms and ms[f] == 'u': | |
1157 | raise util.Abort(_("unresolved merge conflicts " |
|
1157 | raise util.Abort(_("unresolved merge conflicts " | |
1158 | "(see hg help resolve)")) |
|
1158 | "(see hg help resolve)")) | |
1159 |
|
1159 | |||
1160 | cctx = context.workingctx(self, text, user, date, extra, changes) |
|
1160 | cctx = context.workingctx(self, text, user, date, extra, changes) | |
1161 | if editor: |
|
1161 | if editor: | |
1162 | cctx._text = editor(self, cctx, subs) |
|
1162 | cctx._text = editor(self, cctx, subs) | |
1163 | edited = (text != cctx._text) |
|
1163 | edited = (text != cctx._text) | |
1164 |
|
1164 | |||
1165 | # commit subs |
|
1165 | # commit subs | |
1166 | if subs or removedsubs: |
|
1166 | if subs or removedsubs: | |
1167 | state = wctx.substate.copy() |
|
1167 | state = wctx.substate.copy() | |
1168 | for s in sorted(subs): |
|
1168 | for s in sorted(subs): | |
1169 | sub = wctx.sub(s) |
|
1169 | sub = wctx.sub(s) | |
1170 | self.ui.status(_('committing subrepository %s\n') % |
|
1170 | self.ui.status(_('committing subrepository %s\n') % | |
1171 | subrepo.subrelpath(sub)) |
|
1171 | subrepo.subrelpath(sub)) | |
1172 | sr = sub.commit(cctx._text, user, date) |
|
1172 | sr = sub.commit(cctx._text, user, date) | |
1173 | state[s] = (state[s][0], sr) |
|
1173 | state[s] = (state[s][0], sr) | |
1174 | subrepo.writestate(self, state) |
|
1174 | subrepo.writestate(self, state) | |
1175 |
|
1175 | |||
1176 | # Save commit message in case this transaction gets rolled back |
|
1176 | # Save commit message in case this transaction gets rolled back | |
1177 | # (e.g. by a pretxncommit hook). Leave the content alone on |
|
1177 | # (e.g. by a pretxncommit hook). Leave the content alone on | |
1178 | # the assumption that the user will use the same editor again. |
|
1178 | # the assumption that the user will use the same editor again. | |
1179 | msgfn = self.savecommitmessage(cctx._text) |
|
1179 | msgfn = self.savecommitmessage(cctx._text) | |
1180 |
|
1180 | |||
1181 | p1, p2 = self.dirstate.parents() |
|
1181 | p1, p2 = self.dirstate.parents() | |
1182 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') |
|
1182 | hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '') | |
1183 | try: |
|
1183 | try: | |
1184 | self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) |
|
1184 | self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) | |
1185 | ret = self.commitctx(cctx, True) |
|
1185 | ret = self.commitctx(cctx, True) | |
1186 | except: |
|
1186 | except: | |
1187 | if edited: |
|
1187 | if edited: | |
1188 | self.ui.write( |
|
1188 | self.ui.write( | |
1189 | _('note: commit message saved in %s\n') % msgfn) |
|
1189 | _('note: commit message saved in %s\n') % msgfn) | |
1190 | raise |
|
1190 | raise | |
1191 |
|
1191 | |||
1192 | # update bookmarks, dirstate and mergestate |
|
1192 | # update bookmarks, dirstate and mergestate | |
1193 | bookmarks.update(self, p1, ret) |
|
1193 | bookmarks.update(self, p1, ret) | |
1194 | for f in changes[0] + changes[1]: |
|
1194 | for f in changes[0] + changes[1]: | |
1195 | self.dirstate.normal(f) |
|
1195 | self.dirstate.normal(f) | |
1196 | for f in changes[2]: |
|
1196 | for f in changes[2]: | |
1197 | self.dirstate.drop(f) |
|
1197 | self.dirstate.drop(f) | |
1198 | self.dirstate.setparents(ret) |
|
1198 | self.dirstate.setparents(ret) | |
1199 | ms.reset() |
|
1199 | ms.reset() | |
1200 | finally: |
|
1200 | finally: | |
1201 | wlock.release() |
|
1201 | wlock.release() | |
1202 |
|
1202 | |||
1203 | self.hook("commit", node=hex(ret), parent1=hookp1, parent2=hookp2) |
|
1203 | self.hook("commit", node=hex(ret), parent1=hookp1, parent2=hookp2) | |
1204 | return ret |
|
1204 | return ret | |
1205 |
|
1205 | |||
1206 | def commitctx(self, ctx, error=False): |
|
1206 | def commitctx(self, ctx, error=False): | |
1207 | """Add a new revision to current repository. |
|
1207 | """Add a new revision to current repository. | |
1208 | Revision information is passed via the context argument. |
|
1208 | Revision information is passed via the context argument. | |
1209 | """ |
|
1209 | """ | |
1210 |
|
1210 | |||
1211 | tr = lock = None |
|
1211 | tr = lock = None | |
1212 | removed = list(ctx.removed()) |
|
1212 | removed = list(ctx.removed()) | |
1213 | p1, p2 = ctx.p1(), ctx.p2() |
|
1213 | p1, p2 = ctx.p1(), ctx.p2() | |
1214 | user = ctx.user() |
|
1214 | user = ctx.user() | |
1215 |
|
1215 | |||
1216 | lock = self.lock() |
|
1216 | lock = self.lock() | |
1217 | try: |
|
1217 | try: | |
1218 | tr = self.transaction("commit") |
|
1218 | tr = self.transaction("commit") | |
1219 | trp = weakref.proxy(tr) |
|
1219 | trp = weakref.proxy(tr) | |
1220 |
|
1220 | |||
1221 | if ctx.files(): |
|
1221 | if ctx.files(): | |
1222 | m1 = p1.manifest().copy() |
|
1222 | m1 = p1.manifest().copy() | |
1223 | m2 = p2.manifest() |
|
1223 | m2 = p2.manifest() | |
1224 |
|
1224 | |||
1225 | # check in files |
|
1225 | # check in files | |
1226 | new = {} |
|
1226 | new = {} | |
1227 | changed = [] |
|
1227 | changed = [] | |
1228 | linkrev = len(self) |
|
1228 | linkrev = len(self) | |
1229 | for f in sorted(ctx.modified() + ctx.added()): |
|
1229 | for f in sorted(ctx.modified() + ctx.added()): | |
1230 | self.ui.note(f + "\n") |
|
1230 | self.ui.note(f + "\n") | |
1231 | try: |
|
1231 | try: | |
1232 | fctx = ctx[f] |
|
1232 | fctx = ctx[f] | |
1233 | new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, |
|
1233 | new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, | |
1234 | changed) |
|
1234 | changed) | |
1235 | m1.set(f, fctx.flags()) |
|
1235 | m1.set(f, fctx.flags()) | |
1236 | except OSError, inst: |
|
1236 | except OSError, inst: | |
1237 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1237 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1238 | raise |
|
1238 | raise | |
1239 | except IOError, inst: |
|
1239 | except IOError, inst: | |
1240 | errcode = getattr(inst, 'errno', errno.ENOENT) |
|
1240 | errcode = getattr(inst, 'errno', errno.ENOENT) | |
1241 | if error or errcode and errcode != errno.ENOENT: |
|
1241 | if error or errcode and errcode != errno.ENOENT: | |
1242 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
1242 | self.ui.warn(_("trouble committing %s!\n") % f) | |
1243 | raise |
|
1243 | raise | |
1244 | else: |
|
1244 | else: | |
1245 | removed.append(f) |
|
1245 | removed.append(f) | |
1246 |
|
1246 | |||
1247 | # update manifest |
|
1247 | # update manifest | |
1248 | m1.update(new) |
|
1248 | m1.update(new) | |
1249 | removed = [f for f in sorted(removed) if f in m1 or f in m2] |
|
1249 | removed = [f for f in sorted(removed) if f in m1 or f in m2] | |
1250 | drop = [f for f in removed if f in m1] |
|
1250 | drop = [f for f in removed if f in m1] | |
1251 | for f in drop: |
|
1251 | for f in drop: | |
1252 | del m1[f] |
|
1252 | del m1[f] | |
1253 | mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(), |
|
1253 | mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(), | |
1254 | p2.manifestnode(), (new, drop)) |
|
1254 | p2.manifestnode(), (new, drop)) | |
1255 | files = changed + removed |
|
1255 | files = changed + removed | |
1256 | else: |
|
1256 | else: | |
1257 | mn = p1.manifestnode() |
|
1257 | mn = p1.manifestnode() | |
1258 | files = [] |
|
1258 | files = [] | |
1259 |
|
1259 | |||
1260 | # update changelog |
|
1260 | # update changelog | |
1261 | self.changelog.delayupdate() |
|
1261 | self.changelog.delayupdate() | |
1262 | n = self.changelog.add(mn, files, ctx.description(), |
|
1262 | n = self.changelog.add(mn, files, ctx.description(), | |
1263 | trp, p1.node(), p2.node(), |
|
1263 | trp, p1.node(), p2.node(), | |
1264 | user, ctx.date(), ctx.extra().copy()) |
|
1264 | user, ctx.date(), ctx.extra().copy()) | |
1265 | p = lambda: self.changelog.writepending() and self.root or "" |
|
1265 | p = lambda: self.changelog.writepending() and self.root or "" | |
1266 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' |
|
1266 | xp1, xp2 = p1.hex(), p2 and p2.hex() or '' | |
1267 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
|
1267 | self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, | |
1268 | parent2=xp2, pending=p) |
|
1268 | parent2=xp2, pending=p) | |
1269 | self.changelog.finalize(trp) |
|
1269 | self.changelog.finalize(trp) | |
1270 | # set the new commit is proper phase |
|
1270 | # set the new commit is proper phase | |
1271 | targetphase = self.ui.configint('phases', 'new-commit', |
|
1271 | targetphase = self.ui.configint('phases', 'new-commit', | |
1272 | phases.draft) |
|
1272 | phases.draft) | |
1273 | if targetphase: |
|
1273 | if targetphase: | |
1274 | # retract boundary do not alter parent changeset. |
|
1274 | # retract boundary do not alter parent changeset. | |
1275 | # if a parent have higher the resulting phase will |
|
1275 | # if a parent have higher the resulting phase will | |
1276 | # be compliant anyway |
|
1276 | # be compliant anyway | |
1277 | # |
|
1277 | # | |
1278 | # if minimal phase was 0 we don't need to retract anything |
|
1278 | # if minimal phase was 0 we don't need to retract anything | |
1279 | phases.retractboundary(self, targetphase, [n]) |
|
1279 | phases.retractboundary(self, targetphase, [n]) | |
1280 | tr.close() |
|
1280 | tr.close() | |
1281 | self.updatebranchcache() |
|
1281 | self.updatebranchcache() | |
1282 | return n |
|
1282 | return n | |
1283 | finally: |
|
1283 | finally: | |
1284 | if tr: |
|
1284 | if tr: | |
1285 | tr.release() |
|
1285 | tr.release() | |
1286 | lock.release() |
|
1286 | lock.release() | |
1287 |
|
1287 | |||
1288 | def destroyed(self): |
|
1288 | def destroyed(self): | |
1289 | '''Inform the repository that nodes have been destroyed. |
|
1289 | '''Inform the repository that nodes have been destroyed. | |
1290 | Intended for use by strip and rollback, so there's a common |
|
1290 | Intended for use by strip and rollback, so there's a common | |
1291 | place for anything that has to be done after destroying history.''' |
|
1291 | place for anything that has to be done after destroying history.''' | |
1292 | # XXX it might be nice if we could take the list of destroyed |
|
1292 | # XXX it might be nice if we could take the list of destroyed | |
1293 | # nodes, but I don't see an easy way for rollback() to do that |
|
1293 | # nodes, but I don't see an easy way for rollback() to do that | |
1294 |
|
1294 | |||
1295 | # Ensure the persistent tag cache is updated. Doing it now |
|
1295 | # Ensure the persistent tag cache is updated. Doing it now | |
1296 | # means that the tag cache only has to worry about destroyed |
|
1296 | # means that the tag cache only has to worry about destroyed | |
1297 | # heads immediately after a strip/rollback. That in turn |
|
1297 | # heads immediately after a strip/rollback. That in turn | |
1298 | # guarantees that "cachetip == currenttip" (comparing both rev |
|
1298 | # guarantees that "cachetip == currenttip" (comparing both rev | |
1299 | # and node) always means no nodes have been added or destroyed. |
|
1299 | # and node) always means no nodes have been added or destroyed. | |
1300 |
|
1300 | |||
1301 | # XXX this is suboptimal when qrefresh'ing: we strip the current |
|
1301 | # XXX this is suboptimal when qrefresh'ing: we strip the current | |
1302 | # head, refresh the tag cache, then immediately add a new head. |
|
1302 | # head, refresh the tag cache, then immediately add a new head. | |
1303 | # But I think doing it this way is necessary for the "instant |
|
1303 | # But I think doing it this way is necessary for the "instant | |
1304 | # tag cache retrieval" case to work. |
|
1304 | # tag cache retrieval" case to work. | |
1305 | self.invalidatecaches() |
|
1305 | self.invalidatecaches() | |
1306 |
|
1306 | |||
1307 | def walk(self, match, node=None): |
|
1307 | def walk(self, match, node=None): | |
1308 | ''' |
|
1308 | ''' | |
1309 | walk recursively through the directory tree or a given |
|
1309 | walk recursively through the directory tree or a given | |
1310 | changeset, finding all files matched by the match |
|
1310 | changeset, finding all files matched by the match | |
1311 | function |
|
1311 | function | |
1312 | ''' |
|
1312 | ''' | |
1313 | return self[node].walk(match) |
|
1313 | return self[node].walk(match) | |
1314 |
|
1314 | |||
1315 | def status(self, node1='.', node2=None, match=None, |
|
1315 | def status(self, node1='.', node2=None, match=None, | |
1316 | ignored=False, clean=False, unknown=False, |
|
1316 | ignored=False, clean=False, unknown=False, | |
1317 | listsubrepos=False): |
|
1317 | listsubrepos=False): | |
1318 | """return status of files between two nodes or node and working directory |
|
1318 | """return status of files between two nodes or node and working directory | |
1319 |
|
1319 | |||
1320 | If node1 is None, use the first dirstate parent instead. |
|
1320 | If node1 is None, use the first dirstate parent instead. | |
1321 | If node2 is None, compare node1 with working directory. |
|
1321 | If node2 is None, compare node1 with working directory. | |
1322 | """ |
|
1322 | """ | |
1323 |
|
1323 | |||
1324 | def mfmatches(ctx): |
|
1324 | def mfmatches(ctx): | |
1325 | mf = ctx.manifest().copy() |
|
1325 | mf = ctx.manifest().copy() | |
1326 | for fn in mf.keys(): |
|
1326 | for fn in mf.keys(): | |
1327 | if not match(fn): |
|
1327 | if not match(fn): | |
1328 | del mf[fn] |
|
1328 | del mf[fn] | |
1329 | return mf |
|
1329 | return mf | |
1330 |
|
1330 | |||
1331 | if isinstance(node1, context.changectx): |
|
1331 | if isinstance(node1, context.changectx): | |
1332 | ctx1 = node1 |
|
1332 | ctx1 = node1 | |
1333 | else: |
|
1333 | else: | |
1334 | ctx1 = self[node1] |
|
1334 | ctx1 = self[node1] | |
1335 | if isinstance(node2, context.changectx): |
|
1335 | if isinstance(node2, context.changectx): | |
1336 | ctx2 = node2 |
|
1336 | ctx2 = node2 | |
1337 | else: |
|
1337 | else: | |
1338 | ctx2 = self[node2] |
|
1338 | ctx2 = self[node2] | |
1339 |
|
1339 | |||
1340 | working = ctx2.rev() is None |
|
1340 | working = ctx2.rev() is None | |
1341 | parentworking = working and ctx1 == self['.'] |
|
1341 | parentworking = working and ctx1 == self['.'] | |
1342 | match = match or matchmod.always(self.root, self.getcwd()) |
|
1342 | match = match or matchmod.always(self.root, self.getcwd()) | |
1343 | listignored, listclean, listunknown = ignored, clean, unknown |
|
1343 | listignored, listclean, listunknown = ignored, clean, unknown | |
1344 |
|
1344 | |||
1345 | # load earliest manifest first for caching reasons |
|
1345 | # load earliest manifest first for caching reasons | |
1346 | if not working and ctx2.rev() < ctx1.rev(): |
|
1346 | if not working and ctx2.rev() < ctx1.rev(): | |
1347 | ctx2.manifest() |
|
1347 | ctx2.manifest() | |
1348 |
|
1348 | |||
1349 | if not parentworking: |
|
1349 | if not parentworking: | |
1350 | def bad(f, msg): |
|
1350 | def bad(f, msg): | |
1351 | if f not in ctx1: |
|
1351 | if f not in ctx1: | |
1352 | self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg)) |
|
1352 | self.ui.warn('%s: %s\n' % (self.dirstate.pathto(f), msg)) | |
1353 | match.bad = bad |
|
1353 | match.bad = bad | |
1354 |
|
1354 | |||
1355 | if working: # we need to scan the working dir |
|
1355 | if working: # we need to scan the working dir | |
1356 | subrepos = [] |
|
1356 | subrepos = [] | |
1357 | if '.hgsub' in self.dirstate: |
|
1357 | if '.hgsub' in self.dirstate: | |
1358 | subrepos = ctx2.substate.keys() |
|
1358 | subrepos = ctx2.substate.keys() | |
1359 | s = self.dirstate.status(match, subrepos, listignored, |
|
1359 | s = self.dirstate.status(match, subrepos, listignored, | |
1360 | listclean, listunknown) |
|
1360 | listclean, listunknown) | |
1361 | cmp, modified, added, removed, deleted, unknown, ignored, clean = s |
|
1361 | cmp, modified, added, removed, deleted, unknown, ignored, clean = s | |
1362 |
|
1362 | |||
1363 | # check for any possibly clean files |
|
1363 | # check for any possibly clean files | |
1364 | if parentworking and cmp: |
|
1364 | if parentworking and cmp: | |
1365 | fixup = [] |
|
1365 | fixup = [] | |
1366 | # do a full compare of any files that might have changed |
|
1366 | # do a full compare of any files that might have changed | |
1367 | for f in sorted(cmp): |
|
1367 | for f in sorted(cmp): | |
1368 | if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) |
|
1368 | if (f not in ctx1 or ctx2.flags(f) != ctx1.flags(f) | |
1369 | or ctx1[f].cmp(ctx2[f])): |
|
1369 | or ctx1[f].cmp(ctx2[f])): | |
1370 | modified.append(f) |
|
1370 | modified.append(f) | |
1371 | else: |
|
1371 | else: | |
1372 | fixup.append(f) |
|
1372 | fixup.append(f) | |
1373 |
|
1373 | |||
1374 | # update dirstate for files that are actually clean |
|
1374 | # update dirstate for files that are actually clean | |
1375 | if fixup: |
|
1375 | if fixup: | |
1376 | if listclean: |
|
1376 | if listclean: | |
1377 | clean += fixup |
|
1377 | clean += fixup | |
1378 |
|
1378 | |||
1379 | try: |
|
1379 | try: | |
1380 | # updating the dirstate is optional |
|
1380 | # updating the dirstate is optional | |
1381 | # so we don't wait on the lock |
|
1381 | # so we don't wait on the lock | |
1382 | wlock = self.wlock(False) |
|
1382 | wlock = self.wlock(False) | |
1383 | try: |
|
1383 | try: | |
1384 | for f in fixup: |
|
1384 | for f in fixup: | |
1385 | self.dirstate.normal(f) |
|
1385 | self.dirstate.normal(f) | |
1386 | finally: |
|
1386 | finally: | |
1387 | wlock.release() |
|
1387 | wlock.release() | |
1388 | except error.LockError: |
|
1388 | except error.LockError: | |
1389 | pass |
|
1389 | pass | |
1390 |
|
1390 | |||
1391 | if not parentworking: |
|
1391 | if not parentworking: | |
1392 | mf1 = mfmatches(ctx1) |
|
1392 | mf1 = mfmatches(ctx1) | |
1393 | if working: |
|
1393 | if working: | |
1394 | # we are comparing working dir against non-parent |
|
1394 | # we are comparing working dir against non-parent | |
1395 | # generate a pseudo-manifest for the working dir |
|
1395 | # generate a pseudo-manifest for the working dir | |
1396 | mf2 = mfmatches(self['.']) |
|
1396 | mf2 = mfmatches(self['.']) | |
1397 | for f in cmp + modified + added: |
|
1397 | for f in cmp + modified + added: | |
1398 | mf2[f] = None |
|
1398 | mf2[f] = None | |
1399 | mf2.set(f, ctx2.flags(f)) |
|
1399 | mf2.set(f, ctx2.flags(f)) | |
1400 | for f in removed: |
|
1400 | for f in removed: | |
1401 | if f in mf2: |
|
1401 | if f in mf2: | |
1402 | del mf2[f] |
|
1402 | del mf2[f] | |
1403 | else: |
|
1403 | else: | |
1404 | # we are comparing two revisions |
|
1404 | # we are comparing two revisions | |
1405 | deleted, unknown, ignored = [], [], [] |
|
1405 | deleted, unknown, ignored = [], [], [] | |
1406 | mf2 = mfmatches(ctx2) |
|
1406 | mf2 = mfmatches(ctx2) | |
1407 |
|
1407 | |||
1408 | modified, added, clean = [], [], [] |
|
1408 | modified, added, clean = [], [], [] | |
1409 | for fn in mf2: |
|
1409 | for fn in mf2: | |
1410 | if fn in mf1: |
|
1410 | if fn in mf1: | |
1411 | if (fn not in deleted and |
|
1411 | if (fn not in deleted and | |
1412 | (mf1.flags(fn) != mf2.flags(fn) or |
|
1412 | (mf1.flags(fn) != mf2.flags(fn) or | |
1413 | (mf1[fn] != mf2[fn] and |
|
1413 | (mf1[fn] != mf2[fn] and | |
1414 | (mf2[fn] or ctx1[fn].cmp(ctx2[fn]))))): |
|
1414 | (mf2[fn] or ctx1[fn].cmp(ctx2[fn]))))): | |
1415 | modified.append(fn) |
|
1415 | modified.append(fn) | |
1416 | elif listclean: |
|
1416 | elif listclean: | |
1417 | clean.append(fn) |
|
1417 | clean.append(fn) | |
1418 | del mf1[fn] |
|
1418 | del mf1[fn] | |
1419 | elif fn not in deleted: |
|
1419 | elif fn not in deleted: | |
1420 | added.append(fn) |
|
1420 | added.append(fn) | |
1421 | removed = mf1.keys() |
|
1421 | removed = mf1.keys() | |
1422 |
|
1422 | |||
1423 | if working and modified and not self.dirstate._checklink: |
|
1423 | if working and modified and not self.dirstate._checklink: | |
1424 | # Symlink placeholders may get non-symlink-like contents |
|
1424 | # Symlink placeholders may get non-symlink-like contents | |
1425 | # via user error or dereferencing by NFS or Samba servers, |
|
1425 | # via user error or dereferencing by NFS or Samba servers, | |
1426 | # so we filter out any placeholders that don't look like a |
|
1426 | # so we filter out any placeholders that don't look like a | |
1427 | # symlink |
|
1427 | # symlink | |
1428 | sane = [] |
|
1428 | sane = [] | |
1429 | for f in modified: |
|
1429 | for f in modified: | |
1430 | if ctx2.flags(f) == 'l': |
|
1430 | if ctx2.flags(f) == 'l': | |
1431 | d = ctx2[f].data() |
|
1431 | d = ctx2[f].data() | |
1432 | if len(d) >= 1024 or '\n' in d or util.binary(d): |
|
1432 | if len(d) >= 1024 or '\n' in d or util.binary(d): | |
1433 | self.ui.debug('ignoring suspect symlink placeholder' |
|
1433 | self.ui.debug('ignoring suspect symlink placeholder' | |
1434 | ' "%s"\n' % f) |
|
1434 | ' "%s"\n' % f) | |
1435 | continue |
|
1435 | continue | |
1436 | sane.append(f) |
|
1436 | sane.append(f) | |
1437 | modified = sane |
|
1437 | modified = sane | |
1438 |
|
1438 | |||
1439 | r = modified, added, removed, deleted, unknown, ignored, clean |
|
1439 | r = modified, added, removed, deleted, unknown, ignored, clean | |
1440 |
|
1440 | |||
1441 | if listsubrepos: |
|
1441 | if listsubrepos: | |
1442 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): |
|
1442 | for subpath, sub in subrepo.itersubrepos(ctx1, ctx2): | |
1443 | if working: |
|
1443 | if working: | |
1444 | rev2 = None |
|
1444 | rev2 = None | |
1445 | else: |
|
1445 | else: | |
1446 | rev2 = ctx2.substate[subpath][1] |
|
1446 | rev2 = ctx2.substate[subpath][1] | |
1447 | try: |
|
1447 | try: | |
1448 | submatch = matchmod.narrowmatcher(subpath, match) |
|
1448 | submatch = matchmod.narrowmatcher(subpath, match) | |
1449 | s = sub.status(rev2, match=submatch, ignored=listignored, |
|
1449 | s = sub.status(rev2, match=submatch, ignored=listignored, | |
1450 | clean=listclean, unknown=listunknown, |
|
1450 | clean=listclean, unknown=listunknown, | |
1451 | listsubrepos=True) |
|
1451 | listsubrepos=True) | |
1452 | for rfiles, sfiles in zip(r, s): |
|
1452 | for rfiles, sfiles in zip(r, s): | |
1453 | rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) |
|
1453 | rfiles.extend("%s/%s" % (subpath, f) for f in sfiles) | |
1454 | except error.LookupError: |
|
1454 | except error.LookupError: | |
1455 | self.ui.status(_("skipping missing subrepository: %s\n") |
|
1455 | self.ui.status(_("skipping missing subrepository: %s\n") | |
1456 | % subpath) |
|
1456 | % subpath) | |
1457 |
|
1457 | |||
1458 | for l in r: |
|
1458 | for l in r: | |
1459 | l.sort() |
|
1459 | l.sort() | |
1460 | return r |
|
1460 | return r | |
1461 |
|
1461 | |||
1462 | def heads(self, start=None): |
|
1462 | def heads(self, start=None): | |
1463 | heads = self.changelog.heads(start) |
|
1463 | heads = self.changelog.heads(start) | |
1464 | # sort the output in rev descending order |
|
1464 | # sort the output in rev descending order | |
1465 | return sorted(heads, key=self.changelog.rev, reverse=True) |
|
1465 | return sorted(heads, key=self.changelog.rev, reverse=True) | |
1466 |
|
1466 | |||
1467 | def branchheads(self, branch=None, start=None, closed=False): |
|
1467 | def branchheads(self, branch=None, start=None, closed=False): | |
1468 | '''return a (possibly filtered) list of heads for the given branch |
|
1468 | '''return a (possibly filtered) list of heads for the given branch | |
1469 |
|
1469 | |||
1470 | Heads are returned in topological order, from newest to oldest. |
|
1470 | Heads are returned in topological order, from newest to oldest. | |
1471 | If branch is None, use the dirstate branch. |
|
1471 | If branch is None, use the dirstate branch. | |
1472 | If start is not None, return only heads reachable from start. |
|
1472 | If start is not None, return only heads reachable from start. | |
1473 | If closed is True, return heads that are marked as closed as well. |
|
1473 | If closed is True, return heads that are marked as closed as well. | |
1474 | ''' |
|
1474 | ''' | |
1475 | if branch is None: |
|
1475 | if branch is None: | |
1476 | branch = self[None].branch() |
|
1476 | branch = self[None].branch() | |
1477 | branches = self.branchmap() |
|
1477 | branches = self.branchmap() | |
1478 | if branch not in branches: |
|
1478 | if branch not in branches: | |
1479 | return [] |
|
1479 | return [] | |
1480 | # the cache returns heads ordered lowest to highest |
|
1480 | # the cache returns heads ordered lowest to highest | |
1481 | bheads = list(reversed(branches[branch])) |
|
1481 | bheads = list(reversed(branches[branch])) | |
1482 | if start is not None: |
|
1482 | if start is not None: | |
1483 | # filter out the heads that cannot be reached from startrev |
|
1483 | # filter out the heads that cannot be reached from startrev | |
1484 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) |
|
1484 | fbheads = set(self.changelog.nodesbetween([start], bheads)[2]) | |
1485 | bheads = [h for h in bheads if h in fbheads] |
|
1485 | bheads = [h for h in bheads if h in fbheads] | |
1486 | if not closed: |
|
1486 | if not closed: | |
1487 | bheads = [h for h in bheads if |
|
1487 | bheads = [h for h in bheads if | |
1488 | ('close' not in self.changelog.read(h)[5])] |
|
1488 | ('close' not in self.changelog.read(h)[5])] | |
1489 | return bheads |
|
1489 | return bheads | |
1490 |
|
1490 | |||
1491 | def branches(self, nodes): |
|
1491 | def branches(self, nodes): | |
1492 | if not nodes: |
|
1492 | if not nodes: | |
1493 | nodes = [self.changelog.tip()] |
|
1493 | nodes = [self.changelog.tip()] | |
1494 | b = [] |
|
1494 | b = [] | |
1495 | for n in nodes: |
|
1495 | for n in nodes: | |
1496 | t = n |
|
1496 | t = n | |
1497 | while True: |
|
1497 | while True: | |
1498 | p = self.changelog.parents(n) |
|
1498 | p = self.changelog.parents(n) | |
1499 | if p[1] != nullid or p[0] == nullid: |
|
1499 | if p[1] != nullid or p[0] == nullid: | |
1500 | b.append((t, n, p[0], p[1])) |
|
1500 | b.append((t, n, p[0], p[1])) | |
1501 | break |
|
1501 | break | |
1502 | n = p[0] |
|
1502 | n = p[0] | |
1503 | return b |
|
1503 | return b | |
1504 |
|
1504 | |||
1505 | def between(self, pairs): |
|
1505 | def between(self, pairs): | |
1506 | r = [] |
|
1506 | r = [] | |
1507 |
|
1507 | |||
1508 | for top, bottom in pairs: |
|
1508 | for top, bottom in pairs: | |
1509 | n, l, i = top, [], 0 |
|
1509 | n, l, i = top, [], 0 | |
1510 | f = 1 |
|
1510 | f = 1 | |
1511 |
|
1511 | |||
1512 | while n != bottom and n != nullid: |
|
1512 | while n != bottom and n != nullid: | |
1513 | p = self.changelog.parents(n)[0] |
|
1513 | p = self.changelog.parents(n)[0] | |
1514 | if i == f: |
|
1514 | if i == f: | |
1515 | l.append(n) |
|
1515 | l.append(n) | |
1516 | f = f * 2 |
|
1516 | f = f * 2 | |
1517 | n = p |
|
1517 | n = p | |
1518 | i += 1 |
|
1518 | i += 1 | |
1519 |
|
1519 | |||
1520 | r.append(l) |
|
1520 | r.append(l) | |
1521 |
|
1521 | |||
1522 | return r |
|
1522 | return r | |
1523 |
|
1523 | |||
1524 | def pull(self, remote, heads=None, force=False): |
|
1524 | def pull(self, remote, heads=None, force=False): | |
1525 | lock = self.lock() |
|
1525 | lock = self.lock() | |
1526 | try: |
|
1526 | try: | |
1527 | tmp = discovery.findcommonincoming(self, remote, heads=heads, |
|
1527 | tmp = discovery.findcommonincoming(self, remote, heads=heads, | |
1528 | force=force) |
|
1528 | force=force) | |
1529 | common, fetch, rheads = tmp |
|
1529 | common, fetch, rheads = tmp | |
1530 | if not fetch: |
|
1530 | if not fetch: | |
1531 | self.ui.status(_("no changes found\n")) |
|
1531 | self.ui.status(_("no changes found\n")) | |
1532 | added = [] |
|
1532 | added = [] | |
1533 | result = 0 |
|
1533 | result = 0 | |
1534 | else: |
|
1534 | else: | |
1535 | if heads is None and list(common) == [nullid]: |
|
1535 | if heads is None and list(common) == [nullid]: | |
1536 | self.ui.status(_("requesting all changes\n")) |
|
1536 | self.ui.status(_("requesting all changes\n")) | |
1537 | elif heads is None and remote.capable('changegroupsubset'): |
|
1537 | elif heads is None and remote.capable('changegroupsubset'): | |
1538 | # issue1320, avoid a race if remote changed after discovery |
|
1538 | # issue1320, avoid a race if remote changed after discovery | |
1539 | heads = rheads |
|
1539 | heads = rheads | |
1540 |
|
1540 | |||
1541 | if remote.capable('getbundle'): |
|
1541 | if remote.capable('getbundle'): | |
1542 | cg = remote.getbundle('pull', common=common, |
|
1542 | cg = remote.getbundle('pull', common=common, | |
1543 | heads=heads or rheads) |
|
1543 | heads=heads or rheads) | |
1544 | elif heads is None: |
|
1544 | elif heads is None: | |
1545 | cg = remote.changegroup(fetch, 'pull') |
|
1545 | cg = remote.changegroup(fetch, 'pull') | |
1546 | elif not remote.capable('changegroupsubset'): |
|
1546 | elif not remote.capable('changegroupsubset'): | |
1547 | raise util.Abort(_("partial pull cannot be done because " |
|
1547 | raise util.Abort(_("partial pull cannot be done because " | |
1548 | "other repository doesn't support " |
|
1548 | "other repository doesn't support " | |
1549 | "changegroupsubset.")) |
|
1549 | "changegroupsubset.")) | |
1550 | else: |
|
1550 | else: | |
1551 | cg = remote.changegroupsubset(fetch, heads, 'pull') |
|
1551 | cg = remote.changegroupsubset(fetch, heads, 'pull') | |
1552 | clstart = len(self.changelog) |
|
1552 | clstart = len(self.changelog) | |
1553 | result = self.addchangegroup(cg, 'pull', remote.url()) |
|
1553 | result = self.addchangegroup(cg, 'pull', remote.url()) | |
1554 | clend = len(self.changelog) |
|
1554 | clend = len(self.changelog) | |
1555 | added = [self.changelog.node(r) for r in xrange(clstart, clend)] |
|
1555 | added = [self.changelog.node(r) for r in xrange(clstart, clend)] | |
1556 |
|
1556 | |||
1557 |
|
1557 | |||
1558 | # Get remote phases data from remote |
|
1558 | # Get remote phases data from remote | |
1559 | remotephases = remote.listkeys('phases') |
|
1559 | remotephases = remote.listkeys('phases') | |
1560 | publishing = bool(remotephases.get('publishing', False)) |
|
1560 | publishing = bool(remotephases.get('publishing', False)) | |
1561 | if remotephases and not publishing: |
|
1561 | if remotephases and not publishing: | |
1562 | # remote is new and unpublishing |
|
1562 | # remote is new and unpublishing | |
1563 | subset = common + added |
|
1563 | subset = common + added | |
1564 | pheads, _dr = phases.analyzeremotephases(self, subset, |
|
1564 | pheads, _dr = phases.analyzeremotephases(self, subset, | |
1565 | remotephases) |
|
1565 | remotephases) | |
1566 | phases.advanceboundary(self, phases.public, pheads) |
|
1566 | phases.advanceboundary(self, phases.public, pheads) | |
1567 | phases.advanceboundary(self, phases.draft, common + added) |
|
1567 | phases.advanceboundary(self, phases.draft, common + added) | |
1568 | else: |
|
1568 | else: | |
1569 | # Remote is old or publishing all common changesets |
|
1569 | # Remote is old or publishing all common changesets | |
1570 | # should be seen as public |
|
1570 | # should be seen as public | |
1571 | phases.advanceboundary(self, phases.public, common + added) |
|
1571 | phases.advanceboundary(self, phases.public, common + added) | |
1572 | finally: |
|
1572 | finally: | |
1573 | lock.release() |
|
1573 | lock.release() | |
1574 |
|
1574 | |||
1575 | return result |
|
1575 | return result | |
1576 |
|
1576 | |||
1577 | def checkpush(self, force, revs): |
|
1577 | def checkpush(self, force, revs): | |
1578 | """Extensions can override this function if additional checks have |
|
1578 | """Extensions can override this function if additional checks have | |
1579 | to be performed before pushing, or call it if they override push |
|
1579 | to be performed before pushing, or call it if they override push | |
1580 | command. |
|
1580 | command. | |
1581 | """ |
|
1581 | """ | |
1582 | pass |
|
1582 | pass | |
1583 |
|
1583 | |||
1584 | def push(self, remote, force=False, revs=None, newbranch=False): |
|
1584 | def push(self, remote, force=False, revs=None, newbranch=False): | |
1585 | '''Push outgoing changesets (limited by revs) from the current |
|
1585 | '''Push outgoing changesets (limited by revs) from the current | |
1586 | repository to remote. Return an integer: |
|
1586 | repository to remote. Return an integer: | |
1587 | - 0 means HTTP error *or* nothing to push |
|
1587 | - 0 means HTTP error *or* nothing to push | |
1588 | - 1 means we pushed and remote head count is unchanged *or* |
|
1588 | - 1 means we pushed and remote head count is unchanged *or* | |
1589 | we have outgoing changesets but refused to push |
|
1589 | we have outgoing changesets but refused to push | |
1590 | - other values as described by addchangegroup() |
|
1590 | - other values as described by addchangegroup() | |
1591 | ''' |
|
1591 | ''' | |
1592 | # there are two ways to push to remote repo: |
|
1592 | # there are two ways to push to remote repo: | |
1593 | # |
|
1593 | # | |
1594 | # addchangegroup assumes local user can lock remote |
|
1594 | # addchangegroup assumes local user can lock remote | |
1595 | # repo (local filesystem, old ssh servers). |
|
1595 | # repo (local filesystem, old ssh servers). | |
1596 | # |
|
1596 | # | |
1597 | # unbundle assumes local user cannot lock remote repo (new ssh |
|
1597 | # unbundle assumes local user cannot lock remote repo (new ssh | |
1598 | # servers, http servers). |
|
1598 | # servers, http servers). | |
1599 |
|
1599 | |||
1600 | self.checkpush(force, revs) |
|
1600 | self.checkpush(force, revs) | |
1601 | lock = None |
|
1601 | lock = None | |
1602 | unbundle = remote.capable('unbundle') |
|
1602 | unbundle = remote.capable('unbundle') | |
1603 | if not unbundle: |
|
1603 | if not unbundle: | |
1604 | lock = remote.lock() |
|
1604 | lock = remote.lock() | |
1605 | try: |
|
1605 | try: | |
1606 | # get local lock as we might write phase data |
|
1606 | # get local lock as we might write phase data | |
1607 | locallock = self.lock() |
|
1607 | locallock = self.lock() | |
1608 | try: |
|
1608 | try: | |
1609 | cg, remote_heads, fut = discovery.prepush(self, remote, force, |
|
1609 | # discovery | |
1610 | revs, newbranch) |
|
1610 | fci = discovery.findcommonincoming | |
1611 | ret = remote_heads |
|
1611 | commoninc = fci(self, remote, force=force) | |
1612 | # create a callback for addchangegroup. |
|
1612 | common, inc, remoteheads = commoninc | |
1613 | # If will be used branch of the conditionnal too. |
|
1613 | fco = discovery.findcommonoutgoing | |
1614 | if cg is not None: |
|
1614 | outgoing = fco(self, remote, onlyheads=revs, | |
|
1615 | commoninc=commoninc, force=force) | |||
|
1616 | ||||
|
1617 | ||||
|
1618 | if not outgoing.missing: | |||
|
1619 | # nothing to push | |||
|
1620 | if outgoing.excluded: | |||
|
1621 | msg = "no changes to push but %i secret changesets\n" | |||
|
1622 | self.ui.status(_(msg) % len(outgoing.excluded)) | |||
|
1623 | else: | |||
|
1624 | self.ui.status(_("no changes found\n")) | |||
|
1625 | fut = outgoing.common | |||
|
1626 | ret = 1 | |||
|
1627 | else: | |||
|
1628 | # something to push | |||
|
1629 | if not force: | |||
|
1630 | discovery.checkheads(self, remote, outgoing, | |||
|
1631 | remoteheads, newbranch) | |||
|
1632 | ||||
|
1633 | # create a changegroup from local | |||
|
1634 | if revs is None and not outgoing.excluded: | |||
|
1635 | # push everything, | |||
|
1636 | # use the fast path, no race possible on push | |||
|
1637 | cg = self._changegroup(outgoing.missing, 'push') | |||
|
1638 | else: | |||
|
1639 | cg = self.getlocalbundle('push', outgoing) | |||
|
1640 | ||||
|
1641 | # apply changegroup to remote | |||
1615 | if unbundle: |
|
1642 | if unbundle: | |
1616 | # local repo finds heads on server, finds out what |
|
1643 | # local repo finds heads on server, finds out what | |
1617 | # revs it must push. once revs transferred, if server |
|
1644 | # revs it must push. once revs transferred, if server | |
1618 | # finds it has different heads (someone else won |
|
1645 | # finds it has different heads (someone else won | |
1619 | # commit/push race), server aborts. |
|
1646 | # commit/push race), server aborts. | |
1620 | if force: |
|
1647 | if force: | |
1621 |
remote |
|
1648 | remoteheads = ['force'] | |
1622 | # ssh: return remote's addchangegroup() |
|
1649 | # ssh: return remote's addchangegroup() | |
1623 | # http: return remote's addchangegroup() or 0 for error |
|
1650 | # http: return remote's addchangegroup() or 0 for error | |
1624 |
ret = remote.unbundle(cg, remote |
|
1651 | ret = remote.unbundle(cg, remoteheads, 'push') | |
1625 | else: |
|
1652 | else: | |
1626 | # we return an integer indicating remote head count change |
|
1653 | # we return an integer indicating remote head count change | |
1627 | ret = remote.addchangegroup(cg, 'push', self.url()) |
|
1654 | ret = remote.addchangegroup(cg, 'push', self.url()) | |
1628 |
|
1655 | |||
|
1656 | # compute what should be the now common | |||
|
1657 | # | |||
|
1658 | # XXX If push failed we should use strict common and not | |||
|
1659 | # future to avoid pushing phase data on unknown changeset. | |||
|
1660 | # This is to done later. | |||
|
1661 | fut = outgoing.commonheads + outgoing.missingheads | |||
1629 | # even when we don't push, exchanging phase data is useful |
|
1662 | # even when we don't push, exchanging phase data is useful | |
1630 | remotephases = remote.listkeys('phases') |
|
1663 | remotephases = remote.listkeys('phases') | |
1631 | if not remotephases: # old server or public only repo |
|
1664 | if not remotephases: # old server or public only repo | |
1632 | phases.advanceboundary(self, phases.public, fut) |
|
1665 | phases.advanceboundary(self, phases.public, fut) | |
1633 | # don't push any phase data as there is nothing to push |
|
1666 | # don't push any phase data as there is nothing to push | |
1634 | else: |
|
1667 | else: | |
1635 | ana = phases.analyzeremotephases(self, fut, remotephases) |
|
1668 | ana = phases.analyzeremotephases(self, fut, remotephases) | |
1636 | pheads, droots = ana |
|
1669 | pheads, droots = ana | |
1637 | ### Apply remote phase on local |
|
1670 | ### Apply remote phase on local | |
1638 | if remotephases.get('publishing', False): |
|
1671 | if remotephases.get('publishing', False): | |
1639 | phases.advanceboundary(self, phases.public, fut) |
|
1672 | phases.advanceboundary(self, phases.public, fut) | |
1640 | else: # publish = False |
|
1673 | else: # publish = False | |
1641 | phases.advanceboundary(self, phases.public, pheads) |
|
1674 | phases.advanceboundary(self, phases.public, pheads) | |
1642 | phases.advanceboundary(self, phases.draft, fut) |
|
1675 | phases.advanceboundary(self, phases.draft, fut) | |
1643 | ### Apply local phase on remote |
|
1676 | ### Apply local phase on remote | |
1644 | # |
|
|||
1645 | # XXX If push failed we should use strict common and not |
|
|||
1646 | # future to avoid pushing phase data on unknown changeset. |
|
|||
1647 | # This is to done later. |
|
|||
1648 |
|
1677 | |||
1649 | # Get the list of all revs draft on remote by public here. |
|
1678 | # Get the list of all revs draft on remote by public here. | |
1650 | # XXX Beware that revset break if droots is not strictly |
|
1679 | # XXX Beware that revset break if droots is not strictly | |
1651 | # XXX root we may want to ensure it is but it is costly |
|
1680 | # XXX root we may want to ensure it is but it is costly | |
1652 | outdated = self.set('heads((%ln::%ln) and public())', |
|
1681 | outdated = self.set('heads((%ln::%ln) and public())', | |
1653 | droots, fut) |
|
1682 | droots, fut) | |
1654 | for newremotehead in outdated: |
|
1683 | for newremotehead in outdated: | |
1655 | r = remote.pushkey('phases', |
|
1684 | r = remote.pushkey('phases', | |
1656 | newremotehead.hex(), |
|
1685 | newremotehead.hex(), | |
1657 | str(phases.draft), |
|
1686 | str(phases.draft), | |
1658 | str(phases.public)) |
|
1687 | str(phases.public)) | |
1659 | if not r: |
|
1688 | if not r: | |
1660 | self.ui.warn(_('updating %s to public failed!\n') |
|
1689 | self.ui.warn(_('updating %s to public failed!\n') | |
1661 | % newremotehead) |
|
1690 | % newremotehead) | |
1662 | finally: |
|
1691 | finally: | |
1663 | locallock.release() |
|
1692 | locallock.release() | |
1664 | finally: |
|
1693 | finally: | |
1665 | if lock is not None: |
|
1694 | if lock is not None: | |
1666 | lock.release() |
|
1695 | lock.release() | |
1667 |
|
1696 | |||
1668 | self.ui.debug("checking for updated bookmarks\n") |
|
1697 | self.ui.debug("checking for updated bookmarks\n") | |
1669 | rb = remote.listkeys('bookmarks') |
|
1698 | rb = remote.listkeys('bookmarks') | |
1670 | for k in rb.keys(): |
|
1699 | for k in rb.keys(): | |
1671 | if k in self._bookmarks: |
|
1700 | if k in self._bookmarks: | |
1672 | nr, nl = rb[k], hex(self._bookmarks[k]) |
|
1701 | nr, nl = rb[k], hex(self._bookmarks[k]) | |
1673 | if nr in self: |
|
1702 | if nr in self: | |
1674 | cr = self[nr] |
|
1703 | cr = self[nr] | |
1675 | cl = self[nl] |
|
1704 | cl = self[nl] | |
1676 | if cl in cr.descendants(): |
|
1705 | if cl in cr.descendants(): | |
1677 | r = remote.pushkey('bookmarks', k, nr, nl) |
|
1706 | r = remote.pushkey('bookmarks', k, nr, nl) | |
1678 | if r: |
|
1707 | if r: | |
1679 | self.ui.status(_("updating bookmark %s\n") % k) |
|
1708 | self.ui.status(_("updating bookmark %s\n") % k) | |
1680 | else: |
|
1709 | else: | |
1681 | self.ui.warn(_('updating bookmark %s' |
|
1710 | self.ui.warn(_('updating bookmark %s' | |
1682 | ' failed!\n') % k) |
|
1711 | ' failed!\n') % k) | |
1683 |
|
1712 | |||
1684 | return ret |
|
1713 | return ret | |
1685 |
|
1714 | |||
1686 | def changegroupinfo(self, nodes, source): |
|
1715 | def changegroupinfo(self, nodes, source): | |
1687 | if self.ui.verbose or source == 'bundle': |
|
1716 | if self.ui.verbose or source == 'bundle': | |
1688 | self.ui.status(_("%d changesets found\n") % len(nodes)) |
|
1717 | self.ui.status(_("%d changesets found\n") % len(nodes)) | |
1689 | if self.ui.debugflag: |
|
1718 | if self.ui.debugflag: | |
1690 | self.ui.debug("list of changesets:\n") |
|
1719 | self.ui.debug("list of changesets:\n") | |
1691 | for node in nodes: |
|
1720 | for node in nodes: | |
1692 | self.ui.debug("%s\n" % hex(node)) |
|
1721 | self.ui.debug("%s\n" % hex(node)) | |
1693 |
|
1722 | |||
1694 | def changegroupsubset(self, bases, heads, source): |
|
1723 | def changegroupsubset(self, bases, heads, source): | |
1695 | """Compute a changegroup consisting of all the nodes that are |
|
1724 | """Compute a changegroup consisting of all the nodes that are | |
1696 | descendants of any of the bases and ancestors of any of the heads. |
|
1725 | descendants of any of the bases and ancestors of any of the heads. | |
1697 | Return a chunkbuffer object whose read() method will return |
|
1726 | Return a chunkbuffer object whose read() method will return | |
1698 | successive changegroup chunks. |
|
1727 | successive changegroup chunks. | |
1699 |
|
1728 | |||
1700 | It is fairly complex as determining which filenodes and which |
|
1729 | It is fairly complex as determining which filenodes and which | |
1701 | manifest nodes need to be included for the changeset to be complete |
|
1730 | manifest nodes need to be included for the changeset to be complete | |
1702 | is non-trivial. |
|
1731 | is non-trivial. | |
1703 |
|
1732 | |||
1704 | Another wrinkle is doing the reverse, figuring out which changeset in |
|
1733 | Another wrinkle is doing the reverse, figuring out which changeset in | |
1705 | the changegroup a particular filenode or manifestnode belongs to. |
|
1734 | the changegroup a particular filenode or manifestnode belongs to. | |
1706 | """ |
|
1735 | """ | |
1707 | cl = self.changelog |
|
1736 | cl = self.changelog | |
1708 | if not bases: |
|
1737 | if not bases: | |
1709 | bases = [nullid] |
|
1738 | bases = [nullid] | |
1710 | csets, bases, heads = cl.nodesbetween(bases, heads) |
|
1739 | csets, bases, heads = cl.nodesbetween(bases, heads) | |
1711 | # We assume that all ancestors of bases are known |
|
1740 | # We assume that all ancestors of bases are known | |
1712 | common = set(cl.ancestors(*[cl.rev(n) for n in bases])) |
|
1741 | common = set(cl.ancestors(*[cl.rev(n) for n in bases])) | |
1713 | return self._changegroupsubset(common, csets, heads, source) |
|
1742 | return self._changegroupsubset(common, csets, heads, source) | |
1714 |
|
1743 | |||
1715 | def getlocalbundle(self, source, outgoing): |
|
1744 | def getlocalbundle(self, source, outgoing): | |
1716 | """Like getbundle, but taking a discovery.outgoing as an argument. |
|
1745 | """Like getbundle, but taking a discovery.outgoing as an argument. | |
1717 |
|
1746 | |||
1718 | This is only implemented for local repos and reuses potentially |
|
1747 | This is only implemented for local repos and reuses potentially | |
1719 | precomputed sets in outgoing.""" |
|
1748 | precomputed sets in outgoing.""" | |
1720 | if not outgoing.missing: |
|
1749 | if not outgoing.missing: | |
1721 | return None |
|
1750 | return None | |
1722 | return self._changegroupsubset(outgoing.common, |
|
1751 | return self._changegroupsubset(outgoing.common, | |
1723 | outgoing.missing, |
|
1752 | outgoing.missing, | |
1724 | outgoing.missingheads, |
|
1753 | outgoing.missingheads, | |
1725 | source) |
|
1754 | source) | |
1726 |
|
1755 | |||
1727 | def getbundle(self, source, heads=None, common=None): |
|
1756 | def getbundle(self, source, heads=None, common=None): | |
1728 | """Like changegroupsubset, but returns the set difference between the |
|
1757 | """Like changegroupsubset, but returns the set difference between the | |
1729 | ancestors of heads and the ancestors common. |
|
1758 | ancestors of heads and the ancestors common. | |
1730 |
|
1759 | |||
1731 | If heads is None, use the local heads. If common is None, use [nullid]. |
|
1760 | If heads is None, use the local heads. If common is None, use [nullid]. | |
1732 |
|
1761 | |||
1733 | The nodes in common might not all be known locally due to the way the |
|
1762 | The nodes in common might not all be known locally due to the way the | |
1734 | current discovery protocol works. |
|
1763 | current discovery protocol works. | |
1735 | """ |
|
1764 | """ | |
1736 | cl = self.changelog |
|
1765 | cl = self.changelog | |
1737 | if common: |
|
1766 | if common: | |
1738 | nm = cl.nodemap |
|
1767 | nm = cl.nodemap | |
1739 | common = [n for n in common if n in nm] |
|
1768 | common = [n for n in common if n in nm] | |
1740 | else: |
|
1769 | else: | |
1741 | common = [nullid] |
|
1770 | common = [nullid] | |
1742 | if not heads: |
|
1771 | if not heads: | |
1743 | heads = cl.heads() |
|
1772 | heads = cl.heads() | |
1744 | return self.getlocalbundle(source, |
|
1773 | return self.getlocalbundle(source, | |
1745 | discovery.outgoing(cl, common, heads)) |
|
1774 | discovery.outgoing(cl, common, heads)) | |
1746 |
|
1775 | |||
1747 | def _changegroupsubset(self, commonrevs, csets, heads, source): |
|
1776 | def _changegroupsubset(self, commonrevs, csets, heads, source): | |
1748 |
|
1777 | |||
1749 | cl = self.changelog |
|
1778 | cl = self.changelog | |
1750 | mf = self.manifest |
|
1779 | mf = self.manifest | |
1751 | mfs = {} # needed manifests |
|
1780 | mfs = {} # needed manifests | |
1752 | fnodes = {} # needed file nodes |
|
1781 | fnodes = {} # needed file nodes | |
1753 | changedfiles = set() |
|
1782 | changedfiles = set() | |
1754 | fstate = ['', {}] |
|
1783 | fstate = ['', {}] | |
1755 | count = [0] |
|
1784 | count = [0] | |
1756 |
|
1785 | |||
1757 | # can we go through the fast path ? |
|
1786 | # can we go through the fast path ? | |
1758 | heads.sort() |
|
1787 | heads.sort() | |
1759 | if heads == sorted(self.heads()): |
|
1788 | if heads == sorted(self.heads()): | |
1760 | return self._changegroup(csets, source) |
|
1789 | return self._changegroup(csets, source) | |
1761 |
|
1790 | |||
1762 | # slow path |
|
1791 | # slow path | |
1763 | self.hook('preoutgoing', throw=True, source=source) |
|
1792 | self.hook('preoutgoing', throw=True, source=source) | |
1764 | self.changegroupinfo(csets, source) |
|
1793 | self.changegroupinfo(csets, source) | |
1765 |
|
1794 | |||
1766 | # filter any nodes that claim to be part of the known set |
|
1795 | # filter any nodes that claim to be part of the known set | |
1767 | def prune(revlog, missing): |
|
1796 | def prune(revlog, missing): | |
1768 | return [n for n in missing |
|
1797 | return [n for n in missing | |
1769 | if revlog.linkrev(revlog.rev(n)) not in commonrevs] |
|
1798 | if revlog.linkrev(revlog.rev(n)) not in commonrevs] | |
1770 |
|
1799 | |||
1771 | def lookup(revlog, x): |
|
1800 | def lookup(revlog, x): | |
1772 | if revlog == cl: |
|
1801 | if revlog == cl: | |
1773 | c = cl.read(x) |
|
1802 | c = cl.read(x) | |
1774 | changedfiles.update(c[3]) |
|
1803 | changedfiles.update(c[3]) | |
1775 | mfs.setdefault(c[0], x) |
|
1804 | mfs.setdefault(c[0], x) | |
1776 | count[0] += 1 |
|
1805 | count[0] += 1 | |
1777 | self.ui.progress(_('bundling'), count[0], |
|
1806 | self.ui.progress(_('bundling'), count[0], | |
1778 | unit=_('changesets'), total=len(csets)) |
|
1807 | unit=_('changesets'), total=len(csets)) | |
1779 | return x |
|
1808 | return x | |
1780 | elif revlog == mf: |
|
1809 | elif revlog == mf: | |
1781 | clnode = mfs[x] |
|
1810 | clnode = mfs[x] | |
1782 | mdata = mf.readfast(x) |
|
1811 | mdata = mf.readfast(x) | |
1783 | for f in changedfiles: |
|
1812 | for f in changedfiles: | |
1784 | if f in mdata: |
|
1813 | if f in mdata: | |
1785 | fnodes.setdefault(f, {}).setdefault(mdata[f], clnode) |
|
1814 | fnodes.setdefault(f, {}).setdefault(mdata[f], clnode) | |
1786 | count[0] += 1 |
|
1815 | count[0] += 1 | |
1787 | self.ui.progress(_('bundling'), count[0], |
|
1816 | self.ui.progress(_('bundling'), count[0], | |
1788 | unit=_('manifests'), total=len(mfs)) |
|
1817 | unit=_('manifests'), total=len(mfs)) | |
1789 | return mfs[x] |
|
1818 | return mfs[x] | |
1790 | else: |
|
1819 | else: | |
1791 | self.ui.progress( |
|
1820 | self.ui.progress( | |
1792 | _('bundling'), count[0], item=fstate[0], |
|
1821 | _('bundling'), count[0], item=fstate[0], | |
1793 | unit=_('files'), total=len(changedfiles)) |
|
1822 | unit=_('files'), total=len(changedfiles)) | |
1794 | return fstate[1][x] |
|
1823 | return fstate[1][x] | |
1795 |
|
1824 | |||
1796 | bundler = changegroup.bundle10(lookup) |
|
1825 | bundler = changegroup.bundle10(lookup) | |
1797 | reorder = self.ui.config('bundle', 'reorder', 'auto') |
|
1826 | reorder = self.ui.config('bundle', 'reorder', 'auto') | |
1798 | if reorder == 'auto': |
|
1827 | if reorder == 'auto': | |
1799 | reorder = None |
|
1828 | reorder = None | |
1800 | else: |
|
1829 | else: | |
1801 | reorder = util.parsebool(reorder) |
|
1830 | reorder = util.parsebool(reorder) | |
1802 |
|
1831 | |||
1803 | def gengroup(): |
|
1832 | def gengroup(): | |
1804 | # Create a changenode group generator that will call our functions |
|
1833 | # Create a changenode group generator that will call our functions | |
1805 | # back to lookup the owning changenode and collect information. |
|
1834 | # back to lookup the owning changenode and collect information. | |
1806 | for chunk in cl.group(csets, bundler, reorder=reorder): |
|
1835 | for chunk in cl.group(csets, bundler, reorder=reorder): | |
1807 | yield chunk |
|
1836 | yield chunk | |
1808 | self.ui.progress(_('bundling'), None) |
|
1837 | self.ui.progress(_('bundling'), None) | |
1809 |
|
1838 | |||
1810 | # Create a generator for the manifestnodes that calls our lookup |
|
1839 | # Create a generator for the manifestnodes that calls our lookup | |
1811 | # and data collection functions back. |
|
1840 | # and data collection functions back. | |
1812 | count[0] = 0 |
|
1841 | count[0] = 0 | |
1813 | for chunk in mf.group(prune(mf, mfs), bundler, reorder=reorder): |
|
1842 | for chunk in mf.group(prune(mf, mfs), bundler, reorder=reorder): | |
1814 | yield chunk |
|
1843 | yield chunk | |
1815 | self.ui.progress(_('bundling'), None) |
|
1844 | self.ui.progress(_('bundling'), None) | |
1816 |
|
1845 | |||
1817 | mfs.clear() |
|
1846 | mfs.clear() | |
1818 |
|
1847 | |||
1819 | # Go through all our files in order sorted by name. |
|
1848 | # Go through all our files in order sorted by name. | |
1820 | count[0] = 0 |
|
1849 | count[0] = 0 | |
1821 | for fname in sorted(changedfiles): |
|
1850 | for fname in sorted(changedfiles): | |
1822 | filerevlog = self.file(fname) |
|
1851 | filerevlog = self.file(fname) | |
1823 | if not len(filerevlog): |
|
1852 | if not len(filerevlog): | |
1824 | raise util.Abort(_("empty or missing revlog for %s") % fname) |
|
1853 | raise util.Abort(_("empty or missing revlog for %s") % fname) | |
1825 | fstate[0] = fname |
|
1854 | fstate[0] = fname | |
1826 | fstate[1] = fnodes.pop(fname, {}) |
|
1855 | fstate[1] = fnodes.pop(fname, {}) | |
1827 |
|
1856 | |||
1828 | nodelist = prune(filerevlog, fstate[1]) |
|
1857 | nodelist = prune(filerevlog, fstate[1]) | |
1829 | if nodelist: |
|
1858 | if nodelist: | |
1830 | count[0] += 1 |
|
1859 | count[0] += 1 | |
1831 | yield bundler.fileheader(fname) |
|
1860 | yield bundler.fileheader(fname) | |
1832 | for chunk in filerevlog.group(nodelist, bundler, reorder): |
|
1861 | for chunk in filerevlog.group(nodelist, bundler, reorder): | |
1833 | yield chunk |
|
1862 | yield chunk | |
1834 |
|
1863 | |||
1835 | # Signal that no more groups are left. |
|
1864 | # Signal that no more groups are left. | |
1836 | yield bundler.close() |
|
1865 | yield bundler.close() | |
1837 | self.ui.progress(_('bundling'), None) |
|
1866 | self.ui.progress(_('bundling'), None) | |
1838 |
|
1867 | |||
1839 | if csets: |
|
1868 | if csets: | |
1840 | self.hook('outgoing', node=hex(csets[0]), source=source) |
|
1869 | self.hook('outgoing', node=hex(csets[0]), source=source) | |
1841 |
|
1870 | |||
1842 | return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN') |
|
1871 | return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN') | |
1843 |
|
1872 | |||
1844 | def changegroup(self, basenodes, source): |
|
1873 | def changegroup(self, basenodes, source): | |
1845 | # to avoid a race we use changegroupsubset() (issue1320) |
|
1874 | # to avoid a race we use changegroupsubset() (issue1320) | |
1846 | return self.changegroupsubset(basenodes, self.heads(), source) |
|
1875 | return self.changegroupsubset(basenodes, self.heads(), source) | |
1847 |
|
1876 | |||
1848 | def _changegroup(self, nodes, source): |
|
1877 | def _changegroup(self, nodes, source): | |
1849 | """Compute the changegroup of all nodes that we have that a recipient |
|
1878 | """Compute the changegroup of all nodes that we have that a recipient | |
1850 | doesn't. Return a chunkbuffer object whose read() method will return |
|
1879 | doesn't. Return a chunkbuffer object whose read() method will return | |
1851 | successive changegroup chunks. |
|
1880 | successive changegroup chunks. | |
1852 |
|
1881 | |||
1853 | This is much easier than the previous function as we can assume that |
|
1882 | This is much easier than the previous function as we can assume that | |
1854 | the recipient has any changenode we aren't sending them. |
|
1883 | the recipient has any changenode we aren't sending them. | |
1855 |
|
1884 | |||
1856 | nodes is the set of nodes to send""" |
|
1885 | nodes is the set of nodes to send""" | |
1857 |
|
1886 | |||
1858 | cl = self.changelog |
|
1887 | cl = self.changelog | |
1859 | mf = self.manifest |
|
1888 | mf = self.manifest | |
1860 | mfs = {} |
|
1889 | mfs = {} | |
1861 | changedfiles = set() |
|
1890 | changedfiles = set() | |
1862 | fstate = [''] |
|
1891 | fstate = [''] | |
1863 | count = [0] |
|
1892 | count = [0] | |
1864 |
|
1893 | |||
1865 | self.hook('preoutgoing', throw=True, source=source) |
|
1894 | self.hook('preoutgoing', throw=True, source=source) | |
1866 | self.changegroupinfo(nodes, source) |
|
1895 | self.changegroupinfo(nodes, source) | |
1867 |
|
1896 | |||
1868 | revset = set([cl.rev(n) for n in nodes]) |
|
1897 | revset = set([cl.rev(n) for n in nodes]) | |
1869 |
|
1898 | |||
1870 | def gennodelst(log): |
|
1899 | def gennodelst(log): | |
1871 | return [log.node(r) for r in log if log.linkrev(r) in revset] |
|
1900 | return [log.node(r) for r in log if log.linkrev(r) in revset] | |
1872 |
|
1901 | |||
1873 | def lookup(revlog, x): |
|
1902 | def lookup(revlog, x): | |
1874 | if revlog == cl: |
|
1903 | if revlog == cl: | |
1875 | c = cl.read(x) |
|
1904 | c = cl.read(x) | |
1876 | changedfiles.update(c[3]) |
|
1905 | changedfiles.update(c[3]) | |
1877 | mfs.setdefault(c[0], x) |
|
1906 | mfs.setdefault(c[0], x) | |
1878 | count[0] += 1 |
|
1907 | count[0] += 1 | |
1879 | self.ui.progress(_('bundling'), count[0], |
|
1908 | self.ui.progress(_('bundling'), count[0], | |
1880 | unit=_('changesets'), total=len(nodes)) |
|
1909 | unit=_('changesets'), total=len(nodes)) | |
1881 | return x |
|
1910 | return x | |
1882 | elif revlog == mf: |
|
1911 | elif revlog == mf: | |
1883 | count[0] += 1 |
|
1912 | count[0] += 1 | |
1884 | self.ui.progress(_('bundling'), count[0], |
|
1913 | self.ui.progress(_('bundling'), count[0], | |
1885 | unit=_('manifests'), total=len(mfs)) |
|
1914 | unit=_('manifests'), total=len(mfs)) | |
1886 | return cl.node(revlog.linkrev(revlog.rev(x))) |
|
1915 | return cl.node(revlog.linkrev(revlog.rev(x))) | |
1887 | else: |
|
1916 | else: | |
1888 | self.ui.progress( |
|
1917 | self.ui.progress( | |
1889 | _('bundling'), count[0], item=fstate[0], |
|
1918 | _('bundling'), count[0], item=fstate[0], | |
1890 | total=len(changedfiles), unit=_('files')) |
|
1919 | total=len(changedfiles), unit=_('files')) | |
1891 | return cl.node(revlog.linkrev(revlog.rev(x))) |
|
1920 | return cl.node(revlog.linkrev(revlog.rev(x))) | |
1892 |
|
1921 | |||
1893 | bundler = changegroup.bundle10(lookup) |
|
1922 | bundler = changegroup.bundle10(lookup) | |
1894 | reorder = self.ui.config('bundle', 'reorder', 'auto') |
|
1923 | reorder = self.ui.config('bundle', 'reorder', 'auto') | |
1895 | if reorder == 'auto': |
|
1924 | if reorder == 'auto': | |
1896 | reorder = None |
|
1925 | reorder = None | |
1897 | else: |
|
1926 | else: | |
1898 | reorder = util.parsebool(reorder) |
|
1927 | reorder = util.parsebool(reorder) | |
1899 |
|
1928 | |||
1900 | def gengroup(): |
|
1929 | def gengroup(): | |
1901 | '''yield a sequence of changegroup chunks (strings)''' |
|
1930 | '''yield a sequence of changegroup chunks (strings)''' | |
1902 | # construct a list of all changed files |
|
1931 | # construct a list of all changed files | |
1903 |
|
1932 | |||
1904 | for chunk in cl.group(nodes, bundler, reorder=reorder): |
|
1933 | for chunk in cl.group(nodes, bundler, reorder=reorder): | |
1905 | yield chunk |
|
1934 | yield chunk | |
1906 | self.ui.progress(_('bundling'), None) |
|
1935 | self.ui.progress(_('bundling'), None) | |
1907 |
|
1936 | |||
1908 | count[0] = 0 |
|
1937 | count[0] = 0 | |
1909 | for chunk in mf.group(gennodelst(mf), bundler, reorder=reorder): |
|
1938 | for chunk in mf.group(gennodelst(mf), bundler, reorder=reorder): | |
1910 | yield chunk |
|
1939 | yield chunk | |
1911 | self.ui.progress(_('bundling'), None) |
|
1940 | self.ui.progress(_('bundling'), None) | |
1912 |
|
1941 | |||
1913 | count[0] = 0 |
|
1942 | count[0] = 0 | |
1914 | for fname in sorted(changedfiles): |
|
1943 | for fname in sorted(changedfiles): | |
1915 | filerevlog = self.file(fname) |
|
1944 | filerevlog = self.file(fname) | |
1916 | if not len(filerevlog): |
|
1945 | if not len(filerevlog): | |
1917 | raise util.Abort(_("empty or missing revlog for %s") % fname) |
|
1946 | raise util.Abort(_("empty or missing revlog for %s") % fname) | |
1918 | fstate[0] = fname |
|
1947 | fstate[0] = fname | |
1919 | nodelist = gennodelst(filerevlog) |
|
1948 | nodelist = gennodelst(filerevlog) | |
1920 | if nodelist: |
|
1949 | if nodelist: | |
1921 | count[0] += 1 |
|
1950 | count[0] += 1 | |
1922 | yield bundler.fileheader(fname) |
|
1951 | yield bundler.fileheader(fname) | |
1923 | for chunk in filerevlog.group(nodelist, bundler, reorder): |
|
1952 | for chunk in filerevlog.group(nodelist, bundler, reorder): | |
1924 | yield chunk |
|
1953 | yield chunk | |
1925 | yield bundler.close() |
|
1954 | yield bundler.close() | |
1926 | self.ui.progress(_('bundling'), None) |
|
1955 | self.ui.progress(_('bundling'), None) | |
1927 |
|
1956 | |||
1928 | if nodes: |
|
1957 | if nodes: | |
1929 | self.hook('outgoing', node=hex(nodes[0]), source=source) |
|
1958 | self.hook('outgoing', node=hex(nodes[0]), source=source) | |
1930 |
|
1959 | |||
1931 | return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN') |
|
1960 | return changegroup.unbundle10(util.chunkbuffer(gengroup()), 'UN') | |
1932 |
|
1961 | |||
1933 | def addchangegroup(self, source, srctype, url, emptyok=False): |
|
1962 | def addchangegroup(self, source, srctype, url, emptyok=False): | |
1934 | """Add the changegroup returned by source.read() to this repo. |
|
1963 | """Add the changegroup returned by source.read() to this repo. | |
1935 | srctype is a string like 'push', 'pull', or 'unbundle'. url is |
|
1964 | srctype is a string like 'push', 'pull', or 'unbundle'. url is | |
1936 | the URL of the repo where this changegroup is coming from. |
|
1965 | the URL of the repo where this changegroup is coming from. | |
1937 |
|
1966 | |||
1938 | Return an integer summarizing the change to this repo: |
|
1967 | Return an integer summarizing the change to this repo: | |
1939 | - nothing changed or no source: 0 |
|
1968 | - nothing changed or no source: 0 | |
1940 | - more heads than before: 1+added heads (2..n) |
|
1969 | - more heads than before: 1+added heads (2..n) | |
1941 | - fewer heads than before: -1-removed heads (-2..-n) |
|
1970 | - fewer heads than before: -1-removed heads (-2..-n) | |
1942 | - number of heads stays the same: 1 |
|
1971 | - number of heads stays the same: 1 | |
1943 | """ |
|
1972 | """ | |
1944 | def csmap(x): |
|
1973 | def csmap(x): | |
1945 | self.ui.debug("add changeset %s\n" % short(x)) |
|
1974 | self.ui.debug("add changeset %s\n" % short(x)) | |
1946 | return len(cl) |
|
1975 | return len(cl) | |
1947 |
|
1976 | |||
1948 | def revmap(x): |
|
1977 | def revmap(x): | |
1949 | return cl.rev(x) |
|
1978 | return cl.rev(x) | |
1950 |
|
1979 | |||
1951 | if not source: |
|
1980 | if not source: | |
1952 | return 0 |
|
1981 | return 0 | |
1953 |
|
1982 | |||
1954 | self.hook('prechangegroup', throw=True, source=srctype, url=url) |
|
1983 | self.hook('prechangegroup', throw=True, source=srctype, url=url) | |
1955 |
|
1984 | |||
1956 | changesets = files = revisions = 0 |
|
1985 | changesets = files = revisions = 0 | |
1957 | efiles = set() |
|
1986 | efiles = set() | |
1958 |
|
1987 | |||
1959 | # write changelog data to temp files so concurrent readers will not see |
|
1988 | # write changelog data to temp files so concurrent readers will not see | |
1960 | # inconsistent view |
|
1989 | # inconsistent view | |
1961 | cl = self.changelog |
|
1990 | cl = self.changelog | |
1962 | cl.delayupdate() |
|
1991 | cl.delayupdate() | |
1963 | oldheads = cl.heads() |
|
1992 | oldheads = cl.heads() | |
1964 |
|
1993 | |||
1965 | tr = self.transaction("\n".join([srctype, util.hidepassword(url)])) |
|
1994 | tr = self.transaction("\n".join([srctype, util.hidepassword(url)])) | |
1966 | try: |
|
1995 | try: | |
1967 | trp = weakref.proxy(tr) |
|
1996 | trp = weakref.proxy(tr) | |
1968 | # pull off the changeset group |
|
1997 | # pull off the changeset group | |
1969 | self.ui.status(_("adding changesets\n")) |
|
1998 | self.ui.status(_("adding changesets\n")) | |
1970 | clstart = len(cl) |
|
1999 | clstart = len(cl) | |
1971 | class prog(object): |
|
2000 | class prog(object): | |
1972 | step = _('changesets') |
|
2001 | step = _('changesets') | |
1973 | count = 1 |
|
2002 | count = 1 | |
1974 | ui = self.ui |
|
2003 | ui = self.ui | |
1975 | total = None |
|
2004 | total = None | |
1976 | def __call__(self): |
|
2005 | def __call__(self): | |
1977 | self.ui.progress(self.step, self.count, unit=_('chunks'), |
|
2006 | self.ui.progress(self.step, self.count, unit=_('chunks'), | |
1978 | total=self.total) |
|
2007 | total=self.total) | |
1979 | self.count += 1 |
|
2008 | self.count += 1 | |
1980 | pr = prog() |
|
2009 | pr = prog() | |
1981 | source.callback = pr |
|
2010 | source.callback = pr | |
1982 |
|
2011 | |||
1983 | source.changelogheader() |
|
2012 | source.changelogheader() | |
1984 | srccontent = cl.addgroup(source, csmap, trp) |
|
2013 | srccontent = cl.addgroup(source, csmap, trp) | |
1985 | if not (srccontent or emptyok): |
|
2014 | if not (srccontent or emptyok): | |
1986 | raise util.Abort(_("received changelog group is empty")) |
|
2015 | raise util.Abort(_("received changelog group is empty")) | |
1987 | clend = len(cl) |
|
2016 | clend = len(cl) | |
1988 | changesets = clend - clstart |
|
2017 | changesets = clend - clstart | |
1989 | for c in xrange(clstart, clend): |
|
2018 | for c in xrange(clstart, clend): | |
1990 | efiles.update(self[c].files()) |
|
2019 | efiles.update(self[c].files()) | |
1991 | efiles = len(efiles) |
|
2020 | efiles = len(efiles) | |
1992 | self.ui.progress(_('changesets'), None) |
|
2021 | self.ui.progress(_('changesets'), None) | |
1993 |
|
2022 | |||
1994 | # pull off the manifest group |
|
2023 | # pull off the manifest group | |
1995 | self.ui.status(_("adding manifests\n")) |
|
2024 | self.ui.status(_("adding manifests\n")) | |
1996 | pr.step = _('manifests') |
|
2025 | pr.step = _('manifests') | |
1997 | pr.count = 1 |
|
2026 | pr.count = 1 | |
1998 | pr.total = changesets # manifests <= changesets |
|
2027 | pr.total = changesets # manifests <= changesets | |
1999 | # no need to check for empty manifest group here: |
|
2028 | # no need to check for empty manifest group here: | |
2000 | # if the result of the merge of 1 and 2 is the same in 3 and 4, |
|
2029 | # if the result of the merge of 1 and 2 is the same in 3 and 4, | |
2001 | # no new manifest will be created and the manifest group will |
|
2030 | # no new manifest will be created and the manifest group will | |
2002 | # be empty during the pull |
|
2031 | # be empty during the pull | |
2003 | source.manifestheader() |
|
2032 | source.manifestheader() | |
2004 | self.manifest.addgroup(source, revmap, trp) |
|
2033 | self.manifest.addgroup(source, revmap, trp) | |
2005 | self.ui.progress(_('manifests'), None) |
|
2034 | self.ui.progress(_('manifests'), None) | |
2006 |
|
2035 | |||
2007 | needfiles = {} |
|
2036 | needfiles = {} | |
2008 | if self.ui.configbool('server', 'validate', default=False): |
|
2037 | if self.ui.configbool('server', 'validate', default=False): | |
2009 | # validate incoming csets have their manifests |
|
2038 | # validate incoming csets have their manifests | |
2010 | for cset in xrange(clstart, clend): |
|
2039 | for cset in xrange(clstart, clend): | |
2011 | mfest = self.changelog.read(self.changelog.node(cset))[0] |
|
2040 | mfest = self.changelog.read(self.changelog.node(cset))[0] | |
2012 | mfest = self.manifest.readdelta(mfest) |
|
2041 | mfest = self.manifest.readdelta(mfest) | |
2013 | # store file nodes we must see |
|
2042 | # store file nodes we must see | |
2014 | for f, n in mfest.iteritems(): |
|
2043 | for f, n in mfest.iteritems(): | |
2015 | needfiles.setdefault(f, set()).add(n) |
|
2044 | needfiles.setdefault(f, set()).add(n) | |
2016 |
|
2045 | |||
2017 | # process the files |
|
2046 | # process the files | |
2018 | self.ui.status(_("adding file changes\n")) |
|
2047 | self.ui.status(_("adding file changes\n")) | |
2019 | pr.step = _('files') |
|
2048 | pr.step = _('files') | |
2020 | pr.count = 1 |
|
2049 | pr.count = 1 | |
2021 | pr.total = efiles |
|
2050 | pr.total = efiles | |
2022 | source.callback = None |
|
2051 | source.callback = None | |
2023 |
|
2052 | |||
2024 | while True: |
|
2053 | while True: | |
2025 | chunkdata = source.filelogheader() |
|
2054 | chunkdata = source.filelogheader() | |
2026 | if not chunkdata: |
|
2055 | if not chunkdata: | |
2027 | break |
|
2056 | break | |
2028 | f = chunkdata["filename"] |
|
2057 | f = chunkdata["filename"] | |
2029 | self.ui.debug("adding %s revisions\n" % f) |
|
2058 | self.ui.debug("adding %s revisions\n" % f) | |
2030 | pr() |
|
2059 | pr() | |
2031 | fl = self.file(f) |
|
2060 | fl = self.file(f) | |
2032 | o = len(fl) |
|
2061 | o = len(fl) | |
2033 | if not fl.addgroup(source, revmap, trp): |
|
2062 | if not fl.addgroup(source, revmap, trp): | |
2034 | raise util.Abort(_("received file revlog group is empty")) |
|
2063 | raise util.Abort(_("received file revlog group is empty")) | |
2035 | revisions += len(fl) - o |
|
2064 | revisions += len(fl) - o | |
2036 | files += 1 |
|
2065 | files += 1 | |
2037 | if f in needfiles: |
|
2066 | if f in needfiles: | |
2038 | needs = needfiles[f] |
|
2067 | needs = needfiles[f] | |
2039 | for new in xrange(o, len(fl)): |
|
2068 | for new in xrange(o, len(fl)): | |
2040 | n = fl.node(new) |
|
2069 | n = fl.node(new) | |
2041 | if n in needs: |
|
2070 | if n in needs: | |
2042 | needs.remove(n) |
|
2071 | needs.remove(n) | |
2043 | if not needs: |
|
2072 | if not needs: | |
2044 | del needfiles[f] |
|
2073 | del needfiles[f] | |
2045 | self.ui.progress(_('files'), None) |
|
2074 | self.ui.progress(_('files'), None) | |
2046 |
|
2075 | |||
2047 | for f, needs in needfiles.iteritems(): |
|
2076 | for f, needs in needfiles.iteritems(): | |
2048 | fl = self.file(f) |
|
2077 | fl = self.file(f) | |
2049 | for n in needs: |
|
2078 | for n in needs: | |
2050 | try: |
|
2079 | try: | |
2051 | fl.rev(n) |
|
2080 | fl.rev(n) | |
2052 | except error.LookupError: |
|
2081 | except error.LookupError: | |
2053 | raise util.Abort( |
|
2082 | raise util.Abort( | |
2054 | _('missing file data for %s:%s - run hg verify') % |
|
2083 | _('missing file data for %s:%s - run hg verify') % | |
2055 | (f, hex(n))) |
|
2084 | (f, hex(n))) | |
2056 |
|
2085 | |||
2057 | dh = 0 |
|
2086 | dh = 0 | |
2058 | if oldheads: |
|
2087 | if oldheads: | |
2059 | heads = cl.heads() |
|
2088 | heads = cl.heads() | |
2060 | dh = len(heads) - len(oldheads) |
|
2089 | dh = len(heads) - len(oldheads) | |
2061 | for h in heads: |
|
2090 | for h in heads: | |
2062 | if h not in oldheads and 'close' in self[h].extra(): |
|
2091 | if h not in oldheads and 'close' in self[h].extra(): | |
2063 | dh -= 1 |
|
2092 | dh -= 1 | |
2064 | htext = "" |
|
2093 | htext = "" | |
2065 | if dh: |
|
2094 | if dh: | |
2066 | htext = _(" (%+d heads)") % dh |
|
2095 | htext = _(" (%+d heads)") % dh | |
2067 |
|
2096 | |||
2068 | self.ui.status(_("added %d changesets" |
|
2097 | self.ui.status(_("added %d changesets" | |
2069 | " with %d changes to %d files%s\n") |
|
2098 | " with %d changes to %d files%s\n") | |
2070 | % (changesets, revisions, files, htext)) |
|
2099 | % (changesets, revisions, files, htext)) | |
2071 |
|
2100 | |||
2072 | if changesets > 0: |
|
2101 | if changesets > 0: | |
2073 | p = lambda: cl.writepending() and self.root or "" |
|
2102 | p = lambda: cl.writepending() and self.root or "" | |
2074 | self.hook('pretxnchangegroup', throw=True, |
|
2103 | self.hook('pretxnchangegroup', throw=True, | |
2075 | node=hex(cl.node(clstart)), source=srctype, |
|
2104 | node=hex(cl.node(clstart)), source=srctype, | |
2076 | url=url, pending=p) |
|
2105 | url=url, pending=p) | |
2077 |
|
2106 | |||
2078 | added = [cl.node(r) for r in xrange(clstart, clend)] |
|
2107 | added = [cl.node(r) for r in xrange(clstart, clend)] | |
2079 | publishing = self.ui.configbool('phases', 'publish', True) |
|
2108 | publishing = self.ui.configbool('phases', 'publish', True) | |
2080 | if srctype == 'push': |
|
2109 | if srctype == 'push': | |
2081 | # Old server can not push the boundary themself. |
|
2110 | # Old server can not push the boundary themself. | |
2082 | # New server won't push the boundary if changeset already |
|
2111 | # New server won't push the boundary if changeset already | |
2083 | # existed locally as secrete |
|
2112 | # existed locally as secrete | |
2084 | # |
|
2113 | # | |
2085 | # We should not use added here but the list of all change in |
|
2114 | # We should not use added here but the list of all change in | |
2086 | # the bundle |
|
2115 | # the bundle | |
2087 | if publishing: |
|
2116 | if publishing: | |
2088 | phases.advanceboundary(self, phases.public, srccontent) |
|
2117 | phases.advanceboundary(self, phases.public, srccontent) | |
2089 | else: |
|
2118 | else: | |
2090 | phases.advanceboundary(self, phases.draft, srccontent) |
|
2119 | phases.advanceboundary(self, phases.draft, srccontent) | |
2091 | phases.retractboundary(self, phases.draft, added) |
|
2120 | phases.retractboundary(self, phases.draft, added) | |
2092 | elif srctype != 'strip': |
|
2121 | elif srctype != 'strip': | |
2093 | # publishing only alter behavior during push |
|
2122 | # publishing only alter behavior during push | |
2094 | # |
|
2123 | # | |
2095 | # strip should not touch boundary at all |
|
2124 | # strip should not touch boundary at all | |
2096 | phases.retractboundary(self, phases.draft, added) |
|
2125 | phases.retractboundary(self, phases.draft, added) | |
2097 |
|
2126 | |||
2098 | # make changelog see real files again |
|
2127 | # make changelog see real files again | |
2099 | cl.finalize(trp) |
|
2128 | cl.finalize(trp) | |
2100 |
|
2129 | |||
2101 | tr.close() |
|
2130 | tr.close() | |
2102 |
|
2131 | |||
2103 | if changesets > 0: |
|
2132 | if changesets > 0: | |
2104 | def runhooks(): |
|
2133 | def runhooks(): | |
2105 | # forcefully update the on-disk branch cache |
|
2134 | # forcefully update the on-disk branch cache | |
2106 | self.ui.debug("updating the branch cache\n") |
|
2135 | self.ui.debug("updating the branch cache\n") | |
2107 | self.updatebranchcache() |
|
2136 | self.updatebranchcache() | |
2108 | self.hook("changegroup", node=hex(cl.node(clstart)), |
|
2137 | self.hook("changegroup", node=hex(cl.node(clstart)), | |
2109 | source=srctype, url=url) |
|
2138 | source=srctype, url=url) | |
2110 |
|
2139 | |||
2111 | for n in added: |
|
2140 | for n in added: | |
2112 | self.hook("incoming", node=hex(n), source=srctype, |
|
2141 | self.hook("incoming", node=hex(n), source=srctype, | |
2113 | url=url) |
|
2142 | url=url) | |
2114 | self._afterlock(runhooks) |
|
2143 | self._afterlock(runhooks) | |
2115 |
|
2144 | |||
2116 | finally: |
|
2145 | finally: | |
2117 | tr.release() |
|
2146 | tr.release() | |
2118 | # never return 0 here: |
|
2147 | # never return 0 here: | |
2119 | if dh < 0: |
|
2148 | if dh < 0: | |
2120 | return dh - 1 |
|
2149 | return dh - 1 | |
2121 | else: |
|
2150 | else: | |
2122 | return dh + 1 |
|
2151 | return dh + 1 | |
2123 |
|
2152 | |||
2124 | def stream_in(self, remote, requirements): |
|
2153 | def stream_in(self, remote, requirements): | |
2125 | lock = self.lock() |
|
2154 | lock = self.lock() | |
2126 | try: |
|
2155 | try: | |
2127 | fp = remote.stream_out() |
|
2156 | fp = remote.stream_out() | |
2128 | l = fp.readline() |
|
2157 | l = fp.readline() | |
2129 | try: |
|
2158 | try: | |
2130 | resp = int(l) |
|
2159 | resp = int(l) | |
2131 | except ValueError: |
|
2160 | except ValueError: | |
2132 | raise error.ResponseError( |
|
2161 | raise error.ResponseError( | |
2133 | _('Unexpected response from remote server:'), l) |
|
2162 | _('Unexpected response from remote server:'), l) | |
2134 | if resp == 1: |
|
2163 | if resp == 1: | |
2135 | raise util.Abort(_('operation forbidden by server')) |
|
2164 | raise util.Abort(_('operation forbidden by server')) | |
2136 | elif resp == 2: |
|
2165 | elif resp == 2: | |
2137 | raise util.Abort(_('locking the remote repository failed')) |
|
2166 | raise util.Abort(_('locking the remote repository failed')) | |
2138 | elif resp != 0: |
|
2167 | elif resp != 0: | |
2139 | raise util.Abort(_('the server sent an unknown error code')) |
|
2168 | raise util.Abort(_('the server sent an unknown error code')) | |
2140 | self.ui.status(_('streaming all changes\n')) |
|
2169 | self.ui.status(_('streaming all changes\n')) | |
2141 | l = fp.readline() |
|
2170 | l = fp.readline() | |
2142 | try: |
|
2171 | try: | |
2143 | total_files, total_bytes = map(int, l.split(' ', 1)) |
|
2172 | total_files, total_bytes = map(int, l.split(' ', 1)) | |
2144 | except (ValueError, TypeError): |
|
2173 | except (ValueError, TypeError): | |
2145 | raise error.ResponseError( |
|
2174 | raise error.ResponseError( | |
2146 | _('Unexpected response from remote server:'), l) |
|
2175 | _('Unexpected response from remote server:'), l) | |
2147 | self.ui.status(_('%d files to transfer, %s of data\n') % |
|
2176 | self.ui.status(_('%d files to transfer, %s of data\n') % | |
2148 | (total_files, util.bytecount(total_bytes))) |
|
2177 | (total_files, util.bytecount(total_bytes))) | |
2149 | start = time.time() |
|
2178 | start = time.time() | |
2150 | for i in xrange(total_files): |
|
2179 | for i in xrange(total_files): | |
2151 | # XXX doesn't support '\n' or '\r' in filenames |
|
2180 | # XXX doesn't support '\n' or '\r' in filenames | |
2152 | l = fp.readline() |
|
2181 | l = fp.readline() | |
2153 | try: |
|
2182 | try: | |
2154 | name, size = l.split('\0', 1) |
|
2183 | name, size = l.split('\0', 1) | |
2155 | size = int(size) |
|
2184 | size = int(size) | |
2156 | except (ValueError, TypeError): |
|
2185 | except (ValueError, TypeError): | |
2157 | raise error.ResponseError( |
|
2186 | raise error.ResponseError( | |
2158 | _('Unexpected response from remote server:'), l) |
|
2187 | _('Unexpected response from remote server:'), l) | |
2159 | self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size))) |
|
2188 | self.ui.debug('adding %s (%s)\n' % (name, util.bytecount(size))) | |
2160 | # for backwards compat, name was partially encoded |
|
2189 | # for backwards compat, name was partially encoded | |
2161 | ofp = self.sopener(store.decodedir(name), 'w') |
|
2190 | ofp = self.sopener(store.decodedir(name), 'w') | |
2162 | for chunk in util.filechunkiter(fp, limit=size): |
|
2191 | for chunk in util.filechunkiter(fp, limit=size): | |
2163 | ofp.write(chunk) |
|
2192 | ofp.write(chunk) | |
2164 | ofp.close() |
|
2193 | ofp.close() | |
2165 | elapsed = time.time() - start |
|
2194 | elapsed = time.time() - start | |
2166 | if elapsed <= 0: |
|
2195 | if elapsed <= 0: | |
2167 | elapsed = 0.001 |
|
2196 | elapsed = 0.001 | |
2168 | self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % |
|
2197 | self.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') % | |
2169 | (util.bytecount(total_bytes), elapsed, |
|
2198 | (util.bytecount(total_bytes), elapsed, | |
2170 | util.bytecount(total_bytes / elapsed))) |
|
2199 | util.bytecount(total_bytes / elapsed))) | |
2171 |
|
2200 | |||
2172 | # new requirements = old non-format requirements + new format-related |
|
2201 | # new requirements = old non-format requirements + new format-related | |
2173 | # requirements from the streamed-in repository |
|
2202 | # requirements from the streamed-in repository | |
2174 | requirements.update(set(self.requirements) - self.supportedformats) |
|
2203 | requirements.update(set(self.requirements) - self.supportedformats) | |
2175 | self._applyrequirements(requirements) |
|
2204 | self._applyrequirements(requirements) | |
2176 | self._writerequirements() |
|
2205 | self._writerequirements() | |
2177 |
|
2206 | |||
2178 | self.invalidate() |
|
2207 | self.invalidate() | |
2179 | return len(self.heads()) + 1 |
|
2208 | return len(self.heads()) + 1 | |
2180 | finally: |
|
2209 | finally: | |
2181 | lock.release() |
|
2210 | lock.release() | |
2182 |
|
2211 | |||
2183 | def clone(self, remote, heads=[], stream=False): |
|
2212 | def clone(self, remote, heads=[], stream=False): | |
2184 | '''clone remote repository. |
|
2213 | '''clone remote repository. | |
2185 |
|
2214 | |||
2186 | keyword arguments: |
|
2215 | keyword arguments: | |
2187 | heads: list of revs to clone (forces use of pull) |
|
2216 | heads: list of revs to clone (forces use of pull) | |
2188 | stream: use streaming clone if possible''' |
|
2217 | stream: use streaming clone if possible''' | |
2189 |
|
2218 | |||
2190 | # now, all clients that can request uncompressed clones can |
|
2219 | # now, all clients that can request uncompressed clones can | |
2191 | # read repo formats supported by all servers that can serve |
|
2220 | # read repo formats supported by all servers that can serve | |
2192 | # them. |
|
2221 | # them. | |
2193 |
|
2222 | |||
2194 | # if revlog format changes, client will have to check version |
|
2223 | # if revlog format changes, client will have to check version | |
2195 | # and format flags on "stream" capability, and use |
|
2224 | # and format flags on "stream" capability, and use | |
2196 | # uncompressed only if compatible. |
|
2225 | # uncompressed only if compatible. | |
2197 |
|
2226 | |||
2198 | if stream and not heads: |
|
2227 | if stream and not heads: | |
2199 | # 'stream' means remote revlog format is revlogv1 only |
|
2228 | # 'stream' means remote revlog format is revlogv1 only | |
2200 | if remote.capable('stream'): |
|
2229 | if remote.capable('stream'): | |
2201 | return self.stream_in(remote, set(('revlogv1',))) |
|
2230 | return self.stream_in(remote, set(('revlogv1',))) | |
2202 | # otherwise, 'streamreqs' contains the remote revlog format |
|
2231 | # otherwise, 'streamreqs' contains the remote revlog format | |
2203 | streamreqs = remote.capable('streamreqs') |
|
2232 | streamreqs = remote.capable('streamreqs') | |
2204 | if streamreqs: |
|
2233 | if streamreqs: | |
2205 | streamreqs = set(streamreqs.split(',')) |
|
2234 | streamreqs = set(streamreqs.split(',')) | |
2206 | # if we support it, stream in and adjust our requirements |
|
2235 | # if we support it, stream in and adjust our requirements | |
2207 | if not streamreqs - self.supportedformats: |
|
2236 | if not streamreqs - self.supportedformats: | |
2208 | return self.stream_in(remote, streamreqs) |
|
2237 | return self.stream_in(remote, streamreqs) | |
2209 | return self.pull(remote, heads) |
|
2238 | return self.pull(remote, heads) | |
2210 |
|
2239 | |||
2211 | def pushkey(self, namespace, key, old, new): |
|
2240 | def pushkey(self, namespace, key, old, new): | |
2212 | self.hook('prepushkey', throw=True, namespace=namespace, key=key, |
|
2241 | self.hook('prepushkey', throw=True, namespace=namespace, key=key, | |
2213 | old=old, new=new) |
|
2242 | old=old, new=new) | |
2214 | ret = pushkey.push(self, namespace, key, old, new) |
|
2243 | ret = pushkey.push(self, namespace, key, old, new) | |
2215 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, |
|
2244 | self.hook('pushkey', namespace=namespace, key=key, old=old, new=new, | |
2216 | ret=ret) |
|
2245 | ret=ret) | |
2217 | return ret |
|
2246 | return ret | |
2218 |
|
2247 | |||
2219 | def listkeys(self, namespace): |
|
2248 | def listkeys(self, namespace): | |
2220 | self.hook('prelistkeys', throw=True, namespace=namespace) |
|
2249 | self.hook('prelistkeys', throw=True, namespace=namespace) | |
2221 | values = pushkey.list(self, namespace) |
|
2250 | values = pushkey.list(self, namespace) | |
2222 | self.hook('listkeys', namespace=namespace, values=values) |
|
2251 | self.hook('listkeys', namespace=namespace, values=values) | |
2223 | return values |
|
2252 | return values | |
2224 |
|
2253 | |||
2225 | def debugwireargs(self, one, two, three=None, four=None, five=None): |
|
2254 | def debugwireargs(self, one, two, three=None, four=None, five=None): | |
2226 | '''used to test argument passing over the wire''' |
|
2255 | '''used to test argument passing over the wire''' | |
2227 | return "%s %s %s %s %s" % (one, two, three, four, five) |
|
2256 | return "%s %s %s %s %s" % (one, two, three, four, five) | |
2228 |
|
2257 | |||
2229 | def savecommitmessage(self, text): |
|
2258 | def savecommitmessage(self, text): | |
2230 | fp = self.opener('last-message.txt', 'wb') |
|
2259 | fp = self.opener('last-message.txt', 'wb') | |
2231 | try: |
|
2260 | try: | |
2232 | fp.write(text) |
|
2261 | fp.write(text) | |
2233 | finally: |
|
2262 | finally: | |
2234 | fp.close() |
|
2263 | fp.close() | |
2235 | return self.pathto(fp.name[len(self.root)+1:]) |
|
2264 | return self.pathto(fp.name[len(self.root)+1:]) | |
2236 |
|
2265 | |||
2237 | # used to avoid circular references so destructors work |
|
2266 | # used to avoid circular references so destructors work | |
2238 | def aftertrans(files): |
|
2267 | def aftertrans(files): | |
2239 | renamefiles = [tuple(t) for t in files] |
|
2268 | renamefiles = [tuple(t) for t in files] | |
2240 | def a(): |
|
2269 | def a(): | |
2241 | for src, dest in renamefiles: |
|
2270 | for src, dest in renamefiles: | |
2242 | util.rename(src, dest) |
|
2271 | util.rename(src, dest) | |
2243 | return a |
|
2272 | return a | |
2244 |
|
2273 | |||
2245 | def undoname(fn): |
|
2274 | def undoname(fn): | |
2246 | base, name = os.path.split(fn) |
|
2275 | base, name = os.path.split(fn) | |
2247 | assert name.startswith('journal') |
|
2276 | assert name.startswith('journal') | |
2248 | return os.path.join(base, name.replace('journal', 'undo', 1)) |
|
2277 | return os.path.join(base, name.replace('journal', 'undo', 1)) | |
2249 |
|
2278 | |||
2250 | def instance(ui, path, create): |
|
2279 | def instance(ui, path, create): | |
2251 | return localrepository(ui, util.urllocalpath(path), create) |
|
2280 | return localrepository(ui, util.urllocalpath(path), create) | |
2252 |
|
2281 | |||
2253 | def islocal(path): |
|
2282 | def islocal(path): | |
2254 | return True |
|
2283 | return True |
@@ -1,663 +1,660 b'' | |||||
1 | $ check_code="$TESTDIR"/../contrib/check-code.py |
|
1 | $ check_code="$TESTDIR"/../contrib/check-code.py | |
2 | $ cd "$TESTDIR"/.. |
|
2 | $ cd "$TESTDIR"/.. | |
3 |
|
3 | |||
4 | $ "$check_code" `hg manifest` || echo 'FAILURE IS NOT AN OPTION!!!' |
|
4 | $ "$check_code" `hg manifest` || echo 'FAILURE IS NOT AN OPTION!!!' | |
5 |
|
5 | |||
6 | $ "$check_code" --warnings --nolineno --per-file=0 `hg manifest` |
|
6 | $ "$check_code" --warnings --nolineno --per-file=0 `hg manifest` | |
7 | contrib/check-code.py:0: |
|
7 | contrib/check-code.py:0: | |
8 | > # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"), |
|
8 | > # (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"), | |
9 | warning: line over 80 characters |
|
9 | warning: line over 80 characters | |
10 | contrib/perf.py:0: |
|
10 | contrib/perf.py:0: | |
11 | > except: |
|
11 | > except: | |
12 | warning: naked except clause |
|
12 | warning: naked except clause | |
13 | contrib/perf.py:0: |
|
13 | contrib/perf.py:0: | |
14 | > #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, False)))) |
|
14 | > #timer(lambda: sum(map(len, repo.dirstate.status(m, [], False, False, False)))) | |
15 | warning: line over 80 characters |
|
15 | warning: line over 80 characters | |
16 | contrib/perf.py:0: |
|
16 | contrib/perf.py:0: | |
17 | > except: |
|
17 | > except: | |
18 | warning: naked except clause |
|
18 | warning: naked except clause | |
19 | contrib/setup3k.py:0: |
|
19 | contrib/setup3k.py:0: | |
20 | > except: |
|
20 | > except: | |
21 | warning: naked except clause |
|
21 | warning: naked except clause | |
22 | contrib/setup3k.py:0: |
|
22 | contrib/setup3k.py:0: | |
23 | > except: |
|
23 | > except: | |
24 | warning: naked except clause |
|
24 | warning: naked except clause | |
25 | contrib/setup3k.py:0: |
|
25 | contrib/setup3k.py:0: | |
26 | > except: |
|
26 | > except: | |
27 | warning: naked except clause |
|
27 | warning: naked except clause | |
28 | warning: naked except clause |
|
28 | warning: naked except clause | |
29 | warning: naked except clause |
|
29 | warning: naked except clause | |
30 | contrib/shrink-revlog.py:0: |
|
30 | contrib/shrink-revlog.py:0: | |
31 | > '(You can delete those files when you are satisfied that your\n' |
|
31 | > '(You can delete those files when you are satisfied that your\n' | |
32 | warning: line over 80 characters |
|
32 | warning: line over 80 characters | |
33 | contrib/shrink-revlog.py:0: |
|
33 | contrib/shrink-revlog.py:0: | |
34 | > ('', 'sort', 'reversepostorder', 'name of sort algorithm to use'), |
|
34 | > ('', 'sort', 'reversepostorder', 'name of sort algorithm to use'), | |
35 | warning: line over 80 characters |
|
35 | warning: line over 80 characters | |
36 | contrib/shrink-revlog.py:0: |
|
36 | contrib/shrink-revlog.py:0: | |
37 | > [('', 'revlog', '', _('index (.i) file of the revlog to shrink')), |
|
37 | > [('', 'revlog', '', _('index (.i) file of the revlog to shrink')), | |
38 | warning: line over 80 characters |
|
38 | warning: line over 80 characters | |
39 | contrib/shrink-revlog.py:0: |
|
39 | contrib/shrink-revlog.py:0: | |
40 | > except: |
|
40 | > except: | |
41 | warning: naked except clause |
|
41 | warning: naked except clause | |
42 | doc/gendoc.py:0: |
|
42 | doc/gendoc.py:0: | |
43 | > "together with Mercurial. Help for other extensions is available " |
|
43 | > "together with Mercurial. Help for other extensions is available " | |
44 | warning: line over 80 characters |
|
44 | warning: line over 80 characters | |
45 | hgext/bugzilla.py:0: |
|
45 | hgext/bugzilla.py:0: | |
46 | > raise util.Abort(_('cannot find bugzilla user id for %s or %s') % |
|
46 | > raise util.Abort(_('cannot find bugzilla user id for %s or %s') % | |
47 | warning: line over 80 characters |
|
47 | warning: line over 80 characters | |
48 | hgext/bugzilla.py:0: |
|
48 | hgext/bugzilla.py:0: | |
49 | > bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla') |
|
49 | > bzdir = self.ui.config('bugzilla', 'bzdir', '/var/www/html/bugzilla') | |
50 | warning: line over 80 characters |
|
50 | warning: line over 80 characters | |
51 | hgext/convert/__init__.py:0: |
|
51 | hgext/convert/__init__.py:0: | |
52 | > ('', 'ancestors', '', _('show current changeset in ancestor branches')), |
|
52 | > ('', 'ancestors', '', _('show current changeset in ancestor branches')), | |
53 | warning: line over 80 characters |
|
53 | warning: line over 80 characters | |
54 | hgext/convert/bzr.py:0: |
|
54 | hgext/convert/bzr.py:0: | |
55 | > except: |
|
55 | > except: | |
56 | warning: naked except clause |
|
56 | warning: naked except clause | |
57 | hgext/convert/common.py:0: |
|
57 | hgext/convert/common.py:0: | |
58 | > except: |
|
58 | > except: | |
59 | warning: naked except clause |
|
59 | warning: naked except clause | |
60 | hgext/convert/common.py:0: |
|
60 | hgext/convert/common.py:0: | |
61 | > except: |
|
61 | > except: | |
62 | warning: naked except clause |
|
62 | warning: naked except clause | |
63 | warning: naked except clause |
|
63 | warning: naked except clause | |
64 | hgext/convert/convcmd.py:0: |
|
64 | hgext/convert/convcmd.py:0: | |
65 | > except: |
|
65 | > except: | |
66 | warning: naked except clause |
|
66 | warning: naked except clause | |
67 | hgext/convert/cvs.py:0: |
|
67 | hgext/convert/cvs.py:0: | |
68 | > # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z |
|
68 | > # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z | |
69 | warning: line over 80 characters |
|
69 | warning: line over 80 characters | |
70 | hgext/convert/cvsps.py:0: |
|
70 | hgext/convert/cvsps.py:0: | |
71 | > assert len(branches) == 1, 'unknown branch: %s' % e.mergepoint |
|
71 | > assert len(branches) == 1, 'unknown branch: %s' % e.mergepoint | |
72 | warning: line over 80 characters |
|
72 | warning: line over 80 characters | |
73 | hgext/convert/cvsps.py:0: |
|
73 | hgext/convert/cvsps.py:0: | |
74 | > ui.write('Ancestors: %s\n' % (','.join(r))) |
|
74 | > ui.write('Ancestors: %s\n' % (','.join(r))) | |
75 | warning: unwrapped ui message |
|
75 | warning: unwrapped ui message | |
76 | hgext/convert/cvsps.py:0: |
|
76 | hgext/convert/cvsps.py:0: | |
77 | > ui.write('Parent: %d\n' % cs.parents[0].id) |
|
77 | > ui.write('Parent: %d\n' % cs.parents[0].id) | |
78 | warning: unwrapped ui message |
|
78 | warning: unwrapped ui message | |
79 | hgext/convert/cvsps.py:0: |
|
79 | hgext/convert/cvsps.py:0: | |
80 | > ui.write('Parents: %s\n' % |
|
80 | > ui.write('Parents: %s\n' % | |
81 | warning: unwrapped ui message |
|
81 | warning: unwrapped ui message | |
82 | hgext/convert/cvsps.py:0: |
|
82 | hgext/convert/cvsps.py:0: | |
83 | > except: |
|
83 | > except: | |
84 | warning: naked except clause |
|
84 | warning: naked except clause | |
85 | hgext/convert/cvsps.py:0: |
|
85 | hgext/convert/cvsps.py:0: | |
86 | > ui.write('Branchpoints: %s \n' % ', '.join(branchpoints)) |
|
86 | > ui.write('Branchpoints: %s \n' % ', '.join(branchpoints)) | |
87 | warning: unwrapped ui message |
|
87 | warning: unwrapped ui message | |
88 | hgext/convert/cvsps.py:0: |
|
88 | hgext/convert/cvsps.py:0: | |
89 | > ui.write('Author: %s\n' % cs.author) |
|
89 | > ui.write('Author: %s\n' % cs.author) | |
90 | warning: unwrapped ui message |
|
90 | warning: unwrapped ui message | |
91 | hgext/convert/cvsps.py:0: |
|
91 | hgext/convert/cvsps.py:0: | |
92 | > ui.write('Branch: %s\n' % (cs.branch or 'HEAD')) |
|
92 | > ui.write('Branch: %s\n' % (cs.branch or 'HEAD')) | |
93 | warning: unwrapped ui message |
|
93 | warning: unwrapped ui message | |
94 | hgext/convert/cvsps.py:0: |
|
94 | hgext/convert/cvsps.py:0: | |
95 | > ui.write('Date: %s\n' % util.datestr(cs.date, |
|
95 | > ui.write('Date: %s\n' % util.datestr(cs.date, | |
96 | warning: unwrapped ui message |
|
96 | warning: unwrapped ui message | |
97 | hgext/convert/cvsps.py:0: |
|
97 | hgext/convert/cvsps.py:0: | |
98 | > ui.write('Log:\n') |
|
98 | > ui.write('Log:\n') | |
99 | warning: unwrapped ui message |
|
99 | warning: unwrapped ui message | |
100 | hgext/convert/cvsps.py:0: |
|
100 | hgext/convert/cvsps.py:0: | |
101 | > ui.write('Members: \n') |
|
101 | > ui.write('Members: \n') | |
102 | warning: unwrapped ui message |
|
102 | warning: unwrapped ui message | |
103 | hgext/convert/cvsps.py:0: |
|
103 | hgext/convert/cvsps.py:0: | |
104 | > ui.write('PatchSet %d \n' % cs.id) |
|
104 | > ui.write('PatchSet %d \n' % cs.id) | |
105 | warning: unwrapped ui message |
|
105 | warning: unwrapped ui message | |
106 | hgext/convert/cvsps.py:0: |
|
106 | hgext/convert/cvsps.py:0: | |
107 | > ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1], |
|
107 | > ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags) > 1], | |
108 | warning: unwrapped ui message |
|
108 | warning: unwrapped ui message | |
109 | hgext/convert/git.py:0: |
|
109 | hgext/convert/git.py:0: | |
110 | > except: |
|
110 | > except: | |
111 | warning: naked except clause |
|
111 | warning: naked except clause | |
112 | hgext/convert/git.py:0: |
|
112 | hgext/convert/git.py:0: | |
113 | > fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --' |
|
113 | > fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --' | |
114 | warning: line over 80 characters |
|
114 | warning: line over 80 characters | |
115 | hgext/convert/hg.py:0: |
|
115 | hgext/convert/hg.py:0: | |
116 | > # detect missing revlogs and abort on errors or populate self.ignored |
|
116 | > # detect missing revlogs and abort on errors or populate self.ignored | |
117 | warning: line over 80 characters |
|
117 | warning: line over 80 characters | |
118 | hgext/convert/hg.py:0: |
|
118 | hgext/convert/hg.py:0: | |
119 | > except: |
|
119 | > except: | |
120 | warning: naked except clause |
|
120 | warning: naked except clause | |
121 | warning: naked except clause |
|
121 | warning: naked except clause | |
122 | hgext/convert/hg.py:0: |
|
122 | hgext/convert/hg.py:0: | |
123 | > except: |
|
123 | > except: | |
124 | warning: naked except clause |
|
124 | warning: naked except clause | |
125 | hgext/convert/monotone.py:0: |
|
125 | hgext/convert/monotone.py:0: | |
126 | > except: |
|
126 | > except: | |
127 | warning: naked except clause |
|
127 | warning: naked except clause | |
128 | hgext/convert/monotone.py:0: |
|
128 | hgext/convert/monotone.py:0: | |
129 | > except: |
|
129 | > except: | |
130 | warning: naked except clause |
|
130 | warning: naked except clause | |
131 | hgext/convert/subversion.py:0: |
|
131 | hgext/convert/subversion.py:0: | |
132 | > raise util.Abort(_('svn: branch has no revision %s') % to_revnum) |
|
132 | > raise util.Abort(_('svn: branch has no revision %s') % to_revnum) | |
133 | warning: line over 80 characters |
|
133 | warning: line over 80 characters | |
134 | hgext/convert/subversion.py:0: |
|
134 | hgext/convert/subversion.py:0: | |
135 | > except: |
|
135 | > except: | |
136 | warning: naked except clause |
|
136 | warning: naked except clause | |
137 | hgext/convert/subversion.py:0: |
|
137 | hgext/convert/subversion.py:0: | |
138 | > args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths, |
|
138 | > args = [self.baseurl, relpaths, start, end, limit, discover_changed_paths, | |
139 | warning: line over 80 characters |
|
139 | warning: line over 80 characters | |
140 | hgext/convert/subversion.py:0: |
|
140 | hgext/convert/subversion.py:0: | |
141 | > self.trunkname = self.ui.config('convert', 'svn.trunk', 'trunk').strip('/') |
|
141 | > self.trunkname = self.ui.config('convert', 'svn.trunk', 'trunk').strip('/') | |
142 | warning: line over 80 characters |
|
142 | warning: line over 80 characters | |
143 | hgext/convert/subversion.py:0: |
|
143 | hgext/convert/subversion.py:0: | |
144 | > except: |
|
144 | > except: | |
145 | warning: naked except clause |
|
145 | warning: naked except clause | |
146 | hgext/convert/subversion.py:0: |
|
146 | hgext/convert/subversion.py:0: | |
147 | > def get_log_child(fp, url, paths, start, end, limit=0, discover_changed_paths=True, |
|
147 | > def get_log_child(fp, url, paths, start, end, limit=0, discover_changed_paths=True, | |
148 | warning: line over 80 characters |
|
148 | warning: line over 80 characters | |
149 | hgext/eol.py:0: |
|
149 | hgext/eol.py:0: | |
150 | > if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n': |
|
150 | > if ui.configbool('eol', 'fix-trailing-newline', False) and s and s[-1] != '\n': | |
151 | warning: line over 80 characters |
|
151 | warning: line over 80 characters | |
152 | warning: line over 80 characters |
|
152 | warning: line over 80 characters | |
153 | hgext/gpg.py:0: |
|
153 | hgext/gpg.py:0: | |
154 | > except: |
|
154 | > except: | |
155 | warning: naked except clause |
|
155 | warning: naked except clause | |
156 | hgext/hgcia.py:0: |
|
156 | hgext/hgcia.py:0: | |
157 | > except: |
|
157 | > except: | |
158 | warning: naked except clause |
|
158 | warning: naked except clause | |
159 | hgext/hgk.py:0: |
|
159 | hgext/hgk.py:0: | |
160 | > ui.write("%s%s\n" % (prefix, description.replace('\n', nlprefix).strip())) |
|
160 | > ui.write("%s%s\n" % (prefix, description.replace('\n', nlprefix).strip())) | |
161 | warning: line over 80 characters |
|
161 | warning: line over 80 characters | |
162 | hgext/hgk.py:0: |
|
162 | hgext/hgk.py:0: | |
163 | > ui.write("parent %s\n" % p) |
|
163 | > ui.write("parent %s\n" % p) | |
164 | warning: unwrapped ui message |
|
164 | warning: unwrapped ui message | |
165 | hgext/hgk.py:0: |
|
165 | hgext/hgk.py:0: | |
166 | > ui.write('k=%s\nv=%s\n' % (name, value)) |
|
166 | > ui.write('k=%s\nv=%s\n' % (name, value)) | |
167 | warning: unwrapped ui message |
|
167 | warning: unwrapped ui message | |
168 | hgext/hgk.py:0: |
|
168 | hgext/hgk.py:0: | |
169 | > ui.write("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1])) |
|
169 | > ui.write("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1])) | |
170 | warning: unwrapped ui message |
|
170 | warning: unwrapped ui message | |
171 | hgext/hgk.py:0: |
|
171 | hgext/hgk.py:0: | |
172 | > ui.write("branch %s\n\n" % ctx.branch()) |
|
172 | > ui.write("branch %s\n\n" % ctx.branch()) | |
173 | warning: unwrapped ui message |
|
173 | warning: unwrapped ui message | |
174 | hgext/hgk.py:0: |
|
174 | hgext/hgk.py:0: | |
175 | > ui.write("committer %s %s %s\n" % (committer, int(date[0]), date[1])) |
|
175 | > ui.write("committer %s %s %s\n" % (committer, int(date[0]), date[1])) | |
176 | warning: unwrapped ui message |
|
176 | warning: unwrapped ui message | |
177 | hgext/hgk.py:0: |
|
177 | hgext/hgk.py:0: | |
178 | > ui.write("revision %d\n" % ctx.rev()) |
|
178 | > ui.write("revision %d\n" % ctx.rev()) | |
179 | warning: unwrapped ui message |
|
179 | warning: unwrapped ui message | |
180 | hgext/hgk.py:0: |
|
180 | hgext/hgk.py:0: | |
181 | > ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ?? |
|
181 | > ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ?? | |
182 | warning: line over 80 characters |
|
182 | warning: line over 80 characters | |
183 | warning: unwrapped ui message |
|
183 | warning: unwrapped ui message | |
184 | hgext/highlight/__init__.py:0: |
|
184 | hgext/highlight/__init__.py:0: | |
185 | > extensions.wrapfunction(webcommands, '_filerevision', filerevision_highlight) |
|
185 | > extensions.wrapfunction(webcommands, '_filerevision', filerevision_highlight) | |
186 | warning: line over 80 characters |
|
186 | warning: line over 80 characters | |
187 | hgext/highlight/__init__.py:0: |
|
187 | hgext/highlight/__init__.py:0: | |
188 | > return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')] |
|
188 | > return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')] | |
189 | warning: line over 80 characters |
|
189 | warning: line over 80 characters | |
190 | hgext/inotify/__init__.py:0: |
|
190 | hgext/inotify/__init__.py:0: | |
191 | > if self._inotifyon and not ignored and not subrepos and not self._dirty: |
|
191 | > if self._inotifyon and not ignored and not subrepos and not self._dirty: | |
192 | warning: line over 80 characters |
|
192 | warning: line over 80 characters | |
193 | hgext/inotify/server.py:0: |
|
193 | hgext/inotify/server.py:0: | |
194 | > except: |
|
194 | > except: | |
195 | warning: naked except clause |
|
195 | warning: naked except clause | |
196 | hgext/inotify/server.py:0: |
|
196 | hgext/inotify/server.py:0: | |
197 | > except: |
|
197 | > except: | |
198 | warning: naked except clause |
|
198 | warning: naked except clause | |
199 | hgext/keyword.py:0: |
|
199 | hgext/keyword.py:0: | |
200 | > ui.note("hg ci -m '%s'\n" % msg) |
|
200 | > ui.note("hg ci -m '%s'\n" % msg) | |
201 | warning: unwrapped ui message |
|
201 | warning: unwrapped ui message | |
202 | hgext/largefiles/overrides.py:0: |
|
202 | hgext/largefiles/overrides.py:0: | |
203 | > # When we call orig below it creates the standins but we don't add them |
|
203 | > # When we call orig below it creates the standins but we don't add them | |
204 | warning: line over 80 characters |
|
204 | warning: line over 80 characters | |
205 | hgext/largefiles/reposetup.py:0: |
|
205 | hgext/largefiles/reposetup.py:0: | |
206 | > if os.path.exists(self.wjoin(lfutil.standin(lfile))): |
|
206 | > if os.path.exists(self.wjoin(lfutil.standin(lfile))): | |
207 | warning: line over 80 characters |
|
207 | warning: line over 80 characters | |
208 | hgext/mq.py:0: |
|
208 | hgext/mq.py:0: | |
209 | > raise util.Abort(_("%s does not have a parent recorded" % root)) |
|
209 | > raise util.Abort(_("%s does not have a parent recorded" % root)) | |
210 | warning: line over 80 characters |
|
210 | warning: line over 80 characters | |
211 | hgext/mq.py:0: |
|
211 | hgext/mq.py:0: | |
212 | > raise util.Abort(_("cannot push --exact with applied patches")) |
|
212 | > raise util.Abort(_("cannot push --exact with applied patches")) | |
213 | warning: line over 80 characters |
|
213 | warning: line over 80 characters | |
214 | hgext/mq.py:0: |
|
214 | hgext/mq.py:0: | |
215 | > raise util.Abort(_("cannot use --exact and --move together")) |
|
215 | > raise util.Abort(_("cannot use --exact and --move together")) | |
216 | warning: line over 80 characters |
|
216 | warning: line over 80 characters | |
217 | hgext/mq.py:0: |
|
217 | hgext/mq.py:0: | |
218 | > self.ui.warn(_('Tag %s overrides mq patch of the same name\n') |
|
218 | > self.ui.warn(_('Tag %s overrides mq patch of the same name\n') | |
219 | warning: line over 80 characters |
|
219 | warning: line over 80 characters | |
220 | hgext/mq.py:0: |
|
220 | hgext/mq.py:0: | |
221 | > except: |
|
221 | > except: | |
222 | warning: naked except clause |
|
222 | warning: naked except clause | |
223 | warning: naked except clause |
|
223 | warning: naked except clause | |
224 | hgext/mq.py:0: |
|
224 | hgext/mq.py:0: | |
225 | > except: |
|
225 | > except: | |
226 | warning: naked except clause |
|
226 | warning: naked except clause | |
227 | warning: naked except clause |
|
227 | warning: naked except clause | |
228 | warning: naked except clause |
|
228 | warning: naked except clause | |
229 | warning: naked except clause |
|
229 | warning: naked except clause | |
230 | hgext/mq.py:0: |
|
230 | hgext/mq.py:0: | |
231 | > raise util.Abort(_('cannot mix -l/--list with options or arguments')) |
|
231 | > raise util.Abort(_('cannot mix -l/--list with options or arguments')) | |
232 | warning: line over 80 characters |
|
232 | warning: line over 80 characters | |
233 | hgext/mq.py:0: |
|
233 | hgext/mq.py:0: | |
234 | > raise util.Abort(_('qfold cannot fold already applied patch %s') % p) |
|
234 | > raise util.Abort(_('qfold cannot fold already applied patch %s') % p) | |
235 | warning: line over 80 characters |
|
235 | warning: line over 80 characters | |
236 | hgext/mq.py:0: |
|
236 | hgext/mq.py:0: | |
237 | > ('', 'move', None, _('reorder patch series and apply only the patch'))], |
|
237 | > ('', 'move', None, _('reorder patch series and apply only the patch'))], | |
238 | warning: line over 80 characters |
|
238 | warning: line over 80 characters | |
239 | hgext/mq.py:0: |
|
239 | hgext/mq.py:0: | |
240 | > ('U', 'noupdate', None, _('do not update the new working directories')), |
|
240 | > ('U', 'noupdate', None, _('do not update the new working directories')), | |
241 | warning: line over 80 characters |
|
241 | warning: line over 80 characters | |
242 | hgext/mq.py:0: |
|
242 | hgext/mq.py:0: | |
243 | > ('e', 'exact', None, _('apply the target patch to its recorded parent')), |
|
243 | > ('e', 'exact', None, _('apply the target patch to its recorded parent')), | |
244 | warning: line over 80 characters |
|
244 | warning: line over 80 characters | |
245 | hgext/mq.py:0: |
|
245 | hgext/mq.py:0: | |
246 | > except: |
|
246 | > except: | |
247 | warning: naked except clause |
|
247 | warning: naked except clause | |
248 | hgext/mq.py:0: |
|
248 | hgext/mq.py:0: | |
249 | > ui.write("mq: %s\n" % ', '.join(m)) |
|
249 | > ui.write("mq: %s\n" % ', '.join(m)) | |
250 | warning: unwrapped ui message |
|
250 | warning: unwrapped ui message | |
251 | hgext/mq.py:0: |
|
251 | hgext/mq.py:0: | |
252 | > repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary')) |
|
252 | > repo.mq.qseries(repo, missing=opts.get('missing'), summary=opts.get('summary')) | |
253 | warning: line over 80 characters |
|
253 | warning: line over 80 characters | |
254 | hgext/notify.py:0: |
|
254 | hgext/notify.py:0: | |
255 | > ui.note(_('notify: suppressing notification for merge %d:%s\n') % |
|
255 | > ui.note(_('notify: suppressing notification for merge %d:%s\n') % | |
256 | warning: line over 80 characters |
|
256 | warning: line over 80 characters | |
257 | hgext/patchbomb.py:0: |
|
257 | hgext/patchbomb.py:0: | |
258 | > binnode, seqno=idx, total=total) |
|
258 | > binnode, seqno=idx, total=total) | |
259 | warning: line over 80 characters |
|
259 | warning: line over 80 characters | |
260 | hgext/patchbomb.py:0: |
|
260 | hgext/patchbomb.py:0: | |
261 | > except: |
|
261 | > except: | |
262 | warning: naked except clause |
|
262 | warning: naked except clause | |
263 | hgext/patchbomb.py:0: |
|
263 | hgext/patchbomb.py:0: | |
264 | > ui.write('Subject: %s\n' % subj) |
|
264 | > ui.write('Subject: %s\n' % subj) | |
265 | warning: unwrapped ui message |
|
265 | warning: unwrapped ui message | |
266 | hgext/patchbomb.py:0: |
|
266 | hgext/patchbomb.py:0: | |
267 | > p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch', opts.get('test')) |
|
267 | > p = mail.mimetextpatch('\n'.join(patchlines), 'x-patch', opts.get('test')) | |
268 | warning: line over 80 characters |
|
268 | warning: line over 80 characters | |
269 | hgext/patchbomb.py:0: |
|
269 | hgext/patchbomb.py:0: | |
270 | > ui.write('From: %s\n' % sender) |
|
270 | > ui.write('From: %s\n' % sender) | |
271 | warning: unwrapped ui message |
|
271 | warning: unwrapped ui message | |
272 | hgext/record.py:0: |
|
272 | hgext/record.py:0: | |
273 | > ignoreblanklines=opts.get('ignore_blank_lines')) |
|
273 | > ignoreblanklines=opts.get('ignore_blank_lines')) | |
274 | warning: line over 80 characters |
|
274 | warning: line over 80 characters | |
275 | hgext/record.py:0: |
|
275 | hgext/record.py:0: | |
276 | > ignorewsamount=opts.get('ignore_space_change'), |
|
276 | > ignorewsamount=opts.get('ignore_space_change'), | |
277 | warning: line over 80 characters |
|
277 | warning: line over 80 characters | |
278 | hgext/zeroconf/__init__.py:0: |
|
278 | hgext/zeroconf/__init__.py:0: | |
279 | > publish(name, desc, path, util.getport(u.config("web", "port", 8000))) |
|
279 | > publish(name, desc, path, util.getport(u.config("web", "port", 8000))) | |
280 | warning: line over 80 characters |
|
280 | warning: line over 80 characters | |
281 | hgext/zeroconf/__init__.py:0: |
|
281 | hgext/zeroconf/__init__.py:0: | |
282 | > except: |
|
282 | > except: | |
283 | warning: naked except clause |
|
283 | warning: naked except clause | |
284 | warning: naked except clause |
|
284 | warning: naked except clause | |
285 | mercurial/bundlerepo.py:0: |
|
285 | mercurial/bundlerepo.py:0: | |
286 | > is a bundlerepo for the obtained bundle when the original "other" is remote. |
|
286 | > is a bundlerepo for the obtained bundle when the original "other" is remote. | |
287 | warning: line over 80 characters |
|
287 | warning: line over 80 characters | |
288 | mercurial/bundlerepo.py:0: |
|
288 | mercurial/bundlerepo.py:0: | |
289 | > "local" is a local repo from which to obtain the actual incoming changesets; it |
|
289 | > "local" is a local repo from which to obtain the actual incoming changesets; it | |
290 | warning: line over 80 characters |
|
290 | warning: line over 80 characters | |
291 | mercurial/bundlerepo.py:0: |
|
291 | mercurial/bundlerepo.py:0: | |
292 | > tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force) |
|
292 | > tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force) | |
293 | warning: line over 80 characters |
|
293 | warning: line over 80 characters | |
294 | mercurial/commands.py:0: |
|
294 | mercurial/commands.py:0: | |
295 | > " size " + basehdr + " link p1 p2 nodeid\n") |
|
295 | > " size " + basehdr + " link p1 p2 nodeid\n") | |
296 | warning: line over 80 characters |
|
296 | warning: line over 80 characters | |
297 | mercurial/commands.py:0: |
|
297 | mercurial/commands.py:0: | |
298 | > raise util.Abort('cannot use localheads with old style discovery') |
|
298 | > raise util.Abort('cannot use localheads with old style discovery') | |
299 | warning: line over 80 characters |
|
299 | warning: line over 80 characters | |
300 | mercurial/commands.py:0: |
|
300 | mercurial/commands.py:0: | |
301 | > ui.note('branch %s\n' % data) |
|
301 | > ui.note('branch %s\n' % data) | |
302 | warning: unwrapped ui message |
|
302 | warning: unwrapped ui message | |
303 | mercurial/commands.py:0: |
|
303 | mercurial/commands.py:0: | |
304 | > ui.note('node %s\n' % str(data)) |
|
304 | > ui.note('node %s\n' % str(data)) | |
305 | warning: unwrapped ui message |
|
305 | warning: unwrapped ui message | |
306 | mercurial/commands.py:0: |
|
306 | mercurial/commands.py:0: | |
307 | > ui.note('tag %s\n' % name) |
|
307 | > ui.note('tag %s\n' % name) | |
308 | warning: unwrapped ui message |
|
308 | warning: unwrapped ui message | |
309 | mercurial/commands.py:0: |
|
309 | mercurial/commands.py:0: | |
310 | > ui.write("unpruned common: %s\n" % " ".join([short(n) |
|
310 | > ui.write("unpruned common: %s\n" % " ".join([short(n) | |
311 | warning: unwrapped ui message |
|
311 | warning: unwrapped ui message | |
312 | mercurial/commands.py:0: |
|
312 | mercurial/commands.py:0: | |
313 | > yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) |
|
313 | > yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1))) | |
314 | warning: line over 80 characters |
|
314 | warning: line over 80 characters | |
315 | mercurial/commands.py:0: |
|
315 | mercurial/commands.py:0: | |
316 | > yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) |
|
316 | > yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) | |
317 | warning: line over 80 characters |
|
317 | warning: line over 80 characters | |
318 | mercurial/commands.py:0: |
|
318 | mercurial/commands.py:0: | |
319 | > except: |
|
319 | > except: | |
320 | warning: naked except clause |
|
320 | warning: naked except clause | |
321 | mercurial/commands.py:0: |
|
321 | mercurial/commands.py:0: | |
322 | > ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n")) |
|
322 | > ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n")) | |
323 | warning: line over 80 characters |
|
323 | warning: line over 80 characters | |
324 | mercurial/commands.py:0: |
|
324 | mercurial/commands.py:0: | |
325 | > ui.write("format: id, p1, p2, cset, delta base, len(delta)\n") |
|
325 | > ui.write("format: id, p1, p2, cset, delta base, len(delta)\n") | |
326 | warning: unwrapped ui message |
|
326 | warning: unwrapped ui message | |
327 | mercurial/commands.py:0: |
|
327 | mercurial/commands.py:0: | |
328 | > ui.write("local is subset\n") |
|
328 | > ui.write("local is subset\n") | |
329 | warning: unwrapped ui message |
|
329 | warning: unwrapped ui message | |
330 | mercurial/commands.py:0: |
|
330 | mercurial/commands.py:0: | |
331 | > ui.write("remote is subset\n") |
|
331 | > ui.write("remote is subset\n") | |
332 | warning: unwrapped ui message |
|
332 | warning: unwrapped ui message | |
333 | mercurial/commands.py:0: |
|
333 | mercurial/commands.py:0: | |
334 | > ui.write(' other : ' + fmt2 % pcfmt(numoprev, numprev)) |
|
334 | > ui.write(' other : ' + fmt2 % pcfmt(numoprev, numprev)) | |
335 | warning: line over 80 characters |
|
335 | warning: line over 80 characters | |
336 | mercurial/commands.py:0: |
|
336 | mercurial/commands.py:0: | |
337 | > ui.write(' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev)) |
|
337 | > ui.write(' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev)) | |
338 | warning: line over 80 characters |
|
338 | warning: line over 80 characters | |
339 | mercurial/commands.py:0: |
|
339 | mercurial/commands.py:0: | |
340 | > ui.write(' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev)) |
|
340 | > ui.write(' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev)) | |
341 | warning: line over 80 characters |
|
341 | warning: line over 80 characters | |
342 | mercurial/commands.py:0: |
|
342 | mercurial/commands.py:0: | |
343 | > ui.write('deltas against other : ' + fmt % pcfmt(numother, numdeltas)) |
|
343 | > ui.write('deltas against other : ' + fmt % pcfmt(numother, numdeltas)) | |
344 | warning: line over 80 characters |
|
344 | warning: line over 80 characters | |
345 | warning: unwrapped ui message |
|
345 | warning: unwrapped ui message | |
346 | mercurial/commands.py:0: |
|
346 | mercurial/commands.py:0: | |
347 | > ui.write('deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas)) |
|
347 | > ui.write('deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas)) | |
348 | warning: unwrapped ui message |
|
348 | warning: unwrapped ui message | |
349 | mercurial/commands.py:0: |
|
349 | mercurial/commands.py:0: | |
350 | > ui.write('deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas)) |
|
350 | > ui.write('deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas)) | |
351 | warning: unwrapped ui message |
|
351 | warning: unwrapped ui message | |
352 | mercurial/commands.py:0: |
|
352 | mercurial/commands.py:0: | |
353 | > cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict')) |
|
353 | > cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict')) | |
354 | warning: line over 80 characters |
|
354 | warning: line over 80 characters | |
355 | mercurial/commands.py:0: |
|
355 | mercurial/commands.py:0: | |
356 | > except: |
|
356 | > except: | |
357 | warning: naked except clause |
|
357 | warning: naked except clause | |
358 | mercurial/commands.py:0: |
|
358 | mercurial/commands.py:0: | |
359 | > revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
359 | > revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
360 | warning: line over 80 characters |
|
360 | warning: line over 80 characters | |
361 | mercurial/commands.py:0: |
|
361 | mercurial/commands.py:0: | |
362 | > ui.write("common heads: %s\n" % " ".join([short(n) for n in common])) |
|
362 | > ui.write("common heads: %s\n" % " ".join([short(n) for n in common])) | |
363 | warning: unwrapped ui message |
|
363 | warning: unwrapped ui message | |
364 | mercurial/commands.py:0: |
|
364 | mercurial/commands.py:0: | |
365 | > ui.write("match: %s\n" % m(d[0])) |
|
365 | > ui.write("match: %s\n" % m(d[0])) | |
366 | warning: unwrapped ui message |
|
366 | warning: unwrapped ui message | |
367 | mercurial/commands.py:0: |
|
367 | mercurial/commands.py:0: | |
368 | > ui.write('deltas against prev : ' + fmt % pcfmt(numprev, numdeltas)) |
|
368 | > ui.write('deltas against prev : ' + fmt % pcfmt(numprev, numdeltas)) | |
369 | warning: unwrapped ui message |
|
369 | warning: unwrapped ui message | |
370 | mercurial/commands.py:0: |
|
370 | mercurial/commands.py:0: | |
371 | > ui.write('path %s\n' % k) |
|
371 | > ui.write('path %s\n' % k) | |
372 | warning: unwrapped ui message |
|
372 | warning: unwrapped ui message | |
373 | mercurial/commands.py:0: |
|
373 | mercurial/commands.py:0: | |
374 | > ui.write('uncompressed data size (min/max/avg) : %d / %d / %d\n' |
|
374 | > ui.write('uncompressed data size (min/max/avg) : %d / %d / %d\n' | |
375 | warning: unwrapped ui message |
|
375 | warning: unwrapped ui message | |
376 | mercurial/commands.py:0: |
|
376 | mercurial/commands.py:0: | |
377 | > Every ID must be a full-length hex node id string. Returns a list of 0s and 1s |
|
377 | > Every ID must be a full-length hex node id string. Returns a list of 0s and 1s | |
378 | warning: line over 80 characters |
|
378 | warning: line over 80 characters | |
379 | mercurial/commands.py:0: |
|
379 | mercurial/commands.py:0: | |
380 | > remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch')) |
|
380 | > remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl), opts.get('branch')) | |
381 | warning: line over 80 characters |
|
381 | warning: line over 80 characters | |
382 | mercurial/commands.py:0: |
|
382 | mercurial/commands.py:0: | |
383 | > ui.write("digraph G {\n") |
|
383 | > ui.write("digraph G {\n") | |
384 | warning: unwrapped ui message |
|
384 | warning: unwrapped ui message | |
385 | mercurial/commands.py:0: |
|
385 | mercurial/commands.py:0: | |
386 | > ui.write("internal: %s %s\n" % d) |
|
386 | > ui.write("internal: %s %s\n" % d) | |
387 | warning: unwrapped ui message |
|
387 | warning: unwrapped ui message | |
388 | mercurial/commands.py:0: |
|
388 | mercurial/commands.py:0: | |
389 | > ui.write("standard: %s\n" % util.datestr(d)) |
|
389 | > ui.write("standard: %s\n" % util.datestr(d)) | |
390 | warning: unwrapped ui message |
|
390 | warning: unwrapped ui message | |
391 | mercurial/commands.py:0: |
|
391 | mercurial/commands.py:0: | |
392 | > ui.write('avg chain length : ' + fmt % avgchainlen) |
|
392 | > ui.write('avg chain length : ' + fmt % avgchainlen) | |
393 | warning: unwrapped ui message |
|
393 | warning: unwrapped ui message | |
394 | mercurial/commands.py:0: |
|
394 | mercurial/commands.py:0: | |
395 | > ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') |
|
395 | > ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') | |
396 | warning: unwrapped ui message |
|
396 | warning: unwrapped ui message | |
397 | mercurial/commands.py:0: |
|
397 | mercurial/commands.py:0: | |
398 | > ui.write('compression ratio : ' + fmt % compratio) |
|
398 | > ui.write('compression ratio : ' + fmt % compratio) | |
399 | warning: unwrapped ui message |
|
399 | warning: unwrapped ui message | |
400 | mercurial/commands.py:0: |
|
400 | mercurial/commands.py:0: | |
401 | > ui.write('delta size (min/max/avg) : %d / %d / %d\n' |
|
401 | > ui.write('delta size (min/max/avg) : %d / %d / %d\n' | |
402 | warning: unwrapped ui message |
|
402 | warning: unwrapped ui message | |
403 | mercurial/commands.py:0: |
|
403 | mercurial/commands.py:0: | |
404 | > ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) |
|
404 | > ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) | |
405 | warning: unwrapped ui message |
|
405 | warning: unwrapped ui message | |
406 | mercurial/commands.py:0: |
|
406 | mercurial/commands.py:0: | |
407 | > ui.write('flags : %s\n' % ', '.join(flags)) |
|
407 | > ui.write('flags : %s\n' % ', '.join(flags)) | |
408 | warning: unwrapped ui message |
|
408 | warning: unwrapped ui message | |
409 | mercurial/commands.py:0: |
|
409 | mercurial/commands.py:0: | |
410 | > ui.write('format : %d\n' % format) |
|
410 | > ui.write('format : %d\n' % format) | |
411 | warning: unwrapped ui message |
|
411 | warning: unwrapped ui message | |
412 | mercurial/commands.py:0: |
|
412 | mercurial/commands.py:0: | |
413 | > ui.write('full revision size (min/max/avg) : %d / %d / %d\n' |
|
413 | > ui.write('full revision size (min/max/avg) : %d / %d / %d\n' | |
414 | warning: unwrapped ui message |
|
414 | warning: unwrapped ui message | |
415 | mercurial/commands.py:0: |
|
415 | mercurial/commands.py:0: | |
416 | > ui.write('revision size : ' + fmt2 % totalsize) |
|
416 | > ui.write('revision size : ' + fmt2 % totalsize) | |
417 | warning: unwrapped ui message |
|
417 | warning: unwrapped ui message | |
418 | mercurial/commands.py:0: |
|
418 | mercurial/commands.py:0: | |
419 | > ui.write('revisions : ' + fmt2 % numrevs) |
|
419 | > ui.write('revisions : ' + fmt2 % numrevs) | |
420 | warning: unwrapped ui message |
|
420 | warning: unwrapped ui message | |
421 | warning: unwrapped ui message |
|
421 | warning: unwrapped ui message | |
422 | mercurial/commands.py:0: |
|
422 | mercurial/commands.py:0: | |
423 | > ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) |
|
423 | > ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) | |
424 | warning: unwrapped ui message |
|
424 | warning: unwrapped ui message | |
425 | mercurial/commandserver.py:0: |
|
425 | mercurial/commandserver.py:0: | |
426 | > # the ui here is really the repo ui so take its baseui so we don't end up |
|
426 | > # the ui here is really the repo ui so take its baseui so we don't end up | |
427 | warning: line over 80 characters |
|
427 | warning: line over 80 characters | |
428 | mercurial/context.py:0: |
|
428 | mercurial/context.py:0: | |
429 | > return self._manifestdelta[path], self._manifestdelta.flags(path) |
|
429 | > return self._manifestdelta[path], self._manifestdelta.flags(path) | |
430 | warning: line over 80 characters |
|
430 | warning: line over 80 characters | |
431 | mercurial/dagparser.py:0: |
|
431 | mercurial/dagparser.py:0: | |
432 | > raise util.Abort(_("invalid character in dag description: %s...") % s) |
|
432 | > raise util.Abort(_("invalid character in dag description: %s...") % s) | |
433 | warning: line over 80 characters |
|
433 | warning: line over 80 characters | |
434 | mercurial/dagparser.py:0: |
|
434 | mercurial/dagparser.py:0: | |
435 | > >>> dagtext([('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))]) |
|
435 | > >>> dagtext([('n', (0, [-1])), ('C', 'my command line'), ('n', (1, [0]))]) | |
436 | warning: line over 80 characters |
|
436 | warning: line over 80 characters | |
437 | mercurial/dirstate.py:0: |
|
437 | mercurial/dirstate.py:0: | |
438 | > if not st is None and not getkind(st.st_mode) in (regkind, lnkkind): |
|
438 | > if not st is None and not getkind(st.st_mode) in (regkind, lnkkind): | |
439 | warning: line over 80 characters |
|
439 | warning: line over 80 characters | |
440 | mercurial/discovery.py:0: |
|
440 | mercurial/discovery.py:0: | |
441 | > repo.ui.note(_("new remote heads on branch '%s'\n") % branch) |
|
|||
442 | warning: line over 80 characters |
|
|||
443 | mercurial/discovery.py:0: |
|
|||
444 | > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) |
|
441 | > If onlyheads is given, only nodes ancestral to nodes in onlyheads (inclusive) | |
445 | warning: line over 80 characters |
|
442 | warning: line over 80 characters | |
446 | mercurial/discovery.py:0: |
|
443 | mercurial/discovery.py:0: | |
447 | > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): |
|
444 | > def findcommonoutgoing(repo, other, onlyheads=None, force=False, commoninc=None): | |
448 | warning: line over 80 characters |
|
445 | warning: line over 80 characters | |
449 | mercurial/dispatch.py:0: |
|
446 | mercurial/dispatch.py:0: | |
450 | > " (.hg not found)") % os.getcwd()) |
|
447 | > " (.hg not found)") % os.getcwd()) | |
451 | warning: line over 80 characters |
|
448 | warning: line over 80 characters | |
452 | mercurial/dispatch.py:0: |
|
449 | mercurial/dispatch.py:0: | |
453 | > aliases, entry = cmdutil.findcmd(cmd, cmdtable, lui.config("ui", "strict")) |
|
450 | > aliases, entry = cmdutil.findcmd(cmd, cmdtable, lui.config("ui", "strict")) | |
454 | warning: line over 80 characters |
|
451 | warning: line over 80 characters | |
455 | mercurial/dispatch.py:0: |
|
452 | mercurial/dispatch.py:0: | |
456 | > except: |
|
453 | > except: | |
457 | warning: naked except clause |
|
454 | warning: naked except clause | |
458 | mercurial/dispatch.py:0: |
|
455 | mercurial/dispatch.py:0: | |
459 | > return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {}) |
|
456 | > return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {}) | |
460 | warning: line over 80 characters |
|
457 | warning: line over 80 characters | |
461 | mercurial/dispatch.py:0: |
|
458 | mercurial/dispatch.py:0: | |
462 | > def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None): |
|
459 | > def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None): | |
463 | warning: line over 80 characters |
|
460 | warning: line over 80 characters | |
464 | mercurial/dispatch.py:0: |
|
461 | mercurial/dispatch.py:0: | |
465 | > except: |
|
462 | > except: | |
466 | warning: naked except clause |
|
463 | warning: naked except clause | |
467 | mercurial/hg.py:0: |
|
464 | mercurial/hg.py:0: | |
468 | > except: |
|
465 | > except: | |
469 | warning: naked except clause |
|
466 | warning: naked except clause | |
470 | mercurial/hgweb/hgweb_mod.py:0: |
|
467 | mercurial/hgweb/hgweb_mod.py:0: | |
471 | > self.maxshortchanges = int(self.config("web", "maxshortchanges", 60)) |
|
468 | > self.maxshortchanges = int(self.config("web", "maxshortchanges", 60)) | |
472 | warning: line over 80 characters |
|
469 | warning: line over 80 characters | |
473 | mercurial/keepalive.py:0: |
|
470 | mercurial/keepalive.py:0: | |
474 | > except: |
|
471 | > except: | |
475 | warning: naked except clause |
|
472 | warning: naked except clause | |
476 | mercurial/keepalive.py:0: |
|
473 | mercurial/keepalive.py:0: | |
477 | > except: |
|
474 | > except: | |
478 | warning: naked except clause |
|
475 | warning: naked except clause | |
479 | mercurial/localrepo.py:0: |
|
476 | mercurial/localrepo.py:0: | |
480 | > hint=_("use --subrepos for recursive commit")) |
|
477 | > hint=_("use --subrepos for recursive commit")) | |
481 | warning: line over 80 characters |
|
478 | warning: line over 80 characters | |
482 | mercurial/localrepo.py:0: |
|
479 | mercurial/localrepo.py:0: | |
483 | > # we return an integer indicating remote head count change |
|
480 | > # we return an integer indicating remote head count change | |
484 | warning: line over 80 characters |
|
481 | warning: line over 80 characters | |
485 | mercurial/localrepo.py:0: |
|
482 | mercurial/localrepo.py:0: | |
486 | > raise util.Abort(_("empty or missing revlog for %s") % fname) |
|
483 | > raise util.Abort(_("empty or missing revlog for %s") % fname) | |
487 | warning: line over 80 characters |
|
484 | warning: line over 80 characters | |
488 | warning: line over 80 characters |
|
485 | warning: line over 80 characters | |
489 | mercurial/localrepo.py:0: |
|
486 | mercurial/localrepo.py:0: | |
490 | > if self._tagscache.tagtypes and name in self._tagscache.tagtypes: |
|
487 | > if self._tagscache.tagtypes and name in self._tagscache.tagtypes: | |
491 | warning: line over 80 characters |
|
488 | warning: line over 80 characters | |
492 | mercurial/localrepo.py:0: |
|
489 | mercurial/localrepo.py:0: | |
493 | > self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) |
|
490 | > self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2) | |
494 | warning: line over 80 characters |
|
491 | warning: line over 80 characters | |
495 | mercurial/localrepo.py:0: |
|
492 | mercurial/localrepo.py:0: | |
496 | > # new requirements = old non-format requirements + new format-related |
|
493 | > # new requirements = old non-format requirements + new format-related | |
497 | warning: line over 80 characters |
|
494 | warning: line over 80 characters | |
498 | mercurial/localrepo.py:0: |
|
495 | mercurial/localrepo.py:0: | |
499 | > except: |
|
496 | > except: | |
500 | warning: naked except clause |
|
497 | warning: naked except clause | |
501 | mercurial/localrepo.py:0: |
|
498 | mercurial/localrepo.py:0: | |
502 | > """return status of files between two nodes or node and working directory |
|
499 | > """return status of files between two nodes or node and working directory | |
503 | warning: line over 80 characters |
|
500 | warning: line over 80 characters | |
504 | mercurial/localrepo.py:0: |
|
501 | mercurial/localrepo.py:0: | |
505 | > '''Returns a tagscache object that contains various tags related caches.''' |
|
502 | > '''Returns a tagscache object that contains various tags related caches.''' | |
506 | warning: line over 80 characters |
|
503 | warning: line over 80 characters | |
507 | mercurial/manifest.py:0: |
|
504 | mercurial/manifest.py:0: | |
508 | > return "".join(struct.pack(">lll", start, end, len(content)) + content |
|
505 | > return "".join(struct.pack(">lll", start, end, len(content)) + content | |
509 | warning: line over 80 characters |
|
506 | warning: line over 80 characters | |
510 | mercurial/merge.py:0: |
|
507 | mercurial/merge.py:0: | |
511 | > subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite) |
|
508 | > subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx), overwrite) | |
512 | warning: line over 80 characters |
|
509 | warning: line over 80 characters | |
513 | mercurial/patch.py:0: |
|
510 | mercurial/patch.py:0: | |
514 | > modified, added, removed, copy, getfilectx, opts, losedata, prefix) |
|
511 | > modified, added, removed, copy, getfilectx, opts, losedata, prefix) | |
515 | warning: line over 80 characters |
|
512 | warning: line over 80 characters | |
516 | mercurial/patch.py:0: |
|
513 | mercurial/patch.py:0: | |
517 | > diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb, self.a, self.b) |
|
514 | > diffhelpers.addlines(lr, self.hunk, self.lena, self.lenb, self.a, self.b) | |
518 | warning: line over 80 characters |
|
515 | warning: line over 80 characters | |
519 | mercurial/patch.py:0: |
|
516 | mercurial/patch.py:0: | |
520 | > output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n') |
|
517 | > output.append(_(' %d files changed, %d insertions(+), %d deletions(-)\n') | |
521 | warning: line over 80 characters |
|
518 | warning: line over 80 characters | |
522 | mercurial/patch.py:0: |
|
519 | mercurial/patch.py:0: | |
523 | > except: |
|
520 | > except: | |
524 | warning: naked except clause |
|
521 | warning: naked except clause | |
525 | mercurial/pure/base85.py:0: |
|
522 | mercurial/pure/base85.py:0: | |
526 | > raise OverflowError('Base85 overflow in hunk starting at byte %d' % i) |
|
523 | > raise OverflowError('Base85 overflow in hunk starting at byte %d' % i) | |
527 | warning: line over 80 characters |
|
524 | warning: line over 80 characters | |
528 | mercurial/pure/mpatch.py:0: |
|
525 | mercurial/pure/mpatch.py:0: | |
529 | > frags.extend(reversed(new)) # what was left at the end |
|
526 | > frags.extend(reversed(new)) # what was left at the end | |
530 | warning: line over 80 characters |
|
527 | warning: line over 80 characters | |
531 | mercurial/repair.py:0: |
|
528 | mercurial/repair.py:0: | |
532 | > except: |
|
529 | > except: | |
533 | warning: naked except clause |
|
530 | warning: naked except clause | |
534 | mercurial/repair.py:0: |
|
531 | mercurial/repair.py:0: | |
535 | > except: |
|
532 | > except: | |
536 | warning: naked except clause |
|
533 | warning: naked except clause | |
537 | mercurial/revset.py:0: |
|
534 | mercurial/revset.py:0: | |
538 | > elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword |
|
535 | > elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword | |
539 | warning: line over 80 characters |
|
536 | warning: line over 80 characters | |
540 | mercurial/revset.py:0: |
|
537 | mercurial/revset.py:0: | |
541 | > Changesets that are the Nth ancestor (first parents only) of a changeset in set. |
|
538 | > Changesets that are the Nth ancestor (first parents only) of a changeset in set. | |
542 | warning: line over 80 characters |
|
539 | warning: line over 80 characters | |
543 | mercurial/scmutil.py:0: |
|
540 | mercurial/scmutil.py:0: | |
544 | > raise util.Abort(_("path '%s' is inside nested repo %r") % |
|
541 | > raise util.Abort(_("path '%s' is inside nested repo %r") % | |
545 | warning: line over 80 characters |
|
542 | warning: line over 80 characters | |
546 | mercurial/scmutil.py:0: |
|
543 | mercurial/scmutil.py:0: | |
547 | > "requires features '%s' (upgrade Mercurial)") % "', '".join(missings)) |
|
544 | > "requires features '%s' (upgrade Mercurial)") % "', '".join(missings)) | |
548 | warning: line over 80 characters |
|
545 | warning: line over 80 characters | |
549 | mercurial/scmutil.py:0: |
|
546 | mercurial/scmutil.py:0: | |
550 | > elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) |
|
547 | > elif repo.dirstate[abs] != 'r' and (not good or not os.path.lexists(target) | |
551 | warning: line over 80 characters |
|
548 | warning: line over 80 characters | |
552 | mercurial/setdiscovery.py:0: |
|
549 | mercurial/setdiscovery.py:0: | |
553 | > # treat remote heads (and maybe own heads) as a first implicit sample response |
|
550 | > # treat remote heads (and maybe own heads) as a first implicit sample response | |
554 | warning: line over 80 characters |
|
551 | warning: line over 80 characters | |
555 | mercurial/setdiscovery.py:0: |
|
552 | mercurial/setdiscovery.py:0: | |
556 | > undecided = dag.nodeset() # own nodes where I don't know if remote knows them |
|
553 | > undecided = dag.nodeset() # own nodes where I don't know if remote knows them | |
557 | warning: line over 80 characters |
|
554 | warning: line over 80 characters | |
558 | mercurial/similar.py:0: |
|
555 | mercurial/similar.py:0: | |
559 | > repo.ui.progress(_('searching for similar files'), i, total=len(removed)) |
|
556 | > repo.ui.progress(_('searching for similar files'), i, total=len(removed)) | |
560 | warning: line over 80 characters |
|
557 | warning: line over 80 characters | |
561 | mercurial/simplemerge.py:0: |
|
558 | mercurial/simplemerge.py:0: | |
562 | > for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions(): |
|
559 | > for zmatch, zend, amatch, aend, bmatch, bend in self.find_sync_regions(): | |
563 | warning: line over 80 characters |
|
560 | warning: line over 80 characters | |
564 | mercurial/sshrepo.py:0: |
|
561 | mercurial/sshrepo.py:0: | |
565 | > self._abort(error.RepoError(_("no suitable response from remote hg"))) |
|
562 | > self._abort(error.RepoError(_("no suitable response from remote hg"))) | |
566 | warning: line over 80 characters |
|
563 | warning: line over 80 characters | |
567 | mercurial/sshrepo.py:0: |
|
564 | mercurial/sshrepo.py:0: | |
568 | > except: |
|
565 | > except: | |
569 | warning: naked except clause |
|
566 | warning: naked except clause | |
570 | mercurial/subrepo.py:0: |
|
567 | mercurial/subrepo.py:0: | |
571 | > other, self._repo = hg.clone(self._repo._subparent.ui, {}, other, |
|
568 | > other, self._repo = hg.clone(self._repo._subparent.ui, {}, other, | |
572 | warning: line over 80 characters |
|
569 | warning: line over 80 characters | |
573 | mercurial/subrepo.py:0: |
|
570 | mercurial/subrepo.py:0: | |
574 | > msg = (_(' subrepository sources for %s differ (in checked out version)\n' |
|
571 | > msg = (_(' subrepository sources for %s differ (in checked out version)\n' | |
575 | warning: line over 80 characters |
|
572 | warning: line over 80 characters | |
576 | mercurial/transaction.py:0: |
|
573 | mercurial/transaction.py:0: | |
577 | > except: |
|
574 | > except: | |
578 | warning: naked except clause |
|
575 | warning: naked except clause | |
579 | mercurial/ui.py:0: |
|
576 | mercurial/ui.py:0: | |
580 | > traceback.print_exception(exc[0], exc[1], exc[2], file=self.ferr) |
|
577 | > traceback.print_exception(exc[0], exc[1], exc[2], file=self.ferr) | |
581 | warning: line over 80 characters |
|
578 | warning: line over 80 characters | |
582 | mercurial/url.py:0: |
|
579 | mercurial/url.py:0: | |
583 | > conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs) |
|
580 | > conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs) | |
584 | warning: line over 80 characters |
|
581 | warning: line over 80 characters | |
585 | mercurial/util.py:0: |
|
582 | mercurial/util.py:0: | |
586 | > except: |
|
583 | > except: | |
587 | warning: naked except clause |
|
584 | warning: naked except clause | |
588 | mercurial/util.py:0: |
|
585 | mercurial/util.py:0: | |
589 | > except: |
|
586 | > except: | |
590 | warning: naked except clause |
|
587 | warning: naked except clause | |
591 | mercurial/verify.py:0: |
|
588 | mercurial/verify.py:0: | |
592 | > except: |
|
589 | > except: | |
593 | warning: naked except clause |
|
590 | warning: naked except clause | |
594 | mercurial/verify.py:0: |
|
591 | mercurial/verify.py:0: | |
595 | > except: |
|
592 | > except: | |
596 | warning: naked except clause |
|
593 | warning: naked except clause | |
597 | mercurial/wireproto.py:0: |
|
594 | mercurial/wireproto.py:0: | |
598 | > # Assuming the future to be filled with the result from the batched request |
|
595 | > # Assuming the future to be filled with the result from the batched request | |
599 | warning: line over 80 characters |
|
596 | warning: line over 80 characters | |
600 | mercurial/wireproto.py:0: |
|
597 | mercurial/wireproto.py:0: | |
601 | > '''remote must support _submitbatch(encbatch) and _submitone(op, encargs)''' |
|
598 | > '''remote must support _submitbatch(encbatch) and _submitone(op, encargs)''' | |
602 | warning: line over 80 characters |
|
599 | warning: line over 80 characters | |
603 | mercurial/wireproto.py:0: |
|
600 | mercurial/wireproto.py:0: | |
604 | > All methods invoked on instances of this class are simply queued and return a |
|
601 | > All methods invoked on instances of this class are simply queued and return a | |
605 | warning: line over 80 characters |
|
602 | warning: line over 80 characters | |
606 | mercurial/wireproto.py:0: |
|
603 | mercurial/wireproto.py:0: | |
607 | > The decorator returns a function which wraps this coroutine as a plain method, |
|
604 | > The decorator returns a function which wraps this coroutine as a plain method, | |
608 | warning: line over 80 characters |
|
605 | warning: line over 80 characters | |
609 | setup.py:0: |
|
606 | setup.py:0: | |
610 | > raise SystemExit("Python headers are required to build Mercurial") |
|
607 | > raise SystemExit("Python headers are required to build Mercurial") | |
611 | warning: line over 80 characters |
|
608 | warning: line over 80 characters | |
612 | setup.py:0: |
|
609 | setup.py:0: | |
613 | > except: |
|
610 | > except: | |
614 | warning: naked except clause |
|
611 | warning: naked except clause | |
615 | setup.py:0: |
|
612 | setup.py:0: | |
616 | > # build_py), it will not find osutil & friends, thinking that those modules are |
|
613 | > # build_py), it will not find osutil & friends, thinking that those modules are | |
617 | warning: line over 80 characters |
|
614 | warning: line over 80 characters | |
618 | setup.py:0: |
|
615 | setup.py:0: | |
619 | > except: |
|
616 | > except: | |
620 | warning: naked except clause |
|
617 | warning: naked except clause | |
621 | warning: naked except clause |
|
618 | warning: naked except clause | |
622 | setup.py:0: |
|
619 | setup.py:0: | |
623 | > isironpython = platform.python_implementation().lower().find("ironpython") != -1 |
|
620 | > isironpython = platform.python_implementation().lower().find("ironpython") != -1 | |
624 | warning: line over 80 characters |
|
621 | warning: line over 80 characters | |
625 | setup.py:0: |
|
622 | setup.py:0: | |
626 | > except: |
|
623 | > except: | |
627 | warning: naked except clause |
|
624 | warning: naked except clause | |
628 | warning: naked except clause |
|
625 | warning: naked except clause | |
629 | warning: naked except clause |
|
626 | warning: naked except clause | |
630 | tests/autodiff.py:0: |
|
627 | tests/autodiff.py:0: | |
631 | > ui.write('data lost for: %s\n' % fn) |
|
628 | > ui.write('data lost for: %s\n' % fn) | |
632 | warning: unwrapped ui message |
|
629 | warning: unwrapped ui message | |
633 | tests/run-tests.py:0: |
|
630 | tests/run-tests.py:0: | |
634 | > except: |
|
631 | > except: | |
635 | warning: naked except clause |
|
632 | warning: naked except clause | |
636 | tests/test-commandserver.py:0: |
|
633 | tests/test-commandserver.py:0: | |
637 | > 'hooks.pre-identify=python:test-commandserver.hook', 'id'], |
|
634 | > 'hooks.pre-identify=python:test-commandserver.hook', 'id'], | |
638 | warning: line over 80 characters |
|
635 | warning: line over 80 characters | |
639 | tests/test-commandserver.py:0: |
|
636 | tests/test-commandserver.py:0: | |
640 | > # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it |
|
637 | > # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it | |
641 | warning: line over 80 characters |
|
638 | warning: line over 80 characters | |
642 | tests/test-commandserver.py:0: |
|
639 | tests/test-commandserver.py:0: | |
643 | > print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data)) |
|
640 | > print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data)) | |
644 | warning: line over 80 characters |
|
641 | warning: line over 80 characters | |
645 | tests/test-filecache.py:0: |
|
642 | tests/test-filecache.py:0: | |
646 | > except: |
|
643 | > except: | |
647 | warning: naked except clause |
|
644 | warning: naked except clause | |
648 | tests/test-filecache.py:0: |
|
645 | tests/test-filecache.py:0: | |
649 | > if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], 'cacheable']): |
|
646 | > if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'], 'cacheable']): | |
650 | warning: line over 80 characters |
|
647 | warning: line over 80 characters | |
651 | tests/test-ui-color.py:0: |
|
648 | tests/test-ui-color.py:0: | |
652 | > testui.warn('warning\n') |
|
649 | > testui.warn('warning\n') | |
653 | warning: unwrapped ui message |
|
650 | warning: unwrapped ui message | |
654 | tests/test-ui-color.py:0: |
|
651 | tests/test-ui-color.py:0: | |
655 | > testui.write('buffered\n') |
|
652 | > testui.write('buffered\n') | |
656 | warning: unwrapped ui message |
|
653 | warning: unwrapped ui message | |
657 | tests/test-walkrepo.py:0: |
|
654 | tests/test-walkrepo.py:0: | |
658 | > print "Found %d repositories when I should have found 2" % (len(reposet),) |
|
655 | > print "Found %d repositories when I should have found 2" % (len(reposet),) | |
659 | warning: line over 80 characters |
|
656 | warning: line over 80 characters | |
660 | tests/test-walkrepo.py:0: |
|
657 | tests/test-walkrepo.py:0: | |
661 | > print "Found %d repositories when I should have found 3" % (len(reposet),) |
|
658 | > print "Found %d repositories when I should have found 3" % (len(reposet),) | |
662 | warning: line over 80 characters |
|
659 | warning: line over 80 characters | |
663 | [1] |
|
660 | [1] |
General Comments 0
You need to be logged in to leave comments.
Login now