##// END OF EJS Templates
merge with stable
Matt Mackall -
r25270:61b3529e merge default
parent child Browse files
Show More
@@ -1,439 +1,443 b''
1 # branchmap.py - logic to computes, maintain and stores branchmap for local repo
1 # branchmap.py - logic to computes, maintain and stores branchmap for local repo
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
8 from node import bin, hex, nullid, nullrev
9 import encoding
9 import encoding
10 import scmutil
10 import scmutil
11 import util
11 import util
12 import time
12 import time
13 from array import array
13 from array import array
14 from struct import calcsize, pack, unpack
14 from struct import calcsize, pack, unpack
15
15
16 def _filename(repo):
16 def _filename(repo):
17 """name of a branchcache file for a given repo or repoview"""
17 """name of a branchcache file for a given repo or repoview"""
18 filename = "cache/branch2"
18 filename = "cache/branch2"
19 if repo.filtername:
19 if repo.filtername:
20 filename = '%s-%s' % (filename, repo.filtername)
20 filename = '%s-%s' % (filename, repo.filtername)
21 return filename
21 return filename
22
22
23 def read(repo):
23 def read(repo):
24 try:
24 try:
25 f = repo.vfs(_filename(repo))
25 f = repo.vfs(_filename(repo))
26 lines = f.read().split('\n')
26 lines = f.read().split('\n')
27 f.close()
27 f.close()
28 except (IOError, OSError):
28 except (IOError, OSError):
29 return None
29 return None
30
30
31 try:
31 try:
32 cachekey = lines.pop(0).split(" ", 2)
32 cachekey = lines.pop(0).split(" ", 2)
33 last, lrev = cachekey[:2]
33 last, lrev = cachekey[:2]
34 last, lrev = bin(last), int(lrev)
34 last, lrev = bin(last), int(lrev)
35 filteredhash = None
35 filteredhash = None
36 if len(cachekey) > 2:
36 if len(cachekey) > 2:
37 filteredhash = bin(cachekey[2])
37 filteredhash = bin(cachekey[2])
38 partial = branchcache(tipnode=last, tiprev=lrev,
38 partial = branchcache(tipnode=last, tiprev=lrev,
39 filteredhash=filteredhash)
39 filteredhash=filteredhash)
40 if not partial.validfor(repo):
40 if not partial.validfor(repo):
41 # invalidate the cache
41 # invalidate the cache
42 raise ValueError('tip differs')
42 raise ValueError('tip differs')
43 for l in lines:
43 for l in lines:
44 if not l:
44 if not l:
45 continue
45 continue
46 node, state, label = l.split(" ", 2)
46 node, state, label = l.split(" ", 2)
47 if state not in 'oc':
47 if state not in 'oc':
48 raise ValueError('invalid branch state')
48 raise ValueError('invalid branch state')
49 label = encoding.tolocal(label.strip())
49 label = encoding.tolocal(label.strip())
50 if not node in repo:
50 if not node in repo:
51 raise ValueError('node %s does not exist' % node)
51 raise ValueError('node %s does not exist' % node)
52 node = bin(node)
52 node = bin(node)
53 partial.setdefault(label, []).append(node)
53 partial.setdefault(label, []).append(node)
54 if state == 'c':
54 if state == 'c':
55 partial._closednodes.add(node)
55 partial._closednodes.add(node)
56 except KeyboardInterrupt:
56 except KeyboardInterrupt:
57 raise
57 raise
58 except Exception, inst:
58 except Exception, inst:
59 if repo.ui.debugflag:
59 if repo.ui.debugflag:
60 msg = 'invalid branchheads cache'
60 msg = 'invalid branchheads cache'
61 if repo.filtername is not None:
61 if repo.filtername is not None:
62 msg += ' (%s)' % repo.filtername
62 msg += ' (%s)' % repo.filtername
63 msg += ': %s\n'
63 msg += ': %s\n'
64 repo.ui.debug(msg % inst)
64 repo.ui.debug(msg % inst)
65 partial = None
65 partial = None
66 return partial
66 return partial
67
67
68 ### Nearest subset relation
68 ### Nearest subset relation
69 # Nearest subset of filter X is a filter Y so that:
69 # Nearest subset of filter X is a filter Y so that:
70 # * Y is included in X,
70 # * Y is included in X,
71 # * X - Y is as small as possible.
71 # * X - Y is as small as possible.
72 # This create and ordering used for branchmap purpose.
72 # This create and ordering used for branchmap purpose.
73 # the ordering may be partial
73 # the ordering may be partial
74 subsettable = {None: 'visible',
74 subsettable = {None: 'visible',
75 'visible': 'served',
75 'visible': 'served',
76 'served': 'immutable',
76 'served': 'immutable',
77 'immutable': 'base'}
77 'immutable': 'base'}
78
78
79 def updatecache(repo):
79 def updatecache(repo):
80 cl = repo.changelog
80 cl = repo.changelog
81 filtername = repo.filtername
81 filtername = repo.filtername
82 partial = repo._branchcaches.get(filtername)
82 partial = repo._branchcaches.get(filtername)
83
83
84 revs = []
84 revs = []
85 if partial is None or not partial.validfor(repo):
85 if partial is None or not partial.validfor(repo):
86 partial = read(repo)
86 partial = read(repo)
87 if partial is None:
87 if partial is None:
88 subsetname = subsettable.get(filtername)
88 subsetname = subsettable.get(filtername)
89 if subsetname is None:
89 if subsetname is None:
90 partial = branchcache()
90 partial = branchcache()
91 else:
91 else:
92 subset = repo.filtered(subsetname)
92 subset = repo.filtered(subsetname)
93 partial = subset.branchmap().copy()
93 partial = subset.branchmap().copy()
94 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
94 extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
95 revs.extend(r for r in extrarevs if r <= partial.tiprev)
95 revs.extend(r for r in extrarevs if r <= partial.tiprev)
96 revs.extend(cl.revs(start=partial.tiprev + 1))
96 revs.extend(cl.revs(start=partial.tiprev + 1))
97 if revs:
97 if revs:
98 partial.update(repo, revs)
98 partial.update(repo, revs)
99 partial.write(repo)
99 partial.write(repo)
100
100
101 assert partial.validfor(repo), filtername
101 assert partial.validfor(repo), filtername
102 repo._branchcaches[repo.filtername] = partial
102 repo._branchcaches[repo.filtername] = partial
103
103
104 class branchcache(dict):
104 class branchcache(dict):
105 """A dict like object that hold branches heads cache.
105 """A dict like object that hold branches heads cache.
106
106
107 This cache is used to avoid costly computations to determine all the
107 This cache is used to avoid costly computations to determine all the
108 branch heads of a repo.
108 branch heads of a repo.
109
109
110 The cache is serialized on disk in the following format:
110 The cache is serialized on disk in the following format:
111
111
112 <tip hex node> <tip rev number> [optional filtered repo hex hash]
112 <tip hex node> <tip rev number> [optional filtered repo hex hash]
113 <branch head hex node> <open/closed state> <branch name>
113 <branch head hex node> <open/closed state> <branch name>
114 <branch head hex node> <open/closed state> <branch name>
114 <branch head hex node> <open/closed state> <branch name>
115 ...
115 ...
116
116
117 The first line is used to check if the cache is still valid. If the
117 The first line is used to check if the cache is still valid. If the
118 branch cache is for a filtered repo view, an optional third hash is
118 branch cache is for a filtered repo view, an optional third hash is
119 included that hashes the hashes of all filtered revisions.
119 included that hashes the hashes of all filtered revisions.
120
120
121 The open/closed state is represented by a single letter 'o' or 'c'.
121 The open/closed state is represented by a single letter 'o' or 'c'.
122 This field can be used to avoid changelog reads when determining if a
122 This field can be used to avoid changelog reads when determining if a
123 branch head closes a branch or not.
123 branch head closes a branch or not.
124 """
124 """
125
125
126 def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
126 def __init__(self, entries=(), tipnode=nullid, tiprev=nullrev,
127 filteredhash=None, closednodes=None):
127 filteredhash=None, closednodes=None):
128 super(branchcache, self).__init__(entries)
128 super(branchcache, self).__init__(entries)
129 self.tipnode = tipnode
129 self.tipnode = tipnode
130 self.tiprev = tiprev
130 self.tiprev = tiprev
131 self.filteredhash = filteredhash
131 self.filteredhash = filteredhash
132 # closednodes is a set of nodes that close their branch. If the branch
132 # closednodes is a set of nodes that close their branch. If the branch
133 # cache has been updated, it may contain nodes that are no longer
133 # cache has been updated, it may contain nodes that are no longer
134 # heads.
134 # heads.
135 if closednodes is None:
135 if closednodes is None:
136 self._closednodes = set()
136 self._closednodes = set()
137 else:
137 else:
138 self._closednodes = closednodes
138 self._closednodes = closednodes
139
139
140 def validfor(self, repo):
140 def validfor(self, repo):
141 """Is the cache content valid regarding a repo
141 """Is the cache content valid regarding a repo
142
142
143 - False when cached tipnode is unknown or if we detect a strip.
143 - False when cached tipnode is unknown or if we detect a strip.
144 - True when cache is up to date or a subset of current repo."""
144 - True when cache is up to date or a subset of current repo."""
145 try:
145 try:
146 return ((self.tipnode == repo.changelog.node(self.tiprev))
146 return ((self.tipnode == repo.changelog.node(self.tiprev))
147 and (self.filteredhash == \
147 and (self.filteredhash == \
148 scmutil.filteredhash(repo, self.tiprev)))
148 scmutil.filteredhash(repo, self.tiprev)))
149 except IndexError:
149 except IndexError:
150 return False
150 return False
151
151
152 def _branchtip(self, heads):
152 def _branchtip(self, heads):
153 '''Return tuple with last open head in heads and false,
153 '''Return tuple with last open head in heads and false,
154 otherwise return last closed head and true.'''
154 otherwise return last closed head and true.'''
155 tip = heads[-1]
155 tip = heads[-1]
156 closed = True
156 closed = True
157 for h in reversed(heads):
157 for h in reversed(heads):
158 if h not in self._closednodes:
158 if h not in self._closednodes:
159 tip = h
159 tip = h
160 closed = False
160 closed = False
161 break
161 break
162 return tip, closed
162 return tip, closed
163
163
164 def branchtip(self, branch):
164 def branchtip(self, branch):
165 '''Return the tipmost open head on branch head, otherwise return the
165 '''Return the tipmost open head on branch head, otherwise return the
166 tipmost closed head on branch.
166 tipmost closed head on branch.
167 Raise KeyError for unknown branch.'''
167 Raise KeyError for unknown branch.'''
168 return self._branchtip(self[branch])[0]
168 return self._branchtip(self[branch])[0]
169
169
170 def branchheads(self, branch, closed=False):
170 def branchheads(self, branch, closed=False):
171 heads = self[branch]
171 heads = self[branch]
172 if not closed:
172 if not closed:
173 heads = [h for h in heads if h not in self._closednodes]
173 heads = [h for h in heads if h not in self._closednodes]
174 return heads
174 return heads
175
175
176 def iterbranches(self):
176 def iterbranches(self):
177 for bn, heads in self.iteritems():
177 for bn, heads in self.iteritems():
178 yield (bn, heads) + self._branchtip(heads)
178 yield (bn, heads) + self._branchtip(heads)
179
179
180 def copy(self):
180 def copy(self):
181 """return an deep copy of the branchcache object"""
181 """return an deep copy of the branchcache object"""
182 return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
182 return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
183 self._closednodes)
183 self._closednodes)
184
184
185 def write(self, repo):
185 def write(self, repo):
186 try:
186 try:
187 f = repo.vfs(_filename(repo), "w", atomictemp=True)
187 f = repo.vfs(_filename(repo), "w", atomictemp=True)
188 cachekey = [hex(self.tipnode), str(self.tiprev)]
188 cachekey = [hex(self.tipnode), str(self.tiprev)]
189 if self.filteredhash is not None:
189 if self.filteredhash is not None:
190 cachekey.append(hex(self.filteredhash))
190 cachekey.append(hex(self.filteredhash))
191 f.write(" ".join(cachekey) + '\n')
191 f.write(" ".join(cachekey) + '\n')
192 nodecount = 0
192 nodecount = 0
193 for label, nodes in sorted(self.iteritems()):
193 for label, nodes in sorted(self.iteritems()):
194 for node in nodes:
194 for node in nodes:
195 nodecount += 1
195 nodecount += 1
196 if node in self._closednodes:
196 if node in self._closednodes:
197 state = 'c'
197 state = 'c'
198 else:
198 else:
199 state = 'o'
199 state = 'o'
200 f.write("%s %s %s\n" % (hex(node), state,
200 f.write("%s %s %s\n" % (hex(node), state,
201 encoding.fromlocal(label)))
201 encoding.fromlocal(label)))
202 f.close()
202 f.close()
203 repo.ui.log('branchcache',
203 repo.ui.log('branchcache',
204 'wrote %s branch cache with %d labels and %d nodes\n',
204 'wrote %s branch cache with %d labels and %d nodes\n',
205 repo.filtername, len(self), nodecount)
205 repo.filtername, len(self), nodecount)
206 except (IOError, OSError, util.Abort), inst:
206 except (IOError, OSError, util.Abort), inst:
207 repo.ui.debug("couldn't write branch cache: %s\n" % inst)
207 repo.ui.debug("couldn't write branch cache: %s\n" % inst)
208 # Abort may be raise by read only opener
208 # Abort may be raise by read only opener
209 pass
209 pass
210
210
211 def update(self, repo, revgen):
211 def update(self, repo, revgen):
212 """Given a branchhead cache, self, that may have extra nodes or be
212 """Given a branchhead cache, self, that may have extra nodes or be
213 missing heads, and a generator of nodes that are strictly a superset of
213 missing heads, and a generator of nodes that are strictly a superset of
214 heads missing, this function updates self to be correct.
214 heads missing, this function updates self to be correct.
215 """
215 """
216 starttime = time.time()
216 starttime = time.time()
217 cl = repo.changelog
217 cl = repo.changelog
218 # collect new branch entries
218 # collect new branch entries
219 newbranches = {}
219 newbranches = {}
220 getbranchinfo = repo.revbranchcache().branchinfo
220 getbranchinfo = repo.revbranchcache().branchinfo
221 for r in revgen:
221 for r in revgen:
222 branch, closesbranch = getbranchinfo(r)
222 branch, closesbranch = getbranchinfo(r)
223 newbranches.setdefault(branch, []).append(r)
223 newbranches.setdefault(branch, []).append(r)
224 if closesbranch:
224 if closesbranch:
225 self._closednodes.add(cl.node(r))
225 self._closednodes.add(cl.node(r))
226
226
227 # fetch current topological heads to speed up filtering
227 # fetch current topological heads to speed up filtering
228 topoheads = set(cl.headrevs())
228 topoheads = set(cl.headrevs())
229
229
230 # if older branchheads are reachable from new ones, they aren't
230 # if older branchheads are reachable from new ones, they aren't
231 # really branchheads. Note checking parents is insufficient:
231 # really branchheads. Note checking parents is insufficient:
232 # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
232 # 1 (branch a) -> 2 (branch b) -> 3 (branch a)
233 for branch, newheadrevs in newbranches.iteritems():
233 for branch, newheadrevs in newbranches.iteritems():
234 bheads = self.setdefault(branch, [])
234 bheads = self.setdefault(branch, [])
235 bheadset = set(cl.rev(node) for node in bheads)
235 bheadset = set(cl.rev(node) for node in bheads)
236
236
237 # This have been tested True on all internal usage of this function.
237 # This have been tested True on all internal usage of this function.
238 # run it again in case of doubt
238 # run it again in case of doubt
239 # assert not (set(bheadrevs) & set(newheadrevs))
239 # assert not (set(bheadrevs) & set(newheadrevs))
240 newheadrevs.sort()
240 newheadrevs.sort()
241 bheadset.update(newheadrevs)
241 bheadset.update(newheadrevs)
242
242
243 # This prunes out two kinds of heads - heads that are superseded by
243 # This prunes out two kinds of heads - heads that are superseded by
244 # a head in newheadrevs, and newheadrevs that are not heads because
244 # a head in newheadrevs, and newheadrevs that are not heads because
245 # an existing head is their descendant.
245 # an existing head is their descendant.
246 uncertain = bheadset - topoheads
246 uncertain = bheadset - topoheads
247 if uncertain:
247 if uncertain:
248 floorrev = min(uncertain)
248 floorrev = min(uncertain)
249 ancestors = set(cl.ancestors(newheadrevs, floorrev))
249 ancestors = set(cl.ancestors(newheadrevs, floorrev))
250 bheadset -= ancestors
250 bheadset -= ancestors
251 bheadrevs = sorted(bheadset)
251 bheadrevs = sorted(bheadset)
252 self[branch] = [cl.node(rev) for rev in bheadrevs]
252 self[branch] = [cl.node(rev) for rev in bheadrevs]
253 tiprev = bheadrevs[-1]
253 tiprev = bheadrevs[-1]
254 if tiprev > self.tiprev:
254 if tiprev > self.tiprev:
255 self.tipnode = cl.node(tiprev)
255 self.tipnode = cl.node(tiprev)
256 self.tiprev = tiprev
256 self.tiprev = tiprev
257
257
258 if not self.validfor(repo):
258 if not self.validfor(repo):
259 # cache key are not valid anymore
259 # cache key are not valid anymore
260 self.tipnode = nullid
260 self.tipnode = nullid
261 self.tiprev = nullrev
261 self.tiprev = nullrev
262 for heads in self.values():
262 for heads in self.values():
263 tiprev = max(cl.rev(node) for node in heads)
263 tiprev = max(cl.rev(node) for node in heads)
264 if tiprev > self.tiprev:
264 if tiprev > self.tiprev:
265 self.tipnode = cl.node(tiprev)
265 self.tipnode = cl.node(tiprev)
266 self.tiprev = tiprev
266 self.tiprev = tiprev
267 self.filteredhash = scmutil.filteredhash(repo, self.tiprev)
267 self.filteredhash = scmutil.filteredhash(repo, self.tiprev)
268
268
269 duration = time.time() - starttime
269 duration = time.time() - starttime
270 repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
270 repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
271 repo.filtername, duration)
271 repo.filtername, duration)
272
272
273 # Revision branch info cache
273 # Revision branch info cache
274
274
275 _rbcversion = '-v1'
275 _rbcversion = '-v1'
276 _rbcnames = 'cache/rbc-names' + _rbcversion
276 _rbcnames = 'cache/rbc-names' + _rbcversion
277 _rbcrevs = 'cache/rbc-revs' + _rbcversion
277 _rbcrevs = 'cache/rbc-revs' + _rbcversion
278 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
278 # [4 byte hash prefix][4 byte branch name number with sign bit indicating open]
279 _rbcrecfmt = '>4sI'
279 _rbcrecfmt = '>4sI'
280 _rbcrecsize = calcsize(_rbcrecfmt)
280 _rbcrecsize = calcsize(_rbcrecfmt)
281 _rbcnodelen = 4
281 _rbcnodelen = 4
282 _rbcbranchidxmask = 0x7fffffff
282 _rbcbranchidxmask = 0x7fffffff
283 _rbccloseflag = 0x80000000
283 _rbccloseflag = 0x80000000
284
284
285 class revbranchcache(object):
285 class revbranchcache(object):
286 """Persistent cache, mapping from revision number to branch name and close.
286 """Persistent cache, mapping from revision number to branch name and close.
287 This is a low level cache, independent of filtering.
287 This is a low level cache, independent of filtering.
288
288
289 Branch names are stored in rbc-names in internal encoding separated by 0.
289 Branch names are stored in rbc-names in internal encoding separated by 0.
290 rbc-names is append-only, and each branch name is only stored once and will
290 rbc-names is append-only, and each branch name is only stored once and will
291 thus have a unique index.
291 thus have a unique index.
292
292
293 The branch info for each revision is stored in rbc-revs as constant size
293 The branch info for each revision is stored in rbc-revs as constant size
294 records. The whole file is read into memory, but it is only 'parsed' on
294 records. The whole file is read into memory, but it is only 'parsed' on
295 demand. The file is usually append-only but will be truncated if repo
295 demand. The file is usually append-only but will be truncated if repo
296 modification is detected.
296 modification is detected.
297 The record for each revision contains the first 4 bytes of the
297 The record for each revision contains the first 4 bytes of the
298 corresponding node hash, and the record is only used if it still matches.
298 corresponding node hash, and the record is only used if it still matches.
299 Even a completely trashed rbc-revs fill thus still give the right result
299 Even a completely trashed rbc-revs fill thus still give the right result
300 while converging towards full recovery ... assuming no incorrectly matching
300 while converging towards full recovery ... assuming no incorrectly matching
301 node hashes.
301 node hashes.
302 The record also contains 4 bytes where 31 bits contains the index of the
302 The record also contains 4 bytes where 31 bits contains the index of the
303 branch and the last bit indicate that it is a branch close commit.
303 branch and the last bit indicate that it is a branch close commit.
304 The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i
304 The usage pattern for rbc-revs is thus somewhat similar to 00changelog.i
305 and will grow with it but be 1/8th of its size.
305 and will grow with it but be 1/8th of its size.
306 """
306 """
307
307
308 def __init__(self, repo, readonly=True):
308 def __init__(self, repo, readonly=True):
309 assert repo.filtername is None
309 assert repo.filtername is None
310 self._repo = repo
310 self._repo = repo
311 self._names = [] # branch names in local encoding with static index
311 self._names = [] # branch names in local encoding with static index
312 self._rbcrevs = array('c') # structs of type _rbcrecfmt
312 self._rbcrevs = array('c') # structs of type _rbcrecfmt
313 self._rbcsnameslen = 0
313 self._rbcsnameslen = 0
314 try:
314 try:
315 bndata = repo.vfs.read(_rbcnames)
315 bndata = repo.vfs.read(_rbcnames)
316 self._rbcsnameslen = len(bndata) # for verification before writing
316 self._rbcsnameslen = len(bndata) # for verification before writing
317 self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')]
317 self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')]
318 except (IOError, OSError), inst:
318 except (IOError, OSError), inst:
319 if readonly:
319 if readonly:
320 # don't try to use cache - fall back to the slow path
320 # don't try to use cache - fall back to the slow path
321 self.branchinfo = self._branchinfo
321 self.branchinfo = self._branchinfo
322
322
323 if self._names:
323 if self._names:
324 try:
324 try:
325 data = repo.vfs.read(_rbcrevs)
325 data = repo.vfs.read(_rbcrevs)
326 self._rbcrevs.fromstring(data)
326 self._rbcrevs.fromstring(data)
327 except (IOError, OSError), inst:
327 except (IOError, OSError), inst:
328 repo.ui.debug("couldn't read revision branch cache: %s\n" %
328 repo.ui.debug("couldn't read revision branch cache: %s\n" %
329 inst)
329 inst)
330 # remember number of good records on disk
330 # remember number of good records on disk
331 self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize,
331 self._rbcrevslen = min(len(self._rbcrevs) // _rbcrecsize,
332 len(repo.changelog))
332 len(repo.changelog))
333 if self._rbcrevslen == 0:
333 if self._rbcrevslen == 0:
334 self._names = []
334 self._names = []
335 self._rbcnamescount = len(self._names) # number of good names on disk
335 self._rbcnamescount = len(self._names) # number of good names on disk
336 self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
336 self._namesreverse = dict((b, r) for r, b in enumerate(self._names))
337
337
338 def branchinfo(self, rev):
338 def branchinfo(self, rev):
339 """Return branch name and close flag for rev, using and updating
339 """Return branch name and close flag for rev, using and updating
340 persistent cache."""
340 persistent cache."""
341 changelog = self._repo.changelog
341 changelog = self._repo.changelog
342 rbcrevidx = rev * _rbcrecsize
342 rbcrevidx = rev * _rbcrecsize
343
343
344 # avoid negative index, changelog.read(nullrev) is fast without cache
345 if rev == nullrev:
346 return changelog.branchinfo(rev)
347
344 # if requested rev is missing, add and populate all missing revs
348 # if requested rev is missing, add and populate all missing revs
345 if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
349 if len(self._rbcrevs) < rbcrevidx + _rbcrecsize:
346 self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize -
350 self._rbcrevs.extend('\0' * (len(changelog) * _rbcrecsize -
347 len(self._rbcrevs)))
351 len(self._rbcrevs)))
348
352
349 # fast path: extract data from cache, use it if node is matching
353 # fast path: extract data from cache, use it if node is matching
350 reponode = changelog.node(rev)[:_rbcnodelen]
354 reponode = changelog.node(rev)[:_rbcnodelen]
351 cachenode, branchidx = unpack(
355 cachenode, branchidx = unpack(
352 _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize))
356 _rbcrecfmt, buffer(self._rbcrevs, rbcrevidx, _rbcrecsize))
353 close = bool(branchidx & _rbccloseflag)
357 close = bool(branchidx & _rbccloseflag)
354 if close:
358 if close:
355 branchidx &= _rbcbranchidxmask
359 branchidx &= _rbcbranchidxmask
356 if cachenode == '\0\0\0\0':
360 if cachenode == '\0\0\0\0':
357 pass
361 pass
358 elif cachenode == reponode:
362 elif cachenode == reponode:
359 return self._names[branchidx], close
363 return self._names[branchidx], close
360 else:
364 else:
361 # rev/node map has changed, invalidate the cache from here up
365 # rev/node map has changed, invalidate the cache from here up
362 truncate = rbcrevidx + _rbcrecsize
366 truncate = rbcrevidx + _rbcrecsize
363 del self._rbcrevs[truncate:]
367 del self._rbcrevs[truncate:]
364 self._rbcrevslen = min(self._rbcrevslen, truncate)
368 self._rbcrevslen = min(self._rbcrevslen, truncate)
365
369
366 # fall back to slow path and make sure it will be written to disk
370 # fall back to slow path and make sure it will be written to disk
367 return self._branchinfo(rev)
371 return self._branchinfo(rev)
368
372
369 def _branchinfo(self, rev):
373 def _branchinfo(self, rev):
370 """Retrieve branch info from changelog and update _rbcrevs"""
374 """Retrieve branch info from changelog and update _rbcrevs"""
371 changelog = self._repo.changelog
375 changelog = self._repo.changelog
372 b, close = changelog.branchinfo(rev)
376 b, close = changelog.branchinfo(rev)
373 if b in self._namesreverse:
377 if b in self._namesreverse:
374 branchidx = self._namesreverse[b]
378 branchidx = self._namesreverse[b]
375 else:
379 else:
376 branchidx = len(self._names)
380 branchidx = len(self._names)
377 self._names.append(b)
381 self._names.append(b)
378 self._namesreverse[b] = branchidx
382 self._namesreverse[b] = branchidx
379 reponode = changelog.node(rev)
383 reponode = changelog.node(rev)
380 if close:
384 if close:
381 branchidx |= _rbccloseflag
385 branchidx |= _rbccloseflag
382 self._setcachedata(rev, reponode, branchidx)
386 self._setcachedata(rev, reponode, branchidx)
383 return b, close
387 return b, close
384
388
385 def _setcachedata(self, rev, node, branchidx):
389 def _setcachedata(self, rev, node, branchidx):
386 """Writes the node's branch data to the in-memory cache data."""
390 """Writes the node's branch data to the in-memory cache data."""
387 rbcrevidx = rev * _rbcrecsize
391 rbcrevidx = rev * _rbcrecsize
388 rec = array('c')
392 rec = array('c')
389 rec.fromstring(pack(_rbcrecfmt, node, branchidx))
393 rec.fromstring(pack(_rbcrecfmt, node, branchidx))
390 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
394 self._rbcrevs[rbcrevidx:rbcrevidx + _rbcrecsize] = rec
391 self._rbcrevslen = min(self._rbcrevslen, rev)
395 self._rbcrevslen = min(self._rbcrevslen, rev)
392
396
393 tr = self._repo.currenttransaction()
397 tr = self._repo.currenttransaction()
394 if tr:
398 if tr:
395 tr.addfinalize('write-revbranchcache', self.write)
399 tr.addfinalize('write-revbranchcache', self.write)
396
400
397 def write(self, tr=None):
401 def write(self, tr=None):
398 """Save branch cache if it is dirty."""
402 """Save branch cache if it is dirty."""
399 repo = self._repo
403 repo = self._repo
400 if self._rbcnamescount < len(self._names):
404 if self._rbcnamescount < len(self._names):
401 try:
405 try:
402 if self._rbcnamescount != 0:
406 if self._rbcnamescount != 0:
403 f = repo.vfs.open(_rbcnames, 'ab')
407 f = repo.vfs.open(_rbcnames, 'ab')
404 if f.tell() == self._rbcsnameslen:
408 if f.tell() == self._rbcsnameslen:
405 f.write('\0')
409 f.write('\0')
406 else:
410 else:
407 f.close()
411 f.close()
408 repo.ui.debug("%s changed - rewriting it\n" % _rbcnames)
412 repo.ui.debug("%s changed - rewriting it\n" % _rbcnames)
409 self._rbcnamescount = 0
413 self._rbcnamescount = 0
410 self._rbcrevslen = 0
414 self._rbcrevslen = 0
411 if self._rbcnamescount == 0:
415 if self._rbcnamescount == 0:
412 f = repo.vfs.open(_rbcnames, 'wb')
416 f = repo.vfs.open(_rbcnames, 'wb')
413 f.write('\0'.join(encoding.fromlocal(b)
417 f.write('\0'.join(encoding.fromlocal(b)
414 for b in self._names[self._rbcnamescount:]))
418 for b in self._names[self._rbcnamescount:]))
415 self._rbcsnameslen = f.tell()
419 self._rbcsnameslen = f.tell()
416 f.close()
420 f.close()
417 except (IOError, OSError, util.Abort), inst:
421 except (IOError, OSError, util.Abort), inst:
418 repo.ui.debug("couldn't write revision branch cache names: "
422 repo.ui.debug("couldn't write revision branch cache names: "
419 "%s\n" % inst)
423 "%s\n" % inst)
420 return
424 return
421 self._rbcnamescount = len(self._names)
425 self._rbcnamescount = len(self._names)
422
426
423 start = self._rbcrevslen * _rbcrecsize
427 start = self._rbcrevslen * _rbcrecsize
424 if start != len(self._rbcrevs):
428 if start != len(self._rbcrevs):
425 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
429 revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
426 try:
430 try:
427 f = repo.vfs.open(_rbcrevs, 'ab')
431 f = repo.vfs.open(_rbcrevs, 'ab')
428 if f.tell() != start:
432 if f.tell() != start:
429 repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start))
433 repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start))
430 f.seek(start)
434 f.seek(start)
431 f.truncate()
435 f.truncate()
432 end = revs * _rbcrecsize
436 end = revs * _rbcrecsize
433 f.write(self._rbcrevs[start:end])
437 f.write(self._rbcrevs[start:end])
434 f.close()
438 f.close()
435 except (IOError, OSError, util.Abort), inst:
439 except (IOError, OSError, util.Abort), inst:
436 repo.ui.debug("couldn't write revision branch cache: %s\n" %
440 repo.ui.debug("couldn't write revision branch cache: %s\n" %
437 inst)
441 inst)
438 return
442 return
439 self._rbcrevslen = revs
443 self._rbcrevslen = revs
@@ -1,1937 +1,1938 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 from node import hex, nullid, short
7 from node import hex, nullid, short
8 from i18n import _
8 from i18n import _
9 import urllib
9 import urllib
10 import peer, changegroup, subrepo, pushkey, obsolete, repoview
10 import peer, changegroup, subrepo, pushkey, obsolete, repoview
11 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
11 import changelog, dirstate, filelog, manifest, context, bookmarks, phases
12 import lock as lockmod
12 import lock as lockmod
13 import transaction, store, encoding, exchange, bundle2
13 import transaction, store, encoding, exchange, bundle2
14 import scmutil, util, extensions, hook, error, revset
14 import scmutil, util, extensions, hook, error, revset
15 import match as matchmod
15 import match as matchmod
16 import merge as mergemod
16 import merge as mergemod
17 import tags as tagsmod
17 import tags as tagsmod
18 from lock import release
18 from lock import release
19 import weakref, errno, os, time, inspect
19 import weakref, errno, os, time, inspect, random
20 import branchmap, pathutil
20 import branchmap, pathutil
21 import namespaces
21 import namespaces
22 propertycache = util.propertycache
22 propertycache = util.propertycache
23 filecache = scmutil.filecache
23 filecache = scmutil.filecache
24
24
25 class repofilecache(filecache):
25 class repofilecache(filecache):
26 """All filecache usage on repo are done for logic that should be unfiltered
26 """All filecache usage on repo are done for logic that should be unfiltered
27 """
27 """
28
28
29 def __get__(self, repo, type=None):
29 def __get__(self, repo, type=None):
30 return super(repofilecache, self).__get__(repo.unfiltered(), type)
30 return super(repofilecache, self).__get__(repo.unfiltered(), type)
31 def __set__(self, repo, value):
31 def __set__(self, repo, value):
32 return super(repofilecache, self).__set__(repo.unfiltered(), value)
32 return super(repofilecache, self).__set__(repo.unfiltered(), value)
33 def __delete__(self, repo):
33 def __delete__(self, repo):
34 return super(repofilecache, self).__delete__(repo.unfiltered())
34 return super(repofilecache, self).__delete__(repo.unfiltered())
35
35
36 class storecache(repofilecache):
36 class storecache(repofilecache):
37 """filecache for files in the store"""
37 """filecache for files in the store"""
38 def join(self, obj, fname):
38 def join(self, obj, fname):
39 return obj.sjoin(fname)
39 return obj.sjoin(fname)
40
40
41 class unfilteredpropertycache(propertycache):
41 class unfilteredpropertycache(propertycache):
42 """propertycache that apply to unfiltered repo only"""
42 """propertycache that apply to unfiltered repo only"""
43
43
44 def __get__(self, repo, type=None):
44 def __get__(self, repo, type=None):
45 unfi = repo.unfiltered()
45 unfi = repo.unfiltered()
46 if unfi is repo:
46 if unfi is repo:
47 return super(unfilteredpropertycache, self).__get__(unfi)
47 return super(unfilteredpropertycache, self).__get__(unfi)
48 return getattr(unfi, self.name)
48 return getattr(unfi, self.name)
49
49
50 class filteredpropertycache(propertycache):
50 class filteredpropertycache(propertycache):
51 """propertycache that must take filtering in account"""
51 """propertycache that must take filtering in account"""
52
52
53 def cachevalue(self, obj, value):
53 def cachevalue(self, obj, value):
54 object.__setattr__(obj, self.name, value)
54 object.__setattr__(obj, self.name, value)
55
55
56
56
57 def hasunfilteredcache(repo, name):
57 def hasunfilteredcache(repo, name):
58 """check if a repo has an unfilteredpropertycache value for <name>"""
58 """check if a repo has an unfilteredpropertycache value for <name>"""
59 return name in vars(repo.unfiltered())
59 return name in vars(repo.unfiltered())
60
60
61 def unfilteredmethod(orig):
61 def unfilteredmethod(orig):
62 """decorate method that always need to be run on unfiltered version"""
62 """decorate method that always need to be run on unfiltered version"""
63 def wrapper(repo, *args, **kwargs):
63 def wrapper(repo, *args, **kwargs):
64 return orig(repo.unfiltered(), *args, **kwargs)
64 return orig(repo.unfiltered(), *args, **kwargs)
65 return wrapper
65 return wrapper
66
66
67 moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
67 moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle',
68 'unbundle'))
68 'unbundle'))
69 legacycaps = moderncaps.union(set(['changegroupsubset']))
69 legacycaps = moderncaps.union(set(['changegroupsubset']))
70
70
71 class localpeer(peer.peerrepository):
71 class localpeer(peer.peerrepository):
72 '''peer for a local repo; reflects only the most recent API'''
72 '''peer for a local repo; reflects only the most recent API'''
73
73
74 def __init__(self, repo, caps=moderncaps):
74 def __init__(self, repo, caps=moderncaps):
75 peer.peerrepository.__init__(self)
75 peer.peerrepository.__init__(self)
76 self._repo = repo.filtered('served')
76 self._repo = repo.filtered('served')
77 self.ui = repo.ui
77 self.ui = repo.ui
78 self._caps = repo._restrictcapabilities(caps)
78 self._caps = repo._restrictcapabilities(caps)
79 self.requirements = repo.requirements
79 self.requirements = repo.requirements
80 self.supportedformats = repo.supportedformats
80 self.supportedformats = repo.supportedformats
81
81
82 def close(self):
82 def close(self):
83 self._repo.close()
83 self._repo.close()
84
84
85 def _capabilities(self):
85 def _capabilities(self):
86 return self._caps
86 return self._caps
87
87
88 def local(self):
88 def local(self):
89 return self._repo
89 return self._repo
90
90
91 def canpush(self):
91 def canpush(self):
92 return True
92 return True
93
93
94 def url(self):
94 def url(self):
95 return self._repo.url()
95 return self._repo.url()
96
96
97 def lookup(self, key):
97 def lookup(self, key):
98 return self._repo.lookup(key)
98 return self._repo.lookup(key)
99
99
100 def branchmap(self):
100 def branchmap(self):
101 return self._repo.branchmap()
101 return self._repo.branchmap()
102
102
103 def heads(self):
103 def heads(self):
104 return self._repo.heads()
104 return self._repo.heads()
105
105
106 def known(self, nodes):
106 def known(self, nodes):
107 return self._repo.known(nodes)
107 return self._repo.known(nodes)
108
108
109 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
109 def getbundle(self, source, heads=None, common=None, bundlecaps=None,
110 **kwargs):
110 **kwargs):
111 cg = exchange.getbundle(self._repo, source, heads=heads,
111 cg = exchange.getbundle(self._repo, source, heads=heads,
112 common=common, bundlecaps=bundlecaps, **kwargs)
112 common=common, bundlecaps=bundlecaps, **kwargs)
113 if bundlecaps is not None and 'HG20' in bundlecaps:
113 if bundlecaps is not None and 'HG20' in bundlecaps:
114 # When requesting a bundle2, getbundle returns a stream to make the
114 # When requesting a bundle2, getbundle returns a stream to make the
115 # wire level function happier. We need to build a proper object
115 # wire level function happier. We need to build a proper object
116 # from it in local peer.
116 # from it in local peer.
117 cg = bundle2.getunbundler(self.ui, cg)
117 cg = bundle2.getunbundler(self.ui, cg)
118 return cg
118 return cg
119
119
120 # TODO We might want to move the next two calls into legacypeer and add
120 # TODO We might want to move the next two calls into legacypeer and add
121 # unbundle instead.
121 # unbundle instead.
122
122
123 def unbundle(self, cg, heads, url):
123 def unbundle(self, cg, heads, url):
124 """apply a bundle on a repo
124 """apply a bundle on a repo
125
125
126 This function handles the repo locking itself."""
126 This function handles the repo locking itself."""
127 try:
127 try:
128 try:
128 try:
129 cg = exchange.readbundle(self.ui, cg, None)
129 cg = exchange.readbundle(self.ui, cg, None)
130 ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
130 ret = exchange.unbundle(self._repo, cg, heads, 'push', url)
131 if util.safehasattr(ret, 'getchunks'):
131 if util.safehasattr(ret, 'getchunks'):
132 # This is a bundle20 object, turn it into an unbundler.
132 # This is a bundle20 object, turn it into an unbundler.
133 # This little dance should be dropped eventually when the
133 # This little dance should be dropped eventually when the
134 # API is finally improved.
134 # API is finally improved.
135 stream = util.chunkbuffer(ret.getchunks())
135 stream = util.chunkbuffer(ret.getchunks())
136 ret = bundle2.getunbundler(self.ui, stream)
136 ret = bundle2.getunbundler(self.ui, stream)
137 return ret
137 return ret
138 except Exception, exc:
138 except Exception, exc:
139 # If the exception contains output salvaged from a bundle2
139 # If the exception contains output salvaged from a bundle2
140 # reply, we need to make sure it is printed before continuing
140 # reply, we need to make sure it is printed before continuing
141 # to fail. So we build a bundle2 with such output and consume
141 # to fail. So we build a bundle2 with such output and consume
142 # it directly.
142 # it directly.
143 #
143 #
144 # This is not very elegant but allows a "simple" solution for
144 # This is not very elegant but allows a "simple" solution for
145 # issue4594
145 # issue4594
146 output = getattr(exc, '_bundle2salvagedoutput', ())
146 output = getattr(exc, '_bundle2salvagedoutput', ())
147 if output:
147 if output:
148 bundler = bundle2.bundle20(self._repo.ui)
148 bundler = bundle2.bundle20(self._repo.ui)
149 for out in output:
149 for out in output:
150 bundler.addpart(out)
150 bundler.addpart(out)
151 stream = util.chunkbuffer(bundler.getchunks())
151 stream = util.chunkbuffer(bundler.getchunks())
152 b = bundle2.getunbundler(self.ui, stream)
152 b = bundle2.getunbundler(self.ui, stream)
153 bundle2.processbundle(self._repo, b)
153 bundle2.processbundle(self._repo, b)
154 raise
154 raise
155 except error.PushRaced, exc:
155 except error.PushRaced, exc:
156 raise error.ResponseError(_('push failed:'), str(exc))
156 raise error.ResponseError(_('push failed:'), str(exc))
157
157
158 def lock(self):
158 def lock(self):
159 return self._repo.lock()
159 return self._repo.lock()
160
160
161 def addchangegroup(self, cg, source, url):
161 def addchangegroup(self, cg, source, url):
162 return changegroup.addchangegroup(self._repo, cg, source, url)
162 return changegroup.addchangegroup(self._repo, cg, source, url)
163
163
164 def pushkey(self, namespace, key, old, new):
164 def pushkey(self, namespace, key, old, new):
165 return self._repo.pushkey(namespace, key, old, new)
165 return self._repo.pushkey(namespace, key, old, new)
166
166
167 def listkeys(self, namespace):
167 def listkeys(self, namespace):
168 return self._repo.listkeys(namespace)
168 return self._repo.listkeys(namespace)
169
169
170 def debugwireargs(self, one, two, three=None, four=None, five=None):
170 def debugwireargs(self, one, two, three=None, four=None, five=None):
171 '''used to test argument passing over the wire'''
171 '''used to test argument passing over the wire'''
172 return "%s %s %s %s %s" % (one, two, three, four, five)
172 return "%s %s %s %s %s" % (one, two, three, four, five)
173
173
174 class locallegacypeer(localpeer):
174 class locallegacypeer(localpeer):
175 '''peer extension which implements legacy methods too; used for tests with
175 '''peer extension which implements legacy methods too; used for tests with
176 restricted capabilities'''
176 restricted capabilities'''
177
177
178 def __init__(self, repo):
178 def __init__(self, repo):
179 localpeer.__init__(self, repo, caps=legacycaps)
179 localpeer.__init__(self, repo, caps=legacycaps)
180
180
181 def branches(self, nodes):
181 def branches(self, nodes):
182 return self._repo.branches(nodes)
182 return self._repo.branches(nodes)
183
183
184 def between(self, pairs):
184 def between(self, pairs):
185 return self._repo.between(pairs)
185 return self._repo.between(pairs)
186
186
187 def changegroup(self, basenodes, source):
187 def changegroup(self, basenodes, source):
188 return changegroup.changegroup(self._repo, basenodes, source)
188 return changegroup.changegroup(self._repo, basenodes, source)
189
189
190 def changegroupsubset(self, bases, heads, source):
190 def changegroupsubset(self, bases, heads, source):
191 return changegroup.changegroupsubset(self._repo, bases, heads, source)
191 return changegroup.changegroupsubset(self._repo, bases, heads, source)
192
192
193 class localrepository(object):
193 class localrepository(object):
194
194
195 supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest',
195 supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest',
196 'manifestv2'))
196 'manifestv2'))
197 _basesupported = supportedformats | set(('store', 'fncache', 'shared',
197 _basesupported = supportedformats | set(('store', 'fncache', 'shared',
198 'dotencode'))
198 'dotencode'))
199 openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2'))
199 openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2'))
200 filtername = None
200 filtername = None
201
201
202 # a list of (ui, featureset) functions.
202 # a list of (ui, featureset) functions.
203 # only functions defined in module of enabled extensions are invoked
203 # only functions defined in module of enabled extensions are invoked
204 featuresetupfuncs = set()
204 featuresetupfuncs = set()
205
205
206 def _baserequirements(self, create):
206 def _baserequirements(self, create):
207 return ['revlogv1']
207 return ['revlogv1']
208
208
209 def __init__(self, baseui, path=None, create=False):
209 def __init__(self, baseui, path=None, create=False):
210 self.requirements = set()
210 self.requirements = set()
211 self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True)
211 self.wvfs = scmutil.vfs(path, expandpath=True, realpath=True)
212 self.wopener = self.wvfs
212 self.wopener = self.wvfs
213 self.root = self.wvfs.base
213 self.root = self.wvfs.base
214 self.path = self.wvfs.join(".hg")
214 self.path = self.wvfs.join(".hg")
215 self.origroot = path
215 self.origroot = path
216 self.auditor = pathutil.pathauditor(self.root, self._checknested)
216 self.auditor = pathutil.pathauditor(self.root, self._checknested)
217 self.vfs = scmutil.vfs(self.path)
217 self.vfs = scmutil.vfs(self.path)
218 self.opener = self.vfs
218 self.opener = self.vfs
219 self.baseui = baseui
219 self.baseui = baseui
220 self.ui = baseui.copy()
220 self.ui = baseui.copy()
221 self.ui.copy = baseui.copy # prevent copying repo configuration
221 self.ui.copy = baseui.copy # prevent copying repo configuration
222 # A list of callback to shape the phase if no data were found.
222 # A list of callback to shape the phase if no data were found.
223 # Callback are in the form: func(repo, roots) --> processed root.
223 # Callback are in the form: func(repo, roots) --> processed root.
224 # This list it to be filled by extension during repo setup
224 # This list it to be filled by extension during repo setup
225 self._phasedefaults = []
225 self._phasedefaults = []
226 try:
226 try:
227 self.ui.readconfig(self.join("hgrc"), self.root)
227 self.ui.readconfig(self.join("hgrc"), self.root)
228 extensions.loadall(self.ui)
228 extensions.loadall(self.ui)
229 except IOError:
229 except IOError:
230 pass
230 pass
231
231
232 if self.featuresetupfuncs:
232 if self.featuresetupfuncs:
233 self.supported = set(self._basesupported) # use private copy
233 self.supported = set(self._basesupported) # use private copy
234 extmods = set(m.__name__ for n, m
234 extmods = set(m.__name__ for n, m
235 in extensions.extensions(self.ui))
235 in extensions.extensions(self.ui))
236 for setupfunc in self.featuresetupfuncs:
236 for setupfunc in self.featuresetupfuncs:
237 if setupfunc.__module__ in extmods:
237 if setupfunc.__module__ in extmods:
238 setupfunc(self.ui, self.supported)
238 setupfunc(self.ui, self.supported)
239 else:
239 else:
240 self.supported = self._basesupported
240 self.supported = self._basesupported
241
241
242 if not self.vfs.isdir():
242 if not self.vfs.isdir():
243 if create:
243 if create:
244 if not self.wvfs.exists():
244 if not self.wvfs.exists():
245 self.wvfs.makedirs()
245 self.wvfs.makedirs()
246 self.vfs.makedir(notindexed=True)
246 self.vfs.makedir(notindexed=True)
247 self.requirements.update(self._baserequirements(create))
247 self.requirements.update(self._baserequirements(create))
248 if self.ui.configbool('format', 'usestore', True):
248 if self.ui.configbool('format', 'usestore', True):
249 self.vfs.mkdir("store")
249 self.vfs.mkdir("store")
250 self.requirements.add("store")
250 self.requirements.add("store")
251 if self.ui.configbool('format', 'usefncache', True):
251 if self.ui.configbool('format', 'usefncache', True):
252 self.requirements.add("fncache")
252 self.requirements.add("fncache")
253 if self.ui.configbool('format', 'dotencode', True):
253 if self.ui.configbool('format', 'dotencode', True):
254 self.requirements.add('dotencode')
254 self.requirements.add('dotencode')
255 # create an invalid changelog
255 # create an invalid changelog
256 self.vfs.append(
256 self.vfs.append(
257 "00changelog.i",
257 "00changelog.i",
258 '\0\0\0\2' # represents revlogv2
258 '\0\0\0\2' # represents revlogv2
259 ' dummy changelog to prevent using the old repo layout'
259 ' dummy changelog to prevent using the old repo layout'
260 )
260 )
261 if self.ui.configbool('format', 'generaldelta', False):
261 if self.ui.configbool('format', 'generaldelta', False):
262 self.requirements.add("generaldelta")
262 self.requirements.add("generaldelta")
263 if self.ui.configbool('experimental', 'treemanifest', False):
263 if self.ui.configbool('experimental', 'treemanifest', False):
264 self.requirements.add("treemanifest")
264 self.requirements.add("treemanifest")
265 if self.ui.configbool('experimental', 'manifestv2', False):
265 if self.ui.configbool('experimental', 'manifestv2', False):
266 self.requirements.add("manifestv2")
266 self.requirements.add("manifestv2")
267 else:
267 else:
268 raise error.RepoError(_("repository %s not found") % path)
268 raise error.RepoError(_("repository %s not found") % path)
269 elif create:
269 elif create:
270 raise error.RepoError(_("repository %s already exists") % path)
270 raise error.RepoError(_("repository %s already exists") % path)
271 else:
271 else:
272 try:
272 try:
273 self.requirements = scmutil.readrequires(
273 self.requirements = scmutil.readrequires(
274 self.vfs, self.supported)
274 self.vfs, self.supported)
275 except IOError, inst:
275 except IOError, inst:
276 if inst.errno != errno.ENOENT:
276 if inst.errno != errno.ENOENT:
277 raise
277 raise
278
278
279 self.sharedpath = self.path
279 self.sharedpath = self.path
280 try:
280 try:
281 vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
281 vfs = scmutil.vfs(self.vfs.read("sharedpath").rstrip('\n'),
282 realpath=True)
282 realpath=True)
283 s = vfs.base
283 s = vfs.base
284 if not vfs.exists():
284 if not vfs.exists():
285 raise error.RepoError(
285 raise error.RepoError(
286 _('.hg/sharedpath points to nonexistent directory %s') % s)
286 _('.hg/sharedpath points to nonexistent directory %s') % s)
287 self.sharedpath = s
287 self.sharedpath = s
288 except IOError, inst:
288 except IOError, inst:
289 if inst.errno != errno.ENOENT:
289 if inst.errno != errno.ENOENT:
290 raise
290 raise
291
291
292 self.store = store.store(
292 self.store = store.store(
293 self.requirements, self.sharedpath, scmutil.vfs)
293 self.requirements, self.sharedpath, scmutil.vfs)
294 self.spath = self.store.path
294 self.spath = self.store.path
295 self.svfs = self.store.vfs
295 self.svfs = self.store.vfs
296 self.sopener = self.svfs
296 self.sopener = self.svfs
297 self.sjoin = self.store.join
297 self.sjoin = self.store.join
298 self.vfs.createmode = self.store.createmode
298 self.vfs.createmode = self.store.createmode
299 self._applyopenerreqs()
299 self._applyopenerreqs()
300 if create:
300 if create:
301 self._writerequirements()
301 self._writerequirements()
302
302
303
303
304 self._branchcaches = {}
304 self._branchcaches = {}
305 self._revbranchcache = None
305 self._revbranchcache = None
306 self.filterpats = {}
306 self.filterpats = {}
307 self._datafilters = {}
307 self._datafilters = {}
308 self._transref = self._lockref = self._wlockref = None
308 self._transref = self._lockref = self._wlockref = None
309
309
310 # A cache for various files under .hg/ that tracks file changes,
310 # A cache for various files under .hg/ that tracks file changes,
311 # (used by the filecache decorator)
311 # (used by the filecache decorator)
312 #
312 #
313 # Maps a property name to its util.filecacheentry
313 # Maps a property name to its util.filecacheentry
314 self._filecache = {}
314 self._filecache = {}
315
315
316 # hold sets of revision to be filtered
316 # hold sets of revision to be filtered
317 # should be cleared when something might have changed the filter value:
317 # should be cleared when something might have changed the filter value:
318 # - new changesets,
318 # - new changesets,
319 # - phase change,
319 # - phase change,
320 # - new obsolescence marker,
320 # - new obsolescence marker,
321 # - working directory parent change,
321 # - working directory parent change,
322 # - bookmark changes
322 # - bookmark changes
323 self.filteredrevcache = {}
323 self.filteredrevcache = {}
324
324
325 # generic mapping between names and nodes
325 # generic mapping between names and nodes
326 self.names = namespaces.namespaces()
326 self.names = namespaces.namespaces()
327
327
328 def close(self):
328 def close(self):
329 self._writecaches()
329 self._writecaches()
330
330
331 def _writecaches(self):
331 def _writecaches(self):
332 if self._revbranchcache:
332 if self._revbranchcache:
333 self._revbranchcache.write()
333 self._revbranchcache.write()
334
334
335 def _restrictcapabilities(self, caps):
335 def _restrictcapabilities(self, caps):
336 if self.ui.configbool('experimental', 'bundle2-advertise', True):
336 if self.ui.configbool('experimental', 'bundle2-advertise', True):
337 caps = set(caps)
337 caps = set(caps)
338 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
338 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
339 caps.add('bundle2=' + urllib.quote(capsblob))
339 caps.add('bundle2=' + urllib.quote(capsblob))
340 return caps
340 return caps
341
341
342 def _applyopenerreqs(self):
342 def _applyopenerreqs(self):
343 self.svfs.options = dict((r, 1) for r in self.requirements
343 self.svfs.options = dict((r, 1) for r in self.requirements
344 if r in self.openerreqs)
344 if r in self.openerreqs)
345 chunkcachesize = self.ui.configint('format', 'chunkcachesize')
345 chunkcachesize = self.ui.configint('format', 'chunkcachesize')
346 if chunkcachesize is not None:
346 if chunkcachesize is not None:
347 self.svfs.options['chunkcachesize'] = chunkcachesize
347 self.svfs.options['chunkcachesize'] = chunkcachesize
348 maxchainlen = self.ui.configint('format', 'maxchainlen')
348 maxchainlen = self.ui.configint('format', 'maxchainlen')
349 if maxchainlen is not None:
349 if maxchainlen is not None:
350 self.svfs.options['maxchainlen'] = maxchainlen
350 self.svfs.options['maxchainlen'] = maxchainlen
351 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
351 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
352 if manifestcachesize is not None:
352 if manifestcachesize is not None:
353 self.svfs.options['manifestcachesize'] = manifestcachesize
353 self.svfs.options['manifestcachesize'] = manifestcachesize
354
354
355 def _writerequirements(self):
355 def _writerequirements(self):
356 scmutil.writerequires(self.vfs, self.requirements)
356 scmutil.writerequires(self.vfs, self.requirements)
357
357
358 def _checknested(self, path):
358 def _checknested(self, path):
359 """Determine if path is a legal nested repository."""
359 """Determine if path is a legal nested repository."""
360 if not path.startswith(self.root):
360 if not path.startswith(self.root):
361 return False
361 return False
362 subpath = path[len(self.root) + 1:]
362 subpath = path[len(self.root) + 1:]
363 normsubpath = util.pconvert(subpath)
363 normsubpath = util.pconvert(subpath)
364
364
365 # XXX: Checking against the current working copy is wrong in
365 # XXX: Checking against the current working copy is wrong in
366 # the sense that it can reject things like
366 # the sense that it can reject things like
367 #
367 #
368 # $ hg cat -r 10 sub/x.txt
368 # $ hg cat -r 10 sub/x.txt
369 #
369 #
370 # if sub/ is no longer a subrepository in the working copy
370 # if sub/ is no longer a subrepository in the working copy
371 # parent revision.
371 # parent revision.
372 #
372 #
373 # However, it can of course also allow things that would have
373 # However, it can of course also allow things that would have
374 # been rejected before, such as the above cat command if sub/
374 # been rejected before, such as the above cat command if sub/
375 # is a subrepository now, but was a normal directory before.
375 # is a subrepository now, but was a normal directory before.
376 # The old path auditor would have rejected by mistake since it
376 # The old path auditor would have rejected by mistake since it
377 # panics when it sees sub/.hg/.
377 # panics when it sees sub/.hg/.
378 #
378 #
379 # All in all, checking against the working copy seems sensible
379 # All in all, checking against the working copy seems sensible
380 # since we want to prevent access to nested repositories on
380 # since we want to prevent access to nested repositories on
381 # the filesystem *now*.
381 # the filesystem *now*.
382 ctx = self[None]
382 ctx = self[None]
383 parts = util.splitpath(subpath)
383 parts = util.splitpath(subpath)
384 while parts:
384 while parts:
385 prefix = '/'.join(parts)
385 prefix = '/'.join(parts)
386 if prefix in ctx.substate:
386 if prefix in ctx.substate:
387 if prefix == normsubpath:
387 if prefix == normsubpath:
388 return True
388 return True
389 else:
389 else:
390 sub = ctx.sub(prefix)
390 sub = ctx.sub(prefix)
391 return sub.checknested(subpath[len(prefix) + 1:])
391 return sub.checknested(subpath[len(prefix) + 1:])
392 else:
392 else:
393 parts.pop()
393 parts.pop()
394 return False
394 return False
395
395
396 def peer(self):
396 def peer(self):
397 return localpeer(self) # not cached to avoid reference cycle
397 return localpeer(self) # not cached to avoid reference cycle
398
398
399 def unfiltered(self):
399 def unfiltered(self):
400 """Return unfiltered version of the repository
400 """Return unfiltered version of the repository
401
401
402 Intended to be overwritten by filtered repo."""
402 Intended to be overwritten by filtered repo."""
403 return self
403 return self
404
404
405 def filtered(self, name):
405 def filtered(self, name):
406 """Return a filtered version of a repository"""
406 """Return a filtered version of a repository"""
407 # build a new class with the mixin and the current class
407 # build a new class with the mixin and the current class
408 # (possibly subclass of the repo)
408 # (possibly subclass of the repo)
409 class proxycls(repoview.repoview, self.unfiltered().__class__):
409 class proxycls(repoview.repoview, self.unfiltered().__class__):
410 pass
410 pass
411 return proxycls(self, name)
411 return proxycls(self, name)
412
412
413 @repofilecache('bookmarks')
413 @repofilecache('bookmarks')
414 def _bookmarks(self):
414 def _bookmarks(self):
415 return bookmarks.bmstore(self)
415 return bookmarks.bmstore(self)
416
416
417 @repofilecache('bookmarks.current')
417 @repofilecache('bookmarks.current')
418 def _activebookmark(self):
418 def _activebookmark(self):
419 return bookmarks.readactive(self)
419 return bookmarks.readactive(self)
420
420
421 def bookmarkheads(self, bookmark):
421 def bookmarkheads(self, bookmark):
422 name = bookmark.split('@', 1)[0]
422 name = bookmark.split('@', 1)[0]
423 heads = []
423 heads = []
424 for mark, n in self._bookmarks.iteritems():
424 for mark, n in self._bookmarks.iteritems():
425 if mark.split('@', 1)[0] == name:
425 if mark.split('@', 1)[0] == name:
426 heads.append(n)
426 heads.append(n)
427 return heads
427 return heads
428
428
429 @storecache('phaseroots')
429 @storecache('phaseroots')
430 def _phasecache(self):
430 def _phasecache(self):
431 return phases.phasecache(self, self._phasedefaults)
431 return phases.phasecache(self, self._phasedefaults)
432
432
433 @storecache('obsstore')
433 @storecache('obsstore')
434 def obsstore(self):
434 def obsstore(self):
435 # read default format for new obsstore.
435 # read default format for new obsstore.
436 defaultformat = self.ui.configint('format', 'obsstore-version', None)
436 defaultformat = self.ui.configint('format', 'obsstore-version', None)
437 # rely on obsstore class default when possible.
437 # rely on obsstore class default when possible.
438 kwargs = {}
438 kwargs = {}
439 if defaultformat is not None:
439 if defaultformat is not None:
440 kwargs['defaultformat'] = defaultformat
440 kwargs['defaultformat'] = defaultformat
441 readonly = not obsolete.isenabled(self, obsolete.createmarkersopt)
441 readonly = not obsolete.isenabled(self, obsolete.createmarkersopt)
442 store = obsolete.obsstore(self.svfs, readonly=readonly,
442 store = obsolete.obsstore(self.svfs, readonly=readonly,
443 **kwargs)
443 **kwargs)
444 if store and readonly:
444 if store and readonly:
445 self.ui.warn(
445 self.ui.warn(
446 _('obsolete feature not enabled but %i markers found!\n')
446 _('obsolete feature not enabled but %i markers found!\n')
447 % len(list(store)))
447 % len(list(store)))
448 return store
448 return store
449
449
450 @storecache('00changelog.i')
450 @storecache('00changelog.i')
451 def changelog(self):
451 def changelog(self):
452 c = changelog.changelog(self.svfs)
452 c = changelog.changelog(self.svfs)
453 if 'HG_PENDING' in os.environ:
453 if 'HG_PENDING' in os.environ:
454 p = os.environ['HG_PENDING']
454 p = os.environ['HG_PENDING']
455 if p.startswith(self.root):
455 if p.startswith(self.root):
456 c.readpending('00changelog.i.a')
456 c.readpending('00changelog.i.a')
457 return c
457 return c
458
458
459 @storecache('00manifest.i')
459 @storecache('00manifest.i')
460 def manifest(self):
460 def manifest(self):
461 return manifest.manifest(self.svfs)
461 return manifest.manifest(self.svfs)
462
462
463 def dirlog(self, dir):
463 def dirlog(self, dir):
464 return self.manifest.dirlog(dir)
464 return self.manifest.dirlog(dir)
465
465
466 @repofilecache('dirstate')
466 @repofilecache('dirstate')
467 def dirstate(self):
467 def dirstate(self):
468 warned = [0]
468 warned = [0]
469 def validate(node):
469 def validate(node):
470 try:
470 try:
471 self.changelog.rev(node)
471 self.changelog.rev(node)
472 return node
472 return node
473 except error.LookupError:
473 except error.LookupError:
474 if not warned[0]:
474 if not warned[0]:
475 warned[0] = True
475 warned[0] = True
476 self.ui.warn(_("warning: ignoring unknown"
476 self.ui.warn(_("warning: ignoring unknown"
477 " working parent %s!\n") % short(node))
477 " working parent %s!\n") % short(node))
478 return nullid
478 return nullid
479
479
480 return dirstate.dirstate(self.vfs, self.ui, self.root, validate)
480 return dirstate.dirstate(self.vfs, self.ui, self.root, validate)
481
481
482 def __getitem__(self, changeid):
482 def __getitem__(self, changeid):
483 if changeid is None:
483 if changeid is None:
484 return context.workingctx(self)
484 return context.workingctx(self)
485 if isinstance(changeid, slice):
485 if isinstance(changeid, slice):
486 return [context.changectx(self, i)
486 return [context.changectx(self, i)
487 for i in xrange(*changeid.indices(len(self)))
487 for i in xrange(*changeid.indices(len(self)))
488 if i not in self.changelog.filteredrevs]
488 if i not in self.changelog.filteredrevs]
489 return context.changectx(self, changeid)
489 return context.changectx(self, changeid)
490
490
491 def __contains__(self, changeid):
491 def __contains__(self, changeid):
492 try:
492 try:
493 self[changeid]
493 self[changeid]
494 return True
494 return True
495 except error.RepoLookupError:
495 except error.RepoLookupError:
496 return False
496 return False
497
497
498 def __nonzero__(self):
498 def __nonzero__(self):
499 return True
499 return True
500
500
501 def __len__(self):
501 def __len__(self):
502 return len(self.changelog)
502 return len(self.changelog)
503
503
504 def __iter__(self):
504 def __iter__(self):
505 return iter(self.changelog)
505 return iter(self.changelog)
506
506
507 def revs(self, expr, *args):
507 def revs(self, expr, *args):
508 '''Return a list of revisions matching the given revset'''
508 '''Return a list of revisions matching the given revset'''
509 expr = revset.formatspec(expr, *args)
509 expr = revset.formatspec(expr, *args)
510 m = revset.match(None, expr)
510 m = revset.match(None, expr)
511 return m(self)
511 return m(self)
512
512
513 def set(self, expr, *args):
513 def set(self, expr, *args):
514 '''
514 '''
515 Yield a context for each matching revision, after doing arg
515 Yield a context for each matching revision, after doing arg
516 replacement via revset.formatspec
516 replacement via revset.formatspec
517 '''
517 '''
518 for r in self.revs(expr, *args):
518 for r in self.revs(expr, *args):
519 yield self[r]
519 yield self[r]
520
520
521 def url(self):
521 def url(self):
522 return 'file:' + self.root
522 return 'file:' + self.root
523
523
524 def hook(self, name, throw=False, **args):
524 def hook(self, name, throw=False, **args):
525 """Call a hook, passing this repo instance.
525 """Call a hook, passing this repo instance.
526
526
527 This a convenience method to aid invoking hooks. Extensions likely
527 This a convenience method to aid invoking hooks. Extensions likely
528 won't call this unless they have registered a custom hook or are
528 won't call this unless they have registered a custom hook or are
529 replacing code that is expected to call a hook.
529 replacing code that is expected to call a hook.
530 """
530 """
531 return hook.hook(self.ui, self, name, throw, **args)
531 return hook.hook(self.ui, self, name, throw, **args)
532
532
533 @unfilteredmethod
533 @unfilteredmethod
534 def _tag(self, names, node, message, local, user, date, extra={},
534 def _tag(self, names, node, message, local, user, date, extra={},
535 editor=False):
535 editor=False):
536 if isinstance(names, str):
536 if isinstance(names, str):
537 names = (names,)
537 names = (names,)
538
538
539 branches = self.branchmap()
539 branches = self.branchmap()
540 for name in names:
540 for name in names:
541 self.hook('pretag', throw=True, node=hex(node), tag=name,
541 self.hook('pretag', throw=True, node=hex(node), tag=name,
542 local=local)
542 local=local)
543 if name in branches:
543 if name in branches:
544 self.ui.warn(_("warning: tag %s conflicts with existing"
544 self.ui.warn(_("warning: tag %s conflicts with existing"
545 " branch name\n") % name)
545 " branch name\n") % name)
546
546
547 def writetags(fp, names, munge, prevtags):
547 def writetags(fp, names, munge, prevtags):
548 fp.seek(0, 2)
548 fp.seek(0, 2)
549 if prevtags and prevtags[-1] != '\n':
549 if prevtags and prevtags[-1] != '\n':
550 fp.write('\n')
550 fp.write('\n')
551 for name in names:
551 for name in names:
552 if munge:
552 if munge:
553 m = munge(name)
553 m = munge(name)
554 else:
554 else:
555 m = name
555 m = name
556
556
557 if (self._tagscache.tagtypes and
557 if (self._tagscache.tagtypes and
558 name in self._tagscache.tagtypes):
558 name in self._tagscache.tagtypes):
559 old = self.tags().get(name, nullid)
559 old = self.tags().get(name, nullid)
560 fp.write('%s %s\n' % (hex(old), m))
560 fp.write('%s %s\n' % (hex(old), m))
561 fp.write('%s %s\n' % (hex(node), m))
561 fp.write('%s %s\n' % (hex(node), m))
562 fp.close()
562 fp.close()
563
563
564 prevtags = ''
564 prevtags = ''
565 if local:
565 if local:
566 try:
566 try:
567 fp = self.vfs('localtags', 'r+')
567 fp = self.vfs('localtags', 'r+')
568 except IOError:
568 except IOError:
569 fp = self.vfs('localtags', 'a')
569 fp = self.vfs('localtags', 'a')
570 else:
570 else:
571 prevtags = fp.read()
571 prevtags = fp.read()
572
572
573 # local tags are stored in the current charset
573 # local tags are stored in the current charset
574 writetags(fp, names, None, prevtags)
574 writetags(fp, names, None, prevtags)
575 for name in names:
575 for name in names:
576 self.hook('tag', node=hex(node), tag=name, local=local)
576 self.hook('tag', node=hex(node), tag=name, local=local)
577 return
577 return
578
578
579 try:
579 try:
580 fp = self.wfile('.hgtags', 'rb+')
580 fp = self.wfile('.hgtags', 'rb+')
581 except IOError, e:
581 except IOError, e:
582 if e.errno != errno.ENOENT:
582 if e.errno != errno.ENOENT:
583 raise
583 raise
584 fp = self.wfile('.hgtags', 'ab')
584 fp = self.wfile('.hgtags', 'ab')
585 else:
585 else:
586 prevtags = fp.read()
586 prevtags = fp.read()
587
587
588 # committed tags are stored in UTF-8
588 # committed tags are stored in UTF-8
589 writetags(fp, names, encoding.fromlocal, prevtags)
589 writetags(fp, names, encoding.fromlocal, prevtags)
590
590
591 fp.close()
591 fp.close()
592
592
593 self.invalidatecaches()
593 self.invalidatecaches()
594
594
595 if '.hgtags' not in self.dirstate:
595 if '.hgtags' not in self.dirstate:
596 self[None].add(['.hgtags'])
596 self[None].add(['.hgtags'])
597
597
598 m = matchmod.exact(self.root, '', ['.hgtags'])
598 m = matchmod.exact(self.root, '', ['.hgtags'])
599 tagnode = self.commit(message, user, date, extra=extra, match=m,
599 tagnode = self.commit(message, user, date, extra=extra, match=m,
600 editor=editor)
600 editor=editor)
601
601
602 for name in names:
602 for name in names:
603 self.hook('tag', node=hex(node), tag=name, local=local)
603 self.hook('tag', node=hex(node), tag=name, local=local)
604
604
605 return tagnode
605 return tagnode
606
606
607 def tag(self, names, node, message, local, user, date, editor=False):
607 def tag(self, names, node, message, local, user, date, editor=False):
608 '''tag a revision with one or more symbolic names.
608 '''tag a revision with one or more symbolic names.
609
609
610 names is a list of strings or, when adding a single tag, names may be a
610 names is a list of strings or, when adding a single tag, names may be a
611 string.
611 string.
612
612
613 if local is True, the tags are stored in a per-repository file.
613 if local is True, the tags are stored in a per-repository file.
614 otherwise, they are stored in the .hgtags file, and a new
614 otherwise, they are stored in the .hgtags file, and a new
615 changeset is committed with the change.
615 changeset is committed with the change.
616
616
617 keyword arguments:
617 keyword arguments:
618
618
619 local: whether to store tags in non-version-controlled file
619 local: whether to store tags in non-version-controlled file
620 (default False)
620 (default False)
621
621
622 message: commit message to use if committing
622 message: commit message to use if committing
623
623
624 user: name of user to use if committing
624 user: name of user to use if committing
625
625
626 date: date tuple to use if committing'''
626 date: date tuple to use if committing'''
627
627
628 if not local:
628 if not local:
629 m = matchmod.exact(self.root, '', ['.hgtags'])
629 m = matchmod.exact(self.root, '', ['.hgtags'])
630 if any(self.status(match=m, unknown=True, ignored=True)):
630 if any(self.status(match=m, unknown=True, ignored=True)):
631 raise util.Abort(_('working copy of .hgtags is changed'),
631 raise util.Abort(_('working copy of .hgtags is changed'),
632 hint=_('please commit .hgtags manually'))
632 hint=_('please commit .hgtags manually'))
633
633
634 self.tags() # instantiate the cache
634 self.tags() # instantiate the cache
635 self._tag(names, node, message, local, user, date, editor=editor)
635 self._tag(names, node, message, local, user, date, editor=editor)
636
636
637 @filteredpropertycache
637 @filteredpropertycache
638 def _tagscache(self):
638 def _tagscache(self):
639 '''Returns a tagscache object that contains various tags related
639 '''Returns a tagscache object that contains various tags related
640 caches.'''
640 caches.'''
641
641
642 # This simplifies its cache management by having one decorated
642 # This simplifies its cache management by having one decorated
643 # function (this one) and the rest simply fetch things from it.
643 # function (this one) and the rest simply fetch things from it.
644 class tagscache(object):
644 class tagscache(object):
645 def __init__(self):
645 def __init__(self):
646 # These two define the set of tags for this repository. tags
646 # These two define the set of tags for this repository. tags
647 # maps tag name to node; tagtypes maps tag name to 'global' or
647 # maps tag name to node; tagtypes maps tag name to 'global' or
648 # 'local'. (Global tags are defined by .hgtags across all
648 # 'local'. (Global tags are defined by .hgtags across all
649 # heads, and local tags are defined in .hg/localtags.)
649 # heads, and local tags are defined in .hg/localtags.)
650 # They constitute the in-memory cache of tags.
650 # They constitute the in-memory cache of tags.
651 self.tags = self.tagtypes = None
651 self.tags = self.tagtypes = None
652
652
653 self.nodetagscache = self.tagslist = None
653 self.nodetagscache = self.tagslist = None
654
654
655 cache = tagscache()
655 cache = tagscache()
656 cache.tags, cache.tagtypes = self._findtags()
656 cache.tags, cache.tagtypes = self._findtags()
657
657
658 return cache
658 return cache
659
659
660 def tags(self):
660 def tags(self):
661 '''return a mapping of tag to node'''
661 '''return a mapping of tag to node'''
662 t = {}
662 t = {}
663 if self.changelog.filteredrevs:
663 if self.changelog.filteredrevs:
664 tags, tt = self._findtags()
664 tags, tt = self._findtags()
665 else:
665 else:
666 tags = self._tagscache.tags
666 tags = self._tagscache.tags
667 for k, v in tags.iteritems():
667 for k, v in tags.iteritems():
668 try:
668 try:
669 # ignore tags to unknown nodes
669 # ignore tags to unknown nodes
670 self.changelog.rev(v)
670 self.changelog.rev(v)
671 t[k] = v
671 t[k] = v
672 except (error.LookupError, ValueError):
672 except (error.LookupError, ValueError):
673 pass
673 pass
674 return t
674 return t
675
675
676 def _findtags(self):
676 def _findtags(self):
677 '''Do the hard work of finding tags. Return a pair of dicts
677 '''Do the hard work of finding tags. Return a pair of dicts
678 (tags, tagtypes) where tags maps tag name to node, and tagtypes
678 (tags, tagtypes) where tags maps tag name to node, and tagtypes
679 maps tag name to a string like \'global\' or \'local\'.
679 maps tag name to a string like \'global\' or \'local\'.
680 Subclasses or extensions are free to add their own tags, but
680 Subclasses or extensions are free to add their own tags, but
681 should be aware that the returned dicts will be retained for the
681 should be aware that the returned dicts will be retained for the
682 duration of the localrepo object.'''
682 duration of the localrepo object.'''
683
683
684 # XXX what tagtype should subclasses/extensions use? Currently
684 # XXX what tagtype should subclasses/extensions use? Currently
685 # mq and bookmarks add tags, but do not set the tagtype at all.
685 # mq and bookmarks add tags, but do not set the tagtype at all.
686 # Should each extension invent its own tag type? Should there
686 # Should each extension invent its own tag type? Should there
687 # be one tagtype for all such "virtual" tags? Or is the status
687 # be one tagtype for all such "virtual" tags? Or is the status
688 # quo fine?
688 # quo fine?
689
689
690 alltags = {} # map tag name to (node, hist)
690 alltags = {} # map tag name to (node, hist)
691 tagtypes = {}
691 tagtypes = {}
692
692
693 tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
693 tagsmod.findglobaltags(self.ui, self, alltags, tagtypes)
694 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
694 tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
695
695
696 # Build the return dicts. Have to re-encode tag names because
696 # Build the return dicts. Have to re-encode tag names because
697 # the tags module always uses UTF-8 (in order not to lose info
697 # the tags module always uses UTF-8 (in order not to lose info
698 # writing to the cache), but the rest of Mercurial wants them in
698 # writing to the cache), but the rest of Mercurial wants them in
699 # local encoding.
699 # local encoding.
700 tags = {}
700 tags = {}
701 for (name, (node, hist)) in alltags.iteritems():
701 for (name, (node, hist)) in alltags.iteritems():
702 if node != nullid:
702 if node != nullid:
703 tags[encoding.tolocal(name)] = node
703 tags[encoding.tolocal(name)] = node
704 tags['tip'] = self.changelog.tip()
704 tags['tip'] = self.changelog.tip()
705 tagtypes = dict([(encoding.tolocal(name), value)
705 tagtypes = dict([(encoding.tolocal(name), value)
706 for (name, value) in tagtypes.iteritems()])
706 for (name, value) in tagtypes.iteritems()])
707 return (tags, tagtypes)
707 return (tags, tagtypes)
708
708
709 def tagtype(self, tagname):
709 def tagtype(self, tagname):
710 '''
710 '''
711 return the type of the given tag. result can be:
711 return the type of the given tag. result can be:
712
712
713 'local' : a local tag
713 'local' : a local tag
714 'global' : a global tag
714 'global' : a global tag
715 None : tag does not exist
715 None : tag does not exist
716 '''
716 '''
717
717
718 return self._tagscache.tagtypes.get(tagname)
718 return self._tagscache.tagtypes.get(tagname)
719
719
720 def tagslist(self):
720 def tagslist(self):
721 '''return a list of tags ordered by revision'''
721 '''return a list of tags ordered by revision'''
722 if not self._tagscache.tagslist:
722 if not self._tagscache.tagslist:
723 l = []
723 l = []
724 for t, n in self.tags().iteritems():
724 for t, n in self.tags().iteritems():
725 l.append((self.changelog.rev(n), t, n))
725 l.append((self.changelog.rev(n), t, n))
726 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
726 self._tagscache.tagslist = [(t, n) for r, t, n in sorted(l)]
727
727
728 return self._tagscache.tagslist
728 return self._tagscache.tagslist
729
729
730 def nodetags(self, node):
730 def nodetags(self, node):
731 '''return the tags associated with a node'''
731 '''return the tags associated with a node'''
732 if not self._tagscache.nodetagscache:
732 if not self._tagscache.nodetagscache:
733 nodetagscache = {}
733 nodetagscache = {}
734 for t, n in self._tagscache.tags.iteritems():
734 for t, n in self._tagscache.tags.iteritems():
735 nodetagscache.setdefault(n, []).append(t)
735 nodetagscache.setdefault(n, []).append(t)
736 for tags in nodetagscache.itervalues():
736 for tags in nodetagscache.itervalues():
737 tags.sort()
737 tags.sort()
738 self._tagscache.nodetagscache = nodetagscache
738 self._tagscache.nodetagscache = nodetagscache
739 return self._tagscache.nodetagscache.get(node, [])
739 return self._tagscache.nodetagscache.get(node, [])
740
740
741 def nodebookmarks(self, node):
741 def nodebookmarks(self, node):
742 marks = []
742 marks = []
743 for bookmark, n in self._bookmarks.iteritems():
743 for bookmark, n in self._bookmarks.iteritems():
744 if n == node:
744 if n == node:
745 marks.append(bookmark)
745 marks.append(bookmark)
746 return sorted(marks)
746 return sorted(marks)
747
747
748 def branchmap(self):
748 def branchmap(self):
749 '''returns a dictionary {branch: [branchheads]} with branchheads
749 '''returns a dictionary {branch: [branchheads]} with branchheads
750 ordered by increasing revision number'''
750 ordered by increasing revision number'''
751 branchmap.updatecache(self)
751 branchmap.updatecache(self)
752 return self._branchcaches[self.filtername]
752 return self._branchcaches[self.filtername]
753
753
754 @unfilteredmethod
754 @unfilteredmethod
755 def revbranchcache(self):
755 def revbranchcache(self):
756 if not self._revbranchcache:
756 if not self._revbranchcache:
757 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
757 self._revbranchcache = branchmap.revbranchcache(self.unfiltered())
758 return self._revbranchcache
758 return self._revbranchcache
759
759
760 def branchtip(self, branch, ignoremissing=False):
760 def branchtip(self, branch, ignoremissing=False):
761 '''return the tip node for a given branch
761 '''return the tip node for a given branch
762
762
763 If ignoremissing is True, then this method will not raise an error.
763 If ignoremissing is True, then this method will not raise an error.
764 This is helpful for callers that only expect None for a missing branch
764 This is helpful for callers that only expect None for a missing branch
765 (e.g. namespace).
765 (e.g. namespace).
766
766
767 '''
767 '''
768 try:
768 try:
769 return self.branchmap().branchtip(branch)
769 return self.branchmap().branchtip(branch)
770 except KeyError:
770 except KeyError:
771 if not ignoremissing:
771 if not ignoremissing:
772 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
772 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
773 else:
773 else:
774 pass
774 pass
775
775
776 def lookup(self, key):
776 def lookup(self, key):
777 return self[key].node()
777 return self[key].node()
778
778
779 def lookupbranch(self, key, remote=None):
779 def lookupbranch(self, key, remote=None):
780 repo = remote or self
780 repo = remote or self
781 if key in repo.branchmap():
781 if key in repo.branchmap():
782 return key
782 return key
783
783
784 repo = (remote and remote.local()) and remote or self
784 repo = (remote and remote.local()) and remote or self
785 return repo[key].branch()
785 return repo[key].branch()
786
786
787 def known(self, nodes):
787 def known(self, nodes):
788 nm = self.changelog.nodemap
788 nm = self.changelog.nodemap
789 pc = self._phasecache
789 pc = self._phasecache
790 result = []
790 result = []
791 for n in nodes:
791 for n in nodes:
792 r = nm.get(n)
792 r = nm.get(n)
793 resp = not (r is None or pc.phase(self, r) >= phases.secret)
793 resp = not (r is None or pc.phase(self, r) >= phases.secret)
794 result.append(resp)
794 result.append(resp)
795 return result
795 return result
796
796
797 def local(self):
797 def local(self):
798 return self
798 return self
799
799
800 def cancopy(self):
800 def cancopy(self):
801 # so statichttprepo's override of local() works
801 # so statichttprepo's override of local() works
802 if not self.local():
802 if not self.local():
803 return False
803 return False
804 if not self.ui.configbool('phases', 'publish', True):
804 if not self.ui.configbool('phases', 'publish', True):
805 return True
805 return True
806 # if publishing we can't copy if there is filtered content
806 # if publishing we can't copy if there is filtered content
807 return not self.filtered('visible').changelog.filteredrevs
807 return not self.filtered('visible').changelog.filteredrevs
808
808
809 def shared(self):
809 def shared(self):
810 '''the type of shared repository (None if not shared)'''
810 '''the type of shared repository (None if not shared)'''
811 if self.sharedpath != self.path:
811 if self.sharedpath != self.path:
812 return 'store'
812 return 'store'
813 return None
813 return None
814
814
815 def join(self, f, *insidef):
815 def join(self, f, *insidef):
816 return self.vfs.join(os.path.join(f, *insidef))
816 return self.vfs.join(os.path.join(f, *insidef))
817
817
818 def wjoin(self, f, *insidef):
818 def wjoin(self, f, *insidef):
819 return self.vfs.reljoin(self.root, f, *insidef)
819 return self.vfs.reljoin(self.root, f, *insidef)
820
820
821 def file(self, f):
821 def file(self, f):
822 if f[0] == '/':
822 if f[0] == '/':
823 f = f[1:]
823 f = f[1:]
824 return filelog.filelog(self.svfs, f)
824 return filelog.filelog(self.svfs, f)
825
825
826 def changectx(self, changeid):
826 def changectx(self, changeid):
827 return self[changeid]
827 return self[changeid]
828
828
829 def parents(self, changeid=None):
829 def parents(self, changeid=None):
830 '''get list of changectxs for parents of changeid'''
830 '''get list of changectxs for parents of changeid'''
831 return self[changeid].parents()
831 return self[changeid].parents()
832
832
833 def setparents(self, p1, p2=nullid):
833 def setparents(self, p1, p2=nullid):
834 self.dirstate.beginparentchange()
834 self.dirstate.beginparentchange()
835 copies = self.dirstate.setparents(p1, p2)
835 copies = self.dirstate.setparents(p1, p2)
836 pctx = self[p1]
836 pctx = self[p1]
837 if copies:
837 if copies:
838 # Adjust copy records, the dirstate cannot do it, it
838 # Adjust copy records, the dirstate cannot do it, it
839 # requires access to parents manifests. Preserve them
839 # requires access to parents manifests. Preserve them
840 # only for entries added to first parent.
840 # only for entries added to first parent.
841 for f in copies:
841 for f in copies:
842 if f not in pctx and copies[f] in pctx:
842 if f not in pctx and copies[f] in pctx:
843 self.dirstate.copy(copies[f], f)
843 self.dirstate.copy(copies[f], f)
844 if p2 == nullid:
844 if p2 == nullid:
845 for f, s in sorted(self.dirstate.copies().items()):
845 for f, s in sorted(self.dirstate.copies().items()):
846 if f not in pctx and s not in pctx:
846 if f not in pctx and s not in pctx:
847 self.dirstate.copy(None, f)
847 self.dirstate.copy(None, f)
848 self.dirstate.endparentchange()
848 self.dirstate.endparentchange()
849
849
850 def filectx(self, path, changeid=None, fileid=None):
850 def filectx(self, path, changeid=None, fileid=None):
851 """changeid can be a changeset revision, node, or tag.
851 """changeid can be a changeset revision, node, or tag.
852 fileid can be a file revision or node."""
852 fileid can be a file revision or node."""
853 return context.filectx(self, path, changeid, fileid)
853 return context.filectx(self, path, changeid, fileid)
854
854
855 def getcwd(self):
855 def getcwd(self):
856 return self.dirstate.getcwd()
856 return self.dirstate.getcwd()
857
857
858 def pathto(self, f, cwd=None):
858 def pathto(self, f, cwd=None):
859 return self.dirstate.pathto(f, cwd)
859 return self.dirstate.pathto(f, cwd)
860
860
861 def wfile(self, f, mode='r'):
861 def wfile(self, f, mode='r'):
862 return self.wvfs(f, mode)
862 return self.wvfs(f, mode)
863
863
864 def _link(self, f):
864 def _link(self, f):
865 return self.wvfs.islink(f)
865 return self.wvfs.islink(f)
866
866
867 def _loadfilter(self, filter):
867 def _loadfilter(self, filter):
868 if filter not in self.filterpats:
868 if filter not in self.filterpats:
869 l = []
869 l = []
870 for pat, cmd in self.ui.configitems(filter):
870 for pat, cmd in self.ui.configitems(filter):
871 if cmd == '!':
871 if cmd == '!':
872 continue
872 continue
873 mf = matchmod.match(self.root, '', [pat])
873 mf = matchmod.match(self.root, '', [pat])
874 fn = None
874 fn = None
875 params = cmd
875 params = cmd
876 for name, filterfn in self._datafilters.iteritems():
876 for name, filterfn in self._datafilters.iteritems():
877 if cmd.startswith(name):
877 if cmd.startswith(name):
878 fn = filterfn
878 fn = filterfn
879 params = cmd[len(name):].lstrip()
879 params = cmd[len(name):].lstrip()
880 break
880 break
881 if not fn:
881 if not fn:
882 fn = lambda s, c, **kwargs: util.filter(s, c)
882 fn = lambda s, c, **kwargs: util.filter(s, c)
883 # Wrap old filters not supporting keyword arguments
883 # Wrap old filters not supporting keyword arguments
884 if not inspect.getargspec(fn)[2]:
884 if not inspect.getargspec(fn)[2]:
885 oldfn = fn
885 oldfn = fn
886 fn = lambda s, c, **kwargs: oldfn(s, c)
886 fn = lambda s, c, **kwargs: oldfn(s, c)
887 l.append((mf, fn, params))
887 l.append((mf, fn, params))
888 self.filterpats[filter] = l
888 self.filterpats[filter] = l
889 return self.filterpats[filter]
889 return self.filterpats[filter]
890
890
891 def _filter(self, filterpats, filename, data):
891 def _filter(self, filterpats, filename, data):
892 for mf, fn, cmd in filterpats:
892 for mf, fn, cmd in filterpats:
893 if mf(filename):
893 if mf(filename):
894 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
894 self.ui.debug("filtering %s through %s\n" % (filename, cmd))
895 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
895 data = fn(data, cmd, ui=self.ui, repo=self, filename=filename)
896 break
896 break
897
897
898 return data
898 return data
899
899
900 @unfilteredpropertycache
900 @unfilteredpropertycache
901 def _encodefilterpats(self):
901 def _encodefilterpats(self):
902 return self._loadfilter('encode')
902 return self._loadfilter('encode')
903
903
904 @unfilteredpropertycache
904 @unfilteredpropertycache
905 def _decodefilterpats(self):
905 def _decodefilterpats(self):
906 return self._loadfilter('decode')
906 return self._loadfilter('decode')
907
907
908 def adddatafilter(self, name, filter):
908 def adddatafilter(self, name, filter):
909 self._datafilters[name] = filter
909 self._datafilters[name] = filter
910
910
911 def wread(self, filename):
911 def wread(self, filename):
912 if self._link(filename):
912 if self._link(filename):
913 data = self.wvfs.readlink(filename)
913 data = self.wvfs.readlink(filename)
914 else:
914 else:
915 data = self.wvfs.read(filename)
915 data = self.wvfs.read(filename)
916 return self._filter(self._encodefilterpats, filename, data)
916 return self._filter(self._encodefilterpats, filename, data)
917
917
918 def wwrite(self, filename, data, flags):
918 def wwrite(self, filename, data, flags):
919 """write ``data`` into ``filename`` in the working directory
919 """write ``data`` into ``filename`` in the working directory
920
920
921 This returns length of written (maybe decoded) data.
921 This returns length of written (maybe decoded) data.
922 """
922 """
923 data = self._filter(self._decodefilterpats, filename, data)
923 data = self._filter(self._decodefilterpats, filename, data)
924 if 'l' in flags:
924 if 'l' in flags:
925 self.wvfs.symlink(data, filename)
925 self.wvfs.symlink(data, filename)
926 else:
926 else:
927 self.wvfs.write(filename, data)
927 self.wvfs.write(filename, data)
928 if 'x' in flags:
928 if 'x' in flags:
929 self.wvfs.setflags(filename, False, True)
929 self.wvfs.setflags(filename, False, True)
930 return len(data)
930 return len(data)
931
931
932 def wwritedata(self, filename, data):
932 def wwritedata(self, filename, data):
933 return self._filter(self._decodefilterpats, filename, data)
933 return self._filter(self._decodefilterpats, filename, data)
934
934
935 def currenttransaction(self):
935 def currenttransaction(self):
936 """return the current transaction or None if non exists"""
936 """return the current transaction or None if non exists"""
937 if self._transref:
937 if self._transref:
938 tr = self._transref()
938 tr = self._transref()
939 else:
939 else:
940 tr = None
940 tr = None
941
941
942 if tr and tr.running():
942 if tr and tr.running():
943 return tr
943 return tr
944 return None
944 return None
945
945
946 def transaction(self, desc, report=None):
946 def transaction(self, desc, report=None):
947 if (self.ui.configbool('devel', 'all')
947 if (self.ui.configbool('devel', 'all')
948 or self.ui.configbool('devel', 'check-locks')):
948 or self.ui.configbool('devel', 'check-locks')):
949 l = self._lockref and self._lockref()
949 l = self._lockref and self._lockref()
950 if l is None or not l.held:
950 if l is None or not l.held:
951 scmutil.develwarn(self.ui, 'transaction with no lock')
951 scmutil.develwarn(self.ui, 'transaction with no lock')
952 tr = self.currenttransaction()
952 tr = self.currenttransaction()
953 if tr is not None:
953 if tr is not None:
954 return tr.nest()
954 return tr.nest()
955
955
956 # abort here if the journal already exists
956 # abort here if the journal already exists
957 if self.svfs.exists("journal"):
957 if self.svfs.exists("journal"):
958 raise error.RepoError(
958 raise error.RepoError(
959 _("abandoned transaction found"),
959 _("abandoned transaction found"),
960 hint=_("run 'hg recover' to clean up transaction"))
960 hint=_("run 'hg recover' to clean up transaction"))
961
961
962 self.hook('pretxnopen', throw=True, txnname=desc)
962 idbase = "%.40f#%f" % (random.random(), time.time())
963 txnid = 'TXN:' + util.sha1(idbase).hexdigest()
964 self.hook('pretxnopen', throw=True, txnname=desc, txnid=txnid)
963
965
964 self._writejournal(desc)
966 self._writejournal(desc)
965 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
967 renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
966 if report:
968 if report:
967 rp = report
969 rp = report
968 else:
970 else:
969 rp = self.ui.warn
971 rp = self.ui.warn
970 vfsmap = {'plain': self.vfs} # root of .hg/
972 vfsmap = {'plain': self.vfs} # root of .hg/
971 # we must avoid cyclic reference between repo and transaction.
973 # we must avoid cyclic reference between repo and transaction.
972 reporef = weakref.ref(self)
974 reporef = weakref.ref(self)
973 def validate(tr):
975 def validate(tr):
974 """will run pre-closing hooks"""
976 """will run pre-closing hooks"""
975 pending = lambda: tr.writepending() and self.root or ""
977 pending = lambda: tr.writepending() and self.root or ""
976 reporef().hook('pretxnclose', throw=True, pending=pending,
978 reporef().hook('pretxnclose', throw=True, pending=pending,
977 txnname=desc, **tr.hookargs)
979 txnname=desc, **tr.hookargs)
978
980
979 tr = transaction.transaction(rp, self.sopener, vfsmap,
981 tr = transaction.transaction(rp, self.sopener, vfsmap,
980 "journal",
982 "journal",
981 "undo",
983 "undo",
982 aftertrans(renames),
984 aftertrans(renames),
983 self.store.createmode,
985 self.store.createmode,
984 validator=validate)
986 validator=validate)
985
987
986 trid = 'TXN:' + util.sha1("%s#%f" % (id(tr), time.time())).hexdigest()
988 tr.hookargs['txnid'] = txnid
987 tr.hookargs['txnid'] = trid
988 # note: writing the fncache only during finalize mean that the file is
989 # note: writing the fncache only during finalize mean that the file is
989 # outdated when running hooks. As fncache is used for streaming clone,
990 # outdated when running hooks. As fncache is used for streaming clone,
990 # this is not expected to break anything that happen during the hooks.
991 # this is not expected to break anything that happen during the hooks.
991 tr.addfinalize('flush-fncache', self.store.write)
992 tr.addfinalize('flush-fncache', self.store.write)
992 def txnclosehook(tr2):
993 def txnclosehook(tr2):
993 """To be run if transaction is successful, will schedule a hook run
994 """To be run if transaction is successful, will schedule a hook run
994 """
995 """
995 def hook():
996 def hook():
996 reporef().hook('txnclose', throw=False, txnname=desc,
997 reporef().hook('txnclose', throw=False, txnname=desc,
997 **tr2.hookargs)
998 **tr2.hookargs)
998 reporef()._afterlock(hook)
999 reporef()._afterlock(hook)
999 tr.addfinalize('txnclose-hook', txnclosehook)
1000 tr.addfinalize('txnclose-hook', txnclosehook)
1000 def txnaborthook(tr2):
1001 def txnaborthook(tr2):
1001 """To be run if transaction is aborted
1002 """To be run if transaction is aborted
1002 """
1003 """
1003 reporef().hook('txnabort', throw=False, txnname=desc,
1004 reporef().hook('txnabort', throw=False, txnname=desc,
1004 **tr2.hookargs)
1005 **tr2.hookargs)
1005 tr.addabort('txnabort-hook', txnaborthook)
1006 tr.addabort('txnabort-hook', txnaborthook)
1006 self._transref = weakref.ref(tr)
1007 self._transref = weakref.ref(tr)
1007 return tr
1008 return tr
1008
1009
1009 def _journalfiles(self):
1010 def _journalfiles(self):
1010 return ((self.svfs, 'journal'),
1011 return ((self.svfs, 'journal'),
1011 (self.vfs, 'journal.dirstate'),
1012 (self.vfs, 'journal.dirstate'),
1012 (self.vfs, 'journal.branch'),
1013 (self.vfs, 'journal.branch'),
1013 (self.vfs, 'journal.desc'),
1014 (self.vfs, 'journal.desc'),
1014 (self.vfs, 'journal.bookmarks'),
1015 (self.vfs, 'journal.bookmarks'),
1015 (self.svfs, 'journal.phaseroots'))
1016 (self.svfs, 'journal.phaseroots'))
1016
1017
1017 def undofiles(self):
1018 def undofiles(self):
1018 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1019 return [(vfs, undoname(x)) for vfs, x in self._journalfiles()]
1019
1020
1020 def _writejournal(self, desc):
1021 def _writejournal(self, desc):
1021 self.vfs.write("journal.dirstate",
1022 self.vfs.write("journal.dirstate",
1022 self.vfs.tryread("dirstate"))
1023 self.vfs.tryread("dirstate"))
1023 self.vfs.write("journal.branch",
1024 self.vfs.write("journal.branch",
1024 encoding.fromlocal(self.dirstate.branch()))
1025 encoding.fromlocal(self.dirstate.branch()))
1025 self.vfs.write("journal.desc",
1026 self.vfs.write("journal.desc",
1026 "%d\n%s\n" % (len(self), desc))
1027 "%d\n%s\n" % (len(self), desc))
1027 self.vfs.write("journal.bookmarks",
1028 self.vfs.write("journal.bookmarks",
1028 self.vfs.tryread("bookmarks"))
1029 self.vfs.tryread("bookmarks"))
1029 self.svfs.write("journal.phaseroots",
1030 self.svfs.write("journal.phaseroots",
1030 self.svfs.tryread("phaseroots"))
1031 self.svfs.tryread("phaseroots"))
1031
1032
1032 def recover(self):
1033 def recover(self):
1033 lock = self.lock()
1034 lock = self.lock()
1034 try:
1035 try:
1035 if self.svfs.exists("journal"):
1036 if self.svfs.exists("journal"):
1036 self.ui.status(_("rolling back interrupted transaction\n"))
1037 self.ui.status(_("rolling back interrupted transaction\n"))
1037 vfsmap = {'': self.svfs,
1038 vfsmap = {'': self.svfs,
1038 'plain': self.vfs,}
1039 'plain': self.vfs,}
1039 transaction.rollback(self.svfs, vfsmap, "journal",
1040 transaction.rollback(self.svfs, vfsmap, "journal",
1040 self.ui.warn)
1041 self.ui.warn)
1041 self.invalidate()
1042 self.invalidate()
1042 return True
1043 return True
1043 else:
1044 else:
1044 self.ui.warn(_("no interrupted transaction available\n"))
1045 self.ui.warn(_("no interrupted transaction available\n"))
1045 return False
1046 return False
1046 finally:
1047 finally:
1047 lock.release()
1048 lock.release()
1048
1049
1049 def rollback(self, dryrun=False, force=False):
1050 def rollback(self, dryrun=False, force=False):
1050 wlock = lock = None
1051 wlock = lock = None
1051 try:
1052 try:
1052 wlock = self.wlock()
1053 wlock = self.wlock()
1053 lock = self.lock()
1054 lock = self.lock()
1054 if self.svfs.exists("undo"):
1055 if self.svfs.exists("undo"):
1055 return self._rollback(dryrun, force)
1056 return self._rollback(dryrun, force)
1056 else:
1057 else:
1057 self.ui.warn(_("no rollback information available\n"))
1058 self.ui.warn(_("no rollback information available\n"))
1058 return 1
1059 return 1
1059 finally:
1060 finally:
1060 release(lock, wlock)
1061 release(lock, wlock)
1061
1062
1062 @unfilteredmethod # Until we get smarter cache management
1063 @unfilteredmethod # Until we get smarter cache management
1063 def _rollback(self, dryrun, force):
1064 def _rollback(self, dryrun, force):
1064 ui = self.ui
1065 ui = self.ui
1065 try:
1066 try:
1066 args = self.vfs.read('undo.desc').splitlines()
1067 args = self.vfs.read('undo.desc').splitlines()
1067 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1068 (oldlen, desc, detail) = (int(args[0]), args[1], None)
1068 if len(args) >= 3:
1069 if len(args) >= 3:
1069 detail = args[2]
1070 detail = args[2]
1070 oldtip = oldlen - 1
1071 oldtip = oldlen - 1
1071
1072
1072 if detail and ui.verbose:
1073 if detail and ui.verbose:
1073 msg = (_('repository tip rolled back to revision %s'
1074 msg = (_('repository tip rolled back to revision %s'
1074 ' (undo %s: %s)\n')
1075 ' (undo %s: %s)\n')
1075 % (oldtip, desc, detail))
1076 % (oldtip, desc, detail))
1076 else:
1077 else:
1077 msg = (_('repository tip rolled back to revision %s'
1078 msg = (_('repository tip rolled back to revision %s'
1078 ' (undo %s)\n')
1079 ' (undo %s)\n')
1079 % (oldtip, desc))
1080 % (oldtip, desc))
1080 except IOError:
1081 except IOError:
1081 msg = _('rolling back unknown transaction\n')
1082 msg = _('rolling back unknown transaction\n')
1082 desc = None
1083 desc = None
1083
1084
1084 if not force and self['.'] != self['tip'] and desc == 'commit':
1085 if not force and self['.'] != self['tip'] and desc == 'commit':
1085 raise util.Abort(
1086 raise util.Abort(
1086 _('rollback of last commit while not checked out '
1087 _('rollback of last commit while not checked out '
1087 'may lose data'), hint=_('use -f to force'))
1088 'may lose data'), hint=_('use -f to force'))
1088
1089
1089 ui.status(msg)
1090 ui.status(msg)
1090 if dryrun:
1091 if dryrun:
1091 return 0
1092 return 0
1092
1093
1093 parents = self.dirstate.parents()
1094 parents = self.dirstate.parents()
1094 self.destroying()
1095 self.destroying()
1095 vfsmap = {'plain': self.vfs, '': self.svfs}
1096 vfsmap = {'plain': self.vfs, '': self.svfs}
1096 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn)
1097 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn)
1097 if self.vfs.exists('undo.bookmarks'):
1098 if self.vfs.exists('undo.bookmarks'):
1098 self.vfs.rename('undo.bookmarks', 'bookmarks')
1099 self.vfs.rename('undo.bookmarks', 'bookmarks')
1099 if self.svfs.exists('undo.phaseroots'):
1100 if self.svfs.exists('undo.phaseroots'):
1100 self.svfs.rename('undo.phaseroots', 'phaseroots')
1101 self.svfs.rename('undo.phaseroots', 'phaseroots')
1101 self.invalidate()
1102 self.invalidate()
1102
1103
1103 parentgone = (parents[0] not in self.changelog.nodemap or
1104 parentgone = (parents[0] not in self.changelog.nodemap or
1104 parents[1] not in self.changelog.nodemap)
1105 parents[1] not in self.changelog.nodemap)
1105 if parentgone:
1106 if parentgone:
1106 self.vfs.rename('undo.dirstate', 'dirstate')
1107 self.vfs.rename('undo.dirstate', 'dirstate')
1107 try:
1108 try:
1108 branch = self.vfs.read('undo.branch')
1109 branch = self.vfs.read('undo.branch')
1109 self.dirstate.setbranch(encoding.tolocal(branch))
1110 self.dirstate.setbranch(encoding.tolocal(branch))
1110 except IOError:
1111 except IOError:
1111 ui.warn(_('named branch could not be reset: '
1112 ui.warn(_('named branch could not be reset: '
1112 'current branch is still \'%s\'\n')
1113 'current branch is still \'%s\'\n')
1113 % self.dirstate.branch())
1114 % self.dirstate.branch())
1114
1115
1115 self.dirstate.invalidate()
1116 self.dirstate.invalidate()
1116 parents = tuple([p.rev() for p in self.parents()])
1117 parents = tuple([p.rev() for p in self.parents()])
1117 if len(parents) > 1:
1118 if len(parents) > 1:
1118 ui.status(_('working directory now based on '
1119 ui.status(_('working directory now based on '
1119 'revisions %d and %d\n') % parents)
1120 'revisions %d and %d\n') % parents)
1120 else:
1121 else:
1121 ui.status(_('working directory now based on '
1122 ui.status(_('working directory now based on '
1122 'revision %d\n') % parents)
1123 'revision %d\n') % parents)
1123 ms = mergemod.mergestate(self)
1124 ms = mergemod.mergestate(self)
1124 ms.reset(self['.'].node())
1125 ms.reset(self['.'].node())
1125
1126
1126 # TODO: if we know which new heads may result from this rollback, pass
1127 # TODO: if we know which new heads may result from this rollback, pass
1127 # them to destroy(), which will prevent the branchhead cache from being
1128 # them to destroy(), which will prevent the branchhead cache from being
1128 # invalidated.
1129 # invalidated.
1129 self.destroyed()
1130 self.destroyed()
1130 return 0
1131 return 0
1131
1132
1132 def invalidatecaches(self):
1133 def invalidatecaches(self):
1133
1134
1134 if '_tagscache' in vars(self):
1135 if '_tagscache' in vars(self):
1135 # can't use delattr on proxy
1136 # can't use delattr on proxy
1136 del self.__dict__['_tagscache']
1137 del self.__dict__['_tagscache']
1137
1138
1138 self.unfiltered()._branchcaches.clear()
1139 self.unfiltered()._branchcaches.clear()
1139 self.invalidatevolatilesets()
1140 self.invalidatevolatilesets()
1140
1141
1141 def invalidatevolatilesets(self):
1142 def invalidatevolatilesets(self):
1142 self.filteredrevcache.clear()
1143 self.filteredrevcache.clear()
1143 obsolete.clearobscaches(self)
1144 obsolete.clearobscaches(self)
1144
1145
1145 def invalidatedirstate(self):
1146 def invalidatedirstate(self):
1146 '''Invalidates the dirstate, causing the next call to dirstate
1147 '''Invalidates the dirstate, causing the next call to dirstate
1147 to check if it was modified since the last time it was read,
1148 to check if it was modified since the last time it was read,
1148 rereading it if it has.
1149 rereading it if it has.
1149
1150
1150 This is different to dirstate.invalidate() that it doesn't always
1151 This is different to dirstate.invalidate() that it doesn't always
1151 rereads the dirstate. Use dirstate.invalidate() if you want to
1152 rereads the dirstate. Use dirstate.invalidate() if you want to
1152 explicitly read the dirstate again (i.e. restoring it to a previous
1153 explicitly read the dirstate again (i.e. restoring it to a previous
1153 known good state).'''
1154 known good state).'''
1154 if hasunfilteredcache(self, 'dirstate'):
1155 if hasunfilteredcache(self, 'dirstate'):
1155 for k in self.dirstate._filecache:
1156 for k in self.dirstate._filecache:
1156 try:
1157 try:
1157 delattr(self.dirstate, k)
1158 delattr(self.dirstate, k)
1158 except AttributeError:
1159 except AttributeError:
1159 pass
1160 pass
1160 delattr(self.unfiltered(), 'dirstate')
1161 delattr(self.unfiltered(), 'dirstate')
1161
1162
1162 def invalidate(self):
1163 def invalidate(self):
1163 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1164 unfiltered = self.unfiltered() # all file caches are stored unfiltered
1164 for k in self._filecache:
1165 for k in self._filecache:
1165 # dirstate is invalidated separately in invalidatedirstate()
1166 # dirstate is invalidated separately in invalidatedirstate()
1166 if k == 'dirstate':
1167 if k == 'dirstate':
1167 continue
1168 continue
1168
1169
1169 try:
1170 try:
1170 delattr(unfiltered, k)
1171 delattr(unfiltered, k)
1171 except AttributeError:
1172 except AttributeError:
1172 pass
1173 pass
1173 self.invalidatecaches()
1174 self.invalidatecaches()
1174 self.store.invalidatecaches()
1175 self.store.invalidatecaches()
1175
1176
1176 def invalidateall(self):
1177 def invalidateall(self):
1177 '''Fully invalidates both store and non-store parts, causing the
1178 '''Fully invalidates both store and non-store parts, causing the
1178 subsequent operation to reread any outside changes.'''
1179 subsequent operation to reread any outside changes.'''
1179 # extension should hook this to invalidate its caches
1180 # extension should hook this to invalidate its caches
1180 self.invalidate()
1181 self.invalidate()
1181 self.invalidatedirstate()
1182 self.invalidatedirstate()
1182
1183
1183 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
1184 def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
1184 try:
1185 try:
1185 l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc)
1186 l = lockmod.lock(vfs, lockname, 0, releasefn, desc=desc)
1186 except error.LockHeld, inst:
1187 except error.LockHeld, inst:
1187 if not wait:
1188 if not wait:
1188 raise
1189 raise
1189 self.ui.warn(_("waiting for lock on %s held by %r\n") %
1190 self.ui.warn(_("waiting for lock on %s held by %r\n") %
1190 (desc, inst.locker))
1191 (desc, inst.locker))
1191 # default to 600 seconds timeout
1192 # default to 600 seconds timeout
1192 l = lockmod.lock(vfs, lockname,
1193 l = lockmod.lock(vfs, lockname,
1193 int(self.ui.config("ui", "timeout", "600")),
1194 int(self.ui.config("ui", "timeout", "600")),
1194 releasefn, desc=desc)
1195 releasefn, desc=desc)
1195 self.ui.warn(_("got lock after %s seconds\n") % l.delay)
1196 self.ui.warn(_("got lock after %s seconds\n") % l.delay)
1196 if acquirefn:
1197 if acquirefn:
1197 acquirefn()
1198 acquirefn()
1198 return l
1199 return l
1199
1200
1200 def _afterlock(self, callback):
1201 def _afterlock(self, callback):
1201 """add a callback to be run when the repository is fully unlocked
1202 """add a callback to be run when the repository is fully unlocked
1202
1203
1203 The callback will be executed when the outermost lock is released
1204 The callback will be executed when the outermost lock is released
1204 (with wlock being higher level than 'lock')."""
1205 (with wlock being higher level than 'lock')."""
1205 for ref in (self._wlockref, self._lockref):
1206 for ref in (self._wlockref, self._lockref):
1206 l = ref and ref()
1207 l = ref and ref()
1207 if l and l.held:
1208 if l and l.held:
1208 l.postrelease.append(callback)
1209 l.postrelease.append(callback)
1209 break
1210 break
1210 else: # no lock have been found.
1211 else: # no lock have been found.
1211 callback()
1212 callback()
1212
1213
1213 def lock(self, wait=True):
1214 def lock(self, wait=True):
1214 '''Lock the repository store (.hg/store) and return a weak reference
1215 '''Lock the repository store (.hg/store) and return a weak reference
1215 to the lock. Use this before modifying the store (e.g. committing or
1216 to the lock. Use this before modifying the store (e.g. committing or
1216 stripping). If you are opening a transaction, get a lock as well.)
1217 stripping). If you are opening a transaction, get a lock as well.)
1217
1218
1218 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1219 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1219 'wlock' first to avoid a dead-lock hazard.'''
1220 'wlock' first to avoid a dead-lock hazard.'''
1220 l = self._lockref and self._lockref()
1221 l = self._lockref and self._lockref()
1221 if l is not None and l.held:
1222 if l is not None and l.held:
1222 l.lock()
1223 l.lock()
1223 return l
1224 return l
1224
1225
1225 def unlock():
1226 def unlock():
1226 for k, ce in self._filecache.items():
1227 for k, ce in self._filecache.items():
1227 if k == 'dirstate' or k not in self.__dict__:
1228 if k == 'dirstate' or k not in self.__dict__:
1228 continue
1229 continue
1229 ce.refresh()
1230 ce.refresh()
1230
1231
1231 l = self._lock(self.svfs, "lock", wait, unlock,
1232 l = self._lock(self.svfs, "lock", wait, unlock,
1232 self.invalidate, _('repository %s') % self.origroot)
1233 self.invalidate, _('repository %s') % self.origroot)
1233 self._lockref = weakref.ref(l)
1234 self._lockref = weakref.ref(l)
1234 return l
1235 return l
1235
1236
1236 def wlock(self, wait=True):
1237 def wlock(self, wait=True):
1237 '''Lock the non-store parts of the repository (everything under
1238 '''Lock the non-store parts of the repository (everything under
1238 .hg except .hg/store) and return a weak reference to the lock.
1239 .hg except .hg/store) and return a weak reference to the lock.
1239
1240
1240 Use this before modifying files in .hg.
1241 Use this before modifying files in .hg.
1241
1242
1242 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1243 If both 'lock' and 'wlock' must be acquired, ensure you always acquires
1243 'wlock' first to avoid a dead-lock hazard.'''
1244 'wlock' first to avoid a dead-lock hazard.'''
1244 l = self._wlockref and self._wlockref()
1245 l = self._wlockref and self._wlockref()
1245 if l is not None and l.held:
1246 if l is not None and l.held:
1246 l.lock()
1247 l.lock()
1247 return l
1248 return l
1248
1249
1249 # We do not need to check for non-waiting lock aquisition. Such
1250 # We do not need to check for non-waiting lock aquisition. Such
1250 # acquisition would not cause dead-lock as they would just fail.
1251 # acquisition would not cause dead-lock as they would just fail.
1251 if wait and (self.ui.configbool('devel', 'all')
1252 if wait and (self.ui.configbool('devel', 'all')
1252 or self.ui.configbool('devel', 'check-locks')):
1253 or self.ui.configbool('devel', 'check-locks')):
1253 l = self._lockref and self._lockref()
1254 l = self._lockref and self._lockref()
1254 if l is not None and l.held:
1255 if l is not None and l.held:
1255 scmutil.develwarn(self.ui, '"wlock" acquired after "lock"')
1256 scmutil.develwarn(self.ui, '"wlock" acquired after "lock"')
1256
1257
1257 def unlock():
1258 def unlock():
1258 if self.dirstate.pendingparentchange():
1259 if self.dirstate.pendingparentchange():
1259 self.dirstate.invalidate()
1260 self.dirstate.invalidate()
1260 else:
1261 else:
1261 self.dirstate.write()
1262 self.dirstate.write()
1262
1263
1263 self._filecache['dirstate'].refresh()
1264 self._filecache['dirstate'].refresh()
1264
1265
1265 l = self._lock(self.vfs, "wlock", wait, unlock,
1266 l = self._lock(self.vfs, "wlock", wait, unlock,
1266 self.invalidatedirstate, _('working directory of %s') %
1267 self.invalidatedirstate, _('working directory of %s') %
1267 self.origroot)
1268 self.origroot)
1268 self._wlockref = weakref.ref(l)
1269 self._wlockref = weakref.ref(l)
1269 return l
1270 return l
1270
1271
1271 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1272 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist):
1272 """
1273 """
1273 commit an individual file as part of a larger transaction
1274 commit an individual file as part of a larger transaction
1274 """
1275 """
1275
1276
1276 fname = fctx.path()
1277 fname = fctx.path()
1277 fparent1 = manifest1.get(fname, nullid)
1278 fparent1 = manifest1.get(fname, nullid)
1278 fparent2 = manifest2.get(fname, nullid)
1279 fparent2 = manifest2.get(fname, nullid)
1279 if isinstance(fctx, context.filectx):
1280 if isinstance(fctx, context.filectx):
1280 node = fctx.filenode()
1281 node = fctx.filenode()
1281 if node in [fparent1, fparent2]:
1282 if node in [fparent1, fparent2]:
1282 self.ui.debug('reusing %s filelog entry\n' % fname)
1283 self.ui.debug('reusing %s filelog entry\n' % fname)
1283 return node
1284 return node
1284
1285
1285 flog = self.file(fname)
1286 flog = self.file(fname)
1286 meta = {}
1287 meta = {}
1287 copy = fctx.renamed()
1288 copy = fctx.renamed()
1288 if copy and copy[0] != fname:
1289 if copy and copy[0] != fname:
1289 # Mark the new revision of this file as a copy of another
1290 # Mark the new revision of this file as a copy of another
1290 # file. This copy data will effectively act as a parent
1291 # file. This copy data will effectively act as a parent
1291 # of this new revision. If this is a merge, the first
1292 # of this new revision. If this is a merge, the first
1292 # parent will be the nullid (meaning "look up the copy data")
1293 # parent will be the nullid (meaning "look up the copy data")
1293 # and the second one will be the other parent. For example:
1294 # and the second one will be the other parent. For example:
1294 #
1295 #
1295 # 0 --- 1 --- 3 rev1 changes file foo
1296 # 0 --- 1 --- 3 rev1 changes file foo
1296 # \ / rev2 renames foo to bar and changes it
1297 # \ / rev2 renames foo to bar and changes it
1297 # \- 2 -/ rev3 should have bar with all changes and
1298 # \- 2 -/ rev3 should have bar with all changes and
1298 # should record that bar descends from
1299 # should record that bar descends from
1299 # bar in rev2 and foo in rev1
1300 # bar in rev2 and foo in rev1
1300 #
1301 #
1301 # this allows this merge to succeed:
1302 # this allows this merge to succeed:
1302 #
1303 #
1303 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1304 # 0 --- 1 --- 3 rev4 reverts the content change from rev2
1304 # \ / merging rev3 and rev4 should use bar@rev2
1305 # \ / merging rev3 and rev4 should use bar@rev2
1305 # \- 2 --- 4 as the merge base
1306 # \- 2 --- 4 as the merge base
1306 #
1307 #
1307
1308
1308 cfname = copy[0]
1309 cfname = copy[0]
1309 crev = manifest1.get(cfname)
1310 crev = manifest1.get(cfname)
1310 newfparent = fparent2
1311 newfparent = fparent2
1311
1312
1312 if manifest2: # branch merge
1313 if manifest2: # branch merge
1313 if fparent2 == nullid or crev is None: # copied on remote side
1314 if fparent2 == nullid or crev is None: # copied on remote side
1314 if cfname in manifest2:
1315 if cfname in manifest2:
1315 crev = manifest2[cfname]
1316 crev = manifest2[cfname]
1316 newfparent = fparent1
1317 newfparent = fparent1
1317
1318
1318 # Here, we used to search backwards through history to try to find
1319 # Here, we used to search backwards through history to try to find
1319 # where the file copy came from if the source of a copy was not in
1320 # where the file copy came from if the source of a copy was not in
1320 # the parent directory. However, this doesn't actually make sense to
1321 # the parent directory. However, this doesn't actually make sense to
1321 # do (what does a copy from something not in your working copy even
1322 # do (what does a copy from something not in your working copy even
1322 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1323 # mean?) and it causes bugs (eg, issue4476). Instead, we will warn
1323 # the user that copy information was dropped, so if they didn't
1324 # the user that copy information was dropped, so if they didn't
1324 # expect this outcome it can be fixed, but this is the correct
1325 # expect this outcome it can be fixed, but this is the correct
1325 # behavior in this circumstance.
1326 # behavior in this circumstance.
1326
1327
1327 if crev:
1328 if crev:
1328 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1329 self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
1329 meta["copy"] = cfname
1330 meta["copy"] = cfname
1330 meta["copyrev"] = hex(crev)
1331 meta["copyrev"] = hex(crev)
1331 fparent1, fparent2 = nullid, newfparent
1332 fparent1, fparent2 = nullid, newfparent
1332 else:
1333 else:
1333 self.ui.warn(_("warning: can't find ancestor for '%s' "
1334 self.ui.warn(_("warning: can't find ancestor for '%s' "
1334 "copied from '%s'!\n") % (fname, cfname))
1335 "copied from '%s'!\n") % (fname, cfname))
1335
1336
1336 elif fparent1 == nullid:
1337 elif fparent1 == nullid:
1337 fparent1, fparent2 = fparent2, nullid
1338 fparent1, fparent2 = fparent2, nullid
1338 elif fparent2 != nullid:
1339 elif fparent2 != nullid:
1339 # is one parent an ancestor of the other?
1340 # is one parent an ancestor of the other?
1340 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1341 fparentancestors = flog.commonancestorsheads(fparent1, fparent2)
1341 if fparent1 in fparentancestors:
1342 if fparent1 in fparentancestors:
1342 fparent1, fparent2 = fparent2, nullid
1343 fparent1, fparent2 = fparent2, nullid
1343 elif fparent2 in fparentancestors:
1344 elif fparent2 in fparentancestors:
1344 fparent2 = nullid
1345 fparent2 = nullid
1345
1346
1346 # is the file changed?
1347 # is the file changed?
1347 text = fctx.data()
1348 text = fctx.data()
1348 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1349 if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
1349 changelist.append(fname)
1350 changelist.append(fname)
1350 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1351 return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
1351 # are just the flags changed during merge?
1352 # are just the flags changed during merge?
1352 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1353 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags():
1353 changelist.append(fname)
1354 changelist.append(fname)
1354
1355
1355 return fparent1
1356 return fparent1
1356
1357
1357 @unfilteredmethod
1358 @unfilteredmethod
1358 def commit(self, text="", user=None, date=None, match=None, force=False,
1359 def commit(self, text="", user=None, date=None, match=None, force=False,
1359 editor=False, extra={}):
1360 editor=False, extra={}):
1360 """Add a new revision to current repository.
1361 """Add a new revision to current repository.
1361
1362
1362 Revision information is gathered from the working directory,
1363 Revision information is gathered from the working directory,
1363 match can be used to filter the committed files. If editor is
1364 match can be used to filter the committed files. If editor is
1364 supplied, it is called to get a commit message.
1365 supplied, it is called to get a commit message.
1365 """
1366 """
1366
1367
1367 def fail(f, msg):
1368 def fail(f, msg):
1368 raise util.Abort('%s: %s' % (f, msg))
1369 raise util.Abort('%s: %s' % (f, msg))
1369
1370
1370 if not match:
1371 if not match:
1371 match = matchmod.always(self.root, '')
1372 match = matchmod.always(self.root, '')
1372
1373
1373 if not force:
1374 if not force:
1374 vdirs = []
1375 vdirs = []
1375 match.explicitdir = vdirs.append
1376 match.explicitdir = vdirs.append
1376 match.bad = fail
1377 match.bad = fail
1377
1378
1378 wlock = self.wlock()
1379 wlock = self.wlock()
1379 try:
1380 try:
1380 wctx = self[None]
1381 wctx = self[None]
1381 merge = len(wctx.parents()) > 1
1382 merge = len(wctx.parents()) > 1
1382
1383
1383 if not force and merge and match.ispartial():
1384 if not force and merge and match.ispartial():
1384 raise util.Abort(_('cannot partially commit a merge '
1385 raise util.Abort(_('cannot partially commit a merge '
1385 '(do not specify files or patterns)'))
1386 '(do not specify files or patterns)'))
1386
1387
1387 status = self.status(match=match, clean=force)
1388 status = self.status(match=match, clean=force)
1388 if force:
1389 if force:
1389 status.modified.extend(status.clean) # mq may commit clean files
1390 status.modified.extend(status.clean) # mq may commit clean files
1390
1391
1391 # check subrepos
1392 # check subrepos
1392 subs = []
1393 subs = []
1393 commitsubs = set()
1394 commitsubs = set()
1394 newstate = wctx.substate.copy()
1395 newstate = wctx.substate.copy()
1395 # only manage subrepos and .hgsubstate if .hgsub is present
1396 # only manage subrepos and .hgsubstate if .hgsub is present
1396 if '.hgsub' in wctx:
1397 if '.hgsub' in wctx:
1397 # we'll decide whether to track this ourselves, thanks
1398 # we'll decide whether to track this ourselves, thanks
1398 for c in status.modified, status.added, status.removed:
1399 for c in status.modified, status.added, status.removed:
1399 if '.hgsubstate' in c:
1400 if '.hgsubstate' in c:
1400 c.remove('.hgsubstate')
1401 c.remove('.hgsubstate')
1401
1402
1402 # compare current state to last committed state
1403 # compare current state to last committed state
1403 # build new substate based on last committed state
1404 # build new substate based on last committed state
1404 oldstate = wctx.p1().substate
1405 oldstate = wctx.p1().substate
1405 for s in sorted(newstate.keys()):
1406 for s in sorted(newstate.keys()):
1406 if not match(s):
1407 if not match(s):
1407 # ignore working copy, use old state if present
1408 # ignore working copy, use old state if present
1408 if s in oldstate:
1409 if s in oldstate:
1409 newstate[s] = oldstate[s]
1410 newstate[s] = oldstate[s]
1410 continue
1411 continue
1411 if not force:
1412 if not force:
1412 raise util.Abort(
1413 raise util.Abort(
1413 _("commit with new subrepo %s excluded") % s)
1414 _("commit with new subrepo %s excluded") % s)
1414 dirtyreason = wctx.sub(s).dirtyreason(True)
1415 dirtyreason = wctx.sub(s).dirtyreason(True)
1415 if dirtyreason:
1416 if dirtyreason:
1416 if not self.ui.configbool('ui', 'commitsubrepos'):
1417 if not self.ui.configbool('ui', 'commitsubrepos'):
1417 raise util.Abort(dirtyreason,
1418 raise util.Abort(dirtyreason,
1418 hint=_("use --subrepos for recursive commit"))
1419 hint=_("use --subrepos for recursive commit"))
1419 subs.append(s)
1420 subs.append(s)
1420 commitsubs.add(s)
1421 commitsubs.add(s)
1421 else:
1422 else:
1422 bs = wctx.sub(s).basestate()
1423 bs = wctx.sub(s).basestate()
1423 newstate[s] = (newstate[s][0], bs, newstate[s][2])
1424 newstate[s] = (newstate[s][0], bs, newstate[s][2])
1424 if oldstate.get(s, (None, None, None))[1] != bs:
1425 if oldstate.get(s, (None, None, None))[1] != bs:
1425 subs.append(s)
1426 subs.append(s)
1426
1427
1427 # check for removed subrepos
1428 # check for removed subrepos
1428 for p in wctx.parents():
1429 for p in wctx.parents():
1429 r = [s for s in p.substate if s not in newstate]
1430 r = [s for s in p.substate if s not in newstate]
1430 subs += [s for s in r if match(s)]
1431 subs += [s for s in r if match(s)]
1431 if subs:
1432 if subs:
1432 if (not match('.hgsub') and
1433 if (not match('.hgsub') and
1433 '.hgsub' in (wctx.modified() + wctx.added())):
1434 '.hgsub' in (wctx.modified() + wctx.added())):
1434 raise util.Abort(
1435 raise util.Abort(
1435 _("can't commit subrepos without .hgsub"))
1436 _("can't commit subrepos without .hgsub"))
1436 status.modified.insert(0, '.hgsubstate')
1437 status.modified.insert(0, '.hgsubstate')
1437
1438
1438 elif '.hgsub' in status.removed:
1439 elif '.hgsub' in status.removed:
1439 # clean up .hgsubstate when .hgsub is removed
1440 # clean up .hgsubstate when .hgsub is removed
1440 if ('.hgsubstate' in wctx and
1441 if ('.hgsubstate' in wctx and
1441 '.hgsubstate' not in (status.modified + status.added +
1442 '.hgsubstate' not in (status.modified + status.added +
1442 status.removed)):
1443 status.removed)):
1443 status.removed.insert(0, '.hgsubstate')
1444 status.removed.insert(0, '.hgsubstate')
1444
1445
1445 # make sure all explicit patterns are matched
1446 # make sure all explicit patterns are matched
1446 if not force and match.files():
1447 if not force and match.files():
1447 matched = set(status.modified + status.added + status.removed)
1448 matched = set(status.modified + status.added + status.removed)
1448
1449
1449 for f in match.files():
1450 for f in match.files():
1450 f = self.dirstate.normalize(f)
1451 f = self.dirstate.normalize(f)
1451 if f == '.' or f in matched or f in wctx.substate:
1452 if f == '.' or f in matched or f in wctx.substate:
1452 continue
1453 continue
1453 if f in status.deleted:
1454 if f in status.deleted:
1454 fail(f, _('file not found!'))
1455 fail(f, _('file not found!'))
1455 if f in vdirs: # visited directory
1456 if f in vdirs: # visited directory
1456 d = f + '/'
1457 d = f + '/'
1457 for mf in matched:
1458 for mf in matched:
1458 if mf.startswith(d):
1459 if mf.startswith(d):
1459 break
1460 break
1460 else:
1461 else:
1461 fail(f, _("no match under directory!"))
1462 fail(f, _("no match under directory!"))
1462 elif f not in self.dirstate:
1463 elif f not in self.dirstate:
1463 fail(f, _("file not tracked!"))
1464 fail(f, _("file not tracked!"))
1464
1465
1465 cctx = context.workingcommitctx(self, status,
1466 cctx = context.workingcommitctx(self, status,
1466 text, user, date, extra)
1467 text, user, date, extra)
1467
1468
1468 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1469 allowemptycommit = (wctx.branch() != wctx.p1().branch()
1469 or extra.get('close') or merge or cctx.files()
1470 or extra.get('close') or merge or cctx.files()
1470 or self.ui.configbool('ui', 'allowemptycommit'))
1471 or self.ui.configbool('ui', 'allowemptycommit'))
1471 if not allowemptycommit:
1472 if not allowemptycommit:
1472 return None
1473 return None
1473
1474
1474 if merge and cctx.deleted():
1475 if merge and cctx.deleted():
1475 raise util.Abort(_("cannot commit merge with missing files"))
1476 raise util.Abort(_("cannot commit merge with missing files"))
1476
1477
1477 ms = mergemod.mergestate(self)
1478 ms = mergemod.mergestate(self)
1478 for f in status.modified:
1479 for f in status.modified:
1479 if f in ms and ms[f] == 'u':
1480 if f in ms and ms[f] == 'u':
1480 raise util.Abort(_('unresolved merge conflicts '
1481 raise util.Abort(_('unresolved merge conflicts '
1481 '(see "hg help resolve")'))
1482 '(see "hg help resolve")'))
1482
1483
1483 if editor:
1484 if editor:
1484 cctx._text = editor(self, cctx, subs)
1485 cctx._text = editor(self, cctx, subs)
1485 edited = (text != cctx._text)
1486 edited = (text != cctx._text)
1486
1487
1487 # Save commit message in case this transaction gets rolled back
1488 # Save commit message in case this transaction gets rolled back
1488 # (e.g. by a pretxncommit hook). Leave the content alone on
1489 # (e.g. by a pretxncommit hook). Leave the content alone on
1489 # the assumption that the user will use the same editor again.
1490 # the assumption that the user will use the same editor again.
1490 msgfn = self.savecommitmessage(cctx._text)
1491 msgfn = self.savecommitmessage(cctx._text)
1491
1492
1492 # commit subs and write new state
1493 # commit subs and write new state
1493 if subs:
1494 if subs:
1494 for s in sorted(commitsubs):
1495 for s in sorted(commitsubs):
1495 sub = wctx.sub(s)
1496 sub = wctx.sub(s)
1496 self.ui.status(_('committing subrepository %s\n') %
1497 self.ui.status(_('committing subrepository %s\n') %
1497 subrepo.subrelpath(sub))
1498 subrepo.subrelpath(sub))
1498 sr = sub.commit(cctx._text, user, date)
1499 sr = sub.commit(cctx._text, user, date)
1499 newstate[s] = (newstate[s][0], sr)
1500 newstate[s] = (newstate[s][0], sr)
1500 subrepo.writestate(self, newstate)
1501 subrepo.writestate(self, newstate)
1501
1502
1502 p1, p2 = self.dirstate.parents()
1503 p1, p2 = self.dirstate.parents()
1503 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1504 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
1504 try:
1505 try:
1505 self.hook("precommit", throw=True, parent1=hookp1,
1506 self.hook("precommit", throw=True, parent1=hookp1,
1506 parent2=hookp2)
1507 parent2=hookp2)
1507 ret = self.commitctx(cctx, True)
1508 ret = self.commitctx(cctx, True)
1508 except: # re-raises
1509 except: # re-raises
1509 if edited:
1510 if edited:
1510 self.ui.write(
1511 self.ui.write(
1511 _('note: commit message saved in %s\n') % msgfn)
1512 _('note: commit message saved in %s\n') % msgfn)
1512 raise
1513 raise
1513
1514
1514 # update bookmarks, dirstate and mergestate
1515 # update bookmarks, dirstate and mergestate
1515 bookmarks.update(self, [p1, p2], ret)
1516 bookmarks.update(self, [p1, p2], ret)
1516 cctx.markcommitted(ret)
1517 cctx.markcommitted(ret)
1517 ms.reset()
1518 ms.reset()
1518 finally:
1519 finally:
1519 wlock.release()
1520 wlock.release()
1520
1521
1521 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1522 def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2):
1522 # hack for command that use a temporary commit (eg: histedit)
1523 # hack for command that use a temporary commit (eg: histedit)
1523 # temporary commit got stripped before hook release
1524 # temporary commit got stripped before hook release
1524 if self.changelog.hasnode(ret):
1525 if self.changelog.hasnode(ret):
1525 self.hook("commit", node=node, parent1=parent1,
1526 self.hook("commit", node=node, parent1=parent1,
1526 parent2=parent2)
1527 parent2=parent2)
1527 self._afterlock(commithook)
1528 self._afterlock(commithook)
1528 return ret
1529 return ret
1529
1530
1530 @unfilteredmethod
1531 @unfilteredmethod
1531 def commitctx(self, ctx, error=False):
1532 def commitctx(self, ctx, error=False):
1532 """Add a new revision to current repository.
1533 """Add a new revision to current repository.
1533 Revision information is passed via the context argument.
1534 Revision information is passed via the context argument.
1534 """
1535 """
1535
1536
1536 tr = None
1537 tr = None
1537 p1, p2 = ctx.p1(), ctx.p2()
1538 p1, p2 = ctx.p1(), ctx.p2()
1538 user = ctx.user()
1539 user = ctx.user()
1539
1540
1540 lock = self.lock()
1541 lock = self.lock()
1541 try:
1542 try:
1542 tr = self.transaction("commit")
1543 tr = self.transaction("commit")
1543 trp = weakref.proxy(tr)
1544 trp = weakref.proxy(tr)
1544
1545
1545 if ctx.files():
1546 if ctx.files():
1546 m1 = p1.manifest()
1547 m1 = p1.manifest()
1547 m2 = p2.manifest()
1548 m2 = p2.manifest()
1548 m = m1.copy()
1549 m = m1.copy()
1549
1550
1550 # check in files
1551 # check in files
1551 added = []
1552 added = []
1552 changed = []
1553 changed = []
1553 removed = list(ctx.removed())
1554 removed = list(ctx.removed())
1554 linkrev = len(self)
1555 linkrev = len(self)
1555 self.ui.note(_("committing files:\n"))
1556 self.ui.note(_("committing files:\n"))
1556 for f in sorted(ctx.modified() + ctx.added()):
1557 for f in sorted(ctx.modified() + ctx.added()):
1557 self.ui.note(f + "\n")
1558 self.ui.note(f + "\n")
1558 try:
1559 try:
1559 fctx = ctx[f]
1560 fctx = ctx[f]
1560 if fctx is None:
1561 if fctx is None:
1561 removed.append(f)
1562 removed.append(f)
1562 else:
1563 else:
1563 added.append(f)
1564 added.append(f)
1564 m[f] = self._filecommit(fctx, m1, m2, linkrev,
1565 m[f] = self._filecommit(fctx, m1, m2, linkrev,
1565 trp, changed)
1566 trp, changed)
1566 m.setflag(f, fctx.flags())
1567 m.setflag(f, fctx.flags())
1567 except OSError, inst:
1568 except OSError, inst:
1568 self.ui.warn(_("trouble committing %s!\n") % f)
1569 self.ui.warn(_("trouble committing %s!\n") % f)
1569 raise
1570 raise
1570 except IOError, inst:
1571 except IOError, inst:
1571 errcode = getattr(inst, 'errno', errno.ENOENT)
1572 errcode = getattr(inst, 'errno', errno.ENOENT)
1572 if error or errcode and errcode != errno.ENOENT:
1573 if error or errcode and errcode != errno.ENOENT:
1573 self.ui.warn(_("trouble committing %s!\n") % f)
1574 self.ui.warn(_("trouble committing %s!\n") % f)
1574 raise
1575 raise
1575
1576
1576 # update manifest
1577 # update manifest
1577 self.ui.note(_("committing manifest\n"))
1578 self.ui.note(_("committing manifest\n"))
1578 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1579 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1579 drop = [f for f in removed if f in m]
1580 drop = [f for f in removed if f in m]
1580 for f in drop:
1581 for f in drop:
1581 del m[f]
1582 del m[f]
1582 mn = self.manifest.add(m, trp, linkrev,
1583 mn = self.manifest.add(m, trp, linkrev,
1583 p1.manifestnode(), p2.manifestnode(),
1584 p1.manifestnode(), p2.manifestnode(),
1584 added, drop)
1585 added, drop)
1585 files = changed + removed
1586 files = changed + removed
1586 else:
1587 else:
1587 mn = p1.manifestnode()
1588 mn = p1.manifestnode()
1588 files = []
1589 files = []
1589
1590
1590 # update changelog
1591 # update changelog
1591 self.ui.note(_("committing changelog\n"))
1592 self.ui.note(_("committing changelog\n"))
1592 self.changelog.delayupdate(tr)
1593 self.changelog.delayupdate(tr)
1593 n = self.changelog.add(mn, files, ctx.description(),
1594 n = self.changelog.add(mn, files, ctx.description(),
1594 trp, p1.node(), p2.node(),
1595 trp, p1.node(), p2.node(),
1595 user, ctx.date(), ctx.extra().copy())
1596 user, ctx.date(), ctx.extra().copy())
1596 p = lambda: tr.writepending() and self.root or ""
1597 p = lambda: tr.writepending() and self.root or ""
1597 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1598 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1598 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1599 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
1599 parent2=xp2, pending=p)
1600 parent2=xp2, pending=p)
1600 # set the new commit is proper phase
1601 # set the new commit is proper phase
1601 targetphase = subrepo.newcommitphase(self.ui, ctx)
1602 targetphase = subrepo.newcommitphase(self.ui, ctx)
1602 if targetphase:
1603 if targetphase:
1603 # retract boundary do not alter parent changeset.
1604 # retract boundary do not alter parent changeset.
1604 # if a parent have higher the resulting phase will
1605 # if a parent have higher the resulting phase will
1605 # be compliant anyway
1606 # be compliant anyway
1606 #
1607 #
1607 # if minimal phase was 0 we don't need to retract anything
1608 # if minimal phase was 0 we don't need to retract anything
1608 phases.retractboundary(self, tr, targetphase, [n])
1609 phases.retractboundary(self, tr, targetphase, [n])
1609 tr.close()
1610 tr.close()
1610 branchmap.updatecache(self.filtered('served'))
1611 branchmap.updatecache(self.filtered('served'))
1611 return n
1612 return n
1612 finally:
1613 finally:
1613 if tr:
1614 if tr:
1614 tr.release()
1615 tr.release()
1615 lock.release()
1616 lock.release()
1616
1617
1617 @unfilteredmethod
1618 @unfilteredmethod
1618 def destroying(self):
1619 def destroying(self):
1619 '''Inform the repository that nodes are about to be destroyed.
1620 '''Inform the repository that nodes are about to be destroyed.
1620 Intended for use by strip and rollback, so there's a common
1621 Intended for use by strip and rollback, so there's a common
1621 place for anything that has to be done before destroying history.
1622 place for anything that has to be done before destroying history.
1622
1623
1623 This is mostly useful for saving state that is in memory and waiting
1624 This is mostly useful for saving state that is in memory and waiting
1624 to be flushed when the current lock is released. Because a call to
1625 to be flushed when the current lock is released. Because a call to
1625 destroyed is imminent, the repo will be invalidated causing those
1626 destroyed is imminent, the repo will be invalidated causing those
1626 changes to stay in memory (waiting for the next unlock), or vanish
1627 changes to stay in memory (waiting for the next unlock), or vanish
1627 completely.
1628 completely.
1628 '''
1629 '''
1629 # When using the same lock to commit and strip, the phasecache is left
1630 # When using the same lock to commit and strip, the phasecache is left
1630 # dirty after committing. Then when we strip, the repo is invalidated,
1631 # dirty after committing. Then when we strip, the repo is invalidated,
1631 # causing those changes to disappear.
1632 # causing those changes to disappear.
1632 if '_phasecache' in vars(self):
1633 if '_phasecache' in vars(self):
1633 self._phasecache.write()
1634 self._phasecache.write()
1634
1635
1635 @unfilteredmethod
1636 @unfilteredmethod
1636 def destroyed(self):
1637 def destroyed(self):
1637 '''Inform the repository that nodes have been destroyed.
1638 '''Inform the repository that nodes have been destroyed.
1638 Intended for use by strip and rollback, so there's a common
1639 Intended for use by strip and rollback, so there's a common
1639 place for anything that has to be done after destroying history.
1640 place for anything that has to be done after destroying history.
1640 '''
1641 '''
1641 # When one tries to:
1642 # When one tries to:
1642 # 1) destroy nodes thus calling this method (e.g. strip)
1643 # 1) destroy nodes thus calling this method (e.g. strip)
1643 # 2) use phasecache somewhere (e.g. commit)
1644 # 2) use phasecache somewhere (e.g. commit)
1644 #
1645 #
1645 # then 2) will fail because the phasecache contains nodes that were
1646 # then 2) will fail because the phasecache contains nodes that were
1646 # removed. We can either remove phasecache from the filecache,
1647 # removed. We can either remove phasecache from the filecache,
1647 # causing it to reload next time it is accessed, or simply filter
1648 # causing it to reload next time it is accessed, or simply filter
1648 # the removed nodes now and write the updated cache.
1649 # the removed nodes now and write the updated cache.
1649 self._phasecache.filterunknown(self)
1650 self._phasecache.filterunknown(self)
1650 self._phasecache.write()
1651 self._phasecache.write()
1651
1652
1652 # update the 'served' branch cache to help read only server process
1653 # update the 'served' branch cache to help read only server process
1653 # Thanks to branchcache collaboration this is done from the nearest
1654 # Thanks to branchcache collaboration this is done from the nearest
1654 # filtered subset and it is expected to be fast.
1655 # filtered subset and it is expected to be fast.
1655 branchmap.updatecache(self.filtered('served'))
1656 branchmap.updatecache(self.filtered('served'))
1656
1657
1657 # Ensure the persistent tag cache is updated. Doing it now
1658 # Ensure the persistent tag cache is updated. Doing it now
1658 # means that the tag cache only has to worry about destroyed
1659 # means that the tag cache only has to worry about destroyed
1659 # heads immediately after a strip/rollback. That in turn
1660 # heads immediately after a strip/rollback. That in turn
1660 # guarantees that "cachetip == currenttip" (comparing both rev
1661 # guarantees that "cachetip == currenttip" (comparing both rev
1661 # and node) always means no nodes have been added or destroyed.
1662 # and node) always means no nodes have been added or destroyed.
1662
1663
1663 # XXX this is suboptimal when qrefresh'ing: we strip the current
1664 # XXX this is suboptimal when qrefresh'ing: we strip the current
1664 # head, refresh the tag cache, then immediately add a new head.
1665 # head, refresh the tag cache, then immediately add a new head.
1665 # But I think doing it this way is necessary for the "instant
1666 # But I think doing it this way is necessary for the "instant
1666 # tag cache retrieval" case to work.
1667 # tag cache retrieval" case to work.
1667 self.invalidate()
1668 self.invalidate()
1668
1669
1669 def walk(self, match, node=None):
1670 def walk(self, match, node=None):
1670 '''
1671 '''
1671 walk recursively through the directory tree or a given
1672 walk recursively through the directory tree or a given
1672 changeset, finding all files matched by the match
1673 changeset, finding all files matched by the match
1673 function
1674 function
1674 '''
1675 '''
1675 return self[node].walk(match)
1676 return self[node].walk(match)
1676
1677
1677 def status(self, node1='.', node2=None, match=None,
1678 def status(self, node1='.', node2=None, match=None,
1678 ignored=False, clean=False, unknown=False,
1679 ignored=False, clean=False, unknown=False,
1679 listsubrepos=False):
1680 listsubrepos=False):
1680 '''a convenience method that calls node1.status(node2)'''
1681 '''a convenience method that calls node1.status(node2)'''
1681 return self[node1].status(node2, match, ignored, clean, unknown,
1682 return self[node1].status(node2, match, ignored, clean, unknown,
1682 listsubrepos)
1683 listsubrepos)
1683
1684
1684 def heads(self, start=None):
1685 def heads(self, start=None):
1685 heads = self.changelog.heads(start)
1686 heads = self.changelog.heads(start)
1686 # sort the output in rev descending order
1687 # sort the output in rev descending order
1687 return sorted(heads, key=self.changelog.rev, reverse=True)
1688 return sorted(heads, key=self.changelog.rev, reverse=True)
1688
1689
1689 def branchheads(self, branch=None, start=None, closed=False):
1690 def branchheads(self, branch=None, start=None, closed=False):
1690 '''return a (possibly filtered) list of heads for the given branch
1691 '''return a (possibly filtered) list of heads for the given branch
1691
1692
1692 Heads are returned in topological order, from newest to oldest.
1693 Heads are returned in topological order, from newest to oldest.
1693 If branch is None, use the dirstate branch.
1694 If branch is None, use the dirstate branch.
1694 If start is not None, return only heads reachable from start.
1695 If start is not None, return only heads reachable from start.
1695 If closed is True, return heads that are marked as closed as well.
1696 If closed is True, return heads that are marked as closed as well.
1696 '''
1697 '''
1697 if branch is None:
1698 if branch is None:
1698 branch = self[None].branch()
1699 branch = self[None].branch()
1699 branches = self.branchmap()
1700 branches = self.branchmap()
1700 if branch not in branches:
1701 if branch not in branches:
1701 return []
1702 return []
1702 # the cache returns heads ordered lowest to highest
1703 # the cache returns heads ordered lowest to highest
1703 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
1704 bheads = list(reversed(branches.branchheads(branch, closed=closed)))
1704 if start is not None:
1705 if start is not None:
1705 # filter out the heads that cannot be reached from startrev
1706 # filter out the heads that cannot be reached from startrev
1706 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1707 fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
1707 bheads = [h for h in bheads if h in fbheads]
1708 bheads = [h for h in bheads if h in fbheads]
1708 return bheads
1709 return bheads
1709
1710
1710 def branches(self, nodes):
1711 def branches(self, nodes):
1711 if not nodes:
1712 if not nodes:
1712 nodes = [self.changelog.tip()]
1713 nodes = [self.changelog.tip()]
1713 b = []
1714 b = []
1714 for n in nodes:
1715 for n in nodes:
1715 t = n
1716 t = n
1716 while True:
1717 while True:
1717 p = self.changelog.parents(n)
1718 p = self.changelog.parents(n)
1718 if p[1] != nullid or p[0] == nullid:
1719 if p[1] != nullid or p[0] == nullid:
1719 b.append((t, n, p[0], p[1]))
1720 b.append((t, n, p[0], p[1]))
1720 break
1721 break
1721 n = p[0]
1722 n = p[0]
1722 return b
1723 return b
1723
1724
1724 def between(self, pairs):
1725 def between(self, pairs):
1725 r = []
1726 r = []
1726
1727
1727 for top, bottom in pairs:
1728 for top, bottom in pairs:
1728 n, l, i = top, [], 0
1729 n, l, i = top, [], 0
1729 f = 1
1730 f = 1
1730
1731
1731 while n != bottom and n != nullid:
1732 while n != bottom and n != nullid:
1732 p = self.changelog.parents(n)[0]
1733 p = self.changelog.parents(n)[0]
1733 if i == f:
1734 if i == f:
1734 l.append(n)
1735 l.append(n)
1735 f = f * 2
1736 f = f * 2
1736 n = p
1737 n = p
1737 i += 1
1738 i += 1
1738
1739
1739 r.append(l)
1740 r.append(l)
1740
1741
1741 return r
1742 return r
1742
1743
1743 def checkpush(self, pushop):
1744 def checkpush(self, pushop):
1744 """Extensions can override this function if additional checks have
1745 """Extensions can override this function if additional checks have
1745 to be performed before pushing, or call it if they override push
1746 to be performed before pushing, or call it if they override push
1746 command.
1747 command.
1747 """
1748 """
1748 pass
1749 pass
1749
1750
1750 @unfilteredpropertycache
1751 @unfilteredpropertycache
1751 def prepushoutgoinghooks(self):
1752 def prepushoutgoinghooks(self):
1752 """Return util.hooks consists of "(repo, remote, outgoing)"
1753 """Return util.hooks consists of "(repo, remote, outgoing)"
1753 functions, which are called before pushing changesets.
1754 functions, which are called before pushing changesets.
1754 """
1755 """
1755 return util.hooks()
1756 return util.hooks()
1756
1757
1757 def stream_in(self, remote, remotereqs):
1758 def stream_in(self, remote, remotereqs):
1758 # Save remote branchmap. We will use it later
1759 # Save remote branchmap. We will use it later
1759 # to speed up branchcache creation
1760 # to speed up branchcache creation
1760 rbranchmap = None
1761 rbranchmap = None
1761 if remote.capable("branchmap"):
1762 if remote.capable("branchmap"):
1762 rbranchmap = remote.branchmap()
1763 rbranchmap = remote.branchmap()
1763
1764
1764 fp = remote.stream_out()
1765 fp = remote.stream_out()
1765 l = fp.readline()
1766 l = fp.readline()
1766 try:
1767 try:
1767 resp = int(l)
1768 resp = int(l)
1768 except ValueError:
1769 except ValueError:
1769 raise error.ResponseError(
1770 raise error.ResponseError(
1770 _('unexpected response from remote server:'), l)
1771 _('unexpected response from remote server:'), l)
1771 if resp == 1:
1772 if resp == 1:
1772 raise util.Abort(_('operation forbidden by server'))
1773 raise util.Abort(_('operation forbidden by server'))
1773 elif resp == 2:
1774 elif resp == 2:
1774 raise util.Abort(_('locking the remote repository failed'))
1775 raise util.Abort(_('locking the remote repository failed'))
1775 elif resp != 0:
1776 elif resp != 0:
1776 raise util.Abort(_('the server sent an unknown error code'))
1777 raise util.Abort(_('the server sent an unknown error code'))
1777
1778
1778 self.applystreamclone(remotereqs, rbranchmap, fp)
1779 self.applystreamclone(remotereqs, rbranchmap, fp)
1779 return len(self.heads()) + 1
1780 return len(self.heads()) + 1
1780
1781
1781 def applystreamclone(self, remotereqs, remotebranchmap, fp):
1782 def applystreamclone(self, remotereqs, remotebranchmap, fp):
1782 """Apply stream clone data to this repository.
1783 """Apply stream clone data to this repository.
1783
1784
1784 "remotereqs" is a set of requirements to handle the incoming data.
1785 "remotereqs" is a set of requirements to handle the incoming data.
1785 "remotebranchmap" is the result of a branchmap lookup on the remote. It
1786 "remotebranchmap" is the result of a branchmap lookup on the remote. It
1786 can be None.
1787 can be None.
1787 "fp" is a file object containing the raw stream data, suitable for
1788 "fp" is a file object containing the raw stream data, suitable for
1788 feeding into exchange.consumestreamclone.
1789 feeding into exchange.consumestreamclone.
1789 """
1790 """
1790 lock = self.lock()
1791 lock = self.lock()
1791 try:
1792 try:
1792 exchange.consumestreamclone(self, fp)
1793 exchange.consumestreamclone(self, fp)
1793
1794
1794 # new requirements = old non-format requirements +
1795 # new requirements = old non-format requirements +
1795 # new format-related remote requirements
1796 # new format-related remote requirements
1796 # requirements from the streamed-in repository
1797 # requirements from the streamed-in repository
1797 self.requirements = remotereqs | (
1798 self.requirements = remotereqs | (
1798 self.requirements - self.supportedformats)
1799 self.requirements - self.supportedformats)
1799 self._applyopenerreqs()
1800 self._applyopenerreqs()
1800 self._writerequirements()
1801 self._writerequirements()
1801
1802
1802 if remotebranchmap:
1803 if remotebranchmap:
1803 rbheads = []
1804 rbheads = []
1804 closed = []
1805 closed = []
1805 for bheads in remotebranchmap.itervalues():
1806 for bheads in remotebranchmap.itervalues():
1806 rbheads.extend(bheads)
1807 rbheads.extend(bheads)
1807 for h in bheads:
1808 for h in bheads:
1808 r = self.changelog.rev(h)
1809 r = self.changelog.rev(h)
1809 b, c = self.changelog.branchinfo(r)
1810 b, c = self.changelog.branchinfo(r)
1810 if c:
1811 if c:
1811 closed.append(h)
1812 closed.append(h)
1812
1813
1813 if rbheads:
1814 if rbheads:
1814 rtiprev = max((int(self.changelog.rev(node))
1815 rtiprev = max((int(self.changelog.rev(node))
1815 for node in rbheads))
1816 for node in rbheads))
1816 cache = branchmap.branchcache(remotebranchmap,
1817 cache = branchmap.branchcache(remotebranchmap,
1817 self[rtiprev].node(),
1818 self[rtiprev].node(),
1818 rtiprev,
1819 rtiprev,
1819 closednodes=closed)
1820 closednodes=closed)
1820 # Try to stick it as low as possible
1821 # Try to stick it as low as possible
1821 # filter above served are unlikely to be fetch from a clone
1822 # filter above served are unlikely to be fetch from a clone
1822 for candidate in ('base', 'immutable', 'served'):
1823 for candidate in ('base', 'immutable', 'served'):
1823 rview = self.filtered(candidate)
1824 rview = self.filtered(candidate)
1824 if cache.validfor(rview):
1825 if cache.validfor(rview):
1825 self._branchcaches[candidate] = cache
1826 self._branchcaches[candidate] = cache
1826 cache.write(rview)
1827 cache.write(rview)
1827 break
1828 break
1828 self.invalidate()
1829 self.invalidate()
1829 finally:
1830 finally:
1830 lock.release()
1831 lock.release()
1831
1832
1832 def clone(self, remote, heads=[], stream=None):
1833 def clone(self, remote, heads=[], stream=None):
1833 '''clone remote repository.
1834 '''clone remote repository.
1834
1835
1835 keyword arguments:
1836 keyword arguments:
1836 heads: list of revs to clone (forces use of pull)
1837 heads: list of revs to clone (forces use of pull)
1837 stream: use streaming clone if possible'''
1838 stream: use streaming clone if possible'''
1838
1839
1839 # now, all clients that can request uncompressed clones can
1840 # now, all clients that can request uncompressed clones can
1840 # read repo formats supported by all servers that can serve
1841 # read repo formats supported by all servers that can serve
1841 # them.
1842 # them.
1842
1843
1843 # if revlog format changes, client will have to check version
1844 # if revlog format changes, client will have to check version
1844 # and format flags on "stream" capability, and use
1845 # and format flags on "stream" capability, and use
1845 # uncompressed only if compatible.
1846 # uncompressed only if compatible.
1846
1847
1847 if stream is None:
1848 if stream is None:
1848 # if the server explicitly prefers to stream (for fast LANs)
1849 # if the server explicitly prefers to stream (for fast LANs)
1849 stream = remote.capable('stream-preferred')
1850 stream = remote.capable('stream-preferred')
1850
1851
1851 if stream and not heads:
1852 if stream and not heads:
1852 # 'stream' means remote revlog format is revlogv1 only
1853 # 'stream' means remote revlog format is revlogv1 only
1853 if remote.capable('stream'):
1854 if remote.capable('stream'):
1854 self.stream_in(remote, set(('revlogv1',)))
1855 self.stream_in(remote, set(('revlogv1',)))
1855 else:
1856 else:
1856 # otherwise, 'streamreqs' contains the remote revlog format
1857 # otherwise, 'streamreqs' contains the remote revlog format
1857 streamreqs = remote.capable('streamreqs')
1858 streamreqs = remote.capable('streamreqs')
1858 if streamreqs:
1859 if streamreqs:
1859 streamreqs = set(streamreqs.split(','))
1860 streamreqs = set(streamreqs.split(','))
1860 # if we support it, stream in and adjust our requirements
1861 # if we support it, stream in and adjust our requirements
1861 if not streamreqs - self.supportedformats:
1862 if not streamreqs - self.supportedformats:
1862 self.stream_in(remote, streamreqs)
1863 self.stream_in(remote, streamreqs)
1863
1864
1864 quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
1865 quiet = self.ui.backupconfig('ui', 'quietbookmarkmove')
1865 try:
1866 try:
1866 self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone')
1867 self.ui.setconfig('ui', 'quietbookmarkmove', True, 'clone')
1867 ret = exchange.pull(self, remote, heads).cgresult
1868 ret = exchange.pull(self, remote, heads).cgresult
1868 finally:
1869 finally:
1869 self.ui.restoreconfig(quiet)
1870 self.ui.restoreconfig(quiet)
1870 return ret
1871 return ret
1871
1872
1872 def pushkey(self, namespace, key, old, new):
1873 def pushkey(self, namespace, key, old, new):
1873 try:
1874 try:
1874 tr = self.currenttransaction()
1875 tr = self.currenttransaction()
1875 hookargs = {}
1876 hookargs = {}
1876 if tr is not None:
1877 if tr is not None:
1877 hookargs.update(tr.hookargs)
1878 hookargs.update(tr.hookargs)
1878 pending = lambda: tr.writepending() and self.root or ""
1879 pending = lambda: tr.writepending() and self.root or ""
1879 hookargs['pending'] = pending
1880 hookargs['pending'] = pending
1880 hookargs['namespace'] = namespace
1881 hookargs['namespace'] = namespace
1881 hookargs['key'] = key
1882 hookargs['key'] = key
1882 hookargs['old'] = old
1883 hookargs['old'] = old
1883 hookargs['new'] = new
1884 hookargs['new'] = new
1884 self.hook('prepushkey', throw=True, **hookargs)
1885 self.hook('prepushkey', throw=True, **hookargs)
1885 except error.HookAbort, exc:
1886 except error.HookAbort, exc:
1886 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
1887 self.ui.write_err(_("pushkey-abort: %s\n") % exc)
1887 if exc.hint:
1888 if exc.hint:
1888 self.ui.write_err(_("(%s)\n") % exc.hint)
1889 self.ui.write_err(_("(%s)\n") % exc.hint)
1889 return False
1890 return False
1890 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
1891 self.ui.debug('pushing key for "%s:%s"\n' % (namespace, key))
1891 ret = pushkey.push(self, namespace, key, old, new)
1892 ret = pushkey.push(self, namespace, key, old, new)
1892 def runhook():
1893 def runhook():
1893 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
1894 self.hook('pushkey', namespace=namespace, key=key, old=old, new=new,
1894 ret=ret)
1895 ret=ret)
1895 self._afterlock(runhook)
1896 self._afterlock(runhook)
1896 return ret
1897 return ret
1897
1898
1898 def listkeys(self, namespace):
1899 def listkeys(self, namespace):
1899 self.hook('prelistkeys', throw=True, namespace=namespace)
1900 self.hook('prelistkeys', throw=True, namespace=namespace)
1900 self.ui.debug('listing keys for "%s"\n' % namespace)
1901 self.ui.debug('listing keys for "%s"\n' % namespace)
1901 values = pushkey.list(self, namespace)
1902 values = pushkey.list(self, namespace)
1902 self.hook('listkeys', namespace=namespace, values=values)
1903 self.hook('listkeys', namespace=namespace, values=values)
1903 return values
1904 return values
1904
1905
1905 def debugwireargs(self, one, two, three=None, four=None, five=None):
1906 def debugwireargs(self, one, two, three=None, four=None, five=None):
1906 '''used to test argument passing over the wire'''
1907 '''used to test argument passing over the wire'''
1907 return "%s %s %s %s %s" % (one, two, three, four, five)
1908 return "%s %s %s %s %s" % (one, two, three, four, five)
1908
1909
1909 def savecommitmessage(self, text):
1910 def savecommitmessage(self, text):
1910 fp = self.vfs('last-message.txt', 'wb')
1911 fp = self.vfs('last-message.txt', 'wb')
1911 try:
1912 try:
1912 fp.write(text)
1913 fp.write(text)
1913 finally:
1914 finally:
1914 fp.close()
1915 fp.close()
1915 return self.pathto(fp.name[len(self.root) + 1:])
1916 return self.pathto(fp.name[len(self.root) + 1:])
1916
1917
1917 # used to avoid circular references so destructors work
1918 # used to avoid circular references so destructors work
1918 def aftertrans(files):
1919 def aftertrans(files):
1919 renamefiles = [tuple(t) for t in files]
1920 renamefiles = [tuple(t) for t in files]
1920 def a():
1921 def a():
1921 for vfs, src, dest in renamefiles:
1922 for vfs, src, dest in renamefiles:
1922 try:
1923 try:
1923 vfs.rename(src, dest)
1924 vfs.rename(src, dest)
1924 except OSError: # journal file does not yet exist
1925 except OSError: # journal file does not yet exist
1925 pass
1926 pass
1926 return a
1927 return a
1927
1928
1928 def undoname(fn):
1929 def undoname(fn):
1929 base, name = os.path.split(fn)
1930 base, name = os.path.split(fn)
1930 assert name.startswith('journal')
1931 assert name.startswith('journal')
1931 return os.path.join(base, name.replace('journal', 'undo', 1))
1932 return os.path.join(base, name.replace('journal', 'undo', 1))
1932
1933
1933 def instance(ui, path, create):
1934 def instance(ui, path, create):
1934 return localrepository(ui, util.urllocalpath(path), create)
1935 return localrepository(ui, util.urllocalpath(path), create)
1935
1936
1936 def islocal(path):
1937 def islocal(path):
1937 return True
1938 return True
@@ -1,3511 +1,3507 b''
1 # revset.py - revision set queries for mercurial
1 # revset.py - revision set queries for mercurial
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 import re
8 import re
9 import parser, util, error, hbisect, phases
9 import parser, util, error, hbisect, phases
10 import node
10 import node
11 import heapq
11 import heapq
12 import match as matchmod
12 import match as matchmod
13 from i18n import _
13 from i18n import _
14 import encoding
14 import encoding
15 import obsolete as obsmod
15 import obsolete as obsmod
16 import pathutil
16 import pathutil
17 import repoview
17 import repoview
18
18
19 def _revancestors(repo, revs, followfirst):
19 def _revancestors(repo, revs, followfirst):
20 """Like revlog.ancestors(), but supports followfirst."""
20 """Like revlog.ancestors(), but supports followfirst."""
21 if followfirst:
21 if followfirst:
22 cut = 1
22 cut = 1
23 else:
23 else:
24 cut = None
24 cut = None
25 cl = repo.changelog
25 cl = repo.changelog
26
26
27 def iterate():
27 def iterate():
28 revs.sort(reverse=True)
28 revs.sort(reverse=True)
29 irevs = iter(revs)
29 irevs = iter(revs)
30 h = []
30 h = []
31
31
32 inputrev = next(irevs, None)
32 inputrev = next(irevs, None)
33 if inputrev is not None:
33 if inputrev is not None:
34 heapq.heappush(h, -inputrev)
34 heapq.heappush(h, -inputrev)
35
35
36 seen = set()
36 seen = set()
37 while h:
37 while h:
38 current = -heapq.heappop(h)
38 current = -heapq.heappop(h)
39 if current == inputrev:
39 if current == inputrev:
40 inputrev = next(irevs, None)
40 inputrev = next(irevs, None)
41 if inputrev is not None:
41 if inputrev is not None:
42 heapq.heappush(h, -inputrev)
42 heapq.heappush(h, -inputrev)
43 if current not in seen:
43 if current not in seen:
44 seen.add(current)
44 seen.add(current)
45 yield current
45 yield current
46 for parent in cl.parentrevs(current)[:cut]:
46 for parent in cl.parentrevs(current)[:cut]:
47 if parent != node.nullrev:
47 if parent != node.nullrev:
48 heapq.heappush(h, -parent)
48 heapq.heappush(h, -parent)
49
49
50 return generatorset(iterate(), iterasc=False)
50 return generatorset(iterate(), iterasc=False)
51
51
52 def _revdescendants(repo, revs, followfirst):
52 def _revdescendants(repo, revs, followfirst):
53 """Like revlog.descendants() but supports followfirst."""
53 """Like revlog.descendants() but supports followfirst."""
54 if followfirst:
54 if followfirst:
55 cut = 1
55 cut = 1
56 else:
56 else:
57 cut = None
57 cut = None
58
58
59 def iterate():
59 def iterate():
60 cl = repo.changelog
60 cl = repo.changelog
61 first = min(revs)
61 first = min(revs)
62 nullrev = node.nullrev
62 nullrev = node.nullrev
63 if first == nullrev:
63 if first == nullrev:
64 # Are there nodes with a null first parent and a non-null
64 # Are there nodes with a null first parent and a non-null
65 # second one? Maybe. Do we care? Probably not.
65 # second one? Maybe. Do we care? Probably not.
66 for i in cl:
66 for i in cl:
67 yield i
67 yield i
68 else:
68 else:
69 seen = set(revs)
69 seen = set(revs)
70 for i in cl.revs(first + 1):
70 for i in cl.revs(first + 1):
71 for x in cl.parentrevs(i)[:cut]:
71 for x in cl.parentrevs(i)[:cut]:
72 if x != nullrev and x in seen:
72 if x != nullrev and x in seen:
73 seen.add(i)
73 seen.add(i)
74 yield i
74 yield i
75 break
75 break
76
76
77 return generatorset(iterate(), iterasc=True)
77 return generatorset(iterate(), iterasc=True)
78
78
79 def _revsbetween(repo, roots, heads):
79 def _revsbetween(repo, roots, heads):
80 """Return all paths between roots and heads, inclusive of both endpoint
80 """Return all paths between roots and heads, inclusive of both endpoint
81 sets."""
81 sets."""
82 if not roots:
82 if not roots:
83 return baseset()
83 return baseset()
84 parentrevs = repo.changelog.parentrevs
84 parentrevs = repo.changelog.parentrevs
85 visit = list(heads)
85 visit = list(heads)
86 reachable = set()
86 reachable = set()
87 seen = {}
87 seen = {}
88 minroot = min(roots)
88 minroot = min(roots)
89 roots = set(roots)
89 roots = set(roots)
90 # open-code the post-order traversal due to the tiny size of
90 # open-code the post-order traversal due to the tiny size of
91 # sys.getrecursionlimit()
91 # sys.getrecursionlimit()
92 while visit:
92 while visit:
93 rev = visit.pop()
93 rev = visit.pop()
94 if rev in roots:
94 if rev in roots:
95 reachable.add(rev)
95 reachable.add(rev)
96 parents = parentrevs(rev)
96 parents = parentrevs(rev)
97 seen[rev] = parents
97 seen[rev] = parents
98 for parent in parents:
98 for parent in parents:
99 if parent >= minroot and parent not in seen:
99 if parent >= minroot and parent not in seen:
100 visit.append(parent)
100 visit.append(parent)
101 if not reachable:
101 if not reachable:
102 return baseset()
102 return baseset()
103 for rev in sorted(seen):
103 for rev in sorted(seen):
104 for parent in seen[rev]:
104 for parent in seen[rev]:
105 if parent in reachable:
105 if parent in reachable:
106 reachable.add(rev)
106 reachable.add(rev)
107 return baseset(sorted(reachable))
107 return baseset(sorted(reachable))
108
108
109 elements = {
109 elements = {
110 "(": (21, ("group", 1, ")"), ("func", 1, ")")),
110 "(": (21, ("group", 1, ")"), ("func", 1, ")")),
111 "##": (20, None, ("_concat", 20)),
111 "##": (20, None, ("_concat", 20)),
112 "~": (18, None, ("ancestor", 18)),
112 "~": (18, None, ("ancestor", 18)),
113 "^": (18, None, ("parent", 18), ("parentpost", 18)),
113 "^": (18, None, ("parent", 18), ("parentpost", 18)),
114 "-": (5, ("negate", 19), ("minus", 5)),
114 "-": (5, ("negate", 19), ("minus", 5)),
115 "::": (17, ("dagrangepre", 17), ("dagrange", 17),
115 "::": (17, ("dagrangepre", 17), ("dagrange", 17),
116 ("dagrangepost", 17)),
116 ("dagrangepost", 17)),
117 "..": (17, ("dagrangepre", 17), ("dagrange", 17),
117 "..": (17, ("dagrangepre", 17), ("dagrange", 17),
118 ("dagrangepost", 17)),
118 ("dagrangepost", 17)),
119 ":": (15, ("rangepre", 15), ("range", 15), ("rangepost", 15)),
119 ":": (15, ("rangepre", 15), ("range", 15), ("rangepost", 15)),
120 "not": (10, ("not", 10)),
120 "not": (10, ("not", 10)),
121 "!": (10, ("not", 10)),
121 "!": (10, ("not", 10)),
122 "and": (5, None, ("and", 5)),
122 "and": (5, None, ("and", 5)),
123 "&": (5, None, ("and", 5)),
123 "&": (5, None, ("and", 5)),
124 "%": (5, None, ("only", 5), ("onlypost", 5)),
124 "%": (5, None, ("only", 5), ("onlypost", 5)),
125 "or": (4, None, ("or", 4)),
125 "or": (4, None, ("or", 4)),
126 "|": (4, None, ("or", 4)),
126 "|": (4, None, ("or", 4)),
127 "+": (4, None, ("or", 4)),
127 "+": (4, None, ("or", 4)),
128 ",": (2, None, ("list", 2)),
128 ",": (2, None, ("list", 2)),
129 ")": (0, None, None),
129 ")": (0, None, None),
130 "symbol": (0, ("symbol",), None),
130 "symbol": (0, ("symbol",), None),
131 "string": (0, ("string",), None),
131 "string": (0, ("string",), None),
132 "end": (0, None, None),
132 "end": (0, None, None),
133 }
133 }
134
134
135 keywords = set(['and', 'or', 'not'])
135 keywords = set(['and', 'or', 'not'])
136
136
137 # default set of valid characters for the initial letter of symbols
137 # default set of valid characters for the initial letter of symbols
138 _syminitletters = set(c for c in [chr(i) for i in xrange(256)]
138 _syminitletters = set(c for c in [chr(i) for i in xrange(256)]
139 if c.isalnum() or c in '._@' or ord(c) > 127)
139 if c.isalnum() or c in '._@' or ord(c) > 127)
140
140
141 # default set of valid characters for non-initial letters of symbols
141 # default set of valid characters for non-initial letters of symbols
142 _symletters = set(c for c in [chr(i) for i in xrange(256)]
142 _symletters = set(c for c in [chr(i) for i in xrange(256)]
143 if c.isalnum() or c in '-._/@' or ord(c) > 127)
143 if c.isalnum() or c in '-._/@' or ord(c) > 127)
144
144
145 def tokenize(program, lookup=None, syminitletters=None, symletters=None):
145 def tokenize(program, lookup=None, syminitletters=None, symletters=None):
146 '''
146 '''
147 Parse a revset statement into a stream of tokens
147 Parse a revset statement into a stream of tokens
148
148
149 ``syminitletters`` is the set of valid characters for the initial
149 ``syminitletters`` is the set of valid characters for the initial
150 letter of symbols.
150 letter of symbols.
151
151
152 By default, character ``c`` is recognized as valid for initial
152 By default, character ``c`` is recognized as valid for initial
153 letter of symbols, if ``c.isalnum() or c in '._@' or ord(c) > 127``.
153 letter of symbols, if ``c.isalnum() or c in '._@' or ord(c) > 127``.
154
154
155 ``symletters`` is the set of valid characters for non-initial
155 ``symletters`` is the set of valid characters for non-initial
156 letters of symbols.
156 letters of symbols.
157
157
158 By default, character ``c`` is recognized as valid for non-initial
158 By default, character ``c`` is recognized as valid for non-initial
159 letters of symbols, if ``c.isalnum() or c in '-._/@' or ord(c) > 127``.
159 letters of symbols, if ``c.isalnum() or c in '-._/@' or ord(c) > 127``.
160
160
161 Check that @ is a valid unquoted token character (issue3686):
161 Check that @ is a valid unquoted token character (issue3686):
162 >>> list(tokenize("@::"))
162 >>> list(tokenize("@::"))
163 [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)]
163 [('symbol', '@', 0), ('::', None, 1), ('end', None, 3)]
164
164
165 '''
165 '''
166 if syminitletters is None:
166 if syminitletters is None:
167 syminitletters = _syminitletters
167 syminitletters = _syminitletters
168 if symletters is None:
168 if symletters is None:
169 symletters = _symletters
169 symletters = _symletters
170
170
171 pos, l = 0, len(program)
171 pos, l = 0, len(program)
172 while pos < l:
172 while pos < l:
173 c = program[pos]
173 c = program[pos]
174 if c.isspace(): # skip inter-token whitespace
174 if c.isspace(): # skip inter-token whitespace
175 pass
175 pass
176 elif c == ':' and program[pos:pos + 2] == '::': # look ahead carefully
176 elif c == ':' and program[pos:pos + 2] == '::': # look ahead carefully
177 yield ('::', None, pos)
177 yield ('::', None, pos)
178 pos += 1 # skip ahead
178 pos += 1 # skip ahead
179 elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully
179 elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully
180 yield ('..', None, pos)
180 yield ('..', None, pos)
181 pos += 1 # skip ahead
181 pos += 1 # skip ahead
182 elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
182 elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
183 yield ('##', None, pos)
183 yield ('##', None, pos)
184 pos += 1 # skip ahead
184 pos += 1 # skip ahead
185 elif c in "():,-|&+!~^%": # handle simple operators
185 elif c in "():,-|&+!~^%": # handle simple operators
186 yield (c, None, pos)
186 yield (c, None, pos)
187 elif (c in '"\'' or c == 'r' and
187 elif (c in '"\'' or c == 'r' and
188 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
188 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
189 if c == 'r':
189 if c == 'r':
190 pos += 1
190 pos += 1
191 c = program[pos]
191 c = program[pos]
192 decode = lambda x: x
192 decode = lambda x: x
193 else:
193 else:
194 decode = lambda x: x.decode('string-escape')
194 decode = lambda x: x.decode('string-escape')
195 pos += 1
195 pos += 1
196 s = pos
196 s = pos
197 while pos < l: # find closing quote
197 while pos < l: # find closing quote
198 d = program[pos]
198 d = program[pos]
199 if d == '\\': # skip over escaped characters
199 if d == '\\': # skip over escaped characters
200 pos += 2
200 pos += 2
201 continue
201 continue
202 if d == c:
202 if d == c:
203 yield ('string', decode(program[s:pos]), s)
203 yield ('string', decode(program[s:pos]), s)
204 break
204 break
205 pos += 1
205 pos += 1
206 else:
206 else:
207 raise error.ParseError(_("unterminated string"), s)
207 raise error.ParseError(_("unterminated string"), s)
208 # gather up a symbol/keyword
208 # gather up a symbol/keyword
209 elif c in syminitletters:
209 elif c in syminitletters:
210 s = pos
210 s = pos
211 pos += 1
211 pos += 1
212 while pos < l: # find end of symbol
212 while pos < l: # find end of symbol
213 d = program[pos]
213 d = program[pos]
214 if d not in symletters:
214 if d not in symletters:
215 break
215 break
216 if d == '.' and program[pos - 1] == '.': # special case for ..
216 if d == '.' and program[pos - 1] == '.': # special case for ..
217 pos -= 1
217 pos -= 1
218 break
218 break
219 pos += 1
219 pos += 1
220 sym = program[s:pos]
220 sym = program[s:pos]
221 if sym in keywords: # operator keywords
221 if sym in keywords: # operator keywords
222 yield (sym, None, s)
222 yield (sym, None, s)
223 elif '-' in sym:
223 elif '-' in sym:
224 # some jerk gave us foo-bar-baz, try to check if it's a symbol
224 # some jerk gave us foo-bar-baz, try to check if it's a symbol
225 if lookup and lookup(sym):
225 if lookup and lookup(sym):
226 # looks like a real symbol
226 # looks like a real symbol
227 yield ('symbol', sym, s)
227 yield ('symbol', sym, s)
228 else:
228 else:
229 # looks like an expression
229 # looks like an expression
230 parts = sym.split('-')
230 parts = sym.split('-')
231 for p in parts[:-1]:
231 for p in parts[:-1]:
232 if p: # possible consecutive -
232 if p: # possible consecutive -
233 yield ('symbol', p, s)
233 yield ('symbol', p, s)
234 s += len(p)
234 s += len(p)
235 yield ('-', None, pos)
235 yield ('-', None, pos)
236 s += 1
236 s += 1
237 if parts[-1]: # possible trailing -
237 if parts[-1]: # possible trailing -
238 yield ('symbol', parts[-1], s)
238 yield ('symbol', parts[-1], s)
239 else:
239 else:
240 yield ('symbol', sym, s)
240 yield ('symbol', sym, s)
241 pos -= 1
241 pos -= 1
242 else:
242 else:
243 raise error.ParseError(_("syntax error in revset '%s'") %
243 raise error.ParseError(_("syntax error in revset '%s'") %
244 program, pos)
244 program, pos)
245 pos += 1
245 pos += 1
246 yield ('end', None, pos)
246 yield ('end', None, pos)
247
247
248 def parseerrordetail(inst):
248 def parseerrordetail(inst):
249 """Compose error message from specified ParseError object
249 """Compose error message from specified ParseError object
250 """
250 """
251 if len(inst.args) > 1:
251 if len(inst.args) > 1:
252 return _('at %s: %s') % (inst.args[1], inst.args[0])
252 return _('at %s: %s') % (inst.args[1], inst.args[0])
253 else:
253 else:
254 return inst.args[0]
254 return inst.args[0]
255
255
256 # helpers
256 # helpers
257
257
258 def getstring(x, err):
258 def getstring(x, err):
259 if x and (x[0] == 'string' or x[0] == 'symbol'):
259 if x and (x[0] == 'string' or x[0] == 'symbol'):
260 return x[1]
260 return x[1]
261 raise error.ParseError(err)
261 raise error.ParseError(err)
262
262
263 def getlist(x):
263 def getlist(x):
264 if not x:
264 if not x:
265 return []
265 return []
266 if x[0] == 'list':
266 if x[0] == 'list':
267 return getlist(x[1]) + [x[2]]
267 return getlist(x[1]) + [x[2]]
268 return [x]
268 return [x]
269
269
270 def getargs(x, min, max, err):
270 def getargs(x, min, max, err):
271 l = getlist(x)
271 l = getlist(x)
272 if len(l) < min or (max >= 0 and len(l) > max):
272 if len(l) < min or (max >= 0 and len(l) > max):
273 raise error.ParseError(err)
273 raise error.ParseError(err)
274 return l
274 return l
275
275
276 def isvalidsymbol(tree):
276 def isvalidsymbol(tree):
277 """Examine whether specified ``tree`` is valid ``symbol`` or not
277 """Examine whether specified ``tree`` is valid ``symbol`` or not
278 """
278 """
279 return tree[0] == 'symbol' and len(tree) > 1
279 return tree[0] == 'symbol' and len(tree) > 1
280
280
281 def getsymbol(tree):
281 def getsymbol(tree):
282 """Get symbol name from valid ``symbol`` in ``tree``
282 """Get symbol name from valid ``symbol`` in ``tree``
283
283
284 This assumes that ``tree`` is already examined by ``isvalidsymbol``.
284 This assumes that ``tree`` is already examined by ``isvalidsymbol``.
285 """
285 """
286 return tree[1]
286 return tree[1]
287
287
288 def isvalidfunc(tree):
288 def isvalidfunc(tree):
289 """Examine whether specified ``tree`` is valid ``func`` or not
289 """Examine whether specified ``tree`` is valid ``func`` or not
290 """
290 """
291 return tree[0] == 'func' and len(tree) > 1 and isvalidsymbol(tree[1])
291 return tree[0] == 'func' and len(tree) > 1 and isvalidsymbol(tree[1])
292
292
293 def getfuncname(tree):
293 def getfuncname(tree):
294 """Get function name from valid ``func`` in ``tree``
294 """Get function name from valid ``func`` in ``tree``
295
295
296 This assumes that ``tree`` is already examined by ``isvalidfunc``.
296 This assumes that ``tree`` is already examined by ``isvalidfunc``.
297 """
297 """
298 return getsymbol(tree[1])
298 return getsymbol(tree[1])
299
299
300 def getfuncargs(tree):
300 def getfuncargs(tree):
301 """Get list of function arguments from valid ``func`` in ``tree``
301 """Get list of function arguments from valid ``func`` in ``tree``
302
302
303 This assumes that ``tree`` is already examined by ``isvalidfunc``.
303 This assumes that ``tree`` is already examined by ``isvalidfunc``.
304 """
304 """
305 if len(tree) > 2:
305 if len(tree) > 2:
306 return getlist(tree[2])
306 return getlist(tree[2])
307 else:
307 else:
308 return []
308 return []
309
309
310 def getset(repo, subset, x):
310 def getset(repo, subset, x):
311 if not x:
311 if not x:
312 raise error.ParseError(_("missing argument"))
312 raise error.ParseError(_("missing argument"))
313 s = methods[x[0]](repo, subset, *x[1:])
313 s = methods[x[0]](repo, subset, *x[1:])
314 if util.safehasattr(s, 'isascending'):
314 if util.safehasattr(s, 'isascending'):
315 return s
315 return s
316 return baseset(s)
316 return baseset(s)
317
317
318 def _getrevsource(repo, r):
318 def _getrevsource(repo, r):
319 extra = repo[r].extra()
319 extra = repo[r].extra()
320 for label in ('source', 'transplant_source', 'rebase_source'):
320 for label in ('source', 'transplant_source', 'rebase_source'):
321 if label in extra:
321 if label in extra:
322 try:
322 try:
323 return repo[extra[label]].rev()
323 return repo[extra[label]].rev()
324 except error.RepoLookupError:
324 except error.RepoLookupError:
325 pass
325 pass
326 return None
326 return None
327
327
328 # operator methods
328 # operator methods
329
329
330 def stringset(repo, subset, x):
330 def stringset(repo, subset, x):
331 x = repo[x].rev()
331 x = repo[x].rev()
332 if x in subset:
332 if (x in subset
333 or x == node.nullrev and isinstance(subset, fullreposet)):
333 return baseset([x])
334 return baseset([x])
334 return baseset()
335 return baseset()
335
336
336 def rangeset(repo, subset, x, y):
337 def rangeset(repo, subset, x, y):
337 m = getset(repo, fullreposet(repo), x)
338 m = getset(repo, fullreposet(repo), x)
338 n = getset(repo, fullreposet(repo), y)
339 n = getset(repo, fullreposet(repo), y)
339
340
340 if not m or not n:
341 if not m or not n:
341 return baseset()
342 return baseset()
342 m, n = m.first(), n.last()
343 m, n = m.first(), n.last()
343
344
344 if m < n:
345 if m < n:
345 r = spanset(repo, m, n + 1)
346 r = spanset(repo, m, n + 1)
346 else:
347 else:
347 r = spanset(repo, m, n - 1)
348 r = spanset(repo, m, n - 1)
348 return r & subset
349 return r & subset
349
350
350 def dagrange(repo, subset, x, y):
351 def dagrange(repo, subset, x, y):
351 r = fullreposet(repo)
352 r = fullreposet(repo)
352 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
353 xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
353 return xs & subset
354 return xs & subset
354
355
355 def andset(repo, subset, x, y):
356 def andset(repo, subset, x, y):
356 return getset(repo, getset(repo, subset, x), y)
357 return getset(repo, getset(repo, subset, x), y)
357
358
358 def orset(repo, subset, x, y):
359 def orset(repo, subset, x, y):
359 xl = getset(repo, subset, x)
360 xl = getset(repo, subset, x)
360 yl = getset(repo, subset, y)
361 yl = getset(repo, subset, y)
361 return xl + yl
362 return xl + yl
362
363
363 def notset(repo, subset, x):
364 def notset(repo, subset, x):
364 return subset - getset(repo, subset, x)
365 return subset - getset(repo, subset, x)
365
366
366 def listset(repo, subset, a, b):
367 def listset(repo, subset, a, b):
367 raise error.ParseError(_("can't use a list in this context"))
368 raise error.ParseError(_("can't use a list in this context"))
368
369
369 def func(repo, subset, a, b):
370 def func(repo, subset, a, b):
370 if a[0] == 'symbol' and a[1] in symbols:
371 if a[0] == 'symbol' and a[1] in symbols:
371 return symbols[a[1]](repo, subset, b)
372 return symbols[a[1]](repo, subset, b)
372 raise error.UnknownIdentifier(a[1], symbols.keys())
373 raise error.UnknownIdentifier(a[1], symbols.keys())
373
374
374 # functions
375 # functions
375
376
376 def adds(repo, subset, x):
377 def adds(repo, subset, x):
377 """``adds(pattern)``
378 """``adds(pattern)``
378 Changesets that add a file matching pattern.
379 Changesets that add a file matching pattern.
379
380
380 The pattern without explicit kind like ``glob:`` is expected to be
381 The pattern without explicit kind like ``glob:`` is expected to be
381 relative to the current directory and match against a file or a
382 relative to the current directory and match against a file or a
382 directory.
383 directory.
383 """
384 """
384 # i18n: "adds" is a keyword
385 # i18n: "adds" is a keyword
385 pat = getstring(x, _("adds requires a pattern"))
386 pat = getstring(x, _("adds requires a pattern"))
386 return checkstatus(repo, subset, pat, 1)
387 return checkstatus(repo, subset, pat, 1)
387
388
388 def ancestor(repo, subset, x):
389 def ancestor(repo, subset, x):
389 """``ancestor(*changeset)``
390 """``ancestor(*changeset)``
390 A greatest common ancestor of the changesets.
391 A greatest common ancestor of the changesets.
391
392
392 Accepts 0 or more changesets.
393 Accepts 0 or more changesets.
393 Will return empty list when passed no args.
394 Will return empty list when passed no args.
394 Greatest common ancestor of a single changeset is that changeset.
395 Greatest common ancestor of a single changeset is that changeset.
395 """
396 """
396 # i18n: "ancestor" is a keyword
397 # i18n: "ancestor" is a keyword
397 l = getlist(x)
398 l = getlist(x)
398 rl = fullreposet(repo)
399 rl = fullreposet(repo)
399 anc = None
400 anc = None
400
401
401 # (getset(repo, rl, i) for i in l) generates a list of lists
402 # (getset(repo, rl, i) for i in l) generates a list of lists
402 for revs in (getset(repo, rl, i) for i in l):
403 for revs in (getset(repo, rl, i) for i in l):
403 for r in revs:
404 for r in revs:
404 if anc is None:
405 if anc is None:
405 anc = repo[r]
406 anc = repo[r]
406 else:
407 else:
407 anc = anc.ancestor(repo[r])
408 anc = anc.ancestor(repo[r])
408
409
409 if anc is not None and anc.rev() in subset:
410 if anc is not None and anc.rev() in subset:
410 return baseset([anc.rev()])
411 return baseset([anc.rev()])
411 return baseset()
412 return baseset()
412
413
413 def _ancestors(repo, subset, x, followfirst=False):
414 def _ancestors(repo, subset, x, followfirst=False):
414 heads = getset(repo, fullreposet(repo), x)
415 heads = getset(repo, fullreposet(repo), x)
415 if not heads:
416 if not heads:
416 return baseset()
417 return baseset()
417 s = _revancestors(repo, heads, followfirst)
418 s = _revancestors(repo, heads, followfirst)
418 return subset & s
419 return subset & s
419
420
420 def ancestors(repo, subset, x):
421 def ancestors(repo, subset, x):
421 """``ancestors(set)``
422 """``ancestors(set)``
422 Changesets that are ancestors of a changeset in set.
423 Changesets that are ancestors of a changeset in set.
423 """
424 """
424 return _ancestors(repo, subset, x)
425 return _ancestors(repo, subset, x)
425
426
426 def _firstancestors(repo, subset, x):
427 def _firstancestors(repo, subset, x):
427 # ``_firstancestors(set)``
428 # ``_firstancestors(set)``
428 # Like ``ancestors(set)`` but follows only the first parents.
429 # Like ``ancestors(set)`` but follows only the first parents.
429 return _ancestors(repo, subset, x, followfirst=True)
430 return _ancestors(repo, subset, x, followfirst=True)
430
431
431 def ancestorspec(repo, subset, x, n):
432 def ancestorspec(repo, subset, x, n):
432 """``set~n``
433 """``set~n``
433 Changesets that are the Nth ancestor (first parents only) of a changeset
434 Changesets that are the Nth ancestor (first parents only) of a changeset
434 in set.
435 in set.
435 """
436 """
436 try:
437 try:
437 n = int(n[1])
438 n = int(n[1])
438 except (TypeError, ValueError):
439 except (TypeError, ValueError):
439 raise error.ParseError(_("~ expects a number"))
440 raise error.ParseError(_("~ expects a number"))
440 ps = set()
441 ps = set()
441 cl = repo.changelog
442 cl = repo.changelog
442 for r in getset(repo, fullreposet(repo), x):
443 for r in getset(repo, fullreposet(repo), x):
443 for i in range(n):
444 for i in range(n):
444 r = cl.parentrevs(r)[0]
445 r = cl.parentrevs(r)[0]
445 ps.add(r)
446 ps.add(r)
446 return subset & ps
447 return subset & ps
447
448
448 def author(repo, subset, x):
449 def author(repo, subset, x):
449 """``author(string)``
450 """``author(string)``
450 Alias for ``user(string)``.
451 Alias for ``user(string)``.
451 """
452 """
452 # i18n: "author" is a keyword
453 # i18n: "author" is a keyword
453 n = encoding.lower(getstring(x, _("author requires a string")))
454 n = encoding.lower(getstring(x, _("author requires a string")))
454 kind, pattern, matcher = _substringmatcher(n)
455 kind, pattern, matcher = _substringmatcher(n)
455 return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())))
456 return subset.filter(lambda x: matcher(encoding.lower(repo[x].user())))
456
457
457 def bisect(repo, subset, x):
458 def bisect(repo, subset, x):
458 """``bisect(string)``
459 """``bisect(string)``
459 Changesets marked in the specified bisect status:
460 Changesets marked in the specified bisect status:
460
461
461 - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip
462 - ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip
462 - ``goods``, ``bads`` : csets topologically good/bad
463 - ``goods``, ``bads`` : csets topologically good/bad
463 - ``range`` : csets taking part in the bisection
464 - ``range`` : csets taking part in the bisection
464 - ``pruned`` : csets that are goods, bads or skipped
465 - ``pruned`` : csets that are goods, bads or skipped
465 - ``untested`` : csets whose fate is yet unknown
466 - ``untested`` : csets whose fate is yet unknown
466 - ``ignored`` : csets ignored due to DAG topology
467 - ``ignored`` : csets ignored due to DAG topology
467 - ``current`` : the cset currently being bisected
468 - ``current`` : the cset currently being bisected
468 """
469 """
469 # i18n: "bisect" is a keyword
470 # i18n: "bisect" is a keyword
470 status = getstring(x, _("bisect requires a string")).lower()
471 status = getstring(x, _("bisect requires a string")).lower()
471 state = set(hbisect.get(repo, status))
472 state = set(hbisect.get(repo, status))
472 return subset & state
473 return subset & state
473
474
474 # Backward-compatibility
475 # Backward-compatibility
475 # - no help entry so that we do not advertise it any more
476 # - no help entry so that we do not advertise it any more
476 def bisected(repo, subset, x):
477 def bisected(repo, subset, x):
477 return bisect(repo, subset, x)
478 return bisect(repo, subset, x)
478
479
479 def bookmark(repo, subset, x):
480 def bookmark(repo, subset, x):
480 """``bookmark([name])``
481 """``bookmark([name])``
481 The named bookmark or all bookmarks.
482 The named bookmark or all bookmarks.
482
483
483 If `name` starts with `re:`, the remainder of the name is treated as
484 If `name` starts with `re:`, the remainder of the name is treated as
484 a regular expression. To match a bookmark that actually starts with `re:`,
485 a regular expression. To match a bookmark that actually starts with `re:`,
485 use the prefix `literal:`.
486 use the prefix `literal:`.
486 """
487 """
487 # i18n: "bookmark" is a keyword
488 # i18n: "bookmark" is a keyword
488 args = getargs(x, 0, 1, _('bookmark takes one or no arguments'))
489 args = getargs(x, 0, 1, _('bookmark takes one or no arguments'))
489 if args:
490 if args:
490 bm = getstring(args[0],
491 bm = getstring(args[0],
491 # i18n: "bookmark" is a keyword
492 # i18n: "bookmark" is a keyword
492 _('the argument to bookmark must be a string'))
493 _('the argument to bookmark must be a string'))
493 kind, pattern, matcher = _stringmatcher(bm)
494 kind, pattern, matcher = _stringmatcher(bm)
494 bms = set()
495 bms = set()
495 if kind == 'literal':
496 if kind == 'literal':
496 bmrev = repo._bookmarks.get(pattern, None)
497 bmrev = repo._bookmarks.get(pattern, None)
497 if not bmrev:
498 if not bmrev:
498 raise error.RepoLookupError(_("bookmark '%s' does not exist")
499 raise error.RepoLookupError(_("bookmark '%s' does not exist")
499 % bm)
500 % bm)
500 bms.add(repo[bmrev].rev())
501 bms.add(repo[bmrev].rev())
501 else:
502 else:
502 matchrevs = set()
503 matchrevs = set()
503 for name, bmrev in repo._bookmarks.iteritems():
504 for name, bmrev in repo._bookmarks.iteritems():
504 if matcher(name):
505 if matcher(name):
505 matchrevs.add(bmrev)
506 matchrevs.add(bmrev)
506 if not matchrevs:
507 if not matchrevs:
507 raise error.RepoLookupError(_("no bookmarks exist"
508 raise error.RepoLookupError(_("no bookmarks exist"
508 " that match '%s'") % pattern)
509 " that match '%s'") % pattern)
509 for bmrev in matchrevs:
510 for bmrev in matchrevs:
510 bms.add(repo[bmrev].rev())
511 bms.add(repo[bmrev].rev())
511 else:
512 else:
512 bms = set([repo[r].rev()
513 bms = set([repo[r].rev()
513 for r in repo._bookmarks.values()])
514 for r in repo._bookmarks.values()])
514 bms -= set([node.nullrev])
515 bms -= set([node.nullrev])
515 return subset & bms
516 return subset & bms
516
517
517 def branch(repo, subset, x):
518 def branch(repo, subset, x):
518 """``branch(string or set)``
519 """``branch(string or set)``
519 All changesets belonging to the given branch or the branches of the given
520 All changesets belonging to the given branch or the branches of the given
520 changesets.
521 changesets.
521
522
522 If `string` starts with `re:`, the remainder of the name is treated as
523 If `string` starts with `re:`, the remainder of the name is treated as
523 a regular expression. To match a branch that actually starts with `re:`,
524 a regular expression. To match a branch that actually starts with `re:`,
524 use the prefix `literal:`.
525 use the prefix `literal:`.
525 """
526 """
526 getbi = repo.revbranchcache().branchinfo
527 getbi = repo.revbranchcache().branchinfo
527
528
528 try:
529 try:
529 b = getstring(x, '')
530 b = getstring(x, '')
530 except error.ParseError:
531 except error.ParseError:
531 # not a string, but another revspec, e.g. tip()
532 # not a string, but another revspec, e.g. tip()
532 pass
533 pass
533 else:
534 else:
534 kind, pattern, matcher = _stringmatcher(b)
535 kind, pattern, matcher = _stringmatcher(b)
535 if kind == 'literal':
536 if kind == 'literal':
536 # note: falls through to the revspec case if no branch with
537 # note: falls through to the revspec case if no branch with
537 # this name exists
538 # this name exists
538 if pattern in repo.branchmap():
539 if pattern in repo.branchmap():
539 return subset.filter(lambda r: matcher(getbi(r)[0]))
540 return subset.filter(lambda r: matcher(getbi(r)[0]))
540 else:
541 else:
541 return subset.filter(lambda r: matcher(getbi(r)[0]))
542 return subset.filter(lambda r: matcher(getbi(r)[0]))
542
543
543 s = getset(repo, fullreposet(repo), x)
544 s = getset(repo, fullreposet(repo), x)
544 b = set()
545 b = set()
545 for r in s:
546 for r in s:
546 b.add(getbi(r)[0])
547 b.add(getbi(r)[0])
547 c = s.__contains__
548 c = s.__contains__
548 return subset.filter(lambda r: c(r) or getbi(r)[0] in b)
549 return subset.filter(lambda r: c(r) or getbi(r)[0] in b)
549
550
550 def bumped(repo, subset, x):
551 def bumped(repo, subset, x):
551 """``bumped()``
552 """``bumped()``
552 Mutable changesets marked as successors of public changesets.
553 Mutable changesets marked as successors of public changesets.
553
554
554 Only non-public and non-obsolete changesets can be `bumped`.
555 Only non-public and non-obsolete changesets can be `bumped`.
555 """
556 """
556 # i18n: "bumped" is a keyword
557 # i18n: "bumped" is a keyword
557 getargs(x, 0, 0, _("bumped takes no arguments"))
558 getargs(x, 0, 0, _("bumped takes no arguments"))
558 bumped = obsmod.getrevs(repo, 'bumped')
559 bumped = obsmod.getrevs(repo, 'bumped')
559 return subset & bumped
560 return subset & bumped
560
561
561 def bundle(repo, subset, x):
562 def bundle(repo, subset, x):
562 """``bundle()``
563 """``bundle()``
563 Changesets in the bundle.
564 Changesets in the bundle.
564
565
565 Bundle must be specified by the -R option."""
566 Bundle must be specified by the -R option."""
566
567
567 try:
568 try:
568 bundlerevs = repo.changelog.bundlerevs
569 bundlerevs = repo.changelog.bundlerevs
569 except AttributeError:
570 except AttributeError:
570 raise util.Abort(_("no bundle provided - specify with -R"))
571 raise util.Abort(_("no bundle provided - specify with -R"))
571 return subset & bundlerevs
572 return subset & bundlerevs
572
573
573 def checkstatus(repo, subset, pat, field):
574 def checkstatus(repo, subset, pat, field):
574 hasset = matchmod.patkind(pat) == 'set'
575 hasset = matchmod.patkind(pat) == 'set'
575
576
576 mcache = [None]
577 mcache = [None]
577 def matches(x):
578 def matches(x):
578 c = repo[x]
579 c = repo[x]
579 if not mcache[0] or hasset:
580 if not mcache[0] or hasset:
580 mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
581 mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
581 m = mcache[0]
582 m = mcache[0]
582 fname = None
583 fname = None
583 if not m.anypats() and len(m.files()) == 1:
584 if not m.anypats() and len(m.files()) == 1:
584 fname = m.files()[0]
585 fname = m.files()[0]
585 if fname is not None:
586 if fname is not None:
586 if fname not in c.files():
587 if fname not in c.files():
587 return False
588 return False
588 else:
589 else:
589 for f in c.files():
590 for f in c.files():
590 if m(f):
591 if m(f):
591 break
592 break
592 else:
593 else:
593 return False
594 return False
594 files = repo.status(c.p1().node(), c.node())[field]
595 files = repo.status(c.p1().node(), c.node())[field]
595 if fname is not None:
596 if fname is not None:
596 if fname in files:
597 if fname in files:
597 return True
598 return True
598 else:
599 else:
599 for f in files:
600 for f in files:
600 if m(f):
601 if m(f):
601 return True
602 return True
602
603
603 return subset.filter(matches)
604 return subset.filter(matches)
604
605
605 def _children(repo, narrow, parentset):
606 def _children(repo, narrow, parentset):
606 cs = set()
607 cs = set()
607 if not parentset:
608 if not parentset:
608 return baseset(cs)
609 return baseset(cs)
609 pr = repo.changelog.parentrevs
610 pr = repo.changelog.parentrevs
610 minrev = min(parentset)
611 minrev = min(parentset)
611 for r in narrow:
612 for r in narrow:
612 if r <= minrev:
613 if r <= minrev:
613 continue
614 continue
614 for p in pr(r):
615 for p in pr(r):
615 if p in parentset:
616 if p in parentset:
616 cs.add(r)
617 cs.add(r)
617 return baseset(cs)
618 return baseset(cs)
618
619
619 def children(repo, subset, x):
620 def children(repo, subset, x):
620 """``children(set)``
621 """``children(set)``
621 Child changesets of changesets in set.
622 Child changesets of changesets in set.
622 """
623 """
623 s = getset(repo, fullreposet(repo), x)
624 s = getset(repo, fullreposet(repo), x)
624 cs = _children(repo, subset, s)
625 cs = _children(repo, subset, s)
625 return subset & cs
626 return subset & cs
626
627
627 def closed(repo, subset, x):
628 def closed(repo, subset, x):
628 """``closed()``
629 """``closed()``
629 Changeset is closed.
630 Changeset is closed.
630 """
631 """
631 # i18n: "closed" is a keyword
632 # i18n: "closed" is a keyword
632 getargs(x, 0, 0, _("closed takes no arguments"))
633 getargs(x, 0, 0, _("closed takes no arguments"))
633 return subset.filter(lambda r: repo[r].closesbranch())
634 return subset.filter(lambda r: repo[r].closesbranch())
634
635
635 def contains(repo, subset, x):
636 def contains(repo, subset, x):
636 """``contains(pattern)``
637 """``contains(pattern)``
637 The revision's manifest contains a file matching pattern (but might not
638 The revision's manifest contains a file matching pattern (but might not
638 modify it). See :hg:`help patterns` for information about file patterns.
639 modify it). See :hg:`help patterns` for information about file patterns.
639
640
640 The pattern without explicit kind like ``glob:`` is expected to be
641 The pattern without explicit kind like ``glob:`` is expected to be
641 relative to the current directory and match against a file exactly
642 relative to the current directory and match against a file exactly
642 for efficiency.
643 for efficiency.
643 """
644 """
644 # i18n: "contains" is a keyword
645 # i18n: "contains" is a keyword
645 pat = getstring(x, _("contains requires a pattern"))
646 pat = getstring(x, _("contains requires a pattern"))
646
647
647 def matches(x):
648 def matches(x):
648 if not matchmod.patkind(pat):
649 if not matchmod.patkind(pat):
649 pats = pathutil.canonpath(repo.root, repo.getcwd(), pat)
650 pats = pathutil.canonpath(repo.root, repo.getcwd(), pat)
650 if pats in repo[x]:
651 if pats in repo[x]:
651 return True
652 return True
652 else:
653 else:
653 c = repo[x]
654 c = repo[x]
654 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
655 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c)
655 for f in c.manifest():
656 for f in c.manifest():
656 if m(f):
657 if m(f):
657 return True
658 return True
658 return False
659 return False
659
660
660 return subset.filter(matches)
661 return subset.filter(matches)
661
662
662 def converted(repo, subset, x):
663 def converted(repo, subset, x):
663 """``converted([id])``
664 """``converted([id])``
664 Changesets converted from the given identifier in the old repository if
665 Changesets converted from the given identifier in the old repository if
665 present, or all converted changesets if no identifier is specified.
666 present, or all converted changesets if no identifier is specified.
666 """
667 """
667
668
668 # There is exactly no chance of resolving the revision, so do a simple
669 # There is exactly no chance of resolving the revision, so do a simple
669 # string compare and hope for the best
670 # string compare and hope for the best
670
671
671 rev = None
672 rev = None
672 # i18n: "converted" is a keyword
673 # i18n: "converted" is a keyword
673 l = getargs(x, 0, 1, _('converted takes one or no arguments'))
674 l = getargs(x, 0, 1, _('converted takes one or no arguments'))
674 if l:
675 if l:
675 # i18n: "converted" is a keyword
676 # i18n: "converted" is a keyword
676 rev = getstring(l[0], _('converted requires a revision'))
677 rev = getstring(l[0], _('converted requires a revision'))
677
678
678 def _matchvalue(r):
679 def _matchvalue(r):
679 source = repo[r].extra().get('convert_revision', None)
680 source = repo[r].extra().get('convert_revision', None)
680 return source is not None and (rev is None or source.startswith(rev))
681 return source is not None and (rev is None or source.startswith(rev))
681
682
682 return subset.filter(lambda r: _matchvalue(r))
683 return subset.filter(lambda r: _matchvalue(r))
683
684
684 def date(repo, subset, x):
685 def date(repo, subset, x):
685 """``date(interval)``
686 """``date(interval)``
686 Changesets within the interval, see :hg:`help dates`.
687 Changesets within the interval, see :hg:`help dates`.
687 """
688 """
688 # i18n: "date" is a keyword
689 # i18n: "date" is a keyword
689 ds = getstring(x, _("date requires a string"))
690 ds = getstring(x, _("date requires a string"))
690 dm = util.matchdate(ds)
691 dm = util.matchdate(ds)
691 return subset.filter(lambda x: dm(repo[x].date()[0]))
692 return subset.filter(lambda x: dm(repo[x].date()[0]))
692
693
693 def desc(repo, subset, x):
694 def desc(repo, subset, x):
694 """``desc(string)``
695 """``desc(string)``
695 Search commit message for string. The match is case-insensitive.
696 Search commit message for string. The match is case-insensitive.
696 """
697 """
697 # i18n: "desc" is a keyword
698 # i18n: "desc" is a keyword
698 ds = encoding.lower(getstring(x, _("desc requires a string")))
699 ds = encoding.lower(getstring(x, _("desc requires a string")))
699
700
700 def matches(x):
701 def matches(x):
701 c = repo[x]
702 c = repo[x]
702 return ds in encoding.lower(c.description())
703 return ds in encoding.lower(c.description())
703
704
704 return subset.filter(matches)
705 return subset.filter(matches)
705
706
706 def _descendants(repo, subset, x, followfirst=False):
707 def _descendants(repo, subset, x, followfirst=False):
707 roots = getset(repo, fullreposet(repo), x)
708 roots = getset(repo, fullreposet(repo), x)
708 if not roots:
709 if not roots:
709 return baseset()
710 return baseset()
710 s = _revdescendants(repo, roots, followfirst)
711 s = _revdescendants(repo, roots, followfirst)
711
712
712 # Both sets need to be ascending in order to lazily return the union
713 # Both sets need to be ascending in order to lazily return the union
713 # in the correct order.
714 # in the correct order.
714 base = subset & roots
715 base = subset & roots
715 desc = subset & s
716 desc = subset & s
716 result = base + desc
717 result = base + desc
717 if subset.isascending():
718 if subset.isascending():
718 result.sort()
719 result.sort()
719 elif subset.isdescending():
720 elif subset.isdescending():
720 result.sort(reverse=True)
721 result.sort(reverse=True)
721 else:
722 else:
722 result = subset & result
723 result = subset & result
723 return result
724 return result
724
725
725 def descendants(repo, subset, x):
726 def descendants(repo, subset, x):
726 """``descendants(set)``
727 """``descendants(set)``
727 Changesets which are descendants of changesets in set.
728 Changesets which are descendants of changesets in set.
728 """
729 """
729 return _descendants(repo, subset, x)
730 return _descendants(repo, subset, x)
730
731
731 def _firstdescendants(repo, subset, x):
732 def _firstdescendants(repo, subset, x):
732 # ``_firstdescendants(set)``
733 # ``_firstdescendants(set)``
733 # Like ``descendants(set)`` but follows only the first parents.
734 # Like ``descendants(set)`` but follows only the first parents.
734 return _descendants(repo, subset, x, followfirst=True)
735 return _descendants(repo, subset, x, followfirst=True)
735
736
736 def destination(repo, subset, x):
737 def destination(repo, subset, x):
737 """``destination([set])``
738 """``destination([set])``
738 Changesets that were created by a graft, transplant or rebase operation,
739 Changesets that were created by a graft, transplant or rebase operation,
739 with the given revisions specified as the source. Omitting the optional set
740 with the given revisions specified as the source. Omitting the optional set
740 is the same as passing all().
741 is the same as passing all().
741 """
742 """
742 if x is not None:
743 if x is not None:
743 sources = getset(repo, fullreposet(repo), x)
744 sources = getset(repo, fullreposet(repo), x)
744 else:
745 else:
745 sources = fullreposet(repo)
746 sources = fullreposet(repo)
746
747
747 dests = set()
748 dests = set()
748
749
749 # subset contains all of the possible destinations that can be returned, so
750 # subset contains all of the possible destinations that can be returned, so
750 # iterate over them and see if their source(s) were provided in the arg set.
751 # iterate over them and see if their source(s) were provided in the arg set.
751 # Even if the immediate src of r is not in the arg set, src's source (or
752 # Even if the immediate src of r is not in the arg set, src's source (or
752 # further back) may be. Scanning back further than the immediate src allows
753 # further back) may be. Scanning back further than the immediate src allows
753 # transitive transplants and rebases to yield the same results as transitive
754 # transitive transplants and rebases to yield the same results as transitive
754 # grafts.
755 # grafts.
755 for r in subset:
756 for r in subset:
756 src = _getrevsource(repo, r)
757 src = _getrevsource(repo, r)
757 lineage = None
758 lineage = None
758
759
759 while src is not None:
760 while src is not None:
760 if lineage is None:
761 if lineage is None:
761 lineage = list()
762 lineage = list()
762
763
763 lineage.append(r)
764 lineage.append(r)
764
765
765 # The visited lineage is a match if the current source is in the arg
766 # The visited lineage is a match if the current source is in the arg
766 # set. Since every candidate dest is visited by way of iterating
767 # set. Since every candidate dest is visited by way of iterating
767 # subset, any dests further back in the lineage will be tested by a
768 # subset, any dests further back in the lineage will be tested by a
768 # different iteration over subset. Likewise, if the src was already
769 # different iteration over subset. Likewise, if the src was already
769 # selected, the current lineage can be selected without going back
770 # selected, the current lineage can be selected without going back
770 # further.
771 # further.
771 if src in sources or src in dests:
772 if src in sources or src in dests:
772 dests.update(lineage)
773 dests.update(lineage)
773 break
774 break
774
775
775 r = src
776 r = src
776 src = _getrevsource(repo, r)
777 src = _getrevsource(repo, r)
777
778
778 return subset.filter(dests.__contains__)
779 return subset.filter(dests.__contains__)
779
780
780 def divergent(repo, subset, x):
781 def divergent(repo, subset, x):
781 """``divergent()``
782 """``divergent()``
782 Final successors of changesets with an alternative set of final successors.
783 Final successors of changesets with an alternative set of final successors.
783 """
784 """
784 # i18n: "divergent" is a keyword
785 # i18n: "divergent" is a keyword
785 getargs(x, 0, 0, _("divergent takes no arguments"))
786 getargs(x, 0, 0, _("divergent takes no arguments"))
786 divergent = obsmod.getrevs(repo, 'divergent')
787 divergent = obsmod.getrevs(repo, 'divergent')
787 return subset & divergent
788 return subset & divergent
788
789
789 def draft(repo, subset, x):
790 def draft(repo, subset, x):
790 """``draft()``
791 """``draft()``
791 Changeset in draft phase."""
792 Changeset in draft phase."""
792 # i18n: "draft" is a keyword
793 # i18n: "draft" is a keyword
793 getargs(x, 0, 0, _("draft takes no arguments"))
794 getargs(x, 0, 0, _("draft takes no arguments"))
794 phase = repo._phasecache.phase
795 phase = repo._phasecache.phase
795 target = phases.draft
796 target = phases.draft
796 condition = lambda r: phase(repo, r) == target
797 condition = lambda r: phase(repo, r) == target
797 return subset.filter(condition, cache=False)
798 return subset.filter(condition, cache=False)
798
799
799 def extinct(repo, subset, x):
800 def extinct(repo, subset, x):
800 """``extinct()``
801 """``extinct()``
801 Obsolete changesets with obsolete descendants only.
802 Obsolete changesets with obsolete descendants only.
802 """
803 """
803 # i18n: "extinct" is a keyword
804 # i18n: "extinct" is a keyword
804 getargs(x, 0, 0, _("extinct takes no arguments"))
805 getargs(x, 0, 0, _("extinct takes no arguments"))
805 extincts = obsmod.getrevs(repo, 'extinct')
806 extincts = obsmod.getrevs(repo, 'extinct')
806 return subset & extincts
807 return subset & extincts
807
808
808 def extra(repo, subset, x):
809 def extra(repo, subset, x):
809 """``extra(label, [value])``
810 """``extra(label, [value])``
810 Changesets with the given label in the extra metadata, with the given
811 Changesets with the given label in the extra metadata, with the given
811 optional value.
812 optional value.
812
813
813 If `value` starts with `re:`, the remainder of the value is treated as
814 If `value` starts with `re:`, the remainder of the value is treated as
814 a regular expression. To match a value that actually starts with `re:`,
815 a regular expression. To match a value that actually starts with `re:`,
815 use the prefix `literal:`.
816 use the prefix `literal:`.
816 """
817 """
817
818
818 # i18n: "extra" is a keyword
819 # i18n: "extra" is a keyword
819 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments'))
820 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments'))
820 # i18n: "extra" is a keyword
821 # i18n: "extra" is a keyword
821 label = getstring(l[0], _('first argument to extra must be a string'))
822 label = getstring(l[0], _('first argument to extra must be a string'))
822 value = None
823 value = None
823
824
824 if len(l) > 1:
825 if len(l) > 1:
825 # i18n: "extra" is a keyword
826 # i18n: "extra" is a keyword
826 value = getstring(l[1], _('second argument to extra must be a string'))
827 value = getstring(l[1], _('second argument to extra must be a string'))
827 kind, value, matcher = _stringmatcher(value)
828 kind, value, matcher = _stringmatcher(value)
828
829
829 def _matchvalue(r):
830 def _matchvalue(r):
830 extra = repo[r].extra()
831 extra = repo[r].extra()
831 return label in extra and (value is None or matcher(extra[label]))
832 return label in extra and (value is None or matcher(extra[label]))
832
833
833 return subset.filter(lambda r: _matchvalue(r))
834 return subset.filter(lambda r: _matchvalue(r))
834
835
835 def filelog(repo, subset, x):
836 def filelog(repo, subset, x):
836 """``filelog(pattern)``
837 """``filelog(pattern)``
837 Changesets connected to the specified filelog.
838 Changesets connected to the specified filelog.
838
839
839 For performance reasons, visits only revisions mentioned in the file-level
840 For performance reasons, visits only revisions mentioned in the file-level
840 filelog, rather than filtering through all changesets (much faster, but
841 filelog, rather than filtering through all changesets (much faster, but
841 doesn't include deletes or duplicate changes). For a slower, more accurate
842 doesn't include deletes or duplicate changes). For a slower, more accurate
842 result, use ``file()``.
843 result, use ``file()``.
843
844
844 The pattern without explicit kind like ``glob:`` is expected to be
845 The pattern without explicit kind like ``glob:`` is expected to be
845 relative to the current directory and match against a file exactly
846 relative to the current directory and match against a file exactly
846 for efficiency.
847 for efficiency.
847
848
848 If some linkrev points to revisions filtered by the current repoview, we'll
849 If some linkrev points to revisions filtered by the current repoview, we'll
849 work around it to return a non-filtered value.
850 work around it to return a non-filtered value.
850 """
851 """
851
852
852 # i18n: "filelog" is a keyword
853 # i18n: "filelog" is a keyword
853 pat = getstring(x, _("filelog requires a pattern"))
854 pat = getstring(x, _("filelog requires a pattern"))
854 s = set()
855 s = set()
855 cl = repo.changelog
856 cl = repo.changelog
856
857
857 if not matchmod.patkind(pat):
858 if not matchmod.patkind(pat):
858 f = pathutil.canonpath(repo.root, repo.getcwd(), pat)
859 f = pathutil.canonpath(repo.root, repo.getcwd(), pat)
859 files = [f]
860 files = [f]
860 else:
861 else:
861 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None])
862 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None])
862 files = (f for f in repo[None] if m(f))
863 files = (f for f in repo[None] if m(f))
863
864
864 for f in files:
865 for f in files:
865 backrevref = {} # final value for: filerev -> changerev
866 backrevref = {} # final value for: filerev -> changerev
866 lowestchild = {} # lowest known filerev child of a filerev
867 lowestchild = {} # lowest known filerev child of a filerev
867 delayed = [] # filerev with filtered linkrev, for post-processing
868 delayed = [] # filerev with filtered linkrev, for post-processing
868 lowesthead = None # cache for manifest content of all head revisions
869 lowesthead = None # cache for manifest content of all head revisions
869 fl = repo.file(f)
870 fl = repo.file(f)
870 for fr in list(fl):
871 for fr in list(fl):
871 rev = fl.linkrev(fr)
872 rev = fl.linkrev(fr)
872 if rev not in cl:
873 if rev not in cl:
873 # changerev pointed in linkrev is filtered
874 # changerev pointed in linkrev is filtered
874 # record it for post processing.
875 # record it for post processing.
875 delayed.append((fr, rev))
876 delayed.append((fr, rev))
876 continue
877 continue
877 for p in fl.parentrevs(fr):
878 for p in fl.parentrevs(fr):
878 if 0 <= p and p not in lowestchild:
879 if 0 <= p and p not in lowestchild:
879 lowestchild[p] = fr
880 lowestchild[p] = fr
880 backrevref[fr] = rev
881 backrevref[fr] = rev
881 s.add(rev)
882 s.add(rev)
882
883
883 # Post-processing of all filerevs we skipped because they were
884 # Post-processing of all filerevs we skipped because they were
884 # filtered. If such filerevs have known and unfiltered children, this
885 # filtered. If such filerevs have known and unfiltered children, this
885 # means they have an unfiltered appearance out there. We'll use linkrev
886 # means they have an unfiltered appearance out there. We'll use linkrev
886 # adjustment to find one of these appearances. The lowest known child
887 # adjustment to find one of these appearances. The lowest known child
887 # will be used as a starting point because it is the best upper-bound we
888 # will be used as a starting point because it is the best upper-bound we
888 # have.
889 # have.
889 #
890 #
890 # This approach will fail when an unfiltered but linkrev-shadowed
891 # This approach will fail when an unfiltered but linkrev-shadowed
891 # appearance exists in a head changeset without unfiltered filerev
892 # appearance exists in a head changeset without unfiltered filerev
892 # children anywhere.
893 # children anywhere.
893 while delayed:
894 while delayed:
894 # must be a descending iteration. To slowly fill lowest child
895 # must be a descending iteration. To slowly fill lowest child
895 # information that is of potential use by the next item.
896 # information that is of potential use by the next item.
896 fr, rev = delayed.pop()
897 fr, rev = delayed.pop()
897 lkr = rev
898 lkr = rev
898
899
899 child = lowestchild.get(fr)
900 child = lowestchild.get(fr)
900
901
901 if child is None:
902 if child is None:
902 # search for existence of this file revision in a head revision.
903 # search for existence of this file revision in a head revision.
903 # There are three possibilities:
904 # There are three possibilities:
904 # - the revision exists in a head and we can find an
905 # - the revision exists in a head and we can find an
905 # introduction from there,
906 # introduction from there,
906 # - the revision does not exist in a head because it has been
907 # - the revision does not exist in a head because it has been
907 # changed since its introduction: we would have found a child
908 # changed since its introduction: we would have found a child
908 # and be in the other 'else' clause,
909 # and be in the other 'else' clause,
909 # - all versions of the revision are hidden.
910 # - all versions of the revision are hidden.
910 if lowesthead is None:
911 if lowesthead is None:
911 lowesthead = {}
912 lowesthead = {}
912 for h in repo.heads():
913 for h in repo.heads():
913 fnode = repo[h].manifest().get(f)
914 fnode = repo[h].manifest().get(f)
914 if fnode is not None:
915 if fnode is not None:
915 lowesthead[fl.rev(fnode)] = h
916 lowesthead[fl.rev(fnode)] = h
916 headrev = lowesthead.get(fr)
917 headrev = lowesthead.get(fr)
917 if headrev is None:
918 if headrev is None:
918 # content is nowhere unfiltered
919 # content is nowhere unfiltered
919 continue
920 continue
920 rev = repo[headrev][f].introrev()
921 rev = repo[headrev][f].introrev()
921 else:
922 else:
922 # the lowest known child is a good upper bound
923 # the lowest known child is a good upper bound
923 childcrev = backrevref[child]
924 childcrev = backrevref[child]
924 # XXX this does not guarantee returning the lowest
925 # XXX this does not guarantee returning the lowest
925 # introduction of this revision, but this gives a
926 # introduction of this revision, but this gives a
926 # result which is a good start and will fit in most
927 # result which is a good start and will fit in most
927 # cases. We probably need to fix the multiple
928 # cases. We probably need to fix the multiple
928 # introductions case properly (report each
929 # introductions case properly (report each
929 # introduction, even for identical file revisions)
930 # introduction, even for identical file revisions)
930 # once and for all at some point anyway.
931 # once and for all at some point anyway.
931 for p in repo[childcrev][f].parents():
932 for p in repo[childcrev][f].parents():
932 if p.filerev() == fr:
933 if p.filerev() == fr:
933 rev = p.rev()
934 rev = p.rev()
934 break
935 break
935 if rev == lkr: # no shadowed entry found
936 if rev == lkr: # no shadowed entry found
936 # XXX This should never happen unless some manifest points
937 # XXX This should never happen unless some manifest points
937 # to biggish file revisions (like a revision that uses a
938 # to biggish file revisions (like a revision that uses a
938 # parent that never appears in the manifest ancestors)
939 # parent that never appears in the manifest ancestors)
939 continue
940 continue
940
941
941 # Fill the data for the next iteration.
942 # Fill the data for the next iteration.
942 for p in fl.parentrevs(fr):
943 for p in fl.parentrevs(fr):
943 if 0 <= p and p not in lowestchild:
944 if 0 <= p and p not in lowestchild:
944 lowestchild[p] = fr
945 lowestchild[p] = fr
945 backrevref[fr] = rev
946 backrevref[fr] = rev
946 s.add(rev)
947 s.add(rev)
947
948
948 return subset & s
949 return subset & s
949
950
950 def first(repo, subset, x):
951 def first(repo, subset, x):
951 """``first(set, [n])``
952 """``first(set, [n])``
952 An alias for limit().
953 An alias for limit().
953 """
954 """
954 return limit(repo, subset, x)
955 return limit(repo, subset, x)
955
956
956 def _follow(repo, subset, x, name, followfirst=False):
957 def _follow(repo, subset, x, name, followfirst=False):
957 l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name)
958 l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name)
958 c = repo['.']
959 c = repo['.']
959 if l:
960 if l:
960 x = getstring(l[0], _("%s expected a filename") % name)
961 x = getstring(l[0], _("%s expected a filename") % name)
961 if x in c:
962 if x in c:
962 cx = c[x]
963 cx = c[x]
963 s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst))
964 s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst))
964 # include the revision responsible for the most recent version
965 # include the revision responsible for the most recent version
965 s.add(cx.introrev())
966 s.add(cx.introrev())
966 else:
967 else:
967 return baseset()
968 return baseset()
968 else:
969 else:
969 s = _revancestors(repo, baseset([c.rev()]), followfirst)
970 s = _revancestors(repo, baseset([c.rev()]), followfirst)
970
971
971 return subset & s
972 return subset & s
972
973
973 def follow(repo, subset, x):
974 def follow(repo, subset, x):
974 """``follow([file])``
975 """``follow([file])``
975 An alias for ``::.`` (ancestors of the working directory's first parent).
976 An alias for ``::.`` (ancestors of the working directory's first parent).
976 If a filename is specified, the history of the given file is followed,
977 If a filename is specified, the history of the given file is followed,
977 including copies.
978 including copies.
978 """
979 """
979 return _follow(repo, subset, x, 'follow')
980 return _follow(repo, subset, x, 'follow')
980
981
981 def _followfirst(repo, subset, x):
982 def _followfirst(repo, subset, x):
982 # ``followfirst([file])``
983 # ``followfirst([file])``
983 # Like ``follow([file])`` but follows only the first parent of
984 # Like ``follow([file])`` but follows only the first parent of
984 # every revision or file revision.
985 # every revision or file revision.
985 return _follow(repo, subset, x, '_followfirst', followfirst=True)
986 return _follow(repo, subset, x, '_followfirst', followfirst=True)
986
987
987 def getall(repo, subset, x):
988 def getall(repo, subset, x):
988 """``all()``
989 """``all()``
989 All changesets, the same as ``0:tip``.
990 All changesets, the same as ``0:tip``.
990 """
991 """
991 # i18n: "all" is a keyword
992 # i18n: "all" is a keyword
992 getargs(x, 0, 0, _("all takes no arguments"))
993 getargs(x, 0, 0, _("all takes no arguments"))
993 return subset & spanset(repo) # drop "null" if any
994 return subset & spanset(repo) # drop "null" if any
994
995
995 def grep(repo, subset, x):
996 def grep(repo, subset, x):
996 """``grep(regex)``
997 """``grep(regex)``
997 Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')``
998 Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')``
998 to ensure special escape characters are handled correctly. Unlike
999 to ensure special escape characters are handled correctly. Unlike
999 ``keyword(string)``, the match is case-sensitive.
1000 ``keyword(string)``, the match is case-sensitive.
1000 """
1001 """
1001 try:
1002 try:
1002 # i18n: "grep" is a keyword
1003 # i18n: "grep" is a keyword
1003 gr = re.compile(getstring(x, _("grep requires a string")))
1004 gr = re.compile(getstring(x, _("grep requires a string")))
1004 except re.error, e:
1005 except re.error, e:
1005 raise error.ParseError(_('invalid match pattern: %s') % e)
1006 raise error.ParseError(_('invalid match pattern: %s') % e)
1006
1007
1007 def matches(x):
1008 def matches(x):
1008 c = repo[x]
1009 c = repo[x]
1009 for e in c.files() + [c.user(), c.description()]:
1010 for e in c.files() + [c.user(), c.description()]:
1010 if gr.search(e):
1011 if gr.search(e):
1011 return True
1012 return True
1012 return False
1013 return False
1013
1014
1014 return subset.filter(matches)
1015 return subset.filter(matches)
1015
1016
1016 def _matchfiles(repo, subset, x):
1017 def _matchfiles(repo, subset, x):
1017 # _matchfiles takes a revset list of prefixed arguments:
1018 # _matchfiles takes a revset list of prefixed arguments:
1018 #
1019 #
1019 # [p:foo, i:bar, x:baz]
1020 # [p:foo, i:bar, x:baz]
1020 #
1021 #
1021 # builds a match object from them and filters subset. Allowed
1022 # builds a match object from them and filters subset. Allowed
1022 # prefixes are 'p:' for regular patterns, 'i:' for include
1023 # prefixes are 'p:' for regular patterns, 'i:' for include
1023 # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass
1024 # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass
1024 # a revision identifier, or the empty string to reference the
1025 # a revision identifier, or the empty string to reference the
1025 # working directory, from which the match object is
1026 # working directory, from which the match object is
1026 # initialized. Use 'd:' to set the default matching mode, default
1027 # initialized. Use 'd:' to set the default matching mode, default
1027 # to 'glob'. At most one 'r:' and 'd:' argument can be passed.
1028 # to 'glob'. At most one 'r:' and 'd:' argument can be passed.
1028
1029
1029 # i18n: "_matchfiles" is a keyword
1030 # i18n: "_matchfiles" is a keyword
1030 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
1031 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
1031 pats, inc, exc = [], [], []
1032 pats, inc, exc = [], [], []
1032 rev, default = None, None
1033 rev, default = None, None
1033 for arg in l:
1034 for arg in l:
1034 # i18n: "_matchfiles" is a keyword
1035 # i18n: "_matchfiles" is a keyword
1035 s = getstring(arg, _("_matchfiles requires string arguments"))
1036 s = getstring(arg, _("_matchfiles requires string arguments"))
1036 prefix, value = s[:2], s[2:]
1037 prefix, value = s[:2], s[2:]
1037 if prefix == 'p:':
1038 if prefix == 'p:':
1038 pats.append(value)
1039 pats.append(value)
1039 elif prefix == 'i:':
1040 elif prefix == 'i:':
1040 inc.append(value)
1041 inc.append(value)
1041 elif prefix == 'x:':
1042 elif prefix == 'x:':
1042 exc.append(value)
1043 exc.append(value)
1043 elif prefix == 'r:':
1044 elif prefix == 'r:':
1044 if rev is not None:
1045 if rev is not None:
1045 # i18n: "_matchfiles" is a keyword
1046 # i18n: "_matchfiles" is a keyword
1046 raise error.ParseError(_('_matchfiles expected at most one '
1047 raise error.ParseError(_('_matchfiles expected at most one '
1047 'revision'))
1048 'revision'))
1048 if value != '': # empty means working directory; leave rev as None
1049 if value != '': # empty means working directory; leave rev as None
1049 rev = value
1050 rev = value
1050 elif prefix == 'd:':
1051 elif prefix == 'd:':
1051 if default is not None:
1052 if default is not None:
1052 # i18n: "_matchfiles" is a keyword
1053 # i18n: "_matchfiles" is a keyword
1053 raise error.ParseError(_('_matchfiles expected at most one '
1054 raise error.ParseError(_('_matchfiles expected at most one '
1054 'default mode'))
1055 'default mode'))
1055 default = value
1056 default = value
1056 else:
1057 else:
1057 # i18n: "_matchfiles" is a keyword
1058 # i18n: "_matchfiles" is a keyword
1058 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
1059 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
1059 if not default:
1060 if not default:
1060 default = 'glob'
1061 default = 'glob'
1061
1062
1062 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
1063 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
1063 exclude=exc, ctx=repo[rev], default=default)
1064 exclude=exc, ctx=repo[rev], default=default)
1064
1065
1065 def matches(x):
1066 def matches(x):
1066 for f in repo[x].files():
1067 for f in repo[x].files():
1067 if m(f):
1068 if m(f):
1068 return True
1069 return True
1069 return False
1070 return False
1070
1071
1071 return subset.filter(matches)
1072 return subset.filter(matches)
1072
1073
1073 def hasfile(repo, subset, x):
1074 def hasfile(repo, subset, x):
1074 """``file(pattern)``
1075 """``file(pattern)``
1075 Changesets affecting files matched by pattern.
1076 Changesets affecting files matched by pattern.
1076
1077
1077 For a faster but less accurate result, consider using ``filelog()``
1078 For a faster but less accurate result, consider using ``filelog()``
1078 instead.
1079 instead.
1079
1080
1080 This predicate uses ``glob:`` as the default kind of pattern.
1081 This predicate uses ``glob:`` as the default kind of pattern.
1081 """
1082 """
1082 # i18n: "file" is a keyword
1083 # i18n: "file" is a keyword
1083 pat = getstring(x, _("file requires a pattern"))
1084 pat = getstring(x, _("file requires a pattern"))
1084 return _matchfiles(repo, subset, ('string', 'p:' + pat))
1085 return _matchfiles(repo, subset, ('string', 'p:' + pat))
1085
1086
1086 def head(repo, subset, x):
1087 def head(repo, subset, x):
1087 """``head()``
1088 """``head()``
1088 Changeset is a named branch head.
1089 Changeset is a named branch head.
1089 """
1090 """
1090 # i18n: "head" is a keyword
1091 # i18n: "head" is a keyword
1091 getargs(x, 0, 0, _("head takes no arguments"))
1092 getargs(x, 0, 0, _("head takes no arguments"))
1092 hs = set()
1093 hs = set()
1093 for b, ls in repo.branchmap().iteritems():
1094 for b, ls in repo.branchmap().iteritems():
1094 hs.update(repo[h].rev() for h in ls)
1095 hs.update(repo[h].rev() for h in ls)
1095 return baseset(hs).filter(subset.__contains__)
1096 return baseset(hs).filter(subset.__contains__)
1096
1097
1097 def heads(repo, subset, x):
1098 def heads(repo, subset, x):
1098 """``heads(set)``
1099 """``heads(set)``
1099 Members of set with no children in set.
1100 Members of set with no children in set.
1100 """
1101 """
1101 s = getset(repo, subset, x)
1102 s = getset(repo, subset, x)
1102 ps = parents(repo, subset, x)
1103 ps = parents(repo, subset, x)
1103 return s - ps
1104 return s - ps
1104
1105
1105 def hidden(repo, subset, x):
1106 def hidden(repo, subset, x):
1106 """``hidden()``
1107 """``hidden()``
1107 Hidden changesets.
1108 Hidden changesets.
1108 """
1109 """
1109 # i18n: "hidden" is a keyword
1110 # i18n: "hidden" is a keyword
1110 getargs(x, 0, 0, _("hidden takes no arguments"))
1111 getargs(x, 0, 0, _("hidden takes no arguments"))
1111 hiddenrevs = repoview.filterrevs(repo, 'visible')
1112 hiddenrevs = repoview.filterrevs(repo, 'visible')
1112 return subset & hiddenrevs
1113 return subset & hiddenrevs
1113
1114
1114 def keyword(repo, subset, x):
1115 def keyword(repo, subset, x):
1115 """``keyword(string)``
1116 """``keyword(string)``
1116 Search commit message, user name, and names of changed files for
1117 Search commit message, user name, and names of changed files for
1117 string. The match is case-insensitive.
1118 string. The match is case-insensitive.
1118 """
1119 """
1119 # i18n: "keyword" is a keyword
1120 # i18n: "keyword" is a keyword
1120 kw = encoding.lower(getstring(x, _("keyword requires a string")))
1121 kw = encoding.lower(getstring(x, _("keyword requires a string")))
1121
1122
1122 def matches(r):
1123 def matches(r):
1123 c = repo[r]
1124 c = repo[r]
1124 return any(kw in encoding.lower(t) for t in c.files() + [c.user(),
1125 return any(kw in encoding.lower(t) for t in c.files() + [c.user(),
1125 c.description()])
1126 c.description()])
1126
1127
1127 return subset.filter(matches)
1128 return subset.filter(matches)
1128
1129
1129 def limit(repo, subset, x):
1130 def limit(repo, subset, x):
1130 """``limit(set, [n])``
1131 """``limit(set, [n])``
1131 First n members of set, defaulting to 1.
1132 First n members of set, defaulting to 1.
1132 """
1133 """
1133 # i18n: "limit" is a keyword
1134 # i18n: "limit" is a keyword
1134 l = getargs(x, 1, 2, _("limit requires one or two arguments"))
1135 l = getargs(x, 1, 2, _("limit requires one or two arguments"))
1135 try:
1136 try:
1136 lim = 1
1137 lim = 1
1137 if len(l) == 2:
1138 if len(l) == 2:
1138 # i18n: "limit" is a keyword
1139 # i18n: "limit" is a keyword
1139 lim = int(getstring(l[1], _("limit requires a number")))
1140 lim = int(getstring(l[1], _("limit requires a number")))
1140 except (TypeError, ValueError):
1141 except (TypeError, ValueError):
1141 # i18n: "limit" is a keyword
1142 # i18n: "limit" is a keyword
1142 raise error.ParseError(_("limit expects a number"))
1143 raise error.ParseError(_("limit expects a number"))
1143 ss = subset
1144 ss = subset
1144 os = getset(repo, fullreposet(repo), l[0])
1145 os = getset(repo, fullreposet(repo), l[0])
1145 result = []
1146 result = []
1146 it = iter(os)
1147 it = iter(os)
1147 for x in xrange(lim):
1148 for x in xrange(lim):
1148 y = next(it, None)
1149 y = next(it, None)
1149 if y is None:
1150 if y is None:
1150 break
1151 break
1151 elif y in ss:
1152 elif y in ss:
1152 result.append(y)
1153 result.append(y)
1153 return baseset(result)
1154 return baseset(result)
1154
1155
1155 def last(repo, subset, x):
1156 def last(repo, subset, x):
1156 """``last(set, [n])``
1157 """``last(set, [n])``
1157 Last n members of set, defaulting to 1.
1158 Last n members of set, defaulting to 1.
1158 """
1159 """
1159 # i18n: "last" is a keyword
1160 # i18n: "last" is a keyword
1160 l = getargs(x, 1, 2, _("last requires one or two arguments"))
1161 l = getargs(x, 1, 2, _("last requires one or two arguments"))
1161 try:
1162 try:
1162 lim = 1
1163 lim = 1
1163 if len(l) == 2:
1164 if len(l) == 2:
1164 # i18n: "last" is a keyword
1165 # i18n: "last" is a keyword
1165 lim = int(getstring(l[1], _("last requires a number")))
1166 lim = int(getstring(l[1], _("last requires a number")))
1166 except (TypeError, ValueError):
1167 except (TypeError, ValueError):
1167 # i18n: "last" is a keyword
1168 # i18n: "last" is a keyword
1168 raise error.ParseError(_("last expects a number"))
1169 raise error.ParseError(_("last expects a number"))
1169 ss = subset
1170 ss = subset
1170 os = getset(repo, fullreposet(repo), l[0])
1171 os = getset(repo, fullreposet(repo), l[0])
1171 os.reverse()
1172 os.reverse()
1172 result = []
1173 result = []
1173 it = iter(os)
1174 it = iter(os)
1174 for x in xrange(lim):
1175 for x in xrange(lim):
1175 y = next(it, None)
1176 y = next(it, None)
1176 if y is None:
1177 if y is None:
1177 break
1178 break
1178 elif y in ss:
1179 elif y in ss:
1179 result.append(y)
1180 result.append(y)
1180 return baseset(result)
1181 return baseset(result)
1181
1182
1182 def maxrev(repo, subset, x):
1183 def maxrev(repo, subset, x):
1183 """``max(set)``
1184 """``max(set)``
1184 Changeset with highest revision number in set.
1185 Changeset with highest revision number in set.
1185 """
1186 """
1186 os = getset(repo, fullreposet(repo), x)
1187 os = getset(repo, fullreposet(repo), x)
1187 if os:
1188 if os:
1188 m = os.max()
1189 m = os.max()
1189 if m in subset:
1190 if m in subset:
1190 return baseset([m])
1191 return baseset([m])
1191 return baseset()
1192 return baseset()
1192
1193
1193 def merge(repo, subset, x):
1194 def merge(repo, subset, x):
1194 """``merge()``
1195 """``merge()``
1195 Changeset is a merge changeset.
1196 Changeset is a merge changeset.
1196 """
1197 """
1197 # i18n: "merge" is a keyword
1198 # i18n: "merge" is a keyword
1198 getargs(x, 0, 0, _("merge takes no arguments"))
1199 getargs(x, 0, 0, _("merge takes no arguments"))
1199 cl = repo.changelog
1200 cl = repo.changelog
1200 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1)
1201 return subset.filter(lambda r: cl.parentrevs(r)[1] != -1)
1201
1202
1202 def branchpoint(repo, subset, x):
1203 def branchpoint(repo, subset, x):
1203 """``branchpoint()``
1204 """``branchpoint()``
1204 Changesets with more than one child.
1205 Changesets with more than one child.
1205 """
1206 """
1206 # i18n: "branchpoint" is a keyword
1207 # i18n: "branchpoint" is a keyword
1207 getargs(x, 0, 0, _("branchpoint takes no arguments"))
1208 getargs(x, 0, 0, _("branchpoint takes no arguments"))
1208 cl = repo.changelog
1209 cl = repo.changelog
1209 if not subset:
1210 if not subset:
1210 return baseset()
1211 return baseset()
1211 baserev = min(subset)
1212 baserev = min(subset)
1212 parentscount = [0]*(len(repo) - baserev)
1213 parentscount = [0]*(len(repo) - baserev)
1213 for r in cl.revs(start=baserev + 1):
1214 for r in cl.revs(start=baserev + 1):
1214 for p in cl.parentrevs(r):
1215 for p in cl.parentrevs(r):
1215 if p >= baserev:
1216 if p >= baserev:
1216 parentscount[p - baserev] += 1
1217 parentscount[p - baserev] += 1
1217 return subset.filter(lambda r: parentscount[r - baserev] > 1)
1218 return subset.filter(lambda r: parentscount[r - baserev] > 1)
1218
1219
1219 def minrev(repo, subset, x):
1220 def minrev(repo, subset, x):
1220 """``min(set)``
1221 """``min(set)``
1221 Changeset with lowest revision number in set.
1222 Changeset with lowest revision number in set.
1222 """
1223 """
1223 os = getset(repo, fullreposet(repo), x)
1224 os = getset(repo, fullreposet(repo), x)
1224 if os:
1225 if os:
1225 m = os.min()
1226 m = os.min()
1226 if m in subset:
1227 if m in subset:
1227 return baseset([m])
1228 return baseset([m])
1228 return baseset()
1229 return baseset()
1229
1230
1230 def modifies(repo, subset, x):
1231 def modifies(repo, subset, x):
1231 """``modifies(pattern)``
1232 """``modifies(pattern)``
1232 Changesets modifying files matched by pattern.
1233 Changesets modifying files matched by pattern.
1233
1234
1234 The pattern without explicit kind like ``glob:`` is expected to be
1235 The pattern without explicit kind like ``glob:`` is expected to be
1235 relative to the current directory and match against a file or a
1236 relative to the current directory and match against a file or a
1236 directory.
1237 directory.
1237 """
1238 """
1238 # i18n: "modifies" is a keyword
1239 # i18n: "modifies" is a keyword
1239 pat = getstring(x, _("modifies requires a pattern"))
1240 pat = getstring(x, _("modifies requires a pattern"))
1240 return checkstatus(repo, subset, pat, 0)
1241 return checkstatus(repo, subset, pat, 0)
1241
1242
1242 def named(repo, subset, x):
1243 def named(repo, subset, x):
1243 """``named(namespace)``
1244 """``named(namespace)``
1244 The changesets in a given namespace.
1245 The changesets in a given namespace.
1245
1246
1246 If `namespace` starts with `re:`, the remainder of the string is treated as
1247 If `namespace` starts with `re:`, the remainder of the string is treated as
1247 a regular expression. To match a namespace that actually starts with `re:`,
1248 a regular expression. To match a namespace that actually starts with `re:`,
1248 use the prefix `literal:`.
1249 use the prefix `literal:`.
1249 """
1250 """
1250 # i18n: "named" is a keyword
1251 # i18n: "named" is a keyword
1251 args = getargs(x, 1, 1, _('named requires a namespace argument'))
1252 args = getargs(x, 1, 1, _('named requires a namespace argument'))
1252
1253
1253 ns = getstring(args[0],
1254 ns = getstring(args[0],
1254 # i18n: "named" is a keyword
1255 # i18n: "named" is a keyword
1255 _('the argument to named must be a string'))
1256 _('the argument to named must be a string'))
1256 kind, pattern, matcher = _stringmatcher(ns)
1257 kind, pattern, matcher = _stringmatcher(ns)
1257 namespaces = set()
1258 namespaces = set()
1258 if kind == 'literal':
1259 if kind == 'literal':
1259 if pattern not in repo.names:
1260 if pattern not in repo.names:
1260 raise error.RepoLookupError(_("namespace '%s' does not exist")
1261 raise error.RepoLookupError(_("namespace '%s' does not exist")
1261 % ns)
1262 % ns)
1262 namespaces.add(repo.names[pattern])
1263 namespaces.add(repo.names[pattern])
1263 else:
1264 else:
1264 for name, ns in repo.names.iteritems():
1265 for name, ns in repo.names.iteritems():
1265 if matcher(name):
1266 if matcher(name):
1266 namespaces.add(ns)
1267 namespaces.add(ns)
1267 if not namespaces:
1268 if not namespaces:
1268 raise error.RepoLookupError(_("no namespace exists"
1269 raise error.RepoLookupError(_("no namespace exists"
1269 " that match '%s'") % pattern)
1270 " that match '%s'") % pattern)
1270
1271
1271 names = set()
1272 names = set()
1272 for ns in namespaces:
1273 for ns in namespaces:
1273 for name in ns.listnames(repo):
1274 for name in ns.listnames(repo):
1274 if name not in ns.deprecated:
1275 if name not in ns.deprecated:
1275 names.update(repo[n].rev() for n in ns.nodes(repo, name))
1276 names.update(repo[n].rev() for n in ns.nodes(repo, name))
1276
1277
1277 names -= set([node.nullrev])
1278 names -= set([node.nullrev])
1278 return subset & names
1279 return subset & names
1279
1280
1280 def node_(repo, subset, x):
1281 def node_(repo, subset, x):
1281 """``id(string)``
1282 """``id(string)``
1282 Revision non-ambiguously specified by the given hex string prefix.
1283 Revision non-ambiguously specified by the given hex string prefix.
1283 """
1284 """
1284 # i18n: "id" is a keyword
1285 # i18n: "id" is a keyword
1285 l = getargs(x, 1, 1, _("id requires one argument"))
1286 l = getargs(x, 1, 1, _("id requires one argument"))
1286 # i18n: "id" is a keyword
1287 # i18n: "id" is a keyword
1287 n = getstring(l[0], _("id requires a string"))
1288 n = getstring(l[0], _("id requires a string"))
1288 if len(n) == 40:
1289 if len(n) == 40:
1289 try:
1290 try:
1290 rn = repo.changelog.rev(node.bin(n))
1291 rn = repo.changelog.rev(node.bin(n))
1291 except (LookupError, TypeError):
1292 except (LookupError, TypeError):
1292 rn = None
1293 rn = None
1293 else:
1294 else:
1294 rn = None
1295 rn = None
1295 pm = repo.changelog._partialmatch(n)
1296 pm = repo.changelog._partialmatch(n)
1296 if pm is not None:
1297 if pm is not None:
1297 rn = repo.changelog.rev(pm)
1298 rn = repo.changelog.rev(pm)
1298
1299
1299 if rn is None:
1300 if rn is None:
1300 return baseset()
1301 return baseset()
1301 result = baseset([rn])
1302 result = baseset([rn])
1302 return result & subset
1303 return result & subset
1303
1304
1304 def obsolete(repo, subset, x):
1305 def obsolete(repo, subset, x):
1305 """``obsolete()``
1306 """``obsolete()``
1306 Mutable changeset with a newer version."""
1307 Mutable changeset with a newer version."""
1307 # i18n: "obsolete" is a keyword
1308 # i18n: "obsolete" is a keyword
1308 getargs(x, 0, 0, _("obsolete takes no arguments"))
1309 getargs(x, 0, 0, _("obsolete takes no arguments"))
1309 obsoletes = obsmod.getrevs(repo, 'obsolete')
1310 obsoletes = obsmod.getrevs(repo, 'obsolete')
1310 return subset & obsoletes
1311 return subset & obsoletes
1311
1312
1312 def only(repo, subset, x):
1313 def only(repo, subset, x):
1313 """``only(set, [set])``
1314 """``only(set, [set])``
1314 Changesets that are ancestors of the first set that are not ancestors
1315 Changesets that are ancestors of the first set that are not ancestors
1315 of any other head in the repo. If a second set is specified, the result
1316 of any other head in the repo. If a second set is specified, the result
1316 is ancestors of the first set that are not ancestors of the second set
1317 is ancestors of the first set that are not ancestors of the second set
1317 (i.e. ::<set1> - ::<set2>).
1318 (i.e. ::<set1> - ::<set2>).
1318 """
1319 """
1319 cl = repo.changelog
1320 cl = repo.changelog
1320 # i18n: "only" is a keyword
1321 # i18n: "only" is a keyword
1321 args = getargs(x, 1, 2, _('only takes one or two arguments'))
1322 args = getargs(x, 1, 2, _('only takes one or two arguments'))
1322 include = getset(repo, fullreposet(repo), args[0])
1323 include = getset(repo, fullreposet(repo), args[0])
1323 if len(args) == 1:
1324 if len(args) == 1:
1324 if not include:
1325 if not include:
1325 return baseset()
1326 return baseset()
1326
1327
1327 descendants = set(_revdescendants(repo, include, False))
1328 descendants = set(_revdescendants(repo, include, False))
1328 exclude = [rev for rev in cl.headrevs()
1329 exclude = [rev for rev in cl.headrevs()
1329 if not rev in descendants and not rev in include]
1330 if not rev in descendants and not rev in include]
1330 else:
1331 else:
1331 exclude = getset(repo, fullreposet(repo), args[1])
1332 exclude = getset(repo, fullreposet(repo), args[1])
1332
1333
1333 results = set(cl.findmissingrevs(common=exclude, heads=include))
1334 results = set(cl.findmissingrevs(common=exclude, heads=include))
1334 return subset & results
1335 return subset & results
1335
1336
1336 def origin(repo, subset, x):
1337 def origin(repo, subset, x):
1337 """``origin([set])``
1338 """``origin([set])``
1338 Changesets that were specified as a source for the grafts, transplants or
1339 Changesets that were specified as a source for the grafts, transplants or
1339 rebases that created the given revisions. Omitting the optional set is the
1340 rebases that created the given revisions. Omitting the optional set is the
1340 same as passing all(). If a changeset created by these operations is itself
1341 same as passing all(). If a changeset created by these operations is itself
1341 specified as a source for one of these operations, only the source changeset
1342 specified as a source for one of these operations, only the source changeset
1342 for the first operation is selected.
1343 for the first operation is selected.
1343 """
1344 """
1344 if x is not None:
1345 if x is not None:
1345 dests = getset(repo, fullreposet(repo), x)
1346 dests = getset(repo, fullreposet(repo), x)
1346 else:
1347 else:
1347 dests = fullreposet(repo)
1348 dests = fullreposet(repo)
1348
1349
1349 def _firstsrc(rev):
1350 def _firstsrc(rev):
1350 src = _getrevsource(repo, rev)
1351 src = _getrevsource(repo, rev)
1351 if src is None:
1352 if src is None:
1352 return None
1353 return None
1353
1354
1354 while True:
1355 while True:
1355 prev = _getrevsource(repo, src)
1356 prev = _getrevsource(repo, src)
1356
1357
1357 if prev is None:
1358 if prev is None:
1358 return src
1359 return src
1359 src = prev
1360 src = prev
1360
1361
1361 o = set([_firstsrc(r) for r in dests])
1362 o = set([_firstsrc(r) for r in dests])
1362 o -= set([None])
1363 o -= set([None])
1363 return subset & o
1364 return subset & o
1364
1365
1365 def outgoing(repo, subset, x):
1366 def outgoing(repo, subset, x):
1366 """``outgoing([path])``
1367 """``outgoing([path])``
1367 Changesets not found in the specified destination repository, or the
1368 Changesets not found in the specified destination repository, or the
1368 default push location.
1369 default push location.
1369 """
1370 """
1370 # Avoid cycles.
1371 # Avoid cycles.
1371 import discovery
1372 import discovery
1372 import hg
1373 import hg
1373 # i18n: "outgoing" is a keyword
1374 # i18n: "outgoing" is a keyword
1374 l = getargs(x, 0, 1, _("outgoing takes one or no arguments"))
1375 l = getargs(x, 0, 1, _("outgoing takes one or no arguments"))
1375 # i18n: "outgoing" is a keyword
1376 # i18n: "outgoing" is a keyword
1376 dest = l and getstring(l[0], _("outgoing requires a repository path")) or ''
1377 dest = l and getstring(l[0], _("outgoing requires a repository path")) or ''
1377 dest = repo.ui.expandpath(dest or 'default-push', dest or 'default')
1378 dest = repo.ui.expandpath(dest or 'default-push', dest or 'default')
1378 dest, branches = hg.parseurl(dest)
1379 dest, branches = hg.parseurl(dest)
1379 revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
1380 revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
1380 if revs:
1381 if revs:
1381 revs = [repo.lookup(rev) for rev in revs]
1382 revs = [repo.lookup(rev) for rev in revs]
1382 other = hg.peer(repo, {}, dest)
1383 other = hg.peer(repo, {}, dest)
1383 repo.ui.pushbuffer()
1384 repo.ui.pushbuffer()
1384 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs)
1385 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs)
1385 repo.ui.popbuffer()
1386 repo.ui.popbuffer()
1386 cl = repo.changelog
1387 cl = repo.changelog
1387 o = set([cl.rev(r) for r in outgoing.missing])
1388 o = set([cl.rev(r) for r in outgoing.missing])
1388 return subset & o
1389 return subset & o
1389
1390
1390 def p1(repo, subset, x):
1391 def p1(repo, subset, x):
1391 """``p1([set])``
1392 """``p1([set])``
1392 First parent of changesets in set, or the working directory.
1393 First parent of changesets in set, or the working directory.
1393 """
1394 """
1394 if x is None:
1395 if x is None:
1395 p = repo[x].p1().rev()
1396 p = repo[x].p1().rev()
1396 if p >= 0:
1397 if p >= 0:
1397 return subset & baseset([p])
1398 return subset & baseset([p])
1398 return baseset()
1399 return baseset()
1399
1400
1400 ps = set()
1401 ps = set()
1401 cl = repo.changelog
1402 cl = repo.changelog
1402 for r in getset(repo, fullreposet(repo), x):
1403 for r in getset(repo, fullreposet(repo), x):
1403 ps.add(cl.parentrevs(r)[0])
1404 ps.add(cl.parentrevs(r)[0])
1404 ps -= set([node.nullrev])
1405 ps -= set([node.nullrev])
1405 return subset & ps
1406 return subset & ps
1406
1407
1407 def p2(repo, subset, x):
1408 def p2(repo, subset, x):
1408 """``p2([set])``
1409 """``p2([set])``
1409 Second parent of changesets in set, or the working directory.
1410 Second parent of changesets in set, or the working directory.
1410 """
1411 """
1411 if x is None:
1412 if x is None:
1412 ps = repo[x].parents()
1413 ps = repo[x].parents()
1413 try:
1414 try:
1414 p = ps[1].rev()
1415 p = ps[1].rev()
1415 if p >= 0:
1416 if p >= 0:
1416 return subset & baseset([p])
1417 return subset & baseset([p])
1417 return baseset()
1418 return baseset()
1418 except IndexError:
1419 except IndexError:
1419 return baseset()
1420 return baseset()
1420
1421
1421 ps = set()
1422 ps = set()
1422 cl = repo.changelog
1423 cl = repo.changelog
1423 for r in getset(repo, fullreposet(repo), x):
1424 for r in getset(repo, fullreposet(repo), x):
1424 ps.add(cl.parentrevs(r)[1])
1425 ps.add(cl.parentrevs(r)[1])
1425 ps -= set([node.nullrev])
1426 ps -= set([node.nullrev])
1426 return subset & ps
1427 return subset & ps
1427
1428
1428 def parents(repo, subset, x):
1429 def parents(repo, subset, x):
1429 """``parents([set])``
1430 """``parents([set])``
1430 The set of all parents for all changesets in set, or the working directory.
1431 The set of all parents for all changesets in set, or the working directory.
1431 """
1432 """
1432 if x is None:
1433 if x is None:
1433 ps = set(p.rev() for p in repo[x].parents())
1434 ps = set(p.rev() for p in repo[x].parents())
1434 else:
1435 else:
1435 ps = set()
1436 ps = set()
1436 cl = repo.changelog
1437 cl = repo.changelog
1437 for r in getset(repo, fullreposet(repo), x):
1438 for r in getset(repo, fullreposet(repo), x):
1438 ps.update(cl.parentrevs(r))
1439 ps.update(cl.parentrevs(r))
1439 ps -= set([node.nullrev])
1440 ps -= set([node.nullrev])
1440 return subset & ps
1441 return subset & ps
1441
1442
1442 def parentspec(repo, subset, x, n):
1443 def parentspec(repo, subset, x, n):
1443 """``set^0``
1444 """``set^0``
1444 The set.
1445 The set.
1445 ``set^1`` (or ``set^``), ``set^2``
1446 ``set^1`` (or ``set^``), ``set^2``
1446 First or second parent, respectively, of all changesets in set.
1447 First or second parent, respectively, of all changesets in set.
1447 """
1448 """
1448 try:
1449 try:
1449 n = int(n[1])
1450 n = int(n[1])
1450 if n not in (0, 1, 2):
1451 if n not in (0, 1, 2):
1451 raise ValueError
1452 raise ValueError
1452 except (TypeError, ValueError):
1453 except (TypeError, ValueError):
1453 raise error.ParseError(_("^ expects a number 0, 1, or 2"))
1454 raise error.ParseError(_("^ expects a number 0, 1, or 2"))
1454 ps = set()
1455 ps = set()
1455 cl = repo.changelog
1456 cl = repo.changelog
1456 for r in getset(repo, fullreposet(repo), x):
1457 for r in getset(repo, fullreposet(repo), x):
1457 if n == 0:
1458 if n == 0:
1458 ps.add(r)
1459 ps.add(r)
1459 elif n == 1:
1460 elif n == 1:
1460 ps.add(cl.parentrevs(r)[0])
1461 ps.add(cl.parentrevs(r)[0])
1461 elif n == 2:
1462 elif n == 2:
1462 parents = cl.parentrevs(r)
1463 parents = cl.parentrevs(r)
1463 if len(parents) > 1:
1464 if len(parents) > 1:
1464 ps.add(parents[1])
1465 ps.add(parents[1])
1465 return subset & ps
1466 return subset & ps
1466
1467
1467 def present(repo, subset, x):
1468 def present(repo, subset, x):
1468 """``present(set)``
1469 """``present(set)``
1469 An empty set, if any revision in set isn't found; otherwise,
1470 An empty set, if any revision in set isn't found; otherwise,
1470 all revisions in set.
1471 all revisions in set.
1471
1472
1472 If any of specified revisions is not present in the local repository,
1473 If any of specified revisions is not present in the local repository,
1473 the query is normally aborted. But this predicate allows the query
1474 the query is normally aborted. But this predicate allows the query
1474 to continue even in such cases.
1475 to continue even in such cases.
1475 """
1476 """
1476 try:
1477 try:
1477 return getset(repo, subset, x)
1478 return getset(repo, subset, x)
1478 except error.RepoLookupError:
1479 except error.RepoLookupError:
1479 return baseset()
1480 return baseset()
1480
1481
1481 # for internal use
1482 # for internal use
1482 def _notpublic(repo, subset, x):
1483 def _notpublic(repo, subset, x):
1483 getargs(x, 0, 0, "_notpublic takes no arguments")
1484 getargs(x, 0, 0, "_notpublic takes no arguments")
1484 if repo._phasecache._phasesets:
1485 if repo._phasecache._phasesets:
1485 s = set()
1486 s = set()
1486 for u in repo._phasecache._phasesets[1:]:
1487 for u in repo._phasecache._phasesets[1:]:
1487 s.update(u)
1488 s.update(u)
1488 return subset & s
1489 return subset & s
1489 else:
1490 else:
1490 phase = repo._phasecache.phase
1491 phase = repo._phasecache.phase
1491 target = phases.public
1492 target = phases.public
1492 condition = lambda r: phase(repo, r) != target
1493 condition = lambda r: phase(repo, r) != target
1493 return subset.filter(condition, cache=False)
1494 return subset.filter(condition, cache=False)
1494
1495
1495 def public(repo, subset, x):
1496 def public(repo, subset, x):
1496 """``public()``
1497 """``public()``
1497 Changeset in public phase."""
1498 Changeset in public phase."""
1498 # i18n: "public" is a keyword
1499 # i18n: "public" is a keyword
1499 getargs(x, 0, 0, _("public takes no arguments"))
1500 getargs(x, 0, 0, _("public takes no arguments"))
1500 phase = repo._phasecache.phase
1501 phase = repo._phasecache.phase
1501 target = phases.public
1502 target = phases.public
1502 condition = lambda r: phase(repo, r) == target
1503 condition = lambda r: phase(repo, r) == target
1503 return subset.filter(condition, cache=False)
1504 return subset.filter(condition, cache=False)
1504
1505
1505 def remote(repo, subset, x):
1506 def remote(repo, subset, x):
1506 """``remote([id [,path]])``
1507 """``remote([id [,path]])``
1507 Local revision that corresponds to the given identifier in a
1508 Local revision that corresponds to the given identifier in a
1508 remote repository, if present. Here, the '.' identifier is a
1509 remote repository, if present. Here, the '.' identifier is a
1509 synonym for the current local branch.
1510 synonym for the current local branch.
1510 """
1511 """
1511
1512
1512 import hg # avoid start-up nasties
1513 import hg # avoid start-up nasties
1513 # i18n: "remote" is a keyword
1514 # i18n: "remote" is a keyword
1514 l = getargs(x, 0, 2, _("remote takes one, two or no arguments"))
1515 l = getargs(x, 0, 2, _("remote takes one, two or no arguments"))
1515
1516
1516 q = '.'
1517 q = '.'
1517 if len(l) > 0:
1518 if len(l) > 0:
1518 # i18n: "remote" is a keyword
1519 # i18n: "remote" is a keyword
1519 q = getstring(l[0], _("remote requires a string id"))
1520 q = getstring(l[0], _("remote requires a string id"))
1520 if q == '.':
1521 if q == '.':
1521 q = repo['.'].branch()
1522 q = repo['.'].branch()
1522
1523
1523 dest = ''
1524 dest = ''
1524 if len(l) > 1:
1525 if len(l) > 1:
1525 # i18n: "remote" is a keyword
1526 # i18n: "remote" is a keyword
1526 dest = getstring(l[1], _("remote requires a repository path"))
1527 dest = getstring(l[1], _("remote requires a repository path"))
1527 dest = repo.ui.expandpath(dest or 'default')
1528 dest = repo.ui.expandpath(dest or 'default')
1528 dest, branches = hg.parseurl(dest)
1529 dest, branches = hg.parseurl(dest)
1529 revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
1530 revs, checkout = hg.addbranchrevs(repo, repo, branches, [])
1530 if revs:
1531 if revs:
1531 revs = [repo.lookup(rev) for rev in revs]
1532 revs = [repo.lookup(rev) for rev in revs]
1532 other = hg.peer(repo, {}, dest)
1533 other = hg.peer(repo, {}, dest)
1533 n = other.lookup(q)
1534 n = other.lookup(q)
1534 if n in repo:
1535 if n in repo:
1535 r = repo[n].rev()
1536 r = repo[n].rev()
1536 if r in subset:
1537 if r in subset:
1537 return baseset([r])
1538 return baseset([r])
1538 return baseset()
1539 return baseset()
1539
1540
1540 def removes(repo, subset, x):
1541 def removes(repo, subset, x):
1541 """``removes(pattern)``
1542 """``removes(pattern)``
1542 Changesets which remove files matching pattern.
1543 Changesets which remove files matching pattern.
1543
1544
1544 The pattern without explicit kind like ``glob:`` is expected to be
1545 The pattern without explicit kind like ``glob:`` is expected to be
1545 relative to the current directory and match against a file or a
1546 relative to the current directory and match against a file or a
1546 directory.
1547 directory.
1547 """
1548 """
1548 # i18n: "removes" is a keyword
1549 # i18n: "removes" is a keyword
1549 pat = getstring(x, _("removes requires a pattern"))
1550 pat = getstring(x, _("removes requires a pattern"))
1550 return checkstatus(repo, subset, pat, 2)
1551 return checkstatus(repo, subset, pat, 2)
1551
1552
1552 def rev(repo, subset, x):
1553 def rev(repo, subset, x):
1553 """``rev(number)``
1554 """``rev(number)``
1554 Revision with the given numeric identifier.
1555 Revision with the given numeric identifier.
1555 """
1556 """
1556 # i18n: "rev" is a keyword
1557 # i18n: "rev" is a keyword
1557 l = getargs(x, 1, 1, _("rev requires one argument"))
1558 l = getargs(x, 1, 1, _("rev requires one argument"))
1558 try:
1559 try:
1559 # i18n: "rev" is a keyword
1560 # i18n: "rev" is a keyword
1560 l = int(getstring(l[0], _("rev requires a number")))
1561 l = int(getstring(l[0], _("rev requires a number")))
1561 except (TypeError, ValueError):
1562 except (TypeError, ValueError):
1562 # i18n: "rev" is a keyword
1563 # i18n: "rev" is a keyword
1563 raise error.ParseError(_("rev expects a number"))
1564 raise error.ParseError(_("rev expects a number"))
1564 if l not in repo.changelog and l != node.nullrev:
1565 if l not in repo.changelog and l != node.nullrev:
1565 return baseset()
1566 return baseset()
1566 return subset & baseset([l])
1567 return subset & baseset([l])
1567
1568
1568 def matching(repo, subset, x):
1569 def matching(repo, subset, x):
1569 """``matching(revision [, field])``
1570 """``matching(revision [, field])``
1570 Changesets in which a given set of fields match the set of fields in the
1571 Changesets in which a given set of fields match the set of fields in the
1571 selected revision or set.
1572 selected revision or set.
1572
1573
1573 To match more than one field pass the list of fields to match separated
1574 To match more than one field pass the list of fields to match separated
1574 by spaces (e.g. ``author description``).
1575 by spaces (e.g. ``author description``).
1575
1576
1576 Valid fields are most regular revision fields and some special fields.
1577 Valid fields are most regular revision fields and some special fields.
1577
1578
1578 Regular revision fields are ``description``, ``author``, ``branch``,
1579 Regular revision fields are ``description``, ``author``, ``branch``,
1579 ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user``
1580 ``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user``
1580 and ``diff``.
1581 and ``diff``.
1581 Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the
1582 Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the
1582 contents of the revision. Two revisions matching their ``diff`` will
1583 contents of the revision. Two revisions matching their ``diff`` will
1583 also match their ``files``.
1584 also match their ``files``.
1584
1585
1585 Special fields are ``summary`` and ``metadata``:
1586 Special fields are ``summary`` and ``metadata``:
1586 ``summary`` matches the first line of the description.
1587 ``summary`` matches the first line of the description.
1587 ``metadata`` is equivalent to matching ``description user date``
1588 ``metadata`` is equivalent to matching ``description user date``
1588 (i.e. it matches the main metadata fields).
1589 (i.e. it matches the main metadata fields).
1589
1590
1590 ``metadata`` is the default field which is used when no fields are
1591 ``metadata`` is the default field which is used when no fields are
1591 specified. You can match more than one field at a time.
1592 specified. You can match more than one field at a time.
1592 """
1593 """
1593 # i18n: "matching" is a keyword
1594 # i18n: "matching" is a keyword
1594 l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments"))
1595 l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments"))
1595
1596
1596 revs = getset(repo, fullreposet(repo), l[0])
1597 revs = getset(repo, fullreposet(repo), l[0])
1597
1598
1598 fieldlist = ['metadata']
1599 fieldlist = ['metadata']
1599 if len(l) > 1:
1600 if len(l) > 1:
1600 fieldlist = getstring(l[1],
1601 fieldlist = getstring(l[1],
1601 # i18n: "matching" is a keyword
1602 # i18n: "matching" is a keyword
1602 _("matching requires a string "
1603 _("matching requires a string "
1603 "as its second argument")).split()
1604 "as its second argument")).split()
1604
1605
1605 # Make sure that there are no repeated fields,
1606 # Make sure that there are no repeated fields,
1606 # expand the 'special' 'metadata' field type
1607 # expand the 'special' 'metadata' field type
1607 # and check the 'files' whenever we check the 'diff'
1608 # and check the 'files' whenever we check the 'diff'
1608 fields = []
1609 fields = []
1609 for field in fieldlist:
1610 for field in fieldlist:
1610 if field == 'metadata':
1611 if field == 'metadata':
1611 fields += ['user', 'description', 'date']
1612 fields += ['user', 'description', 'date']
1612 elif field == 'diff':
1613 elif field == 'diff':
1613 # a revision matching the diff must also match the files
1614 # a revision matching the diff must also match the files
1614 # since matching the diff is very costly, make sure to
1615 # since matching the diff is very costly, make sure to
1615 # also match the files first
1616 # also match the files first
1616 fields += ['files', 'diff']
1617 fields += ['files', 'diff']
1617 else:
1618 else:
1618 if field == 'author':
1619 if field == 'author':
1619 field = 'user'
1620 field = 'user'
1620 fields.append(field)
1621 fields.append(field)
1621 fields = set(fields)
1622 fields = set(fields)
1622 if 'summary' in fields and 'description' in fields:
1623 if 'summary' in fields and 'description' in fields:
1623 # If a revision matches its description it also matches its summary
1624 # If a revision matches its description it also matches its summary
1624 fields.discard('summary')
1625 fields.discard('summary')
1625
1626
1626 # We may want to match more than one field
1627 # We may want to match more than one field
1627 # Not all fields take the same amount of time to be matched
1628 # Not all fields take the same amount of time to be matched
1628 # Sort the selected fields in order of increasing matching cost
1629 # Sort the selected fields in order of increasing matching cost
1629 fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary',
1630 fieldorder = ['phase', 'parents', 'user', 'date', 'branch', 'summary',
1630 'files', 'description', 'substate', 'diff']
1631 'files', 'description', 'substate', 'diff']
1631 def fieldkeyfunc(f):
1632 def fieldkeyfunc(f):
1632 try:
1633 try:
1633 return fieldorder.index(f)
1634 return fieldorder.index(f)
1634 except ValueError:
1635 except ValueError:
1635 # assume an unknown field is very costly
1636 # assume an unknown field is very costly
1636 return len(fieldorder)
1637 return len(fieldorder)
1637 fields = list(fields)
1638 fields = list(fields)
1638 fields.sort(key=fieldkeyfunc)
1639 fields.sort(key=fieldkeyfunc)
1639
1640
1640 # Each field will be matched with its own "getfield" function
1641 # Each field will be matched with its own "getfield" function
1641 # which will be added to the getfieldfuncs array of functions
1642 # which will be added to the getfieldfuncs array of functions
1642 getfieldfuncs = []
1643 getfieldfuncs = []
1643 _funcs = {
1644 _funcs = {
1644 'user': lambda r: repo[r].user(),
1645 'user': lambda r: repo[r].user(),
1645 'branch': lambda r: repo[r].branch(),
1646 'branch': lambda r: repo[r].branch(),
1646 'date': lambda r: repo[r].date(),
1647 'date': lambda r: repo[r].date(),
1647 'description': lambda r: repo[r].description(),
1648 'description': lambda r: repo[r].description(),
1648 'files': lambda r: repo[r].files(),
1649 'files': lambda r: repo[r].files(),
1649 'parents': lambda r: repo[r].parents(),
1650 'parents': lambda r: repo[r].parents(),
1650 'phase': lambda r: repo[r].phase(),
1651 'phase': lambda r: repo[r].phase(),
1651 'substate': lambda r: repo[r].substate,
1652 'substate': lambda r: repo[r].substate,
1652 'summary': lambda r: repo[r].description().splitlines()[0],
1653 'summary': lambda r: repo[r].description().splitlines()[0],
1653 'diff': lambda r: list(repo[r].diff(git=True),)
1654 'diff': lambda r: list(repo[r].diff(git=True),)
1654 }
1655 }
1655 for info in fields:
1656 for info in fields:
1656 getfield = _funcs.get(info, None)
1657 getfield = _funcs.get(info, None)
1657 if getfield is None:
1658 if getfield is None:
1658 raise error.ParseError(
1659 raise error.ParseError(
1659 # i18n: "matching" is a keyword
1660 # i18n: "matching" is a keyword
1660 _("unexpected field name passed to matching: %s") % info)
1661 _("unexpected field name passed to matching: %s") % info)
1661 getfieldfuncs.append(getfield)
1662 getfieldfuncs.append(getfield)
1662 # convert the getfield array of functions into a "getinfo" function
1663 # convert the getfield array of functions into a "getinfo" function
1663 # which returns an array of field values (or a single value if there
1664 # which returns an array of field values (or a single value if there
1664 # is only one field to match)
1665 # is only one field to match)
1665 getinfo = lambda r: [f(r) for f in getfieldfuncs]
1666 getinfo = lambda r: [f(r) for f in getfieldfuncs]
1666
1667
1667 def matches(x):
1668 def matches(x):
1668 for rev in revs:
1669 for rev in revs:
1669 target = getinfo(rev)
1670 target = getinfo(rev)
1670 match = True
1671 match = True
1671 for n, f in enumerate(getfieldfuncs):
1672 for n, f in enumerate(getfieldfuncs):
1672 if target[n] != f(x):
1673 if target[n] != f(x):
1673 match = False
1674 match = False
1674 if match:
1675 if match:
1675 return True
1676 return True
1676 return False
1677 return False
1677
1678
1678 return subset.filter(matches)
1679 return subset.filter(matches)
1679
1680
1680 def reverse(repo, subset, x):
1681 def reverse(repo, subset, x):
1681 """``reverse(set)``
1682 """``reverse(set)``
1682 Reverse order of set.
1683 Reverse order of set.
1683 """
1684 """
1684 l = getset(repo, subset, x)
1685 l = getset(repo, subset, x)
1685 l.reverse()
1686 l.reverse()
1686 return l
1687 return l
1687
1688
1688 def roots(repo, subset, x):
1689 def roots(repo, subset, x):
1689 """``roots(set)``
1690 """``roots(set)``
1690 Changesets in set with no parent changeset in set.
1691 Changesets in set with no parent changeset in set.
1691 """
1692 """
1692 s = getset(repo, fullreposet(repo), x)
1693 s = getset(repo, fullreposet(repo), x)
1693 subset = subset & s# baseset([r for r in s if r in subset])
1694 subset = subset & s# baseset([r for r in s if r in subset])
1694 cs = _children(repo, subset, s)
1695 cs = _children(repo, subset, s)
1695 return subset - cs
1696 return subset - cs
1696
1697
1697 def secret(repo, subset, x):
1698 def secret(repo, subset, x):
1698 """``secret()``
1699 """``secret()``
1699 Changeset in secret phase."""
1700 Changeset in secret phase."""
1700 # i18n: "secret" is a keyword
1701 # i18n: "secret" is a keyword
1701 getargs(x, 0, 0, _("secret takes no arguments"))
1702 getargs(x, 0, 0, _("secret takes no arguments"))
1702 phase = repo._phasecache.phase
1703 phase = repo._phasecache.phase
1703 target = phases.secret
1704 target = phases.secret
1704 condition = lambda r: phase(repo, r) == target
1705 condition = lambda r: phase(repo, r) == target
1705 return subset.filter(condition, cache=False)
1706 return subset.filter(condition, cache=False)
1706
1707
1707 def sort(repo, subset, x):
1708 def sort(repo, subset, x):
1708 """``sort(set[, [-]key...])``
1709 """``sort(set[, [-]key...])``
1709 Sort set by keys. The default sort order is ascending, specify a key
1710 Sort set by keys. The default sort order is ascending, specify a key
1710 as ``-key`` to sort in descending order.
1711 as ``-key`` to sort in descending order.
1711
1712
1712 The keys can be:
1713 The keys can be:
1713
1714
1714 - ``rev`` for the revision number,
1715 - ``rev`` for the revision number,
1715 - ``branch`` for the branch name,
1716 - ``branch`` for the branch name,
1716 - ``desc`` for the commit message (description),
1717 - ``desc`` for the commit message (description),
1717 - ``user`` for user name (``author`` can be used as an alias),
1718 - ``user`` for user name (``author`` can be used as an alias),
1718 - ``date`` for the commit date
1719 - ``date`` for the commit date
1719 """
1720 """
1720 # i18n: "sort" is a keyword
1721 # i18n: "sort" is a keyword
1721 l = getargs(x, 1, 2, _("sort requires one or two arguments"))
1722 l = getargs(x, 1, 2, _("sort requires one or two arguments"))
1722 keys = "rev"
1723 keys = "rev"
1723 if len(l) == 2:
1724 if len(l) == 2:
1724 # i18n: "sort" is a keyword
1725 # i18n: "sort" is a keyword
1725 keys = getstring(l[1], _("sort spec must be a string"))
1726 keys = getstring(l[1], _("sort spec must be a string"))
1726
1727
1727 s = l[0]
1728 s = l[0]
1728 keys = keys.split()
1729 keys = keys.split()
1729 l = []
1730 l = []
1730 def invert(s):
1731 def invert(s):
1731 return "".join(chr(255 - ord(c)) for c in s)
1732 return "".join(chr(255 - ord(c)) for c in s)
1732 revs = getset(repo, subset, s)
1733 revs = getset(repo, subset, s)
1733 if keys == ["rev"]:
1734 if keys == ["rev"]:
1734 revs.sort()
1735 revs.sort()
1735 return revs
1736 return revs
1736 elif keys == ["-rev"]:
1737 elif keys == ["-rev"]:
1737 revs.sort(reverse=True)
1738 revs.sort(reverse=True)
1738 return revs
1739 return revs
1739 for r in revs:
1740 for r in revs:
1740 c = repo[r]
1741 c = repo[r]
1741 e = []
1742 e = []
1742 for k in keys:
1743 for k in keys:
1743 if k == 'rev':
1744 if k == 'rev':
1744 e.append(r)
1745 e.append(r)
1745 elif k == '-rev':
1746 elif k == '-rev':
1746 e.append(-r)
1747 e.append(-r)
1747 elif k == 'branch':
1748 elif k == 'branch':
1748 e.append(c.branch())
1749 e.append(c.branch())
1749 elif k == '-branch':
1750 elif k == '-branch':
1750 e.append(invert(c.branch()))
1751 e.append(invert(c.branch()))
1751 elif k == 'desc':
1752 elif k == 'desc':
1752 e.append(c.description())
1753 e.append(c.description())
1753 elif k == '-desc':
1754 elif k == '-desc':
1754 e.append(invert(c.description()))
1755 e.append(invert(c.description()))
1755 elif k in 'user author':
1756 elif k in 'user author':
1756 e.append(c.user())
1757 e.append(c.user())
1757 elif k in '-user -author':
1758 elif k in '-user -author':
1758 e.append(invert(c.user()))
1759 e.append(invert(c.user()))
1759 elif k == 'date':
1760 elif k == 'date':
1760 e.append(c.date()[0])
1761 e.append(c.date()[0])
1761 elif k == '-date':
1762 elif k == '-date':
1762 e.append(-c.date()[0])
1763 e.append(-c.date()[0])
1763 else:
1764 else:
1764 raise error.ParseError(_("unknown sort key %r") % k)
1765 raise error.ParseError(_("unknown sort key %r") % k)
1765 e.append(r)
1766 e.append(r)
1766 l.append(e)
1767 l.append(e)
1767 l.sort()
1768 l.sort()
1768 return baseset([e[-1] for e in l])
1769 return baseset([e[-1] for e in l])
1769
1770
1770 def subrepo(repo, subset, x):
1771 def subrepo(repo, subset, x):
1771 """``subrepo([pattern])``
1772 """``subrepo([pattern])``
1772 Changesets that add, modify or remove the given subrepo. If no subrepo
1773 Changesets that add, modify or remove the given subrepo. If no subrepo
1773 pattern is named, any subrepo changes are returned.
1774 pattern is named, any subrepo changes are returned.
1774 """
1775 """
1775 # i18n: "subrepo" is a keyword
1776 # i18n: "subrepo" is a keyword
1776 args = getargs(x, 0, 1, _('subrepo takes at most one argument'))
1777 args = getargs(x, 0, 1, _('subrepo takes at most one argument'))
1777 if len(args) != 0:
1778 if len(args) != 0:
1778 pat = getstring(args[0], _("subrepo requires a pattern"))
1779 pat = getstring(args[0], _("subrepo requires a pattern"))
1779
1780
1780 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate'])
1781 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate'])
1781
1782
1782 def submatches(names):
1783 def submatches(names):
1783 k, p, m = _stringmatcher(pat)
1784 k, p, m = _stringmatcher(pat)
1784 for name in names:
1785 for name in names:
1785 if m(name):
1786 if m(name):
1786 yield name
1787 yield name
1787
1788
1788 def matches(x):
1789 def matches(x):
1789 c = repo[x]
1790 c = repo[x]
1790 s = repo.status(c.p1().node(), c.node(), match=m)
1791 s = repo.status(c.p1().node(), c.node(), match=m)
1791
1792
1792 if len(args) == 0:
1793 if len(args) == 0:
1793 return s.added or s.modified or s.removed
1794 return s.added or s.modified or s.removed
1794
1795
1795 if s.added:
1796 if s.added:
1796 return any(submatches(c.substate.keys()))
1797 return any(submatches(c.substate.keys()))
1797
1798
1798 if s.modified:
1799 if s.modified:
1799 subs = set(c.p1().substate.keys())
1800 subs = set(c.p1().substate.keys())
1800 subs.update(c.substate.keys())
1801 subs.update(c.substate.keys())
1801
1802
1802 for path in submatches(subs):
1803 for path in submatches(subs):
1803 if c.p1().substate.get(path) != c.substate.get(path):
1804 if c.p1().substate.get(path) != c.substate.get(path):
1804 return True
1805 return True
1805
1806
1806 if s.removed:
1807 if s.removed:
1807 return any(submatches(c.p1().substate.keys()))
1808 return any(submatches(c.p1().substate.keys()))
1808
1809
1809 return False
1810 return False
1810
1811
1811 return subset.filter(matches)
1812 return subset.filter(matches)
1812
1813
1813 def _stringmatcher(pattern):
1814 def _stringmatcher(pattern):
1814 """
1815 """
1815 accepts a string, possibly starting with 're:' or 'literal:' prefix.
1816 accepts a string, possibly starting with 're:' or 'literal:' prefix.
1816 returns the matcher name, pattern, and matcher function.
1817 returns the matcher name, pattern, and matcher function.
1817 missing or unknown prefixes are treated as literal matches.
1818 missing or unknown prefixes are treated as literal matches.
1818
1819
1819 helper for tests:
1820 helper for tests:
1820 >>> def test(pattern, *tests):
1821 >>> def test(pattern, *tests):
1821 ... kind, pattern, matcher = _stringmatcher(pattern)
1822 ... kind, pattern, matcher = _stringmatcher(pattern)
1822 ... return (kind, pattern, [bool(matcher(t)) for t in tests])
1823 ... return (kind, pattern, [bool(matcher(t)) for t in tests])
1823
1824
1824 exact matching (no prefix):
1825 exact matching (no prefix):
1825 >>> test('abcdefg', 'abc', 'def', 'abcdefg')
1826 >>> test('abcdefg', 'abc', 'def', 'abcdefg')
1826 ('literal', 'abcdefg', [False, False, True])
1827 ('literal', 'abcdefg', [False, False, True])
1827
1828
1828 regex matching ('re:' prefix)
1829 regex matching ('re:' prefix)
1829 >>> test('re:a.+b', 'nomatch', 'fooadef', 'fooadefbar')
1830 >>> test('re:a.+b', 'nomatch', 'fooadef', 'fooadefbar')
1830 ('re', 'a.+b', [False, False, True])
1831 ('re', 'a.+b', [False, False, True])
1831
1832
1832 force exact matches ('literal:' prefix)
1833 force exact matches ('literal:' prefix)
1833 >>> test('literal:re:foobar', 'foobar', 're:foobar')
1834 >>> test('literal:re:foobar', 'foobar', 're:foobar')
1834 ('literal', 're:foobar', [False, True])
1835 ('literal', 're:foobar', [False, True])
1835
1836
1836 unknown prefixes are ignored and treated as literals
1837 unknown prefixes are ignored and treated as literals
1837 >>> test('foo:bar', 'foo', 'bar', 'foo:bar')
1838 >>> test('foo:bar', 'foo', 'bar', 'foo:bar')
1838 ('literal', 'foo:bar', [False, False, True])
1839 ('literal', 'foo:bar', [False, False, True])
1839 """
1840 """
1840 if pattern.startswith('re:'):
1841 if pattern.startswith('re:'):
1841 pattern = pattern[3:]
1842 pattern = pattern[3:]
1842 try:
1843 try:
1843 regex = re.compile(pattern)
1844 regex = re.compile(pattern)
1844 except re.error, e:
1845 except re.error, e:
1845 raise error.ParseError(_('invalid regular expression: %s')
1846 raise error.ParseError(_('invalid regular expression: %s')
1846 % e)
1847 % e)
1847 return 're', pattern, regex.search
1848 return 're', pattern, regex.search
1848 elif pattern.startswith('literal:'):
1849 elif pattern.startswith('literal:'):
1849 pattern = pattern[8:]
1850 pattern = pattern[8:]
1850 return 'literal', pattern, pattern.__eq__
1851 return 'literal', pattern, pattern.__eq__
1851
1852
1852 def _substringmatcher(pattern):
1853 def _substringmatcher(pattern):
1853 kind, pattern, matcher = _stringmatcher(pattern)
1854 kind, pattern, matcher = _stringmatcher(pattern)
1854 if kind == 'literal':
1855 if kind == 'literal':
1855 matcher = lambda s: pattern in s
1856 matcher = lambda s: pattern in s
1856 return kind, pattern, matcher
1857 return kind, pattern, matcher
1857
1858
1858 def tag(repo, subset, x):
1859 def tag(repo, subset, x):
1859 """``tag([name])``
1860 """``tag([name])``
1860 The specified tag by name, or all tagged revisions if no name is given.
1861 The specified tag by name, or all tagged revisions if no name is given.
1861
1862
1862 If `name` starts with `re:`, the remainder of the name is treated as
1863 If `name` starts with `re:`, the remainder of the name is treated as
1863 a regular expression. To match a tag that actually starts with `re:`,
1864 a regular expression. To match a tag that actually starts with `re:`,
1864 use the prefix `literal:`.
1865 use the prefix `literal:`.
1865 """
1866 """
1866 # i18n: "tag" is a keyword
1867 # i18n: "tag" is a keyword
1867 args = getargs(x, 0, 1, _("tag takes one or no arguments"))
1868 args = getargs(x, 0, 1, _("tag takes one or no arguments"))
1868 cl = repo.changelog
1869 cl = repo.changelog
1869 if args:
1870 if args:
1870 pattern = getstring(args[0],
1871 pattern = getstring(args[0],
1871 # i18n: "tag" is a keyword
1872 # i18n: "tag" is a keyword
1872 _('the argument to tag must be a string'))
1873 _('the argument to tag must be a string'))
1873 kind, pattern, matcher = _stringmatcher(pattern)
1874 kind, pattern, matcher = _stringmatcher(pattern)
1874 if kind == 'literal':
1875 if kind == 'literal':
1875 # avoid resolving all tags
1876 # avoid resolving all tags
1876 tn = repo._tagscache.tags.get(pattern, None)
1877 tn = repo._tagscache.tags.get(pattern, None)
1877 if tn is None:
1878 if tn is None:
1878 raise error.RepoLookupError(_("tag '%s' does not exist")
1879 raise error.RepoLookupError(_("tag '%s' does not exist")
1879 % pattern)
1880 % pattern)
1880 s = set([repo[tn].rev()])
1881 s = set([repo[tn].rev()])
1881 else:
1882 else:
1882 s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
1883 s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)])
1883 else:
1884 else:
1884 s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
1885 s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip'])
1885 return subset & s
1886 return subset & s
1886
1887
1887 def tagged(repo, subset, x):
1888 def tagged(repo, subset, x):
1888 return tag(repo, subset, x)
1889 return tag(repo, subset, x)
1889
1890
1890 def unstable(repo, subset, x):
1891 def unstable(repo, subset, x):
1891 """``unstable()``
1892 """``unstable()``
1892 Non-obsolete changesets with obsolete ancestors.
1893 Non-obsolete changesets with obsolete ancestors.
1893 """
1894 """
1894 # i18n: "unstable" is a keyword
1895 # i18n: "unstable" is a keyword
1895 getargs(x, 0, 0, _("unstable takes no arguments"))
1896 getargs(x, 0, 0, _("unstable takes no arguments"))
1896 unstables = obsmod.getrevs(repo, 'unstable')
1897 unstables = obsmod.getrevs(repo, 'unstable')
1897 return subset & unstables
1898 return subset & unstables
1898
1899
1899
1900
1900 def user(repo, subset, x):
1901 def user(repo, subset, x):
1901 """``user(string)``
1902 """``user(string)``
1902 User name contains string. The match is case-insensitive.
1903 User name contains string. The match is case-insensitive.
1903
1904
1904 If `string` starts with `re:`, the remainder of the string is treated as
1905 If `string` starts with `re:`, the remainder of the string is treated as
1905 a regular expression. To match a user that actually contains `re:`, use
1906 a regular expression. To match a user that actually contains `re:`, use
1906 the prefix `literal:`.
1907 the prefix `literal:`.
1907 """
1908 """
1908 return author(repo, subset, x)
1909 return author(repo, subset, x)
1909
1910
1910 # experimental
1911 # experimental
1911 def wdir(repo, subset, x):
1912 def wdir(repo, subset, x):
1912 # i18n: "wdir" is a keyword
1913 # i18n: "wdir" is a keyword
1913 getargs(x, 0, 0, _("wdir takes no arguments"))
1914 getargs(x, 0, 0, _("wdir takes no arguments"))
1914 if None in subset:
1915 if None in subset or isinstance(subset, fullreposet):
1915 return baseset([None])
1916 return baseset([None])
1916 return baseset()
1917 return baseset()
1917
1918
1918 # for internal use
1919 # for internal use
1919 def _list(repo, subset, x):
1920 def _list(repo, subset, x):
1920 s = getstring(x, "internal error")
1921 s = getstring(x, "internal error")
1921 if not s:
1922 if not s:
1922 return baseset()
1923 return baseset()
1923 ls = [repo[r].rev() for r in s.split('\0')]
1924 ls = [repo[r].rev() for r in s.split('\0')]
1924 s = subset
1925 s = subset
1925 return baseset([r for r in ls if r in s])
1926 return baseset([r for r in ls if r in s])
1926
1927
1927 # for internal use
1928 # for internal use
1928 def _intlist(repo, subset, x):
1929 def _intlist(repo, subset, x):
1929 s = getstring(x, "internal error")
1930 s = getstring(x, "internal error")
1930 if not s:
1931 if not s:
1931 return baseset()
1932 return baseset()
1932 ls = [int(r) for r in s.split('\0')]
1933 ls = [int(r) for r in s.split('\0')]
1933 s = subset
1934 s = subset
1934 return baseset([r for r in ls if r in s])
1935 return baseset([r for r in ls if r in s])
1935
1936
1936 # for internal use
1937 # for internal use
1937 def _hexlist(repo, subset, x):
1938 def _hexlist(repo, subset, x):
1938 s = getstring(x, "internal error")
1939 s = getstring(x, "internal error")
1939 if not s:
1940 if not s:
1940 return baseset()
1941 return baseset()
1941 cl = repo.changelog
1942 cl = repo.changelog
1942 ls = [cl.rev(node.bin(r)) for r in s.split('\0')]
1943 ls = [cl.rev(node.bin(r)) for r in s.split('\0')]
1943 s = subset
1944 s = subset
1944 return baseset([r for r in ls if r in s])
1945 return baseset([r for r in ls if r in s])
1945
1946
1946 symbols = {
1947 symbols = {
1947 "adds": adds,
1948 "adds": adds,
1948 "all": getall,
1949 "all": getall,
1949 "ancestor": ancestor,
1950 "ancestor": ancestor,
1950 "ancestors": ancestors,
1951 "ancestors": ancestors,
1951 "_firstancestors": _firstancestors,
1952 "_firstancestors": _firstancestors,
1952 "author": author,
1953 "author": author,
1953 "bisect": bisect,
1954 "bisect": bisect,
1954 "bisected": bisected,
1955 "bisected": bisected,
1955 "bookmark": bookmark,
1956 "bookmark": bookmark,
1956 "branch": branch,
1957 "branch": branch,
1957 "branchpoint": branchpoint,
1958 "branchpoint": branchpoint,
1958 "bumped": bumped,
1959 "bumped": bumped,
1959 "bundle": bundle,
1960 "bundle": bundle,
1960 "children": children,
1961 "children": children,
1961 "closed": closed,
1962 "closed": closed,
1962 "contains": contains,
1963 "contains": contains,
1963 "converted": converted,
1964 "converted": converted,
1964 "date": date,
1965 "date": date,
1965 "desc": desc,
1966 "desc": desc,
1966 "descendants": descendants,
1967 "descendants": descendants,
1967 "_firstdescendants": _firstdescendants,
1968 "_firstdescendants": _firstdescendants,
1968 "destination": destination,
1969 "destination": destination,
1969 "divergent": divergent,
1970 "divergent": divergent,
1970 "draft": draft,
1971 "draft": draft,
1971 "extinct": extinct,
1972 "extinct": extinct,
1972 "extra": extra,
1973 "extra": extra,
1973 "file": hasfile,
1974 "file": hasfile,
1974 "filelog": filelog,
1975 "filelog": filelog,
1975 "first": first,
1976 "first": first,
1976 "follow": follow,
1977 "follow": follow,
1977 "_followfirst": _followfirst,
1978 "_followfirst": _followfirst,
1978 "grep": grep,
1979 "grep": grep,
1979 "head": head,
1980 "head": head,
1980 "heads": heads,
1981 "heads": heads,
1981 "hidden": hidden,
1982 "hidden": hidden,
1982 "id": node_,
1983 "id": node_,
1983 "keyword": keyword,
1984 "keyword": keyword,
1984 "last": last,
1985 "last": last,
1985 "limit": limit,
1986 "limit": limit,
1986 "_matchfiles": _matchfiles,
1987 "_matchfiles": _matchfiles,
1987 "max": maxrev,
1988 "max": maxrev,
1988 "merge": merge,
1989 "merge": merge,
1989 "min": minrev,
1990 "min": minrev,
1990 "modifies": modifies,
1991 "modifies": modifies,
1991 "named": named,
1992 "named": named,
1992 "obsolete": obsolete,
1993 "obsolete": obsolete,
1993 "only": only,
1994 "only": only,
1994 "origin": origin,
1995 "origin": origin,
1995 "outgoing": outgoing,
1996 "outgoing": outgoing,
1996 "p1": p1,
1997 "p1": p1,
1997 "p2": p2,
1998 "p2": p2,
1998 "parents": parents,
1999 "parents": parents,
1999 "present": present,
2000 "present": present,
2000 "public": public,
2001 "public": public,
2001 "_notpublic": _notpublic,
2002 "_notpublic": _notpublic,
2002 "remote": remote,
2003 "remote": remote,
2003 "removes": removes,
2004 "removes": removes,
2004 "rev": rev,
2005 "rev": rev,
2005 "reverse": reverse,
2006 "reverse": reverse,
2006 "roots": roots,
2007 "roots": roots,
2007 "sort": sort,
2008 "sort": sort,
2008 "secret": secret,
2009 "secret": secret,
2009 "subrepo": subrepo,
2010 "subrepo": subrepo,
2010 "matching": matching,
2011 "matching": matching,
2011 "tag": tag,
2012 "tag": tag,
2012 "tagged": tagged,
2013 "tagged": tagged,
2013 "user": user,
2014 "user": user,
2014 "unstable": unstable,
2015 "unstable": unstable,
2015 "wdir": wdir,
2016 "wdir": wdir,
2016 "_list": _list,
2017 "_list": _list,
2017 "_intlist": _intlist,
2018 "_intlist": _intlist,
2018 "_hexlist": _hexlist,
2019 "_hexlist": _hexlist,
2019 }
2020 }
2020
2021
2021 # symbols which can't be used for a DoS attack for any given input
2022 # symbols which can't be used for a DoS attack for any given input
2022 # (e.g. those which accept regexes as plain strings shouldn't be included)
2023 # (e.g. those which accept regexes as plain strings shouldn't be included)
2023 # functions that just return a lot of changesets (like all) don't count here
2024 # functions that just return a lot of changesets (like all) don't count here
2024 safesymbols = set([
2025 safesymbols = set([
2025 "adds",
2026 "adds",
2026 "all",
2027 "all",
2027 "ancestor",
2028 "ancestor",
2028 "ancestors",
2029 "ancestors",
2029 "_firstancestors",
2030 "_firstancestors",
2030 "author",
2031 "author",
2031 "bisect",
2032 "bisect",
2032 "bisected",
2033 "bisected",
2033 "bookmark",
2034 "bookmark",
2034 "branch",
2035 "branch",
2035 "branchpoint",
2036 "branchpoint",
2036 "bumped",
2037 "bumped",
2037 "bundle",
2038 "bundle",
2038 "children",
2039 "children",
2039 "closed",
2040 "closed",
2040 "converted",
2041 "converted",
2041 "date",
2042 "date",
2042 "desc",
2043 "desc",
2043 "descendants",
2044 "descendants",
2044 "_firstdescendants",
2045 "_firstdescendants",
2045 "destination",
2046 "destination",
2046 "divergent",
2047 "divergent",
2047 "draft",
2048 "draft",
2048 "extinct",
2049 "extinct",
2049 "extra",
2050 "extra",
2050 "file",
2051 "file",
2051 "filelog",
2052 "filelog",
2052 "first",
2053 "first",
2053 "follow",
2054 "follow",
2054 "_followfirst",
2055 "_followfirst",
2055 "head",
2056 "head",
2056 "heads",
2057 "heads",
2057 "hidden",
2058 "hidden",
2058 "id",
2059 "id",
2059 "keyword",
2060 "keyword",
2060 "last",
2061 "last",
2061 "limit",
2062 "limit",
2062 "_matchfiles",
2063 "_matchfiles",
2063 "max",
2064 "max",
2064 "merge",
2065 "merge",
2065 "min",
2066 "min",
2066 "modifies",
2067 "modifies",
2067 "obsolete",
2068 "obsolete",
2068 "only",
2069 "only",
2069 "origin",
2070 "origin",
2070 "outgoing",
2071 "outgoing",
2071 "p1",
2072 "p1",
2072 "p2",
2073 "p2",
2073 "parents",
2074 "parents",
2074 "present",
2075 "present",
2075 "public",
2076 "public",
2076 "_notpublic",
2077 "_notpublic",
2077 "remote",
2078 "remote",
2078 "removes",
2079 "removes",
2079 "rev",
2080 "rev",
2080 "reverse",
2081 "reverse",
2081 "roots",
2082 "roots",
2082 "sort",
2083 "sort",
2083 "secret",
2084 "secret",
2084 "matching",
2085 "matching",
2085 "tag",
2086 "tag",
2086 "tagged",
2087 "tagged",
2087 "user",
2088 "user",
2088 "unstable",
2089 "unstable",
2089 "wdir",
2090 "wdir",
2090 "_list",
2091 "_list",
2091 "_intlist",
2092 "_intlist",
2092 "_hexlist",
2093 "_hexlist",
2093 ])
2094 ])
2094
2095
2095 methods = {
2096 methods = {
2096 "range": rangeset,
2097 "range": rangeset,
2097 "dagrange": dagrange,
2098 "dagrange": dagrange,
2098 "string": stringset,
2099 "string": stringset,
2099 "symbol": stringset,
2100 "symbol": stringset,
2100 "and": andset,
2101 "and": andset,
2101 "or": orset,
2102 "or": orset,
2102 "not": notset,
2103 "not": notset,
2103 "list": listset,
2104 "list": listset,
2104 "func": func,
2105 "func": func,
2105 "ancestor": ancestorspec,
2106 "ancestor": ancestorspec,
2106 "parent": parentspec,
2107 "parent": parentspec,
2107 "parentpost": p1,
2108 "parentpost": p1,
2108 }
2109 }
2109
2110
2110 def optimize(x, small):
2111 def optimize(x, small):
2111 if x is None:
2112 if x is None:
2112 return 0, x
2113 return 0, x
2113
2114
2114 smallbonus = 1
2115 smallbonus = 1
2115 if small:
2116 if small:
2116 smallbonus = .5
2117 smallbonus = .5
2117
2118
2118 op = x[0]
2119 op = x[0]
2119 if op == 'minus':
2120 if op == 'minus':
2120 return optimize(('and', x[1], ('not', x[2])), small)
2121 return optimize(('and', x[1], ('not', x[2])), small)
2121 elif op == 'only':
2122 elif op == 'only':
2122 return optimize(('func', ('symbol', 'only'),
2123 return optimize(('func', ('symbol', 'only'),
2123 ('list', x[1], x[2])), small)
2124 ('list', x[1], x[2])), small)
2124 elif op == 'onlypost':
2125 elif op == 'onlypost':
2125 return optimize(('func', ('symbol', 'only'), x[1]), small)
2126 return optimize(('func', ('symbol', 'only'), x[1]), small)
2126 elif op == 'dagrangepre':
2127 elif op == 'dagrangepre':
2127 return optimize(('func', ('symbol', 'ancestors'), x[1]), small)
2128 return optimize(('func', ('symbol', 'ancestors'), x[1]), small)
2128 elif op == 'dagrangepost':
2129 elif op == 'dagrangepost':
2129 return optimize(('func', ('symbol', 'descendants'), x[1]), small)
2130 return optimize(('func', ('symbol', 'descendants'), x[1]), small)
2130 elif op == 'rangepre':
2131 elif op == 'rangepre':
2131 return optimize(('range', ('string', '0'), x[1]), small)
2132 return optimize(('range', ('string', '0'), x[1]), small)
2132 elif op == 'rangepost':
2133 elif op == 'rangepost':
2133 return optimize(('range', x[1], ('string', 'tip')), small)
2134 return optimize(('range', x[1], ('string', 'tip')), small)
2134 elif op == 'negate':
2135 elif op == 'negate':
2135 return optimize(('string',
2136 return optimize(('string',
2136 '-' + getstring(x[1], _("can't negate that"))), small)
2137 '-' + getstring(x[1], _("can't negate that"))), small)
2137 elif op in 'string symbol negate':
2138 elif op in 'string symbol negate':
2138 return smallbonus, x # single revisions are small
2139 return smallbonus, x # single revisions are small
2139 elif op == 'and':
2140 elif op == 'and':
2140 wa, ta = optimize(x[1], True)
2141 wa, ta = optimize(x[1], True)
2141 wb, tb = optimize(x[2], True)
2142 wb, tb = optimize(x[2], True)
2142
2143
2143 # (::x and not ::y)/(not ::y and ::x) have a fast path
2144 # (::x and not ::y)/(not ::y and ::x) have a fast path
2144 def isonly(revs, bases):
2145 def isonly(revs, bases):
2145 return (
2146 return (
2146 revs[0] == 'func'
2147 revs[0] == 'func'
2147 and getstring(revs[1], _('not a symbol')) == 'ancestors'
2148 and getstring(revs[1], _('not a symbol')) == 'ancestors'
2148 and bases[0] == 'not'
2149 and bases[0] == 'not'
2149 and bases[1][0] == 'func'
2150 and bases[1][0] == 'func'
2150 and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
2151 and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
2151
2152
2152 w = min(wa, wb)
2153 w = min(wa, wb)
2153 if isonly(ta, tb):
2154 if isonly(ta, tb):
2154 return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2]))
2155 return w, ('func', ('symbol', 'only'), ('list', ta[2], tb[1][2]))
2155 if isonly(tb, ta):
2156 if isonly(tb, ta):
2156 return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2]))
2157 return w, ('func', ('symbol', 'only'), ('list', tb[2], ta[1][2]))
2157
2158
2158 if wa > wb:
2159 if wa > wb:
2159 return w, (op, tb, ta)
2160 return w, (op, tb, ta)
2160 return w, (op, ta, tb)
2161 return w, (op, ta, tb)
2161 elif op == 'or':
2162 elif op == 'or':
2162 wa, ta = optimize(x[1], False)
2163 wa, ta = optimize(x[1], False)
2163 wb, tb = optimize(x[2], False)
2164 wb, tb = optimize(x[2], False)
2164 if wb < wa:
2165 if wb < wa:
2165 wb, wa = wa, wb
2166 wb, wa = wa, wb
2166 return max(wa, wb), (op, ta, tb)
2167 return max(wa, wb), (op, ta, tb)
2167 elif op == 'not':
2168 elif op == 'not':
2168 # Optimize not public() to _notpublic() because we have a fast version
2169 # Optimize not public() to _notpublic() because we have a fast version
2169 if x[1] == ('func', ('symbol', 'public'), None):
2170 if x[1] == ('func', ('symbol', 'public'), None):
2170 newsym = ('func', ('symbol', '_notpublic'), None)
2171 newsym = ('func', ('symbol', '_notpublic'), None)
2171 o = optimize(newsym, not small)
2172 o = optimize(newsym, not small)
2172 return o[0], o[1]
2173 return o[0], o[1]
2173 else:
2174 else:
2174 o = optimize(x[1], not small)
2175 o = optimize(x[1], not small)
2175 return o[0], (op, o[1])
2176 return o[0], (op, o[1])
2176 elif op == 'parentpost':
2177 elif op == 'parentpost':
2177 o = optimize(x[1], small)
2178 o = optimize(x[1], small)
2178 return o[0], (op, o[1])
2179 return o[0], (op, o[1])
2179 elif op == 'group':
2180 elif op == 'group':
2180 return optimize(x[1], small)
2181 return optimize(x[1], small)
2181 elif op in 'dagrange range list parent ancestorspec':
2182 elif op in 'dagrange range list parent ancestorspec':
2182 if op == 'parent':
2183 if op == 'parent':
2183 # x^:y means (x^) : y, not x ^ (:y)
2184 # x^:y means (x^) : y, not x ^ (:y)
2184 post = ('parentpost', x[1])
2185 post = ('parentpost', x[1])
2185 if x[2][0] == 'dagrangepre':
2186 if x[2][0] == 'dagrangepre':
2186 return optimize(('dagrange', post, x[2][1]), small)
2187 return optimize(('dagrange', post, x[2][1]), small)
2187 elif x[2][0] == 'rangepre':
2188 elif x[2][0] == 'rangepre':
2188 return optimize(('range', post, x[2][1]), small)
2189 return optimize(('range', post, x[2][1]), small)
2189
2190
2190 wa, ta = optimize(x[1], small)
2191 wa, ta = optimize(x[1], small)
2191 wb, tb = optimize(x[2], small)
2192 wb, tb = optimize(x[2], small)
2192 return wa + wb, (op, ta, tb)
2193 return wa + wb, (op, ta, tb)
2193 elif op == 'func':
2194 elif op == 'func':
2194 f = getstring(x[1], _("not a symbol"))
2195 f = getstring(x[1], _("not a symbol"))
2195 wa, ta = optimize(x[2], small)
2196 wa, ta = optimize(x[2], small)
2196 if f in ("author branch closed date desc file grep keyword "
2197 if f in ("author branch closed date desc file grep keyword "
2197 "outgoing user"):
2198 "outgoing user"):
2198 w = 10 # slow
2199 w = 10 # slow
2199 elif f in "modifies adds removes":
2200 elif f in "modifies adds removes":
2200 w = 30 # slower
2201 w = 30 # slower
2201 elif f == "contains":
2202 elif f == "contains":
2202 w = 100 # very slow
2203 w = 100 # very slow
2203 elif f == "ancestor":
2204 elif f == "ancestor":
2204 w = 1 * smallbonus
2205 w = 1 * smallbonus
2205 elif f in "reverse limit first _intlist":
2206 elif f in "reverse limit first _intlist":
2206 w = 0
2207 w = 0
2207 elif f in "sort":
2208 elif f in "sort":
2208 w = 10 # assume most sorts look at changelog
2209 w = 10 # assume most sorts look at changelog
2209 else:
2210 else:
2210 w = 1
2211 w = 1
2211 return w + wa, (op, x[1], ta)
2212 return w + wa, (op, x[1], ta)
2212 return 1, x
2213 return 1, x
2213
2214
2214 _aliasarg = ('func', ('symbol', '_aliasarg'))
2215 _aliasarg = ('func', ('symbol', '_aliasarg'))
2215 def _getaliasarg(tree):
2216 def _getaliasarg(tree):
2216 """If tree matches ('func', ('symbol', '_aliasarg'), ('string', X))
2217 """If tree matches ('func', ('symbol', '_aliasarg'), ('string', X))
2217 return X, None otherwise.
2218 return X, None otherwise.
2218 """
2219 """
2219 if (len(tree) == 3 and tree[:2] == _aliasarg
2220 if (len(tree) == 3 and tree[:2] == _aliasarg
2220 and tree[2][0] == 'string'):
2221 and tree[2][0] == 'string'):
2221 return tree[2][1]
2222 return tree[2][1]
2222 return None
2223 return None
2223
2224
2224 def _checkaliasarg(tree, known=None):
2225 def _checkaliasarg(tree, known=None):
2225 """Check tree contains no _aliasarg construct or only ones which
2226 """Check tree contains no _aliasarg construct or only ones which
2226 value is in known. Used to avoid alias placeholders injection.
2227 value is in known. Used to avoid alias placeholders injection.
2227 """
2228 """
2228 if isinstance(tree, tuple):
2229 if isinstance(tree, tuple):
2229 arg = _getaliasarg(tree)
2230 arg = _getaliasarg(tree)
2230 if arg is not None and (not known or arg not in known):
2231 if arg is not None and (not known or arg not in known):
2231 raise error.UnknownIdentifier('_aliasarg', [])
2232 raise error.UnknownIdentifier('_aliasarg', [])
2232 for t in tree:
2233 for t in tree:
2233 _checkaliasarg(t, known)
2234 _checkaliasarg(t, known)
2234
2235
2235 # the set of valid characters for the initial letter of symbols in
2236 # the set of valid characters for the initial letter of symbols in
2236 # alias declarations and definitions
2237 # alias declarations and definitions
2237 _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)]
2238 _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)]
2238 if c.isalnum() or c in '._@$' or ord(c) > 127)
2239 if c.isalnum() or c in '._@$' or ord(c) > 127)
2239
2240
2240 def _tokenizealias(program, lookup=None):
2241 def _tokenizealias(program, lookup=None):
2241 """Parse alias declaration/definition into a stream of tokens
2242 """Parse alias declaration/definition into a stream of tokens
2242
2243
2243 This allows symbol names to use also ``$`` as an initial letter
2244 This allows symbol names to use also ``$`` as an initial letter
2244 (for backward compatibility), and callers of this function should
2245 (for backward compatibility), and callers of this function should
2245 examine whether ``$`` is used also for unexpected symbols or not.
2246 examine whether ``$`` is used also for unexpected symbols or not.
2246 """
2247 """
2247 return tokenize(program, lookup=lookup,
2248 return tokenize(program, lookup=lookup,
2248 syminitletters=_aliassyminitletters)
2249 syminitletters=_aliassyminitletters)
2249
2250
2250 def _parsealiasdecl(decl):
2251 def _parsealiasdecl(decl):
2251 """Parse alias declaration ``decl``
2252 """Parse alias declaration ``decl``
2252
2253
2253 This returns ``(name, tree, args, errorstr)`` tuple:
2254 This returns ``(name, tree, args, errorstr)`` tuple:
2254
2255
2255 - ``name``: of declared alias (may be ``decl`` itself at error)
2256 - ``name``: of declared alias (may be ``decl`` itself at error)
2256 - ``tree``: parse result (or ``None`` at error)
2257 - ``tree``: parse result (or ``None`` at error)
2257 - ``args``: list of alias argument names (or None for symbol declaration)
2258 - ``args``: list of alias argument names (or None for symbol declaration)
2258 - ``errorstr``: detail about detected error (or None)
2259 - ``errorstr``: detail about detected error (or None)
2259
2260
2260 >>> _parsealiasdecl('foo')
2261 >>> _parsealiasdecl('foo')
2261 ('foo', ('symbol', 'foo'), None, None)
2262 ('foo', ('symbol', 'foo'), None, None)
2262 >>> _parsealiasdecl('$foo')
2263 >>> _parsealiasdecl('$foo')
2263 ('$foo', None, None, "'$' not for alias arguments")
2264 ('$foo', None, None, "'$' not for alias arguments")
2264 >>> _parsealiasdecl('foo::bar')
2265 >>> _parsealiasdecl('foo::bar')
2265 ('foo::bar', None, None, 'invalid format')
2266 ('foo::bar', None, None, 'invalid format')
2266 >>> _parsealiasdecl('foo bar')
2267 >>> _parsealiasdecl('foo bar')
2267 ('foo bar', None, None, 'at 4: invalid token')
2268 ('foo bar', None, None, 'at 4: invalid token')
2268 >>> _parsealiasdecl('foo()')
2269 >>> _parsealiasdecl('foo()')
2269 ('foo', ('func', ('symbol', 'foo')), [], None)
2270 ('foo', ('func', ('symbol', 'foo')), [], None)
2270 >>> _parsealiasdecl('$foo()')
2271 >>> _parsealiasdecl('$foo()')
2271 ('$foo()', None, None, "'$' not for alias arguments")
2272 ('$foo()', None, None, "'$' not for alias arguments")
2272 >>> _parsealiasdecl('foo($1, $2)')
2273 >>> _parsealiasdecl('foo($1, $2)')
2273 ('foo', ('func', ('symbol', 'foo')), ['$1', '$2'], None)
2274 ('foo', ('func', ('symbol', 'foo')), ['$1', '$2'], None)
2274 >>> _parsealiasdecl('foo(bar_bar, baz.baz)')
2275 >>> _parsealiasdecl('foo(bar_bar, baz.baz)')
2275 ('foo', ('func', ('symbol', 'foo')), ['bar_bar', 'baz.baz'], None)
2276 ('foo', ('func', ('symbol', 'foo')), ['bar_bar', 'baz.baz'], None)
2276 >>> _parsealiasdecl('foo($1, $2, nested($1, $2))')
2277 >>> _parsealiasdecl('foo($1, $2, nested($1, $2))')
2277 ('foo($1, $2, nested($1, $2))', None, None, 'invalid argument list')
2278 ('foo($1, $2, nested($1, $2))', None, None, 'invalid argument list')
2278 >>> _parsealiasdecl('foo(bar($1, $2))')
2279 >>> _parsealiasdecl('foo(bar($1, $2))')
2279 ('foo(bar($1, $2))', None, None, 'invalid argument list')
2280 ('foo(bar($1, $2))', None, None, 'invalid argument list')
2280 >>> _parsealiasdecl('foo("string")')
2281 >>> _parsealiasdecl('foo("string")')
2281 ('foo("string")', None, None, 'invalid argument list')
2282 ('foo("string")', None, None, 'invalid argument list')
2282 >>> _parsealiasdecl('foo($1, $2')
2283 >>> _parsealiasdecl('foo($1, $2')
2283 ('foo($1, $2', None, None, 'at 10: unexpected token: end')
2284 ('foo($1, $2', None, None, 'at 10: unexpected token: end')
2284 >>> _parsealiasdecl('foo("string')
2285 >>> _parsealiasdecl('foo("string')
2285 ('foo("string', None, None, 'at 5: unterminated string')
2286 ('foo("string', None, None, 'at 5: unterminated string')
2286 >>> _parsealiasdecl('foo($1, $2, $1)')
2287 >>> _parsealiasdecl('foo($1, $2, $1)')
2287 ('foo', None, None, 'argument names collide with each other')
2288 ('foo', None, None, 'argument names collide with each other')
2288 """
2289 """
2289 p = parser.parser(_tokenizealias, elements)
2290 p = parser.parser(_tokenizealias, elements)
2290 try:
2291 try:
2291 tree, pos = p.parse(decl)
2292 tree, pos = p.parse(decl)
2292 if (pos != len(decl)):
2293 if (pos != len(decl)):
2293 raise error.ParseError(_('invalid token'), pos)
2294 raise error.ParseError(_('invalid token'), pos)
2294
2295
2295 if isvalidsymbol(tree):
2296 if isvalidsymbol(tree):
2296 # "name = ...." style
2297 # "name = ...." style
2297 name = getsymbol(tree)
2298 name = getsymbol(tree)
2298 if name.startswith('$'):
2299 if name.startswith('$'):
2299 return (decl, None, None, _("'$' not for alias arguments"))
2300 return (decl, None, None, _("'$' not for alias arguments"))
2300 return (name, ('symbol', name), None, None)
2301 return (name, ('symbol', name), None, None)
2301
2302
2302 if isvalidfunc(tree):
2303 if isvalidfunc(tree):
2303 # "name(arg, ....) = ...." style
2304 # "name(arg, ....) = ...." style
2304 name = getfuncname(tree)
2305 name = getfuncname(tree)
2305 if name.startswith('$'):
2306 if name.startswith('$'):
2306 return (decl, None, None, _("'$' not for alias arguments"))
2307 return (decl, None, None, _("'$' not for alias arguments"))
2307 args = []
2308 args = []
2308 for arg in getfuncargs(tree):
2309 for arg in getfuncargs(tree):
2309 if not isvalidsymbol(arg):
2310 if not isvalidsymbol(arg):
2310 return (decl, None, None, _("invalid argument list"))
2311 return (decl, None, None, _("invalid argument list"))
2311 args.append(getsymbol(arg))
2312 args.append(getsymbol(arg))
2312 if len(args) != len(set(args)):
2313 if len(args) != len(set(args)):
2313 return (name, None, None,
2314 return (name, None, None,
2314 _("argument names collide with each other"))
2315 _("argument names collide with each other"))
2315 return (name, ('func', ('symbol', name)), args, None)
2316 return (name, ('func', ('symbol', name)), args, None)
2316
2317
2317 return (decl, None, None, _("invalid format"))
2318 return (decl, None, None, _("invalid format"))
2318 except error.ParseError, inst:
2319 except error.ParseError, inst:
2319 return (decl, None, None, parseerrordetail(inst))
2320 return (decl, None, None, parseerrordetail(inst))
2320
2321
2321 def _parsealiasdefn(defn, args):
2322 def _parsealiasdefn(defn, args):
2322 """Parse alias definition ``defn``
2323 """Parse alias definition ``defn``
2323
2324
2324 This function also replaces alias argument references in the
2325 This function also replaces alias argument references in the
2325 specified definition by ``_aliasarg(ARGNAME)``.
2326 specified definition by ``_aliasarg(ARGNAME)``.
2326
2327
2327 ``args`` is a list of alias argument names, or None if the alias
2328 ``args`` is a list of alias argument names, or None if the alias
2328 is declared as a symbol.
2329 is declared as a symbol.
2329
2330
2330 This returns "tree" as parsing result.
2331 This returns "tree" as parsing result.
2331
2332
2332 >>> args = ['$1', '$2', 'foo']
2333 >>> args = ['$1', '$2', 'foo']
2333 >>> print prettyformat(_parsealiasdefn('$1 or foo', args))
2334 >>> print prettyformat(_parsealiasdefn('$1 or foo', args))
2334 (or
2335 (or
2335 (func
2336 (func
2336 ('symbol', '_aliasarg')
2337 ('symbol', '_aliasarg')
2337 ('string', '$1'))
2338 ('string', '$1'))
2338 (func
2339 (func
2339 ('symbol', '_aliasarg')
2340 ('symbol', '_aliasarg')
2340 ('string', 'foo')))
2341 ('string', 'foo')))
2341 >>> try:
2342 >>> try:
2342 ... _parsealiasdefn('$1 or $bar', args)
2343 ... _parsealiasdefn('$1 or $bar', args)
2343 ... except error.ParseError, inst:
2344 ... except error.ParseError, inst:
2344 ... print parseerrordetail(inst)
2345 ... print parseerrordetail(inst)
2345 at 6: '$' not for alias arguments
2346 at 6: '$' not for alias arguments
2346 >>> args = ['$1', '$10', 'foo']
2347 >>> args = ['$1', '$10', 'foo']
2347 >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
2348 >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
2348 (or
2349 (or
2349 (func
2350 (func
2350 ('symbol', '_aliasarg')
2351 ('symbol', '_aliasarg')
2351 ('string', '$10'))
2352 ('string', '$10'))
2352 ('symbol', 'foobar'))
2353 ('symbol', 'foobar'))
2353 >>> print prettyformat(_parsealiasdefn('"$1" or "foo"', args))
2354 >>> print prettyformat(_parsealiasdefn('"$1" or "foo"', args))
2354 (or
2355 (or
2355 ('string', '$1')
2356 ('string', '$1')
2356 ('string', 'foo'))
2357 ('string', 'foo'))
2357 """
2358 """
2358 def tokenizedefn(program, lookup=None):
2359 def tokenizedefn(program, lookup=None):
2359 if args:
2360 if args:
2360 argset = set(args)
2361 argset = set(args)
2361 else:
2362 else:
2362 argset = set()
2363 argset = set()
2363
2364
2364 for t, value, pos in _tokenizealias(program, lookup=lookup):
2365 for t, value, pos in _tokenizealias(program, lookup=lookup):
2365 if t == 'symbol':
2366 if t == 'symbol':
2366 if value in argset:
2367 if value in argset:
2367 # emulate tokenization of "_aliasarg('ARGNAME')":
2368 # emulate tokenization of "_aliasarg('ARGNAME')":
2368 # "_aliasarg()" is an unknown symbol only used separate
2369 # "_aliasarg()" is an unknown symbol only used separate
2369 # alias argument placeholders from regular strings.
2370 # alias argument placeholders from regular strings.
2370 yield ('symbol', '_aliasarg', pos)
2371 yield ('symbol', '_aliasarg', pos)
2371 yield ('(', None, pos)
2372 yield ('(', None, pos)
2372 yield ('string', value, pos)
2373 yield ('string', value, pos)
2373 yield (')', None, pos)
2374 yield (')', None, pos)
2374 continue
2375 continue
2375 elif value.startswith('$'):
2376 elif value.startswith('$'):
2376 raise error.ParseError(_("'$' not for alias arguments"),
2377 raise error.ParseError(_("'$' not for alias arguments"),
2377 pos)
2378 pos)
2378 yield (t, value, pos)
2379 yield (t, value, pos)
2379
2380
2380 p = parser.parser(tokenizedefn, elements)
2381 p = parser.parser(tokenizedefn, elements)
2381 tree, pos = p.parse(defn)
2382 tree, pos = p.parse(defn)
2382 if pos != len(defn):
2383 if pos != len(defn):
2383 raise error.ParseError(_('invalid token'), pos)
2384 raise error.ParseError(_('invalid token'), pos)
2384 return tree
2385 return tree
2385
2386
2386 class revsetalias(object):
2387 class revsetalias(object):
2387 # whether own `error` information is already shown or not.
2388 # whether own `error` information is already shown or not.
2388 # this avoids showing same warning multiple times at each `findaliases`.
2389 # this avoids showing same warning multiple times at each `findaliases`.
2389 warned = False
2390 warned = False
2390
2391
2391 def __init__(self, name, value):
2392 def __init__(self, name, value):
2392 '''Aliases like:
2393 '''Aliases like:
2393
2394
2394 h = heads(default)
2395 h = heads(default)
2395 b($1) = ancestors($1) - ancestors(default)
2396 b($1) = ancestors($1) - ancestors(default)
2396 '''
2397 '''
2397 self.name, self.tree, self.args, self.error = _parsealiasdecl(name)
2398 self.name, self.tree, self.args, self.error = _parsealiasdecl(name)
2398 if self.error:
2399 if self.error:
2399 self.error = _('failed to parse the declaration of revset alias'
2400 self.error = _('failed to parse the declaration of revset alias'
2400 ' "%s": %s') % (self.name, self.error)
2401 ' "%s": %s') % (self.name, self.error)
2401 return
2402 return
2402
2403
2403 try:
2404 try:
2404 self.replacement = _parsealiasdefn(value, self.args)
2405 self.replacement = _parsealiasdefn(value, self.args)
2405 # Check for placeholder injection
2406 # Check for placeholder injection
2406 _checkaliasarg(self.replacement, self.args)
2407 _checkaliasarg(self.replacement, self.args)
2407 except error.ParseError, inst:
2408 except error.ParseError, inst:
2408 self.error = _('failed to parse the definition of revset alias'
2409 self.error = _('failed to parse the definition of revset alias'
2409 ' "%s": %s') % (self.name, parseerrordetail(inst))
2410 ' "%s": %s') % (self.name, parseerrordetail(inst))
2410
2411
2411 def _getalias(aliases, tree):
2412 def _getalias(aliases, tree):
2412 """If tree looks like an unexpanded alias, return it. Return None
2413 """If tree looks like an unexpanded alias, return it. Return None
2413 otherwise.
2414 otherwise.
2414 """
2415 """
2415 if isinstance(tree, tuple) and tree:
2416 if isinstance(tree, tuple) and tree:
2416 if tree[0] == 'symbol' and len(tree) == 2:
2417 if tree[0] == 'symbol' and len(tree) == 2:
2417 name = tree[1]
2418 name = tree[1]
2418 alias = aliases.get(name)
2419 alias = aliases.get(name)
2419 if alias and alias.args is None and alias.tree == tree:
2420 if alias and alias.args is None and alias.tree == tree:
2420 return alias
2421 return alias
2421 if tree[0] == 'func' and len(tree) > 1:
2422 if tree[0] == 'func' and len(tree) > 1:
2422 if tree[1][0] == 'symbol' and len(tree[1]) == 2:
2423 if tree[1][0] == 'symbol' and len(tree[1]) == 2:
2423 name = tree[1][1]
2424 name = tree[1][1]
2424 alias = aliases.get(name)
2425 alias = aliases.get(name)
2425 if alias and alias.args is not None and alias.tree == tree[:2]:
2426 if alias and alias.args is not None and alias.tree == tree[:2]:
2426 return alias
2427 return alias
2427 return None
2428 return None
2428
2429
2429 def _expandargs(tree, args):
2430 def _expandargs(tree, args):
2430 """Replace _aliasarg instances with the substitution value of the
2431 """Replace _aliasarg instances with the substitution value of the
2431 same name in args, recursively.
2432 same name in args, recursively.
2432 """
2433 """
2433 if not tree or not isinstance(tree, tuple):
2434 if not tree or not isinstance(tree, tuple):
2434 return tree
2435 return tree
2435 arg = _getaliasarg(tree)
2436 arg = _getaliasarg(tree)
2436 if arg is not None:
2437 if arg is not None:
2437 return args[arg]
2438 return args[arg]
2438 return tuple(_expandargs(t, args) for t in tree)
2439 return tuple(_expandargs(t, args) for t in tree)
2439
2440
2440 def _expandaliases(aliases, tree, expanding, cache):
2441 def _expandaliases(aliases, tree, expanding, cache):
2441 """Expand aliases in tree, recursively.
2442 """Expand aliases in tree, recursively.
2442
2443
2443 'aliases' is a dictionary mapping user defined aliases to
2444 'aliases' is a dictionary mapping user defined aliases to
2444 revsetalias objects.
2445 revsetalias objects.
2445 """
2446 """
2446 if not isinstance(tree, tuple):
2447 if not isinstance(tree, tuple):
2447 # Do not expand raw strings
2448 # Do not expand raw strings
2448 return tree
2449 return tree
2449 alias = _getalias(aliases, tree)
2450 alias = _getalias(aliases, tree)
2450 if alias is not None:
2451 if alias is not None:
2451 if alias.error:
2452 if alias.error:
2452 raise util.Abort(alias.error)
2453 raise util.Abort(alias.error)
2453 if alias in expanding:
2454 if alias in expanding:
2454 raise error.ParseError(_('infinite expansion of revset alias "%s" '
2455 raise error.ParseError(_('infinite expansion of revset alias "%s" '
2455 'detected') % alias.name)
2456 'detected') % alias.name)
2456 expanding.append(alias)
2457 expanding.append(alias)
2457 if alias.name not in cache:
2458 if alias.name not in cache:
2458 cache[alias.name] = _expandaliases(aliases, alias.replacement,
2459 cache[alias.name] = _expandaliases(aliases, alias.replacement,
2459 expanding, cache)
2460 expanding, cache)
2460 result = cache[alias.name]
2461 result = cache[alias.name]
2461 expanding.pop()
2462 expanding.pop()
2462 if alias.args is not None:
2463 if alias.args is not None:
2463 l = getlist(tree[2])
2464 l = getlist(tree[2])
2464 if len(l) != len(alias.args):
2465 if len(l) != len(alias.args):
2465 raise error.ParseError(
2466 raise error.ParseError(
2466 _('invalid number of arguments: %s') % len(l))
2467 _('invalid number of arguments: %s') % len(l))
2467 l = [_expandaliases(aliases, a, [], cache) for a in l]
2468 l = [_expandaliases(aliases, a, [], cache) for a in l]
2468 result = _expandargs(result, dict(zip(alias.args, l)))
2469 result = _expandargs(result, dict(zip(alias.args, l)))
2469 else:
2470 else:
2470 result = tuple(_expandaliases(aliases, t, expanding, cache)
2471 result = tuple(_expandaliases(aliases, t, expanding, cache)
2471 for t in tree)
2472 for t in tree)
2472 return result
2473 return result
2473
2474
2474 def findaliases(ui, tree, showwarning=None):
2475 def findaliases(ui, tree, showwarning=None):
2475 _checkaliasarg(tree)
2476 _checkaliasarg(tree)
2476 aliases = {}
2477 aliases = {}
2477 for k, v in ui.configitems('revsetalias'):
2478 for k, v in ui.configitems('revsetalias'):
2478 alias = revsetalias(k, v)
2479 alias = revsetalias(k, v)
2479 aliases[alias.name] = alias
2480 aliases[alias.name] = alias
2480 tree = _expandaliases(aliases, tree, [], {})
2481 tree = _expandaliases(aliases, tree, [], {})
2481 if showwarning:
2482 if showwarning:
2482 # warn about problematic (but not referred) aliases
2483 # warn about problematic (but not referred) aliases
2483 for name, alias in sorted(aliases.iteritems()):
2484 for name, alias in sorted(aliases.iteritems()):
2484 if alias.error and not alias.warned:
2485 if alias.error and not alias.warned:
2485 showwarning(_('warning: %s\n') % (alias.error))
2486 showwarning(_('warning: %s\n') % (alias.error))
2486 alias.warned = True
2487 alias.warned = True
2487 return tree
2488 return tree
2488
2489
2489 def foldconcat(tree):
2490 def foldconcat(tree):
2490 """Fold elements to be concatenated by `##`
2491 """Fold elements to be concatenated by `##`
2491 """
2492 """
2492 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
2493 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
2493 return tree
2494 return tree
2494 if tree[0] == '_concat':
2495 if tree[0] == '_concat':
2495 pending = [tree]
2496 pending = [tree]
2496 l = []
2497 l = []
2497 while pending:
2498 while pending:
2498 e = pending.pop()
2499 e = pending.pop()
2499 if e[0] == '_concat':
2500 if e[0] == '_concat':
2500 pending.extend(reversed(e[1:]))
2501 pending.extend(reversed(e[1:]))
2501 elif e[0] in ('string', 'symbol'):
2502 elif e[0] in ('string', 'symbol'):
2502 l.append(e[1])
2503 l.append(e[1])
2503 else:
2504 else:
2504 msg = _("\"##\" can't concatenate \"%s\" element") % (e[0])
2505 msg = _("\"##\" can't concatenate \"%s\" element") % (e[0])
2505 raise error.ParseError(msg)
2506 raise error.ParseError(msg)
2506 return ('string', ''.join(l))
2507 return ('string', ''.join(l))
2507 else:
2508 else:
2508 return tuple(foldconcat(t) for t in tree)
2509 return tuple(foldconcat(t) for t in tree)
2509
2510
2510 def parse(spec, lookup=None):
2511 def parse(spec, lookup=None):
2511 p = parser.parser(tokenize, elements)
2512 p = parser.parser(tokenize, elements)
2512 tree, pos = p.parse(spec, lookup=lookup)
2513 tree, pos = p.parse(spec, lookup=lookup)
2513 if pos != len(spec):
2514 if pos != len(spec):
2514 raise error.ParseError(_("invalid token"), pos)
2515 raise error.ParseError(_("invalid token"), pos)
2515 return tree
2516 return tree
2516
2517
2517 def posttreebuilthook(tree, repo):
2518 def posttreebuilthook(tree, repo):
2518 # hook for extensions to execute code on the optimized tree
2519 # hook for extensions to execute code on the optimized tree
2519 pass
2520 pass
2520
2521
2521 def match(ui, spec, repo=None):
2522 def match(ui, spec, repo=None):
2522 if not spec:
2523 if not spec:
2523 raise error.ParseError(_("empty query"))
2524 raise error.ParseError(_("empty query"))
2524 lookup = None
2525 lookup = None
2525 if repo:
2526 if repo:
2526 lookup = repo.__contains__
2527 lookup = repo.__contains__
2527 tree = parse(spec, lookup)
2528 tree = parse(spec, lookup)
2528 if ui:
2529 if ui:
2529 tree = findaliases(ui, tree, showwarning=ui.warn)
2530 tree = findaliases(ui, tree, showwarning=ui.warn)
2530 tree = foldconcat(tree)
2531 tree = foldconcat(tree)
2531 weight, tree = optimize(tree, True)
2532 weight, tree = optimize(tree, True)
2532 posttreebuilthook(tree, repo)
2533 posttreebuilthook(tree, repo)
2533 def mfunc(repo, subset=None):
2534 def mfunc(repo, subset=None):
2534 if subset is None:
2535 if subset is None:
2535 subset = fullreposet(repo)
2536 subset = fullreposet(repo)
2536 if util.safehasattr(subset, 'isascending'):
2537 if util.safehasattr(subset, 'isascending'):
2537 result = getset(repo, subset, tree)
2538 result = getset(repo, subset, tree)
2538 else:
2539 else:
2539 result = getset(repo, baseset(subset), tree)
2540 result = getset(repo, baseset(subset), tree)
2540 return result
2541 return result
2541 return mfunc
2542 return mfunc
2542
2543
2543 def formatspec(expr, *args):
2544 def formatspec(expr, *args):
2544 '''
2545 '''
2545 This is a convenience function for using revsets internally, and
2546 This is a convenience function for using revsets internally, and
2546 escapes arguments appropriately. Aliases are intentionally ignored
2547 escapes arguments appropriately. Aliases are intentionally ignored
2547 so that intended expression behavior isn't accidentally subverted.
2548 so that intended expression behavior isn't accidentally subverted.
2548
2549
2549 Supported arguments:
2550 Supported arguments:
2550
2551
2551 %r = revset expression, parenthesized
2552 %r = revset expression, parenthesized
2552 %d = int(arg), no quoting
2553 %d = int(arg), no quoting
2553 %s = string(arg), escaped and single-quoted
2554 %s = string(arg), escaped and single-quoted
2554 %b = arg.branch(), escaped and single-quoted
2555 %b = arg.branch(), escaped and single-quoted
2555 %n = hex(arg), single-quoted
2556 %n = hex(arg), single-quoted
2556 %% = a literal '%'
2557 %% = a literal '%'
2557
2558
2558 Prefixing the type with 'l' specifies a parenthesized list of that type.
2559 Prefixing the type with 'l' specifies a parenthesized list of that type.
2559
2560
2560 >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()"))
2561 >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()"))
2561 '(10 or 11):: and ((this()) or (that()))'
2562 '(10 or 11):: and ((this()) or (that()))'
2562 >>> formatspec('%d:: and not %d::', 10, 20)
2563 >>> formatspec('%d:: and not %d::', 10, 20)
2563 '10:: and not 20::'
2564 '10:: and not 20::'
2564 >>> formatspec('%ld or %ld', [], [1])
2565 >>> formatspec('%ld or %ld', [], [1])
2565 "_list('') or 1"
2566 "_list('') or 1"
2566 >>> formatspec('keyword(%s)', 'foo\\xe9')
2567 >>> formatspec('keyword(%s)', 'foo\\xe9')
2567 "keyword('foo\\\\xe9')"
2568 "keyword('foo\\\\xe9')"
2568 >>> b = lambda: 'default'
2569 >>> b = lambda: 'default'
2569 >>> b.branch = b
2570 >>> b.branch = b
2570 >>> formatspec('branch(%b)', b)
2571 >>> formatspec('branch(%b)', b)
2571 "branch('default')"
2572 "branch('default')"
2572 >>> formatspec('root(%ls)', ['a', 'b', 'c', 'd'])
2573 >>> formatspec('root(%ls)', ['a', 'b', 'c', 'd'])
2573 "root(_list('a\\x00b\\x00c\\x00d'))"
2574 "root(_list('a\\x00b\\x00c\\x00d'))"
2574 '''
2575 '''
2575
2576
2576 def quote(s):
2577 def quote(s):
2577 return repr(str(s))
2578 return repr(str(s))
2578
2579
2579 def argtype(c, arg):
2580 def argtype(c, arg):
2580 if c == 'd':
2581 if c == 'd':
2581 return str(int(arg))
2582 return str(int(arg))
2582 elif c == 's':
2583 elif c == 's':
2583 return quote(arg)
2584 return quote(arg)
2584 elif c == 'r':
2585 elif c == 'r':
2585 parse(arg) # make sure syntax errors are confined
2586 parse(arg) # make sure syntax errors are confined
2586 return '(%s)' % arg
2587 return '(%s)' % arg
2587 elif c == 'n':
2588 elif c == 'n':
2588 return quote(node.hex(arg))
2589 return quote(node.hex(arg))
2589 elif c == 'b':
2590 elif c == 'b':
2590 return quote(arg.branch())
2591 return quote(arg.branch())
2591
2592
2592 def listexp(s, t):
2593 def listexp(s, t):
2593 l = len(s)
2594 l = len(s)
2594 if l == 0:
2595 if l == 0:
2595 return "_list('')"
2596 return "_list('')"
2596 elif l == 1:
2597 elif l == 1:
2597 return argtype(t, s[0])
2598 return argtype(t, s[0])
2598 elif t == 'd':
2599 elif t == 'd':
2599 return "_intlist('%s')" % "\0".join(str(int(a)) for a in s)
2600 return "_intlist('%s')" % "\0".join(str(int(a)) for a in s)
2600 elif t == 's':
2601 elif t == 's':
2601 return "_list('%s')" % "\0".join(s)
2602 return "_list('%s')" % "\0".join(s)
2602 elif t == 'n':
2603 elif t == 'n':
2603 return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s)
2604 return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s)
2604 elif t == 'b':
2605 elif t == 'b':
2605 return "_list('%s')" % "\0".join(a.branch() for a in s)
2606 return "_list('%s')" % "\0".join(a.branch() for a in s)
2606
2607
2607 m = l // 2
2608 m = l // 2
2608 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
2609 return '(%s or %s)' % (listexp(s[:m], t), listexp(s[m:], t))
2609
2610
2610 ret = ''
2611 ret = ''
2611 pos = 0
2612 pos = 0
2612 arg = 0
2613 arg = 0
2613 while pos < len(expr):
2614 while pos < len(expr):
2614 c = expr[pos]
2615 c = expr[pos]
2615 if c == '%':
2616 if c == '%':
2616 pos += 1
2617 pos += 1
2617 d = expr[pos]
2618 d = expr[pos]
2618 if d == '%':
2619 if d == '%':
2619 ret += d
2620 ret += d
2620 elif d in 'dsnbr':
2621 elif d in 'dsnbr':
2621 ret += argtype(d, args[arg])
2622 ret += argtype(d, args[arg])
2622 arg += 1
2623 arg += 1
2623 elif d == 'l':
2624 elif d == 'l':
2624 # a list of some type
2625 # a list of some type
2625 pos += 1
2626 pos += 1
2626 d = expr[pos]
2627 d = expr[pos]
2627 ret += listexp(list(args[arg]), d)
2628 ret += listexp(list(args[arg]), d)
2628 arg += 1
2629 arg += 1
2629 else:
2630 else:
2630 raise util.Abort('unexpected revspec format character %s' % d)
2631 raise util.Abort('unexpected revspec format character %s' % d)
2631 else:
2632 else:
2632 ret += c
2633 ret += c
2633 pos += 1
2634 pos += 1
2634
2635
2635 return ret
2636 return ret
2636
2637
2637 def prettyformat(tree):
2638 def prettyformat(tree):
2638 return parser.prettyformat(tree, ('string', 'symbol'))
2639 return parser.prettyformat(tree, ('string', 'symbol'))
2639
2640
2640 def depth(tree):
2641 def depth(tree):
2641 if isinstance(tree, tuple):
2642 if isinstance(tree, tuple):
2642 return max(map(depth, tree)) + 1
2643 return max(map(depth, tree)) + 1
2643 else:
2644 else:
2644 return 0
2645 return 0
2645
2646
2646 def funcsused(tree):
2647 def funcsused(tree):
2647 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
2648 if not isinstance(tree, tuple) or tree[0] in ('string', 'symbol'):
2648 return set()
2649 return set()
2649 else:
2650 else:
2650 funcs = set()
2651 funcs = set()
2651 for s in tree[1:]:
2652 for s in tree[1:]:
2652 funcs |= funcsused(s)
2653 funcs |= funcsused(s)
2653 if tree[0] == 'func':
2654 if tree[0] == 'func':
2654 funcs.add(tree[1][1])
2655 funcs.add(tree[1][1])
2655 return funcs
2656 return funcs
2656
2657
2657 class abstractsmartset(object):
2658 class abstractsmartset(object):
2658
2659
2659 def __nonzero__(self):
2660 def __nonzero__(self):
2660 """True if the smartset is not empty"""
2661 """True if the smartset is not empty"""
2661 raise NotImplementedError()
2662 raise NotImplementedError()
2662
2663
2663 def __contains__(self, rev):
2664 def __contains__(self, rev):
2664 """provide fast membership testing"""
2665 """provide fast membership testing"""
2665 raise NotImplementedError()
2666 raise NotImplementedError()
2666
2667
2667 def __iter__(self):
2668 def __iter__(self):
2668 """iterate the set in the order it is supposed to be iterated"""
2669 """iterate the set in the order it is supposed to be iterated"""
2669 raise NotImplementedError()
2670 raise NotImplementedError()
2670
2671
2671 # Attributes containing a function to perform a fast iteration in a given
2672 # Attributes containing a function to perform a fast iteration in a given
2672 # direction. A smartset can have none, one, or both defined.
2673 # direction. A smartset can have none, one, or both defined.
2673 #
2674 #
2674 # Default value is None instead of a function returning None to avoid
2675 # Default value is None instead of a function returning None to avoid
2675 # initializing an iterator just for testing if a fast method exists.
2676 # initializing an iterator just for testing if a fast method exists.
2676 fastasc = None
2677 fastasc = None
2677 fastdesc = None
2678 fastdesc = None
2678
2679
2679 def isascending(self):
2680 def isascending(self):
2680 """True if the set will iterate in ascending order"""
2681 """True if the set will iterate in ascending order"""
2681 raise NotImplementedError()
2682 raise NotImplementedError()
2682
2683
2683 def isdescending(self):
2684 def isdescending(self):
2684 """True if the set will iterate in descending order"""
2685 """True if the set will iterate in descending order"""
2685 raise NotImplementedError()
2686 raise NotImplementedError()
2686
2687
2687 def min(self):
2688 def min(self):
2688 """return the minimum element in the set"""
2689 """return the minimum element in the set"""
2689 if self.fastasc is not None:
2690 if self.fastasc is not None:
2690 for r in self.fastasc():
2691 for r in self.fastasc():
2691 return r
2692 return r
2692 raise ValueError('arg is an empty sequence')
2693 raise ValueError('arg is an empty sequence')
2693 return min(self)
2694 return min(self)
2694
2695
2695 def max(self):
2696 def max(self):
2696 """return the maximum element in the set"""
2697 """return the maximum element in the set"""
2697 if self.fastdesc is not None:
2698 if self.fastdesc is not None:
2698 for r in self.fastdesc():
2699 for r in self.fastdesc():
2699 return r
2700 return r
2700 raise ValueError('arg is an empty sequence')
2701 raise ValueError('arg is an empty sequence')
2701 return max(self)
2702 return max(self)
2702
2703
2703 def first(self):
2704 def first(self):
2704 """return the first element in the set (user iteration perspective)
2705 """return the first element in the set (user iteration perspective)
2705
2706
2706 Return None if the set is empty"""
2707 Return None if the set is empty"""
2707 raise NotImplementedError()
2708 raise NotImplementedError()
2708
2709
2709 def last(self):
2710 def last(self):
2710 """return the last element in the set (user iteration perspective)
2711 """return the last element in the set (user iteration perspective)
2711
2712
2712 Return None if the set is empty"""
2713 Return None if the set is empty"""
2713 raise NotImplementedError()
2714 raise NotImplementedError()
2714
2715
2715 def __len__(self):
2716 def __len__(self):
2716 """return the length of the smartsets
2717 """return the length of the smartsets
2717
2718
2718 This can be expensive on smartset that could be lazy otherwise."""
2719 This can be expensive on smartset that could be lazy otherwise."""
2719 raise NotImplementedError()
2720 raise NotImplementedError()
2720
2721
2721 def reverse(self):
2722 def reverse(self):
2722 """reverse the expected iteration order"""
2723 """reverse the expected iteration order"""
2723 raise NotImplementedError()
2724 raise NotImplementedError()
2724
2725
2725 def sort(self, reverse=True):
2726 def sort(self, reverse=True):
2726 """get the set to iterate in an ascending or descending order"""
2727 """get the set to iterate in an ascending or descending order"""
2727 raise NotImplementedError()
2728 raise NotImplementedError()
2728
2729
2729 def __and__(self, other):
2730 def __and__(self, other):
2730 """Returns a new object with the intersection of the two collections.
2731 """Returns a new object with the intersection of the two collections.
2731
2732
2732 This is part of the mandatory API for smartset."""
2733 This is part of the mandatory API for smartset."""
2733 if isinstance(other, fullreposet):
2734 if isinstance(other, fullreposet):
2734 return self
2735 return self
2735 return self.filter(other.__contains__, cache=False)
2736 return self.filter(other.__contains__, cache=False)
2736
2737
2737 def __add__(self, other):
2738 def __add__(self, other):
2738 """Returns a new object with the union of the two collections.
2739 """Returns a new object with the union of the two collections.
2739
2740
2740 This is part of the mandatory API for smartset."""
2741 This is part of the mandatory API for smartset."""
2741 return addset(self, other)
2742 return addset(self, other)
2742
2743
2743 def __sub__(self, other):
2744 def __sub__(self, other):
2744 """Returns a new object with the substraction of the two collections.
2745 """Returns a new object with the substraction of the two collections.
2745
2746
2746 This is part of the mandatory API for smartset."""
2747 This is part of the mandatory API for smartset."""
2747 c = other.__contains__
2748 c = other.__contains__
2748 return self.filter(lambda r: not c(r), cache=False)
2749 return self.filter(lambda r: not c(r), cache=False)
2749
2750
2750 def filter(self, condition, cache=True):
2751 def filter(self, condition, cache=True):
2751 """Returns this smartset filtered by condition as a new smartset.
2752 """Returns this smartset filtered by condition as a new smartset.
2752
2753
2753 `condition` is a callable which takes a revision number and returns a
2754 `condition` is a callable which takes a revision number and returns a
2754 boolean.
2755 boolean.
2755
2756
2756 This is part of the mandatory API for smartset."""
2757 This is part of the mandatory API for smartset."""
2757 # builtin cannot be cached. but do not needs to
2758 # builtin cannot be cached. but do not needs to
2758 if cache and util.safehasattr(condition, 'func_code'):
2759 if cache and util.safehasattr(condition, 'func_code'):
2759 condition = util.cachefunc(condition)
2760 condition = util.cachefunc(condition)
2760 return filteredset(self, condition)
2761 return filteredset(self, condition)
2761
2762
2762 class baseset(abstractsmartset):
2763 class baseset(abstractsmartset):
2763 """Basic data structure that represents a revset and contains the basic
2764 """Basic data structure that represents a revset and contains the basic
2764 operation that it should be able to perform.
2765 operation that it should be able to perform.
2765
2766
2766 Every method in this class should be implemented by any smartset class.
2767 Every method in this class should be implemented by any smartset class.
2767 """
2768 """
2768 def __init__(self, data=()):
2769 def __init__(self, data=()):
2769 if not isinstance(data, list):
2770 if not isinstance(data, list):
2770 data = list(data)
2771 data = list(data)
2771 self._list = data
2772 self._list = data
2772 self._ascending = None
2773 self._ascending = None
2773
2774
2774 @util.propertycache
2775 @util.propertycache
2775 def _set(self):
2776 def _set(self):
2776 return set(self._list)
2777 return set(self._list)
2777
2778
2778 @util.propertycache
2779 @util.propertycache
2779 def _asclist(self):
2780 def _asclist(self):
2780 asclist = self._list[:]
2781 asclist = self._list[:]
2781 asclist.sort()
2782 asclist.sort()
2782 return asclist
2783 return asclist
2783
2784
2784 def __iter__(self):
2785 def __iter__(self):
2785 if self._ascending is None:
2786 if self._ascending is None:
2786 return iter(self._list)
2787 return iter(self._list)
2787 elif self._ascending:
2788 elif self._ascending:
2788 return iter(self._asclist)
2789 return iter(self._asclist)
2789 else:
2790 else:
2790 return reversed(self._asclist)
2791 return reversed(self._asclist)
2791
2792
2792 def fastasc(self):
2793 def fastasc(self):
2793 return iter(self._asclist)
2794 return iter(self._asclist)
2794
2795
2795 def fastdesc(self):
2796 def fastdesc(self):
2796 return reversed(self._asclist)
2797 return reversed(self._asclist)
2797
2798
2798 @util.propertycache
2799 @util.propertycache
2799 def __contains__(self):
2800 def __contains__(self):
2800 return self._set.__contains__
2801 return self._set.__contains__
2801
2802
2802 def __nonzero__(self):
2803 def __nonzero__(self):
2803 return bool(self._list)
2804 return bool(self._list)
2804
2805
2805 def sort(self, reverse=False):
2806 def sort(self, reverse=False):
2806 self._ascending = not bool(reverse)
2807 self._ascending = not bool(reverse)
2807
2808
2808 def reverse(self):
2809 def reverse(self):
2809 if self._ascending is None:
2810 if self._ascending is None:
2810 self._list.reverse()
2811 self._list.reverse()
2811 else:
2812 else:
2812 self._ascending = not self._ascending
2813 self._ascending = not self._ascending
2813
2814
2814 def __len__(self):
2815 def __len__(self):
2815 return len(self._list)
2816 return len(self._list)
2816
2817
2817 def isascending(self):
2818 def isascending(self):
2818 """Returns True if the collection is ascending order, False if not.
2819 """Returns True if the collection is ascending order, False if not.
2819
2820
2820 This is part of the mandatory API for smartset."""
2821 This is part of the mandatory API for smartset."""
2821 if len(self) <= 1:
2822 if len(self) <= 1:
2822 return True
2823 return True
2823 return self._ascending is not None and self._ascending
2824 return self._ascending is not None and self._ascending
2824
2825
2825 def isdescending(self):
2826 def isdescending(self):
2826 """Returns True if the collection is descending order, False if not.
2827 """Returns True if the collection is descending order, False if not.
2827
2828
2828 This is part of the mandatory API for smartset."""
2829 This is part of the mandatory API for smartset."""
2829 if len(self) <= 1:
2830 if len(self) <= 1:
2830 return True
2831 return True
2831 return self._ascending is not None and not self._ascending
2832 return self._ascending is not None and not self._ascending
2832
2833
2833 def first(self):
2834 def first(self):
2834 if self:
2835 if self:
2835 if self._ascending is None:
2836 if self._ascending is None:
2836 return self._list[0]
2837 return self._list[0]
2837 elif self._ascending:
2838 elif self._ascending:
2838 return self._asclist[0]
2839 return self._asclist[0]
2839 else:
2840 else:
2840 return self._asclist[-1]
2841 return self._asclist[-1]
2841 return None
2842 return None
2842
2843
2843 def last(self):
2844 def last(self):
2844 if self:
2845 if self:
2845 if self._ascending is None:
2846 if self._ascending is None:
2846 return self._list[-1]
2847 return self._list[-1]
2847 elif self._ascending:
2848 elif self._ascending:
2848 return self._asclist[-1]
2849 return self._asclist[-1]
2849 else:
2850 else:
2850 return self._asclist[0]
2851 return self._asclist[0]
2851 return None
2852 return None
2852
2853
2853 def __repr__(self):
2854 def __repr__(self):
2854 d = {None: '', False: '-', True: '+'}[self._ascending]
2855 d = {None: '', False: '-', True: '+'}[self._ascending]
2855 return '<%s%s %r>' % (type(self).__name__, d, self._list)
2856 return '<%s%s %r>' % (type(self).__name__, d, self._list)
2856
2857
2857 class filteredset(abstractsmartset):
2858 class filteredset(abstractsmartset):
2858 """Duck type for baseset class which iterates lazily over the revisions in
2859 """Duck type for baseset class which iterates lazily over the revisions in
2859 the subset and contains a function which tests for membership in the
2860 the subset and contains a function which tests for membership in the
2860 revset
2861 revset
2861 """
2862 """
2862 def __init__(self, subset, condition=lambda x: True):
2863 def __init__(self, subset, condition=lambda x: True):
2863 """
2864 """
2864 condition: a function that decide whether a revision in the subset
2865 condition: a function that decide whether a revision in the subset
2865 belongs to the revset or not.
2866 belongs to the revset or not.
2866 """
2867 """
2867 self._subset = subset
2868 self._subset = subset
2868 self._condition = condition
2869 self._condition = condition
2869 self._cache = {}
2870 self._cache = {}
2870
2871
2871 def __contains__(self, x):
2872 def __contains__(self, x):
2872 c = self._cache
2873 c = self._cache
2873 if x not in c:
2874 if x not in c:
2874 v = c[x] = x in self._subset and self._condition(x)
2875 v = c[x] = x in self._subset and self._condition(x)
2875 return v
2876 return v
2876 return c[x]
2877 return c[x]
2877
2878
2878 def __iter__(self):
2879 def __iter__(self):
2879 return self._iterfilter(self._subset)
2880 return self._iterfilter(self._subset)
2880
2881
2881 def _iterfilter(self, it):
2882 def _iterfilter(self, it):
2882 cond = self._condition
2883 cond = self._condition
2883 for x in it:
2884 for x in it:
2884 if cond(x):
2885 if cond(x):
2885 yield x
2886 yield x
2886
2887
2887 @property
2888 @property
2888 def fastasc(self):
2889 def fastasc(self):
2889 it = self._subset.fastasc
2890 it = self._subset.fastasc
2890 if it is None:
2891 if it is None:
2891 return None
2892 return None
2892 return lambda: self._iterfilter(it())
2893 return lambda: self._iterfilter(it())
2893
2894
2894 @property
2895 @property
2895 def fastdesc(self):
2896 def fastdesc(self):
2896 it = self._subset.fastdesc
2897 it = self._subset.fastdesc
2897 if it is None:
2898 if it is None:
2898 return None
2899 return None
2899 return lambda: self._iterfilter(it())
2900 return lambda: self._iterfilter(it())
2900
2901
2901 def __nonzero__(self):
2902 def __nonzero__(self):
2902 for r in self:
2903 for r in self:
2903 return True
2904 return True
2904 return False
2905 return False
2905
2906
2906 def __len__(self):
2907 def __len__(self):
2907 # Basic implementation to be changed in future patches.
2908 # Basic implementation to be changed in future patches.
2908 l = baseset([r for r in self])
2909 l = baseset([r for r in self])
2909 return len(l)
2910 return len(l)
2910
2911
2911 def sort(self, reverse=False):
2912 def sort(self, reverse=False):
2912 self._subset.sort(reverse=reverse)
2913 self._subset.sort(reverse=reverse)
2913
2914
2914 def reverse(self):
2915 def reverse(self):
2915 self._subset.reverse()
2916 self._subset.reverse()
2916
2917
2917 def isascending(self):
2918 def isascending(self):
2918 return self._subset.isascending()
2919 return self._subset.isascending()
2919
2920
2920 def isdescending(self):
2921 def isdescending(self):
2921 return self._subset.isdescending()
2922 return self._subset.isdescending()
2922
2923
2923 def first(self):
2924 def first(self):
2924 for x in self:
2925 for x in self:
2925 return x
2926 return x
2926 return None
2927 return None
2927
2928
2928 def last(self):
2929 def last(self):
2929 it = None
2930 it = None
2930 if self._subset.isascending:
2931 if self._subset.isascending:
2931 it = self.fastdesc
2932 it = self.fastdesc
2932 elif self._subset.isdescending:
2933 elif self._subset.isdescending:
2933 it = self.fastdesc
2934 it = self.fastdesc
2934 if it is None:
2935 if it is None:
2935 # slowly consume everything. This needs improvement
2936 # slowly consume everything. This needs improvement
2936 it = lambda: reversed(list(self))
2937 it = lambda: reversed(list(self))
2937 for x in it():
2938 for x in it():
2938 return x
2939 return x
2939 return None
2940 return None
2940
2941
2941 def __repr__(self):
2942 def __repr__(self):
2942 return '<%s %r>' % (type(self).__name__, self._subset)
2943 return '<%s %r>' % (type(self).__name__, self._subset)
2943
2944
2944 def _iterordered(ascending, iter1, iter2):
2945 def _iterordered(ascending, iter1, iter2):
2945 """produce an ordered iteration from two iterators with the same order
2946 """produce an ordered iteration from two iterators with the same order
2946
2947
2947 The ascending is used to indicated the iteration direction.
2948 The ascending is used to indicated the iteration direction.
2948 """
2949 """
2949 choice = max
2950 choice = max
2950 if ascending:
2951 if ascending:
2951 choice = min
2952 choice = min
2952
2953
2953 val1 = None
2954 val1 = None
2954 val2 = None
2955 val2 = None
2955 try:
2956 try:
2956 # Consume both iterators in an ordered way until one is empty
2957 # Consume both iterators in an ordered way until one is empty
2957 while True:
2958 while True:
2958 if val1 is None:
2959 if val1 is None:
2959 val1 = iter1.next()
2960 val1 = iter1.next()
2960 if val2 is None:
2961 if val2 is None:
2961 val2 = iter2.next()
2962 val2 = iter2.next()
2962 next = choice(val1, val2)
2963 next = choice(val1, val2)
2963 yield next
2964 yield next
2964 if val1 == next:
2965 if val1 == next:
2965 val1 = None
2966 val1 = None
2966 if val2 == next:
2967 if val2 == next:
2967 val2 = None
2968 val2 = None
2968 except StopIteration:
2969 except StopIteration:
2969 # Flush any remaining values and consume the other one
2970 # Flush any remaining values and consume the other one
2970 it = iter2
2971 it = iter2
2971 if val1 is not None:
2972 if val1 is not None:
2972 yield val1
2973 yield val1
2973 it = iter1
2974 it = iter1
2974 elif val2 is not None:
2975 elif val2 is not None:
2975 # might have been equality and both are empty
2976 # might have been equality and both are empty
2976 yield val2
2977 yield val2
2977 for val in it:
2978 for val in it:
2978 yield val
2979 yield val
2979
2980
2980 class addset(abstractsmartset):
2981 class addset(abstractsmartset):
2981 """Represent the addition of two sets
2982 """Represent the addition of two sets
2982
2983
2983 Wrapper structure for lazily adding two structures without losing much
2984 Wrapper structure for lazily adding two structures without losing much
2984 performance on the __contains__ method
2985 performance on the __contains__ method
2985
2986
2986 If the ascending attribute is set, that means the two structures are
2987 If the ascending attribute is set, that means the two structures are
2987 ordered in either an ascending or descending way. Therefore, we can add
2988 ordered in either an ascending or descending way. Therefore, we can add
2988 them maintaining the order by iterating over both at the same time
2989 them maintaining the order by iterating over both at the same time
2989
2990
2990 >>> xs = baseset([0, 3, 2])
2991 >>> xs = baseset([0, 3, 2])
2991 >>> ys = baseset([5, 2, 4])
2992 >>> ys = baseset([5, 2, 4])
2992
2993
2993 >>> rs = addset(xs, ys)
2994 >>> rs = addset(xs, ys)
2994 >>> bool(rs), 0 in rs, 1 in rs, 5 in rs, rs.first(), rs.last()
2995 >>> bool(rs), 0 in rs, 1 in rs, 5 in rs, rs.first(), rs.last()
2995 (True, True, False, True, 0, 4)
2996 (True, True, False, True, 0, 4)
2996 >>> rs = addset(xs, baseset([]))
2997 >>> rs = addset(xs, baseset([]))
2997 >>> bool(rs), 0 in rs, 1 in rs, rs.first(), rs.last()
2998 >>> bool(rs), 0 in rs, 1 in rs, rs.first(), rs.last()
2998 (True, True, False, 0, 2)
2999 (True, True, False, 0, 2)
2999 >>> rs = addset(baseset([]), baseset([]))
3000 >>> rs = addset(baseset([]), baseset([]))
3000 >>> bool(rs), 0 in rs, rs.first(), rs.last()
3001 >>> bool(rs), 0 in rs, rs.first(), rs.last()
3001 (False, False, None, None)
3002 (False, False, None, None)
3002
3003
3003 iterate unsorted:
3004 iterate unsorted:
3004 >>> rs = addset(xs, ys)
3005 >>> rs = addset(xs, ys)
3005 >>> [x for x in rs] # without _genlist
3006 >>> [x for x in rs] # without _genlist
3006 [0, 3, 2, 5, 4]
3007 [0, 3, 2, 5, 4]
3007 >>> assert not rs._genlist
3008 >>> assert not rs._genlist
3008 >>> len(rs)
3009 >>> len(rs)
3009 5
3010 5
3010 >>> [x for x in rs] # with _genlist
3011 >>> [x for x in rs] # with _genlist
3011 [0, 3, 2, 5, 4]
3012 [0, 3, 2, 5, 4]
3012 >>> assert rs._genlist
3013 >>> assert rs._genlist
3013
3014
3014 iterate ascending:
3015 iterate ascending:
3015 >>> rs = addset(xs, ys, ascending=True)
3016 >>> rs = addset(xs, ys, ascending=True)
3016 >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist
3017 >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist
3017 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3018 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3018 >>> assert not rs._asclist
3019 >>> assert not rs._asclist
3019 >>> len(rs)
3020 >>> len(rs)
3020 5
3021 5
3021 >>> [x for x in rs], [x for x in rs.fastasc()]
3022 >>> [x for x in rs], [x for x in rs.fastasc()]
3022 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3023 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3023 >>> assert rs._asclist
3024 >>> assert rs._asclist
3024
3025
3025 iterate descending:
3026 iterate descending:
3026 >>> rs = addset(xs, ys, ascending=False)
3027 >>> rs = addset(xs, ys, ascending=False)
3027 >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist
3028 >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist
3028 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
3029 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
3029 >>> assert not rs._asclist
3030 >>> assert not rs._asclist
3030 >>> len(rs)
3031 >>> len(rs)
3031 5
3032 5
3032 >>> [x for x in rs], [x for x in rs.fastdesc()]
3033 >>> [x for x in rs], [x for x in rs.fastdesc()]
3033 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
3034 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
3034 >>> assert rs._asclist
3035 >>> assert rs._asclist
3035
3036
3036 iterate ascending without fastasc:
3037 iterate ascending without fastasc:
3037 >>> rs = addset(xs, generatorset(ys), ascending=True)
3038 >>> rs = addset(xs, generatorset(ys), ascending=True)
3038 >>> assert rs.fastasc is None
3039 >>> assert rs.fastasc is None
3039 >>> [x for x in rs]
3040 >>> [x for x in rs]
3040 [0, 2, 3, 4, 5]
3041 [0, 2, 3, 4, 5]
3041
3042
3042 iterate descending without fastdesc:
3043 iterate descending without fastdesc:
3043 >>> rs = addset(generatorset(xs), ys, ascending=False)
3044 >>> rs = addset(generatorset(xs), ys, ascending=False)
3044 >>> assert rs.fastdesc is None
3045 >>> assert rs.fastdesc is None
3045 >>> [x for x in rs]
3046 >>> [x for x in rs]
3046 [5, 4, 3, 2, 0]
3047 [5, 4, 3, 2, 0]
3047 """
3048 """
3048 def __init__(self, revs1, revs2, ascending=None):
3049 def __init__(self, revs1, revs2, ascending=None):
3049 self._r1 = revs1
3050 self._r1 = revs1
3050 self._r2 = revs2
3051 self._r2 = revs2
3051 self._iter = None
3052 self._iter = None
3052 self._ascending = ascending
3053 self._ascending = ascending
3053 self._genlist = None
3054 self._genlist = None
3054 self._asclist = None
3055 self._asclist = None
3055
3056
3056 def __len__(self):
3057 def __len__(self):
3057 return len(self._list)
3058 return len(self._list)
3058
3059
3059 def __nonzero__(self):
3060 def __nonzero__(self):
3060 return bool(self._r1) or bool(self._r2)
3061 return bool(self._r1) or bool(self._r2)
3061
3062
3062 @util.propertycache
3063 @util.propertycache
3063 def _list(self):
3064 def _list(self):
3064 if not self._genlist:
3065 if not self._genlist:
3065 self._genlist = baseset(iter(self))
3066 self._genlist = baseset(iter(self))
3066 return self._genlist
3067 return self._genlist
3067
3068
3068 def __iter__(self):
3069 def __iter__(self):
3069 """Iterate over both collections without repeating elements
3070 """Iterate over both collections without repeating elements
3070
3071
3071 If the ascending attribute is not set, iterate over the first one and
3072 If the ascending attribute is not set, iterate over the first one and
3072 then over the second one checking for membership on the first one so we
3073 then over the second one checking for membership on the first one so we
3073 dont yield any duplicates.
3074 dont yield any duplicates.
3074
3075
3075 If the ascending attribute is set, iterate over both collections at the
3076 If the ascending attribute is set, iterate over both collections at the
3076 same time, yielding only one value at a time in the given order.
3077 same time, yielding only one value at a time in the given order.
3077 """
3078 """
3078 if self._ascending is None:
3079 if self._ascending is None:
3079 if self._genlist:
3080 if self._genlist:
3080 return iter(self._genlist)
3081 return iter(self._genlist)
3081 def arbitraryordergen():
3082 def arbitraryordergen():
3082 for r in self._r1:
3083 for r in self._r1:
3083 yield r
3084 yield r
3084 inr1 = self._r1.__contains__
3085 inr1 = self._r1.__contains__
3085 for r in self._r2:
3086 for r in self._r2:
3086 if not inr1(r):
3087 if not inr1(r):
3087 yield r
3088 yield r
3088 return arbitraryordergen()
3089 return arbitraryordergen()
3089 # try to use our own fast iterator if it exists
3090 # try to use our own fast iterator if it exists
3090 self._trysetasclist()
3091 self._trysetasclist()
3091 if self._ascending:
3092 if self._ascending:
3092 attr = 'fastasc'
3093 attr = 'fastasc'
3093 else:
3094 else:
3094 attr = 'fastdesc'
3095 attr = 'fastdesc'
3095 it = getattr(self, attr)
3096 it = getattr(self, attr)
3096 if it is not None:
3097 if it is not None:
3097 return it()
3098 return it()
3098 # maybe half of the component supports fast
3099 # maybe half of the component supports fast
3099 # get iterator for _r1
3100 # get iterator for _r1
3100 iter1 = getattr(self._r1, attr)
3101 iter1 = getattr(self._r1, attr)
3101 if iter1 is None:
3102 if iter1 is None:
3102 # let's avoid side effect (not sure it matters)
3103 # let's avoid side effect (not sure it matters)
3103 iter1 = iter(sorted(self._r1, reverse=not self._ascending))
3104 iter1 = iter(sorted(self._r1, reverse=not self._ascending))
3104 else:
3105 else:
3105 iter1 = iter1()
3106 iter1 = iter1()
3106 # get iterator for _r2
3107 # get iterator for _r2
3107 iter2 = getattr(self._r2, attr)
3108 iter2 = getattr(self._r2, attr)
3108 if iter2 is None:
3109 if iter2 is None:
3109 # let's avoid side effect (not sure it matters)
3110 # let's avoid side effect (not sure it matters)
3110 iter2 = iter(sorted(self._r2, reverse=not self._ascending))
3111 iter2 = iter(sorted(self._r2, reverse=not self._ascending))
3111 else:
3112 else:
3112 iter2 = iter2()
3113 iter2 = iter2()
3113 return _iterordered(self._ascending, iter1, iter2)
3114 return _iterordered(self._ascending, iter1, iter2)
3114
3115
3115 def _trysetasclist(self):
3116 def _trysetasclist(self):
3116 """populate the _asclist attribute if possible and necessary"""
3117 """populate the _asclist attribute if possible and necessary"""
3117 if self._genlist is not None and self._asclist is None:
3118 if self._genlist is not None and self._asclist is None:
3118 self._asclist = sorted(self._genlist)
3119 self._asclist = sorted(self._genlist)
3119
3120
3120 @property
3121 @property
3121 def fastasc(self):
3122 def fastasc(self):
3122 self._trysetasclist()
3123 self._trysetasclist()
3123 if self._asclist is not None:
3124 if self._asclist is not None:
3124 return self._asclist.__iter__
3125 return self._asclist.__iter__
3125 iter1 = self._r1.fastasc
3126 iter1 = self._r1.fastasc
3126 iter2 = self._r2.fastasc
3127 iter2 = self._r2.fastasc
3127 if None in (iter1, iter2):
3128 if None in (iter1, iter2):
3128 return None
3129 return None
3129 return lambda: _iterordered(True, iter1(), iter2())
3130 return lambda: _iterordered(True, iter1(), iter2())
3130
3131
3131 @property
3132 @property
3132 def fastdesc(self):
3133 def fastdesc(self):
3133 self._trysetasclist()
3134 self._trysetasclist()
3134 if self._asclist is not None:
3135 if self._asclist is not None:
3135 return self._asclist.__reversed__
3136 return self._asclist.__reversed__
3136 iter1 = self._r1.fastdesc
3137 iter1 = self._r1.fastdesc
3137 iter2 = self._r2.fastdesc
3138 iter2 = self._r2.fastdesc
3138 if None in (iter1, iter2):
3139 if None in (iter1, iter2):
3139 return None
3140 return None
3140 return lambda: _iterordered(False, iter1(), iter2())
3141 return lambda: _iterordered(False, iter1(), iter2())
3141
3142
3142 def __contains__(self, x):
3143 def __contains__(self, x):
3143 return x in self._r1 or x in self._r2
3144 return x in self._r1 or x in self._r2
3144
3145
3145 def sort(self, reverse=False):
3146 def sort(self, reverse=False):
3146 """Sort the added set
3147 """Sort the added set
3147
3148
3148 For this we use the cached list with all the generated values and if we
3149 For this we use the cached list with all the generated values and if we
3149 know they are ascending or descending we can sort them in a smart way.
3150 know they are ascending or descending we can sort them in a smart way.
3150 """
3151 """
3151 self._ascending = not reverse
3152 self._ascending = not reverse
3152
3153
3153 def isascending(self):
3154 def isascending(self):
3154 return self._ascending is not None and self._ascending
3155 return self._ascending is not None and self._ascending
3155
3156
3156 def isdescending(self):
3157 def isdescending(self):
3157 return self._ascending is not None and not self._ascending
3158 return self._ascending is not None and not self._ascending
3158
3159
3159 def reverse(self):
3160 def reverse(self):
3160 if self._ascending is None:
3161 if self._ascending is None:
3161 self._list.reverse()
3162 self._list.reverse()
3162 else:
3163 else:
3163 self._ascending = not self._ascending
3164 self._ascending = not self._ascending
3164
3165
3165 def first(self):
3166 def first(self):
3166 for x in self:
3167 for x in self:
3167 return x
3168 return x
3168 return None
3169 return None
3169
3170
3170 def last(self):
3171 def last(self):
3171 self.reverse()
3172 self.reverse()
3172 val = self.first()
3173 val = self.first()
3173 self.reverse()
3174 self.reverse()
3174 return val
3175 return val
3175
3176
3176 def __repr__(self):
3177 def __repr__(self):
3177 d = {None: '', False: '-', True: '+'}[self._ascending]
3178 d = {None: '', False: '-', True: '+'}[self._ascending]
3178 return '<%s%s %r, %r>' % (type(self).__name__, d, self._r1, self._r2)
3179 return '<%s%s %r, %r>' % (type(self).__name__, d, self._r1, self._r2)
3179
3180
3180 class generatorset(abstractsmartset):
3181 class generatorset(abstractsmartset):
3181 """Wrap a generator for lazy iteration
3182 """Wrap a generator for lazy iteration
3182
3183
3183 Wrapper structure for generators that provides lazy membership and can
3184 Wrapper structure for generators that provides lazy membership and can
3184 be iterated more than once.
3185 be iterated more than once.
3185 When asked for membership it generates values until either it finds the
3186 When asked for membership it generates values until either it finds the
3186 requested one or has gone through all the elements in the generator
3187 requested one or has gone through all the elements in the generator
3187 """
3188 """
3188 def __init__(self, gen, iterasc=None):
3189 def __init__(self, gen, iterasc=None):
3189 """
3190 """
3190 gen: a generator producing the values for the generatorset.
3191 gen: a generator producing the values for the generatorset.
3191 """
3192 """
3192 self._gen = gen
3193 self._gen = gen
3193 self._asclist = None
3194 self._asclist = None
3194 self._cache = {}
3195 self._cache = {}
3195 self._genlist = []
3196 self._genlist = []
3196 self._finished = False
3197 self._finished = False
3197 self._ascending = True
3198 self._ascending = True
3198 if iterasc is not None:
3199 if iterasc is not None:
3199 if iterasc:
3200 if iterasc:
3200 self.fastasc = self._iterator
3201 self.fastasc = self._iterator
3201 self.__contains__ = self._asccontains
3202 self.__contains__ = self._asccontains
3202 else:
3203 else:
3203 self.fastdesc = self._iterator
3204 self.fastdesc = self._iterator
3204 self.__contains__ = self._desccontains
3205 self.__contains__ = self._desccontains
3205
3206
3206 def __nonzero__(self):
3207 def __nonzero__(self):
3207 # Do not use 'for r in self' because it will enforce the iteration
3208 # Do not use 'for r in self' because it will enforce the iteration
3208 # order (default ascending), possibly unrolling a whole descending
3209 # order (default ascending), possibly unrolling a whole descending
3209 # iterator.
3210 # iterator.
3210 if self._genlist:
3211 if self._genlist:
3211 return True
3212 return True
3212 for r in self._consumegen():
3213 for r in self._consumegen():
3213 return True
3214 return True
3214 return False
3215 return False
3215
3216
3216 def __contains__(self, x):
3217 def __contains__(self, x):
3217 if x in self._cache:
3218 if x in self._cache:
3218 return self._cache[x]
3219 return self._cache[x]
3219
3220
3220 # Use new values only, as existing values would be cached.
3221 # Use new values only, as existing values would be cached.
3221 for l in self._consumegen():
3222 for l in self._consumegen():
3222 if l == x:
3223 if l == x:
3223 return True
3224 return True
3224
3225
3225 self._cache[x] = False
3226 self._cache[x] = False
3226 return False
3227 return False
3227
3228
3228 def _asccontains(self, x):
3229 def _asccontains(self, x):
3229 """version of contains optimised for ascending generator"""
3230 """version of contains optimised for ascending generator"""
3230 if x in self._cache:
3231 if x in self._cache:
3231 return self._cache[x]
3232 return self._cache[x]
3232
3233
3233 # Use new values only, as existing values would be cached.
3234 # Use new values only, as existing values would be cached.
3234 for l in self._consumegen():
3235 for l in self._consumegen():
3235 if l == x:
3236 if l == x:
3236 return True
3237 return True
3237 if l > x:
3238 if l > x:
3238 break
3239 break
3239
3240
3240 self._cache[x] = False
3241 self._cache[x] = False
3241 return False
3242 return False
3242
3243
3243 def _desccontains(self, x):
3244 def _desccontains(self, x):
3244 """version of contains optimised for descending generator"""
3245 """version of contains optimised for descending generator"""
3245 if x in self._cache:
3246 if x in self._cache:
3246 return self._cache[x]
3247 return self._cache[x]
3247
3248
3248 # Use new values only, as existing values would be cached.
3249 # Use new values only, as existing values would be cached.
3249 for l in self._consumegen():
3250 for l in self._consumegen():
3250 if l == x:
3251 if l == x:
3251 return True
3252 return True
3252 if l < x:
3253 if l < x:
3253 break
3254 break
3254
3255
3255 self._cache[x] = False
3256 self._cache[x] = False
3256 return False
3257 return False
3257
3258
3258 def __iter__(self):
3259 def __iter__(self):
3259 if self._ascending:
3260 if self._ascending:
3260 it = self.fastasc
3261 it = self.fastasc
3261 else:
3262 else:
3262 it = self.fastdesc
3263 it = self.fastdesc
3263 if it is not None:
3264 if it is not None:
3264 return it()
3265 return it()
3265 # we need to consume the iterator
3266 # we need to consume the iterator
3266 for x in self._consumegen():
3267 for x in self._consumegen():
3267 pass
3268 pass
3268 # recall the same code
3269 # recall the same code
3269 return iter(self)
3270 return iter(self)
3270
3271
3271 def _iterator(self):
3272 def _iterator(self):
3272 if self._finished:
3273 if self._finished:
3273 return iter(self._genlist)
3274 return iter(self._genlist)
3274
3275
3275 # We have to use this complex iteration strategy to allow multiple
3276 # We have to use this complex iteration strategy to allow multiple
3276 # iterations at the same time. We need to be able to catch revision
3277 # iterations at the same time. We need to be able to catch revision
3277 # removed from _consumegen and added to genlist in another instance.
3278 # removed from _consumegen and added to genlist in another instance.
3278 #
3279 #
3279 # Getting rid of it would provide an about 15% speed up on this
3280 # Getting rid of it would provide an about 15% speed up on this
3280 # iteration.
3281 # iteration.
3281 genlist = self._genlist
3282 genlist = self._genlist
3282 nextrev = self._consumegen().next
3283 nextrev = self._consumegen().next
3283 _len = len # cache global lookup
3284 _len = len # cache global lookup
3284 def gen():
3285 def gen():
3285 i = 0
3286 i = 0
3286 while True:
3287 while True:
3287 if i < _len(genlist):
3288 if i < _len(genlist):
3288 yield genlist[i]
3289 yield genlist[i]
3289 else:
3290 else:
3290 yield nextrev()
3291 yield nextrev()
3291 i += 1
3292 i += 1
3292 return gen()
3293 return gen()
3293
3294
3294 def _consumegen(self):
3295 def _consumegen(self):
3295 cache = self._cache
3296 cache = self._cache
3296 genlist = self._genlist.append
3297 genlist = self._genlist.append
3297 for item in self._gen:
3298 for item in self._gen:
3298 cache[item] = True
3299 cache[item] = True
3299 genlist(item)
3300 genlist(item)
3300 yield item
3301 yield item
3301 if not self._finished:
3302 if not self._finished:
3302 self._finished = True
3303 self._finished = True
3303 asc = self._genlist[:]
3304 asc = self._genlist[:]
3304 asc.sort()
3305 asc.sort()
3305 self._asclist = asc
3306 self._asclist = asc
3306 self.fastasc = asc.__iter__
3307 self.fastasc = asc.__iter__
3307 self.fastdesc = asc.__reversed__
3308 self.fastdesc = asc.__reversed__
3308
3309
3309 def __len__(self):
3310 def __len__(self):
3310 for x in self._consumegen():
3311 for x in self._consumegen():
3311 pass
3312 pass
3312 return len(self._genlist)
3313 return len(self._genlist)
3313
3314
3314 def sort(self, reverse=False):
3315 def sort(self, reverse=False):
3315 self._ascending = not reverse
3316 self._ascending = not reverse
3316
3317
3317 def reverse(self):
3318 def reverse(self):
3318 self._ascending = not self._ascending
3319 self._ascending = not self._ascending
3319
3320
3320 def isascending(self):
3321 def isascending(self):
3321 return self._ascending
3322 return self._ascending
3322
3323
3323 def isdescending(self):
3324 def isdescending(self):
3324 return not self._ascending
3325 return not self._ascending
3325
3326
3326 def first(self):
3327 def first(self):
3327 if self._ascending:
3328 if self._ascending:
3328 it = self.fastasc
3329 it = self.fastasc
3329 else:
3330 else:
3330 it = self.fastdesc
3331 it = self.fastdesc
3331 if it is None:
3332 if it is None:
3332 # we need to consume all and try again
3333 # we need to consume all and try again
3333 for x in self._consumegen():
3334 for x in self._consumegen():
3334 pass
3335 pass
3335 return self.first()
3336 return self.first()
3336 return next(it(), None)
3337 return next(it(), None)
3337
3338
3338 def last(self):
3339 def last(self):
3339 if self._ascending:
3340 if self._ascending:
3340 it = self.fastdesc
3341 it = self.fastdesc
3341 else:
3342 else:
3342 it = self.fastasc
3343 it = self.fastasc
3343 if it is None:
3344 if it is None:
3344 # we need to consume all and try again
3345 # we need to consume all and try again
3345 for x in self._consumegen():
3346 for x in self._consumegen():
3346 pass
3347 pass
3347 return self.first()
3348 return self.first()
3348 return next(it(), None)
3349 return next(it(), None)
3349
3350
3350 def __repr__(self):
3351 def __repr__(self):
3351 d = {False: '-', True: '+'}[self._ascending]
3352 d = {False: '-', True: '+'}[self._ascending]
3352 return '<%s%s>' % (type(self).__name__, d)
3353 return '<%s%s>' % (type(self).__name__, d)
3353
3354
3354 class spanset(abstractsmartset):
3355 class spanset(abstractsmartset):
3355 """Duck type for baseset class which represents a range of revisions and
3356 """Duck type for baseset class which represents a range of revisions and
3356 can work lazily and without having all the range in memory
3357 can work lazily and without having all the range in memory
3357
3358
3358 Note that spanset(x, y) behave almost like xrange(x, y) except for two
3359 Note that spanset(x, y) behave almost like xrange(x, y) except for two
3359 notable points:
3360 notable points:
3360 - when x < y it will be automatically descending,
3361 - when x < y it will be automatically descending,
3361 - revision filtered with this repoview will be skipped.
3362 - revision filtered with this repoview will be skipped.
3362
3363
3363 """
3364 """
3364 def __init__(self, repo, start=0, end=None):
3365 def __init__(self, repo, start=0, end=None):
3365 """
3366 """
3366 start: first revision included the set
3367 start: first revision included the set
3367 (default to 0)
3368 (default to 0)
3368 end: first revision excluded (last+1)
3369 end: first revision excluded (last+1)
3369 (default to len(repo)
3370 (default to len(repo)
3370
3371
3371 Spanset will be descending if `end` < `start`.
3372 Spanset will be descending if `end` < `start`.
3372 """
3373 """
3373 if end is None:
3374 if end is None:
3374 end = len(repo)
3375 end = len(repo)
3375 self._ascending = start <= end
3376 self._ascending = start <= end
3376 if not self._ascending:
3377 if not self._ascending:
3377 start, end = end + 1, start +1
3378 start, end = end + 1, start +1
3378 self._start = start
3379 self._start = start
3379 self._end = end
3380 self._end = end
3380 self._hiddenrevs = repo.changelog.filteredrevs
3381 self._hiddenrevs = repo.changelog.filteredrevs
3381
3382
3382 def sort(self, reverse=False):
3383 def sort(self, reverse=False):
3383 self._ascending = not reverse
3384 self._ascending = not reverse
3384
3385
3385 def reverse(self):
3386 def reverse(self):
3386 self._ascending = not self._ascending
3387 self._ascending = not self._ascending
3387
3388
3388 def _iterfilter(self, iterrange):
3389 def _iterfilter(self, iterrange):
3389 s = self._hiddenrevs
3390 s = self._hiddenrevs
3390 for r in iterrange:
3391 for r in iterrange:
3391 if r not in s:
3392 if r not in s:
3392 yield r
3393 yield r
3393
3394
3394 def __iter__(self):
3395 def __iter__(self):
3395 if self._ascending:
3396 if self._ascending:
3396 return self.fastasc()
3397 return self.fastasc()
3397 else:
3398 else:
3398 return self.fastdesc()
3399 return self.fastdesc()
3399
3400
3400 def fastasc(self):
3401 def fastasc(self):
3401 iterrange = xrange(self._start, self._end)
3402 iterrange = xrange(self._start, self._end)
3402 if self._hiddenrevs:
3403 if self._hiddenrevs:
3403 return self._iterfilter(iterrange)
3404 return self._iterfilter(iterrange)
3404 return iter(iterrange)
3405 return iter(iterrange)
3405
3406
3406 def fastdesc(self):
3407 def fastdesc(self):
3407 iterrange = xrange(self._end - 1, self._start - 1, -1)
3408 iterrange = xrange(self._end - 1, self._start - 1, -1)
3408 if self._hiddenrevs:
3409 if self._hiddenrevs:
3409 return self._iterfilter(iterrange)
3410 return self._iterfilter(iterrange)
3410 return iter(iterrange)
3411 return iter(iterrange)
3411
3412
3412 def __contains__(self, rev):
3413 def __contains__(self, rev):
3413 hidden = self._hiddenrevs
3414 hidden = self._hiddenrevs
3414 return ((self._start <= rev < self._end)
3415 return ((self._start <= rev < self._end)
3415 and not (hidden and rev in hidden))
3416 and not (hidden and rev in hidden))
3416
3417
3417 def __nonzero__(self):
3418 def __nonzero__(self):
3418 for r in self:
3419 for r in self:
3419 return True
3420 return True
3420 return False
3421 return False
3421
3422
3422 def __len__(self):
3423 def __len__(self):
3423 if not self._hiddenrevs:
3424 if not self._hiddenrevs:
3424 return abs(self._end - self._start)
3425 return abs(self._end - self._start)
3425 else:
3426 else:
3426 count = 0
3427 count = 0
3427 start = self._start
3428 start = self._start
3428 end = self._end
3429 end = self._end
3429 for rev in self._hiddenrevs:
3430 for rev in self._hiddenrevs:
3430 if (end < rev <= start) or (start <= rev < end):
3431 if (end < rev <= start) or (start <= rev < end):
3431 count += 1
3432 count += 1
3432 return abs(self._end - self._start) - count
3433 return abs(self._end - self._start) - count
3433
3434
3434 def isascending(self):
3435 def isascending(self):
3435 return self._ascending
3436 return self._ascending
3436
3437
3437 def isdescending(self):
3438 def isdescending(self):
3438 return not self._ascending
3439 return not self._ascending
3439
3440
3440 def first(self):
3441 def first(self):
3441 if self._ascending:
3442 if self._ascending:
3442 it = self.fastasc
3443 it = self.fastasc
3443 else:
3444 else:
3444 it = self.fastdesc
3445 it = self.fastdesc
3445 for x in it():
3446 for x in it():
3446 return x
3447 return x
3447 return None
3448 return None
3448
3449
3449 def last(self):
3450 def last(self):
3450 if self._ascending:
3451 if self._ascending:
3451 it = self.fastdesc
3452 it = self.fastdesc
3452 else:
3453 else:
3453 it = self.fastasc
3454 it = self.fastasc
3454 for x in it():
3455 for x in it():
3455 return x
3456 return x
3456 return None
3457 return None
3457
3458
3458 def __repr__(self):
3459 def __repr__(self):
3459 d = {False: '-', True: '+'}[self._ascending]
3460 d = {False: '-', True: '+'}[self._ascending]
3460 return '<%s%s %d:%d>' % (type(self).__name__, d,
3461 return '<%s%s %d:%d>' % (type(self).__name__, d,
3461 self._start, self._end - 1)
3462 self._start, self._end - 1)
3462
3463
3463 class fullreposet(spanset):
3464 class fullreposet(spanset):
3464 """a set containing all revisions in the repo
3465 """a set containing all revisions in the repo
3465
3466
3466 This class exists to host special optimization and magic to handle virtual
3467 This class exists to host special optimization and magic to handle virtual
3467 revisions such as "null".
3468 revisions such as "null".
3468 """
3469 """
3469
3470
3470 def __init__(self, repo):
3471 def __init__(self, repo):
3471 super(fullreposet, self).__init__(repo)
3472 super(fullreposet, self).__init__(repo)
3472
3473
3473 def __contains__(self, rev):
3474 # assumes the given rev is valid
3475 hidden = self._hiddenrevs
3476 return not (hidden and rev in hidden)
3477
3478 def __and__(self, other):
3474 def __and__(self, other):
3479 """As self contains the whole repo, all of the other set should also be
3475 """As self contains the whole repo, all of the other set should also be
3480 in self. Therefore `self & other = other`.
3476 in self. Therefore `self & other = other`.
3481
3477
3482 This boldly assumes the other contains valid revs only.
3478 This boldly assumes the other contains valid revs only.
3483 """
3479 """
3484 # other not a smartset, make is so
3480 # other not a smartset, make is so
3485 if not util.safehasattr(other, 'isascending'):
3481 if not util.safehasattr(other, 'isascending'):
3486 # filter out hidden revision
3482 # filter out hidden revision
3487 # (this boldly assumes all smartset are pure)
3483 # (this boldly assumes all smartset are pure)
3488 #
3484 #
3489 # `other` was used with "&", let's assume this is a set like
3485 # `other` was used with "&", let's assume this is a set like
3490 # object.
3486 # object.
3491 other = baseset(other - self._hiddenrevs)
3487 other = baseset(other - self._hiddenrevs)
3492
3488
3493 other.sort(reverse=self.isdescending())
3489 other.sort(reverse=self.isdescending())
3494 return other
3490 return other
3495
3491
3496 def prettyformatset(revs):
3492 def prettyformatset(revs):
3497 lines = []
3493 lines = []
3498 rs = repr(revs)
3494 rs = repr(revs)
3499 p = 0
3495 p = 0
3500 while p < len(rs):
3496 while p < len(rs):
3501 q = rs.find('<', p + 1)
3497 q = rs.find('<', p + 1)
3502 if q < 0:
3498 if q < 0:
3503 q = len(rs)
3499 q = len(rs)
3504 l = rs.count('<', 0, p) - rs.count('>', 0, p)
3500 l = rs.count('<', 0, p) - rs.count('>', 0, p)
3505 assert l >= 0
3501 assert l >= 0
3506 lines.append((l, rs[p:q].rstrip()))
3502 lines.append((l, rs[p:q].rstrip()))
3507 p = q
3503 p = q
3508 return '\n'.join(' ' * l + s for l, s in lines)
3504 return '\n'.join(' ' * l + s for l, s in lines)
3509
3505
3510 # tell hggettext to extract docstrings from these functions:
3506 # tell hggettext to extract docstrings from these functions:
3511 i18nfunctions = symbols.values()
3507 i18nfunctions = symbols.values()
@@ -1,2378 +1,2386 b''
1 @ (34) head
1 @ (34) head
2 |
2 |
3 | o (33) head
3 | o (33) head
4 | |
4 | |
5 o | (32) expand
5 o | (32) expand
6 |\ \
6 |\ \
7 | o \ (31) expand
7 | o \ (31) expand
8 | |\ \
8 | |\ \
9 | | o \ (30) expand
9 | | o \ (30) expand
10 | | |\ \
10 | | |\ \
11 | | | o | (29) regular commit
11 | | | o | (29) regular commit
12 | | | | |
12 | | | | |
13 | | o | | (28) merge zero known
13 | | o | | (28) merge zero known
14 | | |\ \ \
14 | | |\ \ \
15 o | | | | | (27) collapse
15 o | | | | | (27) collapse
16 |/ / / / /
16 |/ / / / /
17 | | o---+ (26) merge one known; far right
17 | | o---+ (26) merge one known; far right
18 | | | | |
18 | | | | |
19 +---o | | (25) merge one known; far left
19 +---o | | (25) merge one known; far left
20 | | | | |
20 | | | | |
21 | | o | | (24) merge one known; immediate right
21 | | o | | (24) merge one known; immediate right
22 | | |\| |
22 | | |\| |
23 | | o | | (23) merge one known; immediate left
23 | | o | | (23) merge one known; immediate left
24 | |/| | |
24 | |/| | |
25 +---o---+ (22) merge two known; one far left, one far right
25 +---o---+ (22) merge two known; one far left, one far right
26 | | / /
26 | | / /
27 o | | | (21) expand
27 o | | | (21) expand
28 |\ \ \ \
28 |\ \ \ \
29 | o---+-+ (20) merge two known; two far right
29 | o---+-+ (20) merge two known; two far right
30 | / / /
30 | / / /
31 o | | | (19) expand
31 o | | | (19) expand
32 |\ \ \ \
32 |\ \ \ \
33 +---+---o (18) merge two known; two far left
33 +---+---o (18) merge two known; two far left
34 | | | |
34 | | | |
35 | o | | (17) expand
35 | o | | (17) expand
36 | |\ \ \
36 | |\ \ \
37 | | o---+ (16) merge two known; one immediate right, one near right
37 | | o---+ (16) merge two known; one immediate right, one near right
38 | | |/ /
38 | | |/ /
39 o | | | (15) expand
39 o | | | (15) expand
40 |\ \ \ \
40 |\ \ \ \
41 | o-----+ (14) merge two known; one immediate right, one far right
41 | o-----+ (14) merge two known; one immediate right, one far right
42 | |/ / /
42 | |/ / /
43 o | | | (13) expand
43 o | | | (13) expand
44 |\ \ \ \
44 |\ \ \ \
45 +---o | | (12) merge two known; one immediate right, one far left
45 +---o | | (12) merge two known; one immediate right, one far left
46 | | |/ /
46 | | |/ /
47 | o | | (11) expand
47 | o | | (11) expand
48 | |\ \ \
48 | |\ \ \
49 | | o---+ (10) merge two known; one immediate left, one near right
49 | | o---+ (10) merge two known; one immediate left, one near right
50 | |/ / /
50 | |/ / /
51 o | | | (9) expand
51 o | | | (9) expand
52 |\ \ \ \
52 |\ \ \ \
53 | o-----+ (8) merge two known; one immediate left, one far right
53 | o-----+ (8) merge two known; one immediate left, one far right
54 |/ / / /
54 |/ / / /
55 o | | | (7) expand
55 o | | | (7) expand
56 |\ \ \ \
56 |\ \ \ \
57 +---o | | (6) merge two known; one immediate left, one far left
57 +---o | | (6) merge two known; one immediate left, one far left
58 | |/ / /
58 | |/ / /
59 | o | | (5) expand
59 | o | | (5) expand
60 | |\ \ \
60 | |\ \ \
61 | | o | | (4) merge two known; one immediate left, one immediate right
61 | | o | | (4) merge two known; one immediate left, one immediate right
62 | |/|/ /
62 | |/|/ /
63 | o / / (3) collapse
63 | o / / (3) collapse
64 |/ / /
64 |/ / /
65 o / / (2) collapse
65 o / / (2) collapse
66 |/ /
66 |/ /
67 o / (1) collapse
67 o / (1) collapse
68 |/
68 |/
69 o (0) root
69 o (0) root
70
70
71
71
72 $ commit()
72 $ commit()
73 > {
73 > {
74 > rev=$1
74 > rev=$1
75 > msg=$2
75 > msg=$2
76 > shift 2
76 > shift 2
77 > if [ "$#" -gt 0 ]; then
77 > if [ "$#" -gt 0 ]; then
78 > hg debugsetparents "$@"
78 > hg debugsetparents "$@"
79 > fi
79 > fi
80 > echo $rev > a
80 > echo $rev > a
81 > hg commit -Aqd "$rev 0" -m "($rev) $msg"
81 > hg commit -Aqd "$rev 0" -m "($rev) $msg"
82 > }
82 > }
83
83
84 $ cat > printrevset.py <<EOF
84 $ cat > printrevset.py <<EOF
85 > from mercurial import extensions, revset, commands, cmdutil
85 > from mercurial import extensions, revset, commands, cmdutil
86 >
86 >
87 > def uisetup(ui):
87 > def uisetup(ui):
88 > def printrevset(orig, ui, repo, *pats, **opts):
88 > def printrevset(orig, ui, repo, *pats, **opts):
89 > if opts.get('print_revset'):
89 > if opts.get('print_revset'):
90 > expr = cmdutil.getgraphlogrevs(repo, pats, opts)[1]
90 > expr = cmdutil.getgraphlogrevs(repo, pats, opts)[1]
91 > if expr:
91 > if expr:
92 > tree = revset.parse(expr)
92 > tree = revset.parse(expr)
93 > else:
93 > else:
94 > tree = []
94 > tree = []
95 > ui.write('%r\n' % (opts.get('rev', []),))
95 > ui.write('%r\n' % (opts.get('rev', []),))
96 > ui.write(revset.prettyformat(tree) + '\n')
96 > ui.write(revset.prettyformat(tree) + '\n')
97 > return 0
97 > return 0
98 > return orig(ui, repo, *pats, **opts)
98 > return orig(ui, repo, *pats, **opts)
99 > entry = extensions.wrapcommand(commands.table, 'log', printrevset)
99 > entry = extensions.wrapcommand(commands.table, 'log', printrevset)
100 > entry[1].append(('', 'print-revset', False,
100 > entry[1].append(('', 'print-revset', False,
101 > 'print generated revset and exit (DEPRECATED)'))
101 > 'print generated revset and exit (DEPRECATED)'))
102 > EOF
102 > EOF
103
103
104 $ echo "[extensions]" >> $HGRCPATH
104 $ echo "[extensions]" >> $HGRCPATH
105 $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
105 $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
106
106
107 $ hg init repo
107 $ hg init repo
108 $ cd repo
108 $ cd repo
109
109
110 Empty repo:
110 Empty repo:
111
111
112 $ hg log -G
112 $ hg log -G
113
113
114
114
115 Building DAG:
115 Building DAG:
116
116
117 $ commit 0 "root"
117 $ commit 0 "root"
118 $ commit 1 "collapse" 0
118 $ commit 1 "collapse" 0
119 $ commit 2 "collapse" 1
119 $ commit 2 "collapse" 1
120 $ commit 3 "collapse" 2
120 $ commit 3 "collapse" 2
121 $ commit 4 "merge two known; one immediate left, one immediate right" 1 3
121 $ commit 4 "merge two known; one immediate left, one immediate right" 1 3
122 $ commit 5 "expand" 3 4
122 $ commit 5 "expand" 3 4
123 $ commit 6 "merge two known; one immediate left, one far left" 2 5
123 $ commit 6 "merge two known; one immediate left, one far left" 2 5
124 $ commit 7 "expand" 2 5
124 $ commit 7 "expand" 2 5
125 $ commit 8 "merge two known; one immediate left, one far right" 0 7
125 $ commit 8 "merge two known; one immediate left, one far right" 0 7
126 $ commit 9 "expand" 7 8
126 $ commit 9 "expand" 7 8
127 $ commit 10 "merge two known; one immediate left, one near right" 0 6
127 $ commit 10 "merge two known; one immediate left, one near right" 0 6
128 $ commit 11 "expand" 6 10
128 $ commit 11 "expand" 6 10
129 $ commit 12 "merge two known; one immediate right, one far left" 1 9
129 $ commit 12 "merge two known; one immediate right, one far left" 1 9
130 $ commit 13 "expand" 9 11
130 $ commit 13 "expand" 9 11
131 $ commit 14 "merge two known; one immediate right, one far right" 0 12
131 $ commit 14 "merge two known; one immediate right, one far right" 0 12
132 $ commit 15 "expand" 13 14
132 $ commit 15 "expand" 13 14
133 $ commit 16 "merge two known; one immediate right, one near right" 0 1
133 $ commit 16 "merge two known; one immediate right, one near right" 0 1
134 $ commit 17 "expand" 12 16
134 $ commit 17 "expand" 12 16
135 $ commit 18 "merge two known; two far left" 1 15
135 $ commit 18 "merge two known; two far left" 1 15
136 $ commit 19 "expand" 15 17
136 $ commit 19 "expand" 15 17
137 $ commit 20 "merge two known; two far right" 0 18
137 $ commit 20 "merge two known; two far right" 0 18
138 $ commit 21 "expand" 19 20
138 $ commit 21 "expand" 19 20
139 $ commit 22 "merge two known; one far left, one far right" 18 21
139 $ commit 22 "merge two known; one far left, one far right" 18 21
140 $ commit 23 "merge one known; immediate left" 1 22
140 $ commit 23 "merge one known; immediate left" 1 22
141 $ commit 24 "merge one known; immediate right" 0 23
141 $ commit 24 "merge one known; immediate right" 0 23
142 $ commit 25 "merge one known; far left" 21 24
142 $ commit 25 "merge one known; far left" 21 24
143 $ commit 26 "merge one known; far right" 18 25
143 $ commit 26 "merge one known; far right" 18 25
144 $ commit 27 "collapse" 21
144 $ commit 27 "collapse" 21
145 $ commit 28 "merge zero known" 1 26
145 $ commit 28 "merge zero known" 1 26
146 $ commit 29 "regular commit" 0
146 $ commit 29 "regular commit" 0
147 $ commit 30 "expand" 28 29
147 $ commit 30 "expand" 28 29
148 $ commit 31 "expand" 21 30
148 $ commit 31 "expand" 21 30
149 $ commit 32 "expand" 27 31
149 $ commit 32 "expand" 27 31
150 $ commit 33 "head" 18
150 $ commit 33 "head" 18
151 $ commit 34 "head" 32
151 $ commit 34 "head" 32
152
152
153
153
154 $ hg log -G -q
154 $ hg log -G -q
155 @ 34:fea3ac5810e0
155 @ 34:fea3ac5810e0
156 |
156 |
157 | o 33:68608f5145f9
157 | o 33:68608f5145f9
158 | |
158 | |
159 o | 32:d06dffa21a31
159 o | 32:d06dffa21a31
160 |\ \
160 |\ \
161 | o \ 31:621d83e11f67
161 | o \ 31:621d83e11f67
162 | |\ \
162 | |\ \
163 | | o \ 30:6e11cd4b648f
163 | | o \ 30:6e11cd4b648f
164 | | |\ \
164 | | |\ \
165 | | | o | 29:cd9bb2be7593
165 | | | o | 29:cd9bb2be7593
166 | | | | |
166 | | | | |
167 | | o | | 28:44ecd0b9ae99
167 | | o | | 28:44ecd0b9ae99
168 | | |\ \ \
168 | | |\ \ \
169 o | | | | | 27:886ed638191b
169 o | | | | | 27:886ed638191b
170 |/ / / / /
170 |/ / / / /
171 | | o---+ 26:7f25b6c2f0b9
171 | | o---+ 26:7f25b6c2f0b9
172 | | | | |
172 | | | | |
173 +---o | | 25:91da8ed57247
173 +---o | | 25:91da8ed57247
174 | | | | |
174 | | | | |
175 | | o | | 24:a9c19a3d96b7
175 | | o | | 24:a9c19a3d96b7
176 | | |\| |
176 | | |\| |
177 | | o | | 23:a01cddf0766d
177 | | o | | 23:a01cddf0766d
178 | |/| | |
178 | |/| | |
179 +---o---+ 22:e0d9cccacb5d
179 +---o---+ 22:e0d9cccacb5d
180 | | / /
180 | | / /
181 o | | | 21:d42a756af44d
181 o | | | 21:d42a756af44d
182 |\ \ \ \
182 |\ \ \ \
183 | o---+-+ 20:d30ed6450e32
183 | o---+-+ 20:d30ed6450e32
184 | / / /
184 | / / /
185 o | | | 19:31ddc2c1573b
185 o | | | 19:31ddc2c1573b
186 |\ \ \ \
186 |\ \ \ \
187 +---+---o 18:1aa84d96232a
187 +---+---o 18:1aa84d96232a
188 | | | |
188 | | | |
189 | o | | 17:44765d7c06e0
189 | o | | 17:44765d7c06e0
190 | |\ \ \
190 | |\ \ \
191 | | o---+ 16:3677d192927d
191 | | o---+ 16:3677d192927d
192 | | |/ /
192 | | |/ /
193 o | | | 15:1dda3f72782d
193 o | | | 15:1dda3f72782d
194 |\ \ \ \
194 |\ \ \ \
195 | o-----+ 14:8eac370358ef
195 | o-----+ 14:8eac370358ef
196 | |/ / /
196 | |/ / /
197 o | | | 13:22d8966a97e3
197 o | | | 13:22d8966a97e3
198 |\ \ \ \
198 |\ \ \ \
199 +---o | | 12:86b91144a6e9
199 +---o | | 12:86b91144a6e9
200 | | |/ /
200 | | |/ /
201 | o | | 11:832d76e6bdf2
201 | o | | 11:832d76e6bdf2
202 | |\ \ \
202 | |\ \ \
203 | | o---+ 10:74c64d036d72
203 | | o---+ 10:74c64d036d72
204 | |/ / /
204 | |/ / /
205 o | | | 9:7010c0af0a35
205 o | | | 9:7010c0af0a35
206 |\ \ \ \
206 |\ \ \ \
207 | o-----+ 8:7a0b11f71937
207 | o-----+ 8:7a0b11f71937
208 |/ / / /
208 |/ / / /
209 o | | | 7:b632bb1b1224
209 o | | | 7:b632bb1b1224
210 |\ \ \ \
210 |\ \ \ \
211 +---o | | 6:b105a072e251
211 +---o | | 6:b105a072e251
212 | |/ / /
212 | |/ / /
213 | o | | 5:4409d547b708
213 | o | | 5:4409d547b708
214 | |\ \ \
214 | |\ \ \
215 | | o | | 4:26a8bac39d9f
215 | | o | | 4:26a8bac39d9f
216 | |/|/ /
216 | |/|/ /
217 | o / / 3:27eef8ed80b4
217 | o / / 3:27eef8ed80b4
218 |/ / /
218 |/ / /
219 o / / 2:3d9a33b8d1e1
219 o / / 2:3d9a33b8d1e1
220 |/ /
220 |/ /
221 o / 1:6db2ef61d156
221 o / 1:6db2ef61d156
222 |/
222 |/
223 o 0:e6eb3150255d
223 o 0:e6eb3150255d
224
224
225
225
226 $ hg log -G
226 $ hg log -G
227 @ changeset: 34:fea3ac5810e0
227 @ changeset: 34:fea3ac5810e0
228 | tag: tip
228 | tag: tip
229 | parent: 32:d06dffa21a31
229 | parent: 32:d06dffa21a31
230 | user: test
230 | user: test
231 | date: Thu Jan 01 00:00:34 1970 +0000
231 | date: Thu Jan 01 00:00:34 1970 +0000
232 | summary: (34) head
232 | summary: (34) head
233 |
233 |
234 | o changeset: 33:68608f5145f9
234 | o changeset: 33:68608f5145f9
235 | | parent: 18:1aa84d96232a
235 | | parent: 18:1aa84d96232a
236 | | user: test
236 | | user: test
237 | | date: Thu Jan 01 00:00:33 1970 +0000
237 | | date: Thu Jan 01 00:00:33 1970 +0000
238 | | summary: (33) head
238 | | summary: (33) head
239 | |
239 | |
240 o | changeset: 32:d06dffa21a31
240 o | changeset: 32:d06dffa21a31
241 |\ \ parent: 27:886ed638191b
241 |\ \ parent: 27:886ed638191b
242 | | | parent: 31:621d83e11f67
242 | | | parent: 31:621d83e11f67
243 | | | user: test
243 | | | user: test
244 | | | date: Thu Jan 01 00:00:32 1970 +0000
244 | | | date: Thu Jan 01 00:00:32 1970 +0000
245 | | | summary: (32) expand
245 | | | summary: (32) expand
246 | | |
246 | | |
247 | o | changeset: 31:621d83e11f67
247 | o | changeset: 31:621d83e11f67
248 | |\ \ parent: 21:d42a756af44d
248 | |\ \ parent: 21:d42a756af44d
249 | | | | parent: 30:6e11cd4b648f
249 | | | | parent: 30:6e11cd4b648f
250 | | | | user: test
250 | | | | user: test
251 | | | | date: Thu Jan 01 00:00:31 1970 +0000
251 | | | | date: Thu Jan 01 00:00:31 1970 +0000
252 | | | | summary: (31) expand
252 | | | | summary: (31) expand
253 | | | |
253 | | | |
254 | | o | changeset: 30:6e11cd4b648f
254 | | o | changeset: 30:6e11cd4b648f
255 | | |\ \ parent: 28:44ecd0b9ae99
255 | | |\ \ parent: 28:44ecd0b9ae99
256 | | | | | parent: 29:cd9bb2be7593
256 | | | | | parent: 29:cd9bb2be7593
257 | | | | | user: test
257 | | | | | user: test
258 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
258 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
259 | | | | | summary: (30) expand
259 | | | | | summary: (30) expand
260 | | | | |
260 | | | | |
261 | | | o | changeset: 29:cd9bb2be7593
261 | | | o | changeset: 29:cd9bb2be7593
262 | | | | | parent: 0:e6eb3150255d
262 | | | | | parent: 0:e6eb3150255d
263 | | | | | user: test
263 | | | | | user: test
264 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
264 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
265 | | | | | summary: (29) regular commit
265 | | | | | summary: (29) regular commit
266 | | | | |
266 | | | | |
267 | | o | | changeset: 28:44ecd0b9ae99
267 | | o | | changeset: 28:44ecd0b9ae99
268 | | |\ \ \ parent: 1:6db2ef61d156
268 | | |\ \ \ parent: 1:6db2ef61d156
269 | | | | | | parent: 26:7f25b6c2f0b9
269 | | | | | | parent: 26:7f25b6c2f0b9
270 | | | | | | user: test
270 | | | | | | user: test
271 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
271 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
272 | | | | | | summary: (28) merge zero known
272 | | | | | | summary: (28) merge zero known
273 | | | | | |
273 | | | | | |
274 o | | | | | changeset: 27:886ed638191b
274 o | | | | | changeset: 27:886ed638191b
275 |/ / / / / parent: 21:d42a756af44d
275 |/ / / / / parent: 21:d42a756af44d
276 | | | | | user: test
276 | | | | | user: test
277 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
277 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
278 | | | | | summary: (27) collapse
278 | | | | | summary: (27) collapse
279 | | | | |
279 | | | | |
280 | | o---+ changeset: 26:7f25b6c2f0b9
280 | | o---+ changeset: 26:7f25b6c2f0b9
281 | | | | | parent: 18:1aa84d96232a
281 | | | | | parent: 18:1aa84d96232a
282 | | | | | parent: 25:91da8ed57247
282 | | | | | parent: 25:91da8ed57247
283 | | | | | user: test
283 | | | | | user: test
284 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
284 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
285 | | | | | summary: (26) merge one known; far right
285 | | | | | summary: (26) merge one known; far right
286 | | | | |
286 | | | | |
287 +---o | | changeset: 25:91da8ed57247
287 +---o | | changeset: 25:91da8ed57247
288 | | | | | parent: 21:d42a756af44d
288 | | | | | parent: 21:d42a756af44d
289 | | | | | parent: 24:a9c19a3d96b7
289 | | | | | parent: 24:a9c19a3d96b7
290 | | | | | user: test
290 | | | | | user: test
291 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
291 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
292 | | | | | summary: (25) merge one known; far left
292 | | | | | summary: (25) merge one known; far left
293 | | | | |
293 | | | | |
294 | | o | | changeset: 24:a9c19a3d96b7
294 | | o | | changeset: 24:a9c19a3d96b7
295 | | |\| | parent: 0:e6eb3150255d
295 | | |\| | parent: 0:e6eb3150255d
296 | | | | | parent: 23:a01cddf0766d
296 | | | | | parent: 23:a01cddf0766d
297 | | | | | user: test
297 | | | | | user: test
298 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
298 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
299 | | | | | summary: (24) merge one known; immediate right
299 | | | | | summary: (24) merge one known; immediate right
300 | | | | |
300 | | | | |
301 | | o | | changeset: 23:a01cddf0766d
301 | | o | | changeset: 23:a01cddf0766d
302 | |/| | | parent: 1:6db2ef61d156
302 | |/| | | parent: 1:6db2ef61d156
303 | | | | | parent: 22:e0d9cccacb5d
303 | | | | | parent: 22:e0d9cccacb5d
304 | | | | | user: test
304 | | | | | user: test
305 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
305 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
306 | | | | | summary: (23) merge one known; immediate left
306 | | | | | summary: (23) merge one known; immediate left
307 | | | | |
307 | | | | |
308 +---o---+ changeset: 22:e0d9cccacb5d
308 +---o---+ changeset: 22:e0d9cccacb5d
309 | | | | parent: 18:1aa84d96232a
309 | | | | parent: 18:1aa84d96232a
310 | | / / parent: 21:d42a756af44d
310 | | / / parent: 21:d42a756af44d
311 | | | | user: test
311 | | | | user: test
312 | | | | date: Thu Jan 01 00:00:22 1970 +0000
312 | | | | date: Thu Jan 01 00:00:22 1970 +0000
313 | | | | summary: (22) merge two known; one far left, one far right
313 | | | | summary: (22) merge two known; one far left, one far right
314 | | | |
314 | | | |
315 o | | | changeset: 21:d42a756af44d
315 o | | | changeset: 21:d42a756af44d
316 |\ \ \ \ parent: 19:31ddc2c1573b
316 |\ \ \ \ parent: 19:31ddc2c1573b
317 | | | | | parent: 20:d30ed6450e32
317 | | | | | parent: 20:d30ed6450e32
318 | | | | | user: test
318 | | | | | user: test
319 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
319 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
320 | | | | | summary: (21) expand
320 | | | | | summary: (21) expand
321 | | | | |
321 | | | | |
322 | o---+-+ changeset: 20:d30ed6450e32
322 | o---+-+ changeset: 20:d30ed6450e32
323 | | | | parent: 0:e6eb3150255d
323 | | | | parent: 0:e6eb3150255d
324 | / / / parent: 18:1aa84d96232a
324 | / / / parent: 18:1aa84d96232a
325 | | | | user: test
325 | | | | user: test
326 | | | | date: Thu Jan 01 00:00:20 1970 +0000
326 | | | | date: Thu Jan 01 00:00:20 1970 +0000
327 | | | | summary: (20) merge two known; two far right
327 | | | | summary: (20) merge two known; two far right
328 | | | |
328 | | | |
329 o | | | changeset: 19:31ddc2c1573b
329 o | | | changeset: 19:31ddc2c1573b
330 |\ \ \ \ parent: 15:1dda3f72782d
330 |\ \ \ \ parent: 15:1dda3f72782d
331 | | | | | parent: 17:44765d7c06e0
331 | | | | | parent: 17:44765d7c06e0
332 | | | | | user: test
332 | | | | | user: test
333 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
333 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
334 | | | | | summary: (19) expand
334 | | | | | summary: (19) expand
335 | | | | |
335 | | | | |
336 +---+---o changeset: 18:1aa84d96232a
336 +---+---o changeset: 18:1aa84d96232a
337 | | | | parent: 1:6db2ef61d156
337 | | | | parent: 1:6db2ef61d156
338 | | | | parent: 15:1dda3f72782d
338 | | | | parent: 15:1dda3f72782d
339 | | | | user: test
339 | | | | user: test
340 | | | | date: Thu Jan 01 00:00:18 1970 +0000
340 | | | | date: Thu Jan 01 00:00:18 1970 +0000
341 | | | | summary: (18) merge two known; two far left
341 | | | | summary: (18) merge two known; two far left
342 | | | |
342 | | | |
343 | o | | changeset: 17:44765d7c06e0
343 | o | | changeset: 17:44765d7c06e0
344 | |\ \ \ parent: 12:86b91144a6e9
344 | |\ \ \ parent: 12:86b91144a6e9
345 | | | | | parent: 16:3677d192927d
345 | | | | | parent: 16:3677d192927d
346 | | | | | user: test
346 | | | | | user: test
347 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
347 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
348 | | | | | summary: (17) expand
348 | | | | | summary: (17) expand
349 | | | | |
349 | | | | |
350 | | o---+ changeset: 16:3677d192927d
350 | | o---+ changeset: 16:3677d192927d
351 | | | | | parent: 0:e6eb3150255d
351 | | | | | parent: 0:e6eb3150255d
352 | | |/ / parent: 1:6db2ef61d156
352 | | |/ / parent: 1:6db2ef61d156
353 | | | | user: test
353 | | | | user: test
354 | | | | date: Thu Jan 01 00:00:16 1970 +0000
354 | | | | date: Thu Jan 01 00:00:16 1970 +0000
355 | | | | summary: (16) merge two known; one immediate right, one near right
355 | | | | summary: (16) merge two known; one immediate right, one near right
356 | | | |
356 | | | |
357 o | | | changeset: 15:1dda3f72782d
357 o | | | changeset: 15:1dda3f72782d
358 |\ \ \ \ parent: 13:22d8966a97e3
358 |\ \ \ \ parent: 13:22d8966a97e3
359 | | | | | parent: 14:8eac370358ef
359 | | | | | parent: 14:8eac370358ef
360 | | | | | user: test
360 | | | | | user: test
361 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
361 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
362 | | | | | summary: (15) expand
362 | | | | | summary: (15) expand
363 | | | | |
363 | | | | |
364 | o-----+ changeset: 14:8eac370358ef
364 | o-----+ changeset: 14:8eac370358ef
365 | | | | | parent: 0:e6eb3150255d
365 | | | | | parent: 0:e6eb3150255d
366 | |/ / / parent: 12:86b91144a6e9
366 | |/ / / parent: 12:86b91144a6e9
367 | | | | user: test
367 | | | | user: test
368 | | | | date: Thu Jan 01 00:00:14 1970 +0000
368 | | | | date: Thu Jan 01 00:00:14 1970 +0000
369 | | | | summary: (14) merge two known; one immediate right, one far right
369 | | | | summary: (14) merge two known; one immediate right, one far right
370 | | | |
370 | | | |
371 o | | | changeset: 13:22d8966a97e3
371 o | | | changeset: 13:22d8966a97e3
372 |\ \ \ \ parent: 9:7010c0af0a35
372 |\ \ \ \ parent: 9:7010c0af0a35
373 | | | | | parent: 11:832d76e6bdf2
373 | | | | | parent: 11:832d76e6bdf2
374 | | | | | user: test
374 | | | | | user: test
375 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
375 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
376 | | | | | summary: (13) expand
376 | | | | | summary: (13) expand
377 | | | | |
377 | | | | |
378 +---o | | changeset: 12:86b91144a6e9
378 +---o | | changeset: 12:86b91144a6e9
379 | | |/ / parent: 1:6db2ef61d156
379 | | |/ / parent: 1:6db2ef61d156
380 | | | | parent: 9:7010c0af0a35
380 | | | | parent: 9:7010c0af0a35
381 | | | | user: test
381 | | | | user: test
382 | | | | date: Thu Jan 01 00:00:12 1970 +0000
382 | | | | date: Thu Jan 01 00:00:12 1970 +0000
383 | | | | summary: (12) merge two known; one immediate right, one far left
383 | | | | summary: (12) merge two known; one immediate right, one far left
384 | | | |
384 | | | |
385 | o | | changeset: 11:832d76e6bdf2
385 | o | | changeset: 11:832d76e6bdf2
386 | |\ \ \ parent: 6:b105a072e251
386 | |\ \ \ parent: 6:b105a072e251
387 | | | | | parent: 10:74c64d036d72
387 | | | | | parent: 10:74c64d036d72
388 | | | | | user: test
388 | | | | | user: test
389 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
389 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
390 | | | | | summary: (11) expand
390 | | | | | summary: (11) expand
391 | | | | |
391 | | | | |
392 | | o---+ changeset: 10:74c64d036d72
392 | | o---+ changeset: 10:74c64d036d72
393 | | | | | parent: 0:e6eb3150255d
393 | | | | | parent: 0:e6eb3150255d
394 | |/ / / parent: 6:b105a072e251
394 | |/ / / parent: 6:b105a072e251
395 | | | | user: test
395 | | | | user: test
396 | | | | date: Thu Jan 01 00:00:10 1970 +0000
396 | | | | date: Thu Jan 01 00:00:10 1970 +0000
397 | | | | summary: (10) merge two known; one immediate left, one near right
397 | | | | summary: (10) merge two known; one immediate left, one near right
398 | | | |
398 | | | |
399 o | | | changeset: 9:7010c0af0a35
399 o | | | changeset: 9:7010c0af0a35
400 |\ \ \ \ parent: 7:b632bb1b1224
400 |\ \ \ \ parent: 7:b632bb1b1224
401 | | | | | parent: 8:7a0b11f71937
401 | | | | | parent: 8:7a0b11f71937
402 | | | | | user: test
402 | | | | | user: test
403 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
403 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
404 | | | | | summary: (9) expand
404 | | | | | summary: (9) expand
405 | | | | |
405 | | | | |
406 | o-----+ changeset: 8:7a0b11f71937
406 | o-----+ changeset: 8:7a0b11f71937
407 | | | | | parent: 0:e6eb3150255d
407 | | | | | parent: 0:e6eb3150255d
408 |/ / / / parent: 7:b632bb1b1224
408 |/ / / / parent: 7:b632bb1b1224
409 | | | | user: test
409 | | | | user: test
410 | | | | date: Thu Jan 01 00:00:08 1970 +0000
410 | | | | date: Thu Jan 01 00:00:08 1970 +0000
411 | | | | summary: (8) merge two known; one immediate left, one far right
411 | | | | summary: (8) merge two known; one immediate left, one far right
412 | | | |
412 | | | |
413 o | | | changeset: 7:b632bb1b1224
413 o | | | changeset: 7:b632bb1b1224
414 |\ \ \ \ parent: 2:3d9a33b8d1e1
414 |\ \ \ \ parent: 2:3d9a33b8d1e1
415 | | | | | parent: 5:4409d547b708
415 | | | | | parent: 5:4409d547b708
416 | | | | | user: test
416 | | | | | user: test
417 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
417 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
418 | | | | | summary: (7) expand
418 | | | | | summary: (7) expand
419 | | | | |
419 | | | | |
420 +---o | | changeset: 6:b105a072e251
420 +---o | | changeset: 6:b105a072e251
421 | |/ / / parent: 2:3d9a33b8d1e1
421 | |/ / / parent: 2:3d9a33b8d1e1
422 | | | | parent: 5:4409d547b708
422 | | | | parent: 5:4409d547b708
423 | | | | user: test
423 | | | | user: test
424 | | | | date: Thu Jan 01 00:00:06 1970 +0000
424 | | | | date: Thu Jan 01 00:00:06 1970 +0000
425 | | | | summary: (6) merge two known; one immediate left, one far left
425 | | | | summary: (6) merge two known; one immediate left, one far left
426 | | | |
426 | | | |
427 | o | | changeset: 5:4409d547b708
427 | o | | changeset: 5:4409d547b708
428 | |\ \ \ parent: 3:27eef8ed80b4
428 | |\ \ \ parent: 3:27eef8ed80b4
429 | | | | | parent: 4:26a8bac39d9f
429 | | | | | parent: 4:26a8bac39d9f
430 | | | | | user: test
430 | | | | | user: test
431 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
431 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
432 | | | | | summary: (5) expand
432 | | | | | summary: (5) expand
433 | | | | |
433 | | | | |
434 | | o | | changeset: 4:26a8bac39d9f
434 | | o | | changeset: 4:26a8bac39d9f
435 | |/|/ / parent: 1:6db2ef61d156
435 | |/|/ / parent: 1:6db2ef61d156
436 | | | | parent: 3:27eef8ed80b4
436 | | | | parent: 3:27eef8ed80b4
437 | | | | user: test
437 | | | | user: test
438 | | | | date: Thu Jan 01 00:00:04 1970 +0000
438 | | | | date: Thu Jan 01 00:00:04 1970 +0000
439 | | | | summary: (4) merge two known; one immediate left, one immediate right
439 | | | | summary: (4) merge two known; one immediate left, one immediate right
440 | | | |
440 | | | |
441 | o | | changeset: 3:27eef8ed80b4
441 | o | | changeset: 3:27eef8ed80b4
442 |/ / / user: test
442 |/ / / user: test
443 | | | date: Thu Jan 01 00:00:03 1970 +0000
443 | | | date: Thu Jan 01 00:00:03 1970 +0000
444 | | | summary: (3) collapse
444 | | | summary: (3) collapse
445 | | |
445 | | |
446 o | | changeset: 2:3d9a33b8d1e1
446 o | | changeset: 2:3d9a33b8d1e1
447 |/ / user: test
447 |/ / user: test
448 | | date: Thu Jan 01 00:00:02 1970 +0000
448 | | date: Thu Jan 01 00:00:02 1970 +0000
449 | | summary: (2) collapse
449 | | summary: (2) collapse
450 | |
450 | |
451 o | changeset: 1:6db2ef61d156
451 o | changeset: 1:6db2ef61d156
452 |/ user: test
452 |/ user: test
453 | date: Thu Jan 01 00:00:01 1970 +0000
453 | date: Thu Jan 01 00:00:01 1970 +0000
454 | summary: (1) collapse
454 | summary: (1) collapse
455 |
455 |
456 o changeset: 0:e6eb3150255d
456 o changeset: 0:e6eb3150255d
457 user: test
457 user: test
458 date: Thu Jan 01 00:00:00 1970 +0000
458 date: Thu Jan 01 00:00:00 1970 +0000
459 summary: (0) root
459 summary: (0) root
460
460
461
461
462 File glog:
462 File glog:
463 $ hg log -G a
463 $ hg log -G a
464 @ changeset: 34:fea3ac5810e0
464 @ changeset: 34:fea3ac5810e0
465 | tag: tip
465 | tag: tip
466 | parent: 32:d06dffa21a31
466 | parent: 32:d06dffa21a31
467 | user: test
467 | user: test
468 | date: Thu Jan 01 00:00:34 1970 +0000
468 | date: Thu Jan 01 00:00:34 1970 +0000
469 | summary: (34) head
469 | summary: (34) head
470 |
470 |
471 | o changeset: 33:68608f5145f9
471 | o changeset: 33:68608f5145f9
472 | | parent: 18:1aa84d96232a
472 | | parent: 18:1aa84d96232a
473 | | user: test
473 | | user: test
474 | | date: Thu Jan 01 00:00:33 1970 +0000
474 | | date: Thu Jan 01 00:00:33 1970 +0000
475 | | summary: (33) head
475 | | summary: (33) head
476 | |
476 | |
477 o | changeset: 32:d06dffa21a31
477 o | changeset: 32:d06dffa21a31
478 |\ \ parent: 27:886ed638191b
478 |\ \ parent: 27:886ed638191b
479 | | | parent: 31:621d83e11f67
479 | | | parent: 31:621d83e11f67
480 | | | user: test
480 | | | user: test
481 | | | date: Thu Jan 01 00:00:32 1970 +0000
481 | | | date: Thu Jan 01 00:00:32 1970 +0000
482 | | | summary: (32) expand
482 | | | summary: (32) expand
483 | | |
483 | | |
484 | o | changeset: 31:621d83e11f67
484 | o | changeset: 31:621d83e11f67
485 | |\ \ parent: 21:d42a756af44d
485 | |\ \ parent: 21:d42a756af44d
486 | | | | parent: 30:6e11cd4b648f
486 | | | | parent: 30:6e11cd4b648f
487 | | | | user: test
487 | | | | user: test
488 | | | | date: Thu Jan 01 00:00:31 1970 +0000
488 | | | | date: Thu Jan 01 00:00:31 1970 +0000
489 | | | | summary: (31) expand
489 | | | | summary: (31) expand
490 | | | |
490 | | | |
491 | | o | changeset: 30:6e11cd4b648f
491 | | o | changeset: 30:6e11cd4b648f
492 | | |\ \ parent: 28:44ecd0b9ae99
492 | | |\ \ parent: 28:44ecd0b9ae99
493 | | | | | parent: 29:cd9bb2be7593
493 | | | | | parent: 29:cd9bb2be7593
494 | | | | | user: test
494 | | | | | user: test
495 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
495 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
496 | | | | | summary: (30) expand
496 | | | | | summary: (30) expand
497 | | | | |
497 | | | | |
498 | | | o | changeset: 29:cd9bb2be7593
498 | | | o | changeset: 29:cd9bb2be7593
499 | | | | | parent: 0:e6eb3150255d
499 | | | | | parent: 0:e6eb3150255d
500 | | | | | user: test
500 | | | | | user: test
501 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
501 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
502 | | | | | summary: (29) regular commit
502 | | | | | summary: (29) regular commit
503 | | | | |
503 | | | | |
504 | | o | | changeset: 28:44ecd0b9ae99
504 | | o | | changeset: 28:44ecd0b9ae99
505 | | |\ \ \ parent: 1:6db2ef61d156
505 | | |\ \ \ parent: 1:6db2ef61d156
506 | | | | | | parent: 26:7f25b6c2f0b9
506 | | | | | | parent: 26:7f25b6c2f0b9
507 | | | | | | user: test
507 | | | | | | user: test
508 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
508 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
509 | | | | | | summary: (28) merge zero known
509 | | | | | | summary: (28) merge zero known
510 | | | | | |
510 | | | | | |
511 o | | | | | changeset: 27:886ed638191b
511 o | | | | | changeset: 27:886ed638191b
512 |/ / / / / parent: 21:d42a756af44d
512 |/ / / / / parent: 21:d42a756af44d
513 | | | | | user: test
513 | | | | | user: test
514 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
514 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
515 | | | | | summary: (27) collapse
515 | | | | | summary: (27) collapse
516 | | | | |
516 | | | | |
517 | | o---+ changeset: 26:7f25b6c2f0b9
517 | | o---+ changeset: 26:7f25b6c2f0b9
518 | | | | | parent: 18:1aa84d96232a
518 | | | | | parent: 18:1aa84d96232a
519 | | | | | parent: 25:91da8ed57247
519 | | | | | parent: 25:91da8ed57247
520 | | | | | user: test
520 | | | | | user: test
521 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
521 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
522 | | | | | summary: (26) merge one known; far right
522 | | | | | summary: (26) merge one known; far right
523 | | | | |
523 | | | | |
524 +---o | | changeset: 25:91da8ed57247
524 +---o | | changeset: 25:91da8ed57247
525 | | | | | parent: 21:d42a756af44d
525 | | | | | parent: 21:d42a756af44d
526 | | | | | parent: 24:a9c19a3d96b7
526 | | | | | parent: 24:a9c19a3d96b7
527 | | | | | user: test
527 | | | | | user: test
528 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
528 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
529 | | | | | summary: (25) merge one known; far left
529 | | | | | summary: (25) merge one known; far left
530 | | | | |
530 | | | | |
531 | | o | | changeset: 24:a9c19a3d96b7
531 | | o | | changeset: 24:a9c19a3d96b7
532 | | |\| | parent: 0:e6eb3150255d
532 | | |\| | parent: 0:e6eb3150255d
533 | | | | | parent: 23:a01cddf0766d
533 | | | | | parent: 23:a01cddf0766d
534 | | | | | user: test
534 | | | | | user: test
535 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
535 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
536 | | | | | summary: (24) merge one known; immediate right
536 | | | | | summary: (24) merge one known; immediate right
537 | | | | |
537 | | | | |
538 | | o | | changeset: 23:a01cddf0766d
538 | | o | | changeset: 23:a01cddf0766d
539 | |/| | | parent: 1:6db2ef61d156
539 | |/| | | parent: 1:6db2ef61d156
540 | | | | | parent: 22:e0d9cccacb5d
540 | | | | | parent: 22:e0d9cccacb5d
541 | | | | | user: test
541 | | | | | user: test
542 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
542 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
543 | | | | | summary: (23) merge one known; immediate left
543 | | | | | summary: (23) merge one known; immediate left
544 | | | | |
544 | | | | |
545 +---o---+ changeset: 22:e0d9cccacb5d
545 +---o---+ changeset: 22:e0d9cccacb5d
546 | | | | parent: 18:1aa84d96232a
546 | | | | parent: 18:1aa84d96232a
547 | | / / parent: 21:d42a756af44d
547 | | / / parent: 21:d42a756af44d
548 | | | | user: test
548 | | | | user: test
549 | | | | date: Thu Jan 01 00:00:22 1970 +0000
549 | | | | date: Thu Jan 01 00:00:22 1970 +0000
550 | | | | summary: (22) merge two known; one far left, one far right
550 | | | | summary: (22) merge two known; one far left, one far right
551 | | | |
551 | | | |
552 o | | | changeset: 21:d42a756af44d
552 o | | | changeset: 21:d42a756af44d
553 |\ \ \ \ parent: 19:31ddc2c1573b
553 |\ \ \ \ parent: 19:31ddc2c1573b
554 | | | | | parent: 20:d30ed6450e32
554 | | | | | parent: 20:d30ed6450e32
555 | | | | | user: test
555 | | | | | user: test
556 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
556 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
557 | | | | | summary: (21) expand
557 | | | | | summary: (21) expand
558 | | | | |
558 | | | | |
559 | o---+-+ changeset: 20:d30ed6450e32
559 | o---+-+ changeset: 20:d30ed6450e32
560 | | | | parent: 0:e6eb3150255d
560 | | | | parent: 0:e6eb3150255d
561 | / / / parent: 18:1aa84d96232a
561 | / / / parent: 18:1aa84d96232a
562 | | | | user: test
562 | | | | user: test
563 | | | | date: Thu Jan 01 00:00:20 1970 +0000
563 | | | | date: Thu Jan 01 00:00:20 1970 +0000
564 | | | | summary: (20) merge two known; two far right
564 | | | | summary: (20) merge two known; two far right
565 | | | |
565 | | | |
566 o | | | changeset: 19:31ddc2c1573b
566 o | | | changeset: 19:31ddc2c1573b
567 |\ \ \ \ parent: 15:1dda3f72782d
567 |\ \ \ \ parent: 15:1dda3f72782d
568 | | | | | parent: 17:44765d7c06e0
568 | | | | | parent: 17:44765d7c06e0
569 | | | | | user: test
569 | | | | | user: test
570 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
570 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
571 | | | | | summary: (19) expand
571 | | | | | summary: (19) expand
572 | | | | |
572 | | | | |
573 +---+---o changeset: 18:1aa84d96232a
573 +---+---o changeset: 18:1aa84d96232a
574 | | | | parent: 1:6db2ef61d156
574 | | | | parent: 1:6db2ef61d156
575 | | | | parent: 15:1dda3f72782d
575 | | | | parent: 15:1dda3f72782d
576 | | | | user: test
576 | | | | user: test
577 | | | | date: Thu Jan 01 00:00:18 1970 +0000
577 | | | | date: Thu Jan 01 00:00:18 1970 +0000
578 | | | | summary: (18) merge two known; two far left
578 | | | | summary: (18) merge two known; two far left
579 | | | |
579 | | | |
580 | o | | changeset: 17:44765d7c06e0
580 | o | | changeset: 17:44765d7c06e0
581 | |\ \ \ parent: 12:86b91144a6e9
581 | |\ \ \ parent: 12:86b91144a6e9
582 | | | | | parent: 16:3677d192927d
582 | | | | | parent: 16:3677d192927d
583 | | | | | user: test
583 | | | | | user: test
584 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
584 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
585 | | | | | summary: (17) expand
585 | | | | | summary: (17) expand
586 | | | | |
586 | | | | |
587 | | o---+ changeset: 16:3677d192927d
587 | | o---+ changeset: 16:3677d192927d
588 | | | | | parent: 0:e6eb3150255d
588 | | | | | parent: 0:e6eb3150255d
589 | | |/ / parent: 1:6db2ef61d156
589 | | |/ / parent: 1:6db2ef61d156
590 | | | | user: test
590 | | | | user: test
591 | | | | date: Thu Jan 01 00:00:16 1970 +0000
591 | | | | date: Thu Jan 01 00:00:16 1970 +0000
592 | | | | summary: (16) merge two known; one immediate right, one near right
592 | | | | summary: (16) merge two known; one immediate right, one near right
593 | | | |
593 | | | |
594 o | | | changeset: 15:1dda3f72782d
594 o | | | changeset: 15:1dda3f72782d
595 |\ \ \ \ parent: 13:22d8966a97e3
595 |\ \ \ \ parent: 13:22d8966a97e3
596 | | | | | parent: 14:8eac370358ef
596 | | | | | parent: 14:8eac370358ef
597 | | | | | user: test
597 | | | | | user: test
598 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
598 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
599 | | | | | summary: (15) expand
599 | | | | | summary: (15) expand
600 | | | | |
600 | | | | |
601 | o-----+ changeset: 14:8eac370358ef
601 | o-----+ changeset: 14:8eac370358ef
602 | | | | | parent: 0:e6eb3150255d
602 | | | | | parent: 0:e6eb3150255d
603 | |/ / / parent: 12:86b91144a6e9
603 | |/ / / parent: 12:86b91144a6e9
604 | | | | user: test
604 | | | | user: test
605 | | | | date: Thu Jan 01 00:00:14 1970 +0000
605 | | | | date: Thu Jan 01 00:00:14 1970 +0000
606 | | | | summary: (14) merge two known; one immediate right, one far right
606 | | | | summary: (14) merge two known; one immediate right, one far right
607 | | | |
607 | | | |
608 o | | | changeset: 13:22d8966a97e3
608 o | | | changeset: 13:22d8966a97e3
609 |\ \ \ \ parent: 9:7010c0af0a35
609 |\ \ \ \ parent: 9:7010c0af0a35
610 | | | | | parent: 11:832d76e6bdf2
610 | | | | | parent: 11:832d76e6bdf2
611 | | | | | user: test
611 | | | | | user: test
612 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
612 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
613 | | | | | summary: (13) expand
613 | | | | | summary: (13) expand
614 | | | | |
614 | | | | |
615 +---o | | changeset: 12:86b91144a6e9
615 +---o | | changeset: 12:86b91144a6e9
616 | | |/ / parent: 1:6db2ef61d156
616 | | |/ / parent: 1:6db2ef61d156
617 | | | | parent: 9:7010c0af0a35
617 | | | | parent: 9:7010c0af0a35
618 | | | | user: test
618 | | | | user: test
619 | | | | date: Thu Jan 01 00:00:12 1970 +0000
619 | | | | date: Thu Jan 01 00:00:12 1970 +0000
620 | | | | summary: (12) merge two known; one immediate right, one far left
620 | | | | summary: (12) merge two known; one immediate right, one far left
621 | | | |
621 | | | |
622 | o | | changeset: 11:832d76e6bdf2
622 | o | | changeset: 11:832d76e6bdf2
623 | |\ \ \ parent: 6:b105a072e251
623 | |\ \ \ parent: 6:b105a072e251
624 | | | | | parent: 10:74c64d036d72
624 | | | | | parent: 10:74c64d036d72
625 | | | | | user: test
625 | | | | | user: test
626 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
626 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
627 | | | | | summary: (11) expand
627 | | | | | summary: (11) expand
628 | | | | |
628 | | | | |
629 | | o---+ changeset: 10:74c64d036d72
629 | | o---+ changeset: 10:74c64d036d72
630 | | | | | parent: 0:e6eb3150255d
630 | | | | | parent: 0:e6eb3150255d
631 | |/ / / parent: 6:b105a072e251
631 | |/ / / parent: 6:b105a072e251
632 | | | | user: test
632 | | | | user: test
633 | | | | date: Thu Jan 01 00:00:10 1970 +0000
633 | | | | date: Thu Jan 01 00:00:10 1970 +0000
634 | | | | summary: (10) merge two known; one immediate left, one near right
634 | | | | summary: (10) merge two known; one immediate left, one near right
635 | | | |
635 | | | |
636 o | | | changeset: 9:7010c0af0a35
636 o | | | changeset: 9:7010c0af0a35
637 |\ \ \ \ parent: 7:b632bb1b1224
637 |\ \ \ \ parent: 7:b632bb1b1224
638 | | | | | parent: 8:7a0b11f71937
638 | | | | | parent: 8:7a0b11f71937
639 | | | | | user: test
639 | | | | | user: test
640 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
640 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
641 | | | | | summary: (9) expand
641 | | | | | summary: (9) expand
642 | | | | |
642 | | | | |
643 | o-----+ changeset: 8:7a0b11f71937
643 | o-----+ changeset: 8:7a0b11f71937
644 | | | | | parent: 0:e6eb3150255d
644 | | | | | parent: 0:e6eb3150255d
645 |/ / / / parent: 7:b632bb1b1224
645 |/ / / / parent: 7:b632bb1b1224
646 | | | | user: test
646 | | | | user: test
647 | | | | date: Thu Jan 01 00:00:08 1970 +0000
647 | | | | date: Thu Jan 01 00:00:08 1970 +0000
648 | | | | summary: (8) merge two known; one immediate left, one far right
648 | | | | summary: (8) merge two known; one immediate left, one far right
649 | | | |
649 | | | |
650 o | | | changeset: 7:b632bb1b1224
650 o | | | changeset: 7:b632bb1b1224
651 |\ \ \ \ parent: 2:3d9a33b8d1e1
651 |\ \ \ \ parent: 2:3d9a33b8d1e1
652 | | | | | parent: 5:4409d547b708
652 | | | | | parent: 5:4409d547b708
653 | | | | | user: test
653 | | | | | user: test
654 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
654 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
655 | | | | | summary: (7) expand
655 | | | | | summary: (7) expand
656 | | | | |
656 | | | | |
657 +---o | | changeset: 6:b105a072e251
657 +---o | | changeset: 6:b105a072e251
658 | |/ / / parent: 2:3d9a33b8d1e1
658 | |/ / / parent: 2:3d9a33b8d1e1
659 | | | | parent: 5:4409d547b708
659 | | | | parent: 5:4409d547b708
660 | | | | user: test
660 | | | | user: test
661 | | | | date: Thu Jan 01 00:00:06 1970 +0000
661 | | | | date: Thu Jan 01 00:00:06 1970 +0000
662 | | | | summary: (6) merge two known; one immediate left, one far left
662 | | | | summary: (6) merge two known; one immediate left, one far left
663 | | | |
663 | | | |
664 | o | | changeset: 5:4409d547b708
664 | o | | changeset: 5:4409d547b708
665 | |\ \ \ parent: 3:27eef8ed80b4
665 | |\ \ \ parent: 3:27eef8ed80b4
666 | | | | | parent: 4:26a8bac39d9f
666 | | | | | parent: 4:26a8bac39d9f
667 | | | | | user: test
667 | | | | | user: test
668 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
668 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
669 | | | | | summary: (5) expand
669 | | | | | summary: (5) expand
670 | | | | |
670 | | | | |
671 | | o | | changeset: 4:26a8bac39d9f
671 | | o | | changeset: 4:26a8bac39d9f
672 | |/|/ / parent: 1:6db2ef61d156
672 | |/|/ / parent: 1:6db2ef61d156
673 | | | | parent: 3:27eef8ed80b4
673 | | | | parent: 3:27eef8ed80b4
674 | | | | user: test
674 | | | | user: test
675 | | | | date: Thu Jan 01 00:00:04 1970 +0000
675 | | | | date: Thu Jan 01 00:00:04 1970 +0000
676 | | | | summary: (4) merge two known; one immediate left, one immediate right
676 | | | | summary: (4) merge two known; one immediate left, one immediate right
677 | | | |
677 | | | |
678 | o | | changeset: 3:27eef8ed80b4
678 | o | | changeset: 3:27eef8ed80b4
679 |/ / / user: test
679 |/ / / user: test
680 | | | date: Thu Jan 01 00:00:03 1970 +0000
680 | | | date: Thu Jan 01 00:00:03 1970 +0000
681 | | | summary: (3) collapse
681 | | | summary: (3) collapse
682 | | |
682 | | |
683 o | | changeset: 2:3d9a33b8d1e1
683 o | | changeset: 2:3d9a33b8d1e1
684 |/ / user: test
684 |/ / user: test
685 | | date: Thu Jan 01 00:00:02 1970 +0000
685 | | date: Thu Jan 01 00:00:02 1970 +0000
686 | | summary: (2) collapse
686 | | summary: (2) collapse
687 | |
687 | |
688 o | changeset: 1:6db2ef61d156
688 o | changeset: 1:6db2ef61d156
689 |/ user: test
689 |/ user: test
690 | date: Thu Jan 01 00:00:01 1970 +0000
690 | date: Thu Jan 01 00:00:01 1970 +0000
691 | summary: (1) collapse
691 | summary: (1) collapse
692 |
692 |
693 o changeset: 0:e6eb3150255d
693 o changeset: 0:e6eb3150255d
694 user: test
694 user: test
695 date: Thu Jan 01 00:00:00 1970 +0000
695 date: Thu Jan 01 00:00:00 1970 +0000
696 summary: (0) root
696 summary: (0) root
697
697
698
698
699 File glog per revset:
699 File glog per revset:
700
700
701 $ hg log -G -r 'file("a")'
701 $ hg log -G -r 'file("a")'
702 @ changeset: 34:fea3ac5810e0
702 @ changeset: 34:fea3ac5810e0
703 | tag: tip
703 | tag: tip
704 | parent: 32:d06dffa21a31
704 | parent: 32:d06dffa21a31
705 | user: test
705 | user: test
706 | date: Thu Jan 01 00:00:34 1970 +0000
706 | date: Thu Jan 01 00:00:34 1970 +0000
707 | summary: (34) head
707 | summary: (34) head
708 |
708 |
709 | o changeset: 33:68608f5145f9
709 | o changeset: 33:68608f5145f9
710 | | parent: 18:1aa84d96232a
710 | | parent: 18:1aa84d96232a
711 | | user: test
711 | | user: test
712 | | date: Thu Jan 01 00:00:33 1970 +0000
712 | | date: Thu Jan 01 00:00:33 1970 +0000
713 | | summary: (33) head
713 | | summary: (33) head
714 | |
714 | |
715 o | changeset: 32:d06dffa21a31
715 o | changeset: 32:d06dffa21a31
716 |\ \ parent: 27:886ed638191b
716 |\ \ parent: 27:886ed638191b
717 | | | parent: 31:621d83e11f67
717 | | | parent: 31:621d83e11f67
718 | | | user: test
718 | | | user: test
719 | | | date: Thu Jan 01 00:00:32 1970 +0000
719 | | | date: Thu Jan 01 00:00:32 1970 +0000
720 | | | summary: (32) expand
720 | | | summary: (32) expand
721 | | |
721 | | |
722 | o | changeset: 31:621d83e11f67
722 | o | changeset: 31:621d83e11f67
723 | |\ \ parent: 21:d42a756af44d
723 | |\ \ parent: 21:d42a756af44d
724 | | | | parent: 30:6e11cd4b648f
724 | | | | parent: 30:6e11cd4b648f
725 | | | | user: test
725 | | | | user: test
726 | | | | date: Thu Jan 01 00:00:31 1970 +0000
726 | | | | date: Thu Jan 01 00:00:31 1970 +0000
727 | | | | summary: (31) expand
727 | | | | summary: (31) expand
728 | | | |
728 | | | |
729 | | o | changeset: 30:6e11cd4b648f
729 | | o | changeset: 30:6e11cd4b648f
730 | | |\ \ parent: 28:44ecd0b9ae99
730 | | |\ \ parent: 28:44ecd0b9ae99
731 | | | | | parent: 29:cd9bb2be7593
731 | | | | | parent: 29:cd9bb2be7593
732 | | | | | user: test
732 | | | | | user: test
733 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
733 | | | | | date: Thu Jan 01 00:00:30 1970 +0000
734 | | | | | summary: (30) expand
734 | | | | | summary: (30) expand
735 | | | | |
735 | | | | |
736 | | | o | changeset: 29:cd9bb2be7593
736 | | | o | changeset: 29:cd9bb2be7593
737 | | | | | parent: 0:e6eb3150255d
737 | | | | | parent: 0:e6eb3150255d
738 | | | | | user: test
738 | | | | | user: test
739 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
739 | | | | | date: Thu Jan 01 00:00:29 1970 +0000
740 | | | | | summary: (29) regular commit
740 | | | | | summary: (29) regular commit
741 | | | | |
741 | | | | |
742 | | o | | changeset: 28:44ecd0b9ae99
742 | | o | | changeset: 28:44ecd0b9ae99
743 | | |\ \ \ parent: 1:6db2ef61d156
743 | | |\ \ \ parent: 1:6db2ef61d156
744 | | | | | | parent: 26:7f25b6c2f0b9
744 | | | | | | parent: 26:7f25b6c2f0b9
745 | | | | | | user: test
745 | | | | | | user: test
746 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
746 | | | | | | date: Thu Jan 01 00:00:28 1970 +0000
747 | | | | | | summary: (28) merge zero known
747 | | | | | | summary: (28) merge zero known
748 | | | | | |
748 | | | | | |
749 o | | | | | changeset: 27:886ed638191b
749 o | | | | | changeset: 27:886ed638191b
750 |/ / / / / parent: 21:d42a756af44d
750 |/ / / / / parent: 21:d42a756af44d
751 | | | | | user: test
751 | | | | | user: test
752 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
752 | | | | | date: Thu Jan 01 00:00:27 1970 +0000
753 | | | | | summary: (27) collapse
753 | | | | | summary: (27) collapse
754 | | | | |
754 | | | | |
755 | | o---+ changeset: 26:7f25b6c2f0b9
755 | | o---+ changeset: 26:7f25b6c2f0b9
756 | | | | | parent: 18:1aa84d96232a
756 | | | | | parent: 18:1aa84d96232a
757 | | | | | parent: 25:91da8ed57247
757 | | | | | parent: 25:91da8ed57247
758 | | | | | user: test
758 | | | | | user: test
759 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
759 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
760 | | | | | summary: (26) merge one known; far right
760 | | | | | summary: (26) merge one known; far right
761 | | | | |
761 | | | | |
762 +---o | | changeset: 25:91da8ed57247
762 +---o | | changeset: 25:91da8ed57247
763 | | | | | parent: 21:d42a756af44d
763 | | | | | parent: 21:d42a756af44d
764 | | | | | parent: 24:a9c19a3d96b7
764 | | | | | parent: 24:a9c19a3d96b7
765 | | | | | user: test
765 | | | | | user: test
766 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
766 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
767 | | | | | summary: (25) merge one known; far left
767 | | | | | summary: (25) merge one known; far left
768 | | | | |
768 | | | | |
769 | | o | | changeset: 24:a9c19a3d96b7
769 | | o | | changeset: 24:a9c19a3d96b7
770 | | |\| | parent: 0:e6eb3150255d
770 | | |\| | parent: 0:e6eb3150255d
771 | | | | | parent: 23:a01cddf0766d
771 | | | | | parent: 23:a01cddf0766d
772 | | | | | user: test
772 | | | | | user: test
773 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
773 | | | | | date: Thu Jan 01 00:00:24 1970 +0000
774 | | | | | summary: (24) merge one known; immediate right
774 | | | | | summary: (24) merge one known; immediate right
775 | | | | |
775 | | | | |
776 | | o | | changeset: 23:a01cddf0766d
776 | | o | | changeset: 23:a01cddf0766d
777 | |/| | | parent: 1:6db2ef61d156
777 | |/| | | parent: 1:6db2ef61d156
778 | | | | | parent: 22:e0d9cccacb5d
778 | | | | | parent: 22:e0d9cccacb5d
779 | | | | | user: test
779 | | | | | user: test
780 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
780 | | | | | date: Thu Jan 01 00:00:23 1970 +0000
781 | | | | | summary: (23) merge one known; immediate left
781 | | | | | summary: (23) merge one known; immediate left
782 | | | | |
782 | | | | |
783 +---o---+ changeset: 22:e0d9cccacb5d
783 +---o---+ changeset: 22:e0d9cccacb5d
784 | | | | parent: 18:1aa84d96232a
784 | | | | parent: 18:1aa84d96232a
785 | | / / parent: 21:d42a756af44d
785 | | / / parent: 21:d42a756af44d
786 | | | | user: test
786 | | | | user: test
787 | | | | date: Thu Jan 01 00:00:22 1970 +0000
787 | | | | date: Thu Jan 01 00:00:22 1970 +0000
788 | | | | summary: (22) merge two known; one far left, one far right
788 | | | | summary: (22) merge two known; one far left, one far right
789 | | | |
789 | | | |
790 o | | | changeset: 21:d42a756af44d
790 o | | | changeset: 21:d42a756af44d
791 |\ \ \ \ parent: 19:31ddc2c1573b
791 |\ \ \ \ parent: 19:31ddc2c1573b
792 | | | | | parent: 20:d30ed6450e32
792 | | | | | parent: 20:d30ed6450e32
793 | | | | | user: test
793 | | | | | user: test
794 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
794 | | | | | date: Thu Jan 01 00:00:21 1970 +0000
795 | | | | | summary: (21) expand
795 | | | | | summary: (21) expand
796 | | | | |
796 | | | | |
797 | o---+-+ changeset: 20:d30ed6450e32
797 | o---+-+ changeset: 20:d30ed6450e32
798 | | | | parent: 0:e6eb3150255d
798 | | | | parent: 0:e6eb3150255d
799 | / / / parent: 18:1aa84d96232a
799 | / / / parent: 18:1aa84d96232a
800 | | | | user: test
800 | | | | user: test
801 | | | | date: Thu Jan 01 00:00:20 1970 +0000
801 | | | | date: Thu Jan 01 00:00:20 1970 +0000
802 | | | | summary: (20) merge two known; two far right
802 | | | | summary: (20) merge two known; two far right
803 | | | |
803 | | | |
804 o | | | changeset: 19:31ddc2c1573b
804 o | | | changeset: 19:31ddc2c1573b
805 |\ \ \ \ parent: 15:1dda3f72782d
805 |\ \ \ \ parent: 15:1dda3f72782d
806 | | | | | parent: 17:44765d7c06e0
806 | | | | | parent: 17:44765d7c06e0
807 | | | | | user: test
807 | | | | | user: test
808 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
808 | | | | | date: Thu Jan 01 00:00:19 1970 +0000
809 | | | | | summary: (19) expand
809 | | | | | summary: (19) expand
810 | | | | |
810 | | | | |
811 +---+---o changeset: 18:1aa84d96232a
811 +---+---o changeset: 18:1aa84d96232a
812 | | | | parent: 1:6db2ef61d156
812 | | | | parent: 1:6db2ef61d156
813 | | | | parent: 15:1dda3f72782d
813 | | | | parent: 15:1dda3f72782d
814 | | | | user: test
814 | | | | user: test
815 | | | | date: Thu Jan 01 00:00:18 1970 +0000
815 | | | | date: Thu Jan 01 00:00:18 1970 +0000
816 | | | | summary: (18) merge two known; two far left
816 | | | | summary: (18) merge two known; two far left
817 | | | |
817 | | | |
818 | o | | changeset: 17:44765d7c06e0
818 | o | | changeset: 17:44765d7c06e0
819 | |\ \ \ parent: 12:86b91144a6e9
819 | |\ \ \ parent: 12:86b91144a6e9
820 | | | | | parent: 16:3677d192927d
820 | | | | | parent: 16:3677d192927d
821 | | | | | user: test
821 | | | | | user: test
822 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
822 | | | | | date: Thu Jan 01 00:00:17 1970 +0000
823 | | | | | summary: (17) expand
823 | | | | | summary: (17) expand
824 | | | | |
824 | | | | |
825 | | o---+ changeset: 16:3677d192927d
825 | | o---+ changeset: 16:3677d192927d
826 | | | | | parent: 0:e6eb3150255d
826 | | | | | parent: 0:e6eb3150255d
827 | | |/ / parent: 1:6db2ef61d156
827 | | |/ / parent: 1:6db2ef61d156
828 | | | | user: test
828 | | | | user: test
829 | | | | date: Thu Jan 01 00:00:16 1970 +0000
829 | | | | date: Thu Jan 01 00:00:16 1970 +0000
830 | | | | summary: (16) merge two known; one immediate right, one near right
830 | | | | summary: (16) merge two known; one immediate right, one near right
831 | | | |
831 | | | |
832 o | | | changeset: 15:1dda3f72782d
832 o | | | changeset: 15:1dda3f72782d
833 |\ \ \ \ parent: 13:22d8966a97e3
833 |\ \ \ \ parent: 13:22d8966a97e3
834 | | | | | parent: 14:8eac370358ef
834 | | | | | parent: 14:8eac370358ef
835 | | | | | user: test
835 | | | | | user: test
836 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
836 | | | | | date: Thu Jan 01 00:00:15 1970 +0000
837 | | | | | summary: (15) expand
837 | | | | | summary: (15) expand
838 | | | | |
838 | | | | |
839 | o-----+ changeset: 14:8eac370358ef
839 | o-----+ changeset: 14:8eac370358ef
840 | | | | | parent: 0:e6eb3150255d
840 | | | | | parent: 0:e6eb3150255d
841 | |/ / / parent: 12:86b91144a6e9
841 | |/ / / parent: 12:86b91144a6e9
842 | | | | user: test
842 | | | | user: test
843 | | | | date: Thu Jan 01 00:00:14 1970 +0000
843 | | | | date: Thu Jan 01 00:00:14 1970 +0000
844 | | | | summary: (14) merge two known; one immediate right, one far right
844 | | | | summary: (14) merge two known; one immediate right, one far right
845 | | | |
845 | | | |
846 o | | | changeset: 13:22d8966a97e3
846 o | | | changeset: 13:22d8966a97e3
847 |\ \ \ \ parent: 9:7010c0af0a35
847 |\ \ \ \ parent: 9:7010c0af0a35
848 | | | | | parent: 11:832d76e6bdf2
848 | | | | | parent: 11:832d76e6bdf2
849 | | | | | user: test
849 | | | | | user: test
850 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
850 | | | | | date: Thu Jan 01 00:00:13 1970 +0000
851 | | | | | summary: (13) expand
851 | | | | | summary: (13) expand
852 | | | | |
852 | | | | |
853 +---o | | changeset: 12:86b91144a6e9
853 +---o | | changeset: 12:86b91144a6e9
854 | | |/ / parent: 1:6db2ef61d156
854 | | |/ / parent: 1:6db2ef61d156
855 | | | | parent: 9:7010c0af0a35
855 | | | | parent: 9:7010c0af0a35
856 | | | | user: test
856 | | | | user: test
857 | | | | date: Thu Jan 01 00:00:12 1970 +0000
857 | | | | date: Thu Jan 01 00:00:12 1970 +0000
858 | | | | summary: (12) merge two known; one immediate right, one far left
858 | | | | summary: (12) merge two known; one immediate right, one far left
859 | | | |
859 | | | |
860 | o | | changeset: 11:832d76e6bdf2
860 | o | | changeset: 11:832d76e6bdf2
861 | |\ \ \ parent: 6:b105a072e251
861 | |\ \ \ parent: 6:b105a072e251
862 | | | | | parent: 10:74c64d036d72
862 | | | | | parent: 10:74c64d036d72
863 | | | | | user: test
863 | | | | | user: test
864 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
864 | | | | | date: Thu Jan 01 00:00:11 1970 +0000
865 | | | | | summary: (11) expand
865 | | | | | summary: (11) expand
866 | | | | |
866 | | | | |
867 | | o---+ changeset: 10:74c64d036d72
867 | | o---+ changeset: 10:74c64d036d72
868 | | | | | parent: 0:e6eb3150255d
868 | | | | | parent: 0:e6eb3150255d
869 | |/ / / parent: 6:b105a072e251
869 | |/ / / parent: 6:b105a072e251
870 | | | | user: test
870 | | | | user: test
871 | | | | date: Thu Jan 01 00:00:10 1970 +0000
871 | | | | date: Thu Jan 01 00:00:10 1970 +0000
872 | | | | summary: (10) merge two known; one immediate left, one near right
872 | | | | summary: (10) merge two known; one immediate left, one near right
873 | | | |
873 | | | |
874 o | | | changeset: 9:7010c0af0a35
874 o | | | changeset: 9:7010c0af0a35
875 |\ \ \ \ parent: 7:b632bb1b1224
875 |\ \ \ \ parent: 7:b632bb1b1224
876 | | | | | parent: 8:7a0b11f71937
876 | | | | | parent: 8:7a0b11f71937
877 | | | | | user: test
877 | | | | | user: test
878 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
878 | | | | | date: Thu Jan 01 00:00:09 1970 +0000
879 | | | | | summary: (9) expand
879 | | | | | summary: (9) expand
880 | | | | |
880 | | | | |
881 | o-----+ changeset: 8:7a0b11f71937
881 | o-----+ changeset: 8:7a0b11f71937
882 | | | | | parent: 0:e6eb3150255d
882 | | | | | parent: 0:e6eb3150255d
883 |/ / / / parent: 7:b632bb1b1224
883 |/ / / / parent: 7:b632bb1b1224
884 | | | | user: test
884 | | | | user: test
885 | | | | date: Thu Jan 01 00:00:08 1970 +0000
885 | | | | date: Thu Jan 01 00:00:08 1970 +0000
886 | | | | summary: (8) merge two known; one immediate left, one far right
886 | | | | summary: (8) merge two known; one immediate left, one far right
887 | | | |
887 | | | |
888 o | | | changeset: 7:b632bb1b1224
888 o | | | changeset: 7:b632bb1b1224
889 |\ \ \ \ parent: 2:3d9a33b8d1e1
889 |\ \ \ \ parent: 2:3d9a33b8d1e1
890 | | | | | parent: 5:4409d547b708
890 | | | | | parent: 5:4409d547b708
891 | | | | | user: test
891 | | | | | user: test
892 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
892 | | | | | date: Thu Jan 01 00:00:07 1970 +0000
893 | | | | | summary: (7) expand
893 | | | | | summary: (7) expand
894 | | | | |
894 | | | | |
895 +---o | | changeset: 6:b105a072e251
895 +---o | | changeset: 6:b105a072e251
896 | |/ / / parent: 2:3d9a33b8d1e1
896 | |/ / / parent: 2:3d9a33b8d1e1
897 | | | | parent: 5:4409d547b708
897 | | | | parent: 5:4409d547b708
898 | | | | user: test
898 | | | | user: test
899 | | | | date: Thu Jan 01 00:00:06 1970 +0000
899 | | | | date: Thu Jan 01 00:00:06 1970 +0000
900 | | | | summary: (6) merge two known; one immediate left, one far left
900 | | | | summary: (6) merge two known; one immediate left, one far left
901 | | | |
901 | | | |
902 | o | | changeset: 5:4409d547b708
902 | o | | changeset: 5:4409d547b708
903 | |\ \ \ parent: 3:27eef8ed80b4
903 | |\ \ \ parent: 3:27eef8ed80b4
904 | | | | | parent: 4:26a8bac39d9f
904 | | | | | parent: 4:26a8bac39d9f
905 | | | | | user: test
905 | | | | | user: test
906 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
906 | | | | | date: Thu Jan 01 00:00:05 1970 +0000
907 | | | | | summary: (5) expand
907 | | | | | summary: (5) expand
908 | | | | |
908 | | | | |
909 | | o | | changeset: 4:26a8bac39d9f
909 | | o | | changeset: 4:26a8bac39d9f
910 | |/|/ / parent: 1:6db2ef61d156
910 | |/|/ / parent: 1:6db2ef61d156
911 | | | | parent: 3:27eef8ed80b4
911 | | | | parent: 3:27eef8ed80b4
912 | | | | user: test
912 | | | | user: test
913 | | | | date: Thu Jan 01 00:00:04 1970 +0000
913 | | | | date: Thu Jan 01 00:00:04 1970 +0000
914 | | | | summary: (4) merge two known; one immediate left, one immediate right
914 | | | | summary: (4) merge two known; one immediate left, one immediate right
915 | | | |
915 | | | |
916 | o | | changeset: 3:27eef8ed80b4
916 | o | | changeset: 3:27eef8ed80b4
917 |/ / / user: test
917 |/ / / user: test
918 | | | date: Thu Jan 01 00:00:03 1970 +0000
918 | | | date: Thu Jan 01 00:00:03 1970 +0000
919 | | | summary: (3) collapse
919 | | | summary: (3) collapse
920 | | |
920 | | |
921 o | | changeset: 2:3d9a33b8d1e1
921 o | | changeset: 2:3d9a33b8d1e1
922 |/ / user: test
922 |/ / user: test
923 | | date: Thu Jan 01 00:00:02 1970 +0000
923 | | date: Thu Jan 01 00:00:02 1970 +0000
924 | | summary: (2) collapse
924 | | summary: (2) collapse
925 | |
925 | |
926 o | changeset: 1:6db2ef61d156
926 o | changeset: 1:6db2ef61d156
927 |/ user: test
927 |/ user: test
928 | date: Thu Jan 01 00:00:01 1970 +0000
928 | date: Thu Jan 01 00:00:01 1970 +0000
929 | summary: (1) collapse
929 | summary: (1) collapse
930 |
930 |
931 o changeset: 0:e6eb3150255d
931 o changeset: 0:e6eb3150255d
932 user: test
932 user: test
933 date: Thu Jan 01 00:00:00 1970 +0000
933 date: Thu Jan 01 00:00:00 1970 +0000
934 summary: (0) root
934 summary: (0) root
935
935
936
936
937
937
938 File glog per revset (only merges):
938 File glog per revset (only merges):
939
939
940 $ hg log -G -r 'file("a")' -m
940 $ hg log -G -r 'file("a")' -m
941 o changeset: 32:d06dffa21a31
941 o changeset: 32:d06dffa21a31
942 |\ parent: 27:886ed638191b
942 |\ parent: 27:886ed638191b
943 | | parent: 31:621d83e11f67
943 | | parent: 31:621d83e11f67
944 | | user: test
944 | | user: test
945 | | date: Thu Jan 01 00:00:32 1970 +0000
945 | | date: Thu Jan 01 00:00:32 1970 +0000
946 | | summary: (32) expand
946 | | summary: (32) expand
947 | |
947 | |
948 o | changeset: 31:621d83e11f67
948 o | changeset: 31:621d83e11f67
949 |\| parent: 21:d42a756af44d
949 |\| parent: 21:d42a756af44d
950 | | parent: 30:6e11cd4b648f
950 | | parent: 30:6e11cd4b648f
951 | | user: test
951 | | user: test
952 | | date: Thu Jan 01 00:00:31 1970 +0000
952 | | date: Thu Jan 01 00:00:31 1970 +0000
953 | | summary: (31) expand
953 | | summary: (31) expand
954 | |
954 | |
955 o | changeset: 30:6e11cd4b648f
955 o | changeset: 30:6e11cd4b648f
956 |\ \ parent: 28:44ecd0b9ae99
956 |\ \ parent: 28:44ecd0b9ae99
957 | | | parent: 29:cd9bb2be7593
957 | | | parent: 29:cd9bb2be7593
958 | | | user: test
958 | | | user: test
959 | | | date: Thu Jan 01 00:00:30 1970 +0000
959 | | | date: Thu Jan 01 00:00:30 1970 +0000
960 | | | summary: (30) expand
960 | | | summary: (30) expand
961 | | |
961 | | |
962 o | | changeset: 28:44ecd0b9ae99
962 o | | changeset: 28:44ecd0b9ae99
963 |\ \ \ parent: 1:6db2ef61d156
963 |\ \ \ parent: 1:6db2ef61d156
964 | | | | parent: 26:7f25b6c2f0b9
964 | | | | parent: 26:7f25b6c2f0b9
965 | | | | user: test
965 | | | | user: test
966 | | | | date: Thu Jan 01 00:00:28 1970 +0000
966 | | | | date: Thu Jan 01 00:00:28 1970 +0000
967 | | | | summary: (28) merge zero known
967 | | | | summary: (28) merge zero known
968 | | | |
968 | | | |
969 o | | | changeset: 26:7f25b6c2f0b9
969 o | | | changeset: 26:7f25b6c2f0b9
970 |\ \ \ \ parent: 18:1aa84d96232a
970 |\ \ \ \ parent: 18:1aa84d96232a
971 | | | | | parent: 25:91da8ed57247
971 | | | | | parent: 25:91da8ed57247
972 | | | | | user: test
972 | | | | | user: test
973 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
973 | | | | | date: Thu Jan 01 00:00:26 1970 +0000
974 | | | | | summary: (26) merge one known; far right
974 | | | | | summary: (26) merge one known; far right
975 | | | | |
975 | | | | |
976 | o-----+ changeset: 25:91da8ed57247
976 | o-----+ changeset: 25:91da8ed57247
977 | | | | | parent: 21:d42a756af44d
977 | | | | | parent: 21:d42a756af44d
978 | | | | | parent: 24:a9c19a3d96b7
978 | | | | | parent: 24:a9c19a3d96b7
979 | | | | | user: test
979 | | | | | user: test
980 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
980 | | | | | date: Thu Jan 01 00:00:25 1970 +0000
981 | | | | | summary: (25) merge one known; far left
981 | | | | | summary: (25) merge one known; far left
982 | | | | |
982 | | | | |
983 | o | | | changeset: 24:a9c19a3d96b7
983 | o | | | changeset: 24:a9c19a3d96b7
984 | |\ \ \ \ parent: 0:e6eb3150255d
984 | |\ \ \ \ parent: 0:e6eb3150255d
985 | | | | | | parent: 23:a01cddf0766d
985 | | | | | | parent: 23:a01cddf0766d
986 | | | | | | user: test
986 | | | | | | user: test
987 | | | | | | date: Thu Jan 01 00:00:24 1970 +0000
987 | | | | | | date: Thu Jan 01 00:00:24 1970 +0000
988 | | | | | | summary: (24) merge one known; immediate right
988 | | | | | | summary: (24) merge one known; immediate right
989 | | | | | |
989 | | | | | |
990 | o---+ | | changeset: 23:a01cddf0766d
990 | o---+ | | changeset: 23:a01cddf0766d
991 | | | | | | parent: 1:6db2ef61d156
991 | | | | | | parent: 1:6db2ef61d156
992 | | | | | | parent: 22:e0d9cccacb5d
992 | | | | | | parent: 22:e0d9cccacb5d
993 | | | | | | user: test
993 | | | | | | user: test
994 | | | | | | date: Thu Jan 01 00:00:23 1970 +0000
994 | | | | | | date: Thu Jan 01 00:00:23 1970 +0000
995 | | | | | | summary: (23) merge one known; immediate left
995 | | | | | | summary: (23) merge one known; immediate left
996 | | | | | |
996 | | | | | |
997 | o-------+ changeset: 22:e0d9cccacb5d
997 | o-------+ changeset: 22:e0d9cccacb5d
998 | | | | | | parent: 18:1aa84d96232a
998 | | | | | | parent: 18:1aa84d96232a
999 |/ / / / / parent: 21:d42a756af44d
999 |/ / / / / parent: 21:d42a756af44d
1000 | | | | | user: test
1000 | | | | | user: test
1001 | | | | | date: Thu Jan 01 00:00:22 1970 +0000
1001 | | | | | date: Thu Jan 01 00:00:22 1970 +0000
1002 | | | | | summary: (22) merge two known; one far left, one far right
1002 | | | | | summary: (22) merge two known; one far left, one far right
1003 | | | | |
1003 | | | | |
1004 | | | | o changeset: 21:d42a756af44d
1004 | | | | o changeset: 21:d42a756af44d
1005 | | | | |\ parent: 19:31ddc2c1573b
1005 | | | | |\ parent: 19:31ddc2c1573b
1006 | | | | | | parent: 20:d30ed6450e32
1006 | | | | | | parent: 20:d30ed6450e32
1007 | | | | | | user: test
1007 | | | | | | user: test
1008 | | | | | | date: Thu Jan 01 00:00:21 1970 +0000
1008 | | | | | | date: Thu Jan 01 00:00:21 1970 +0000
1009 | | | | | | summary: (21) expand
1009 | | | | | | summary: (21) expand
1010 | | | | | |
1010 | | | | | |
1011 +-+-------o changeset: 20:d30ed6450e32
1011 +-+-------o changeset: 20:d30ed6450e32
1012 | | | | | parent: 0:e6eb3150255d
1012 | | | | | parent: 0:e6eb3150255d
1013 | | | | | parent: 18:1aa84d96232a
1013 | | | | | parent: 18:1aa84d96232a
1014 | | | | | user: test
1014 | | | | | user: test
1015 | | | | | date: Thu Jan 01 00:00:20 1970 +0000
1015 | | | | | date: Thu Jan 01 00:00:20 1970 +0000
1016 | | | | | summary: (20) merge two known; two far right
1016 | | | | | summary: (20) merge two known; two far right
1017 | | | | |
1017 | | | | |
1018 | | | | o changeset: 19:31ddc2c1573b
1018 | | | | o changeset: 19:31ddc2c1573b
1019 | | | | |\ parent: 15:1dda3f72782d
1019 | | | | |\ parent: 15:1dda3f72782d
1020 | | | | | | parent: 17:44765d7c06e0
1020 | | | | | | parent: 17:44765d7c06e0
1021 | | | | | | user: test
1021 | | | | | | user: test
1022 | | | | | | date: Thu Jan 01 00:00:19 1970 +0000
1022 | | | | | | date: Thu Jan 01 00:00:19 1970 +0000
1023 | | | | | | summary: (19) expand
1023 | | | | | | summary: (19) expand
1024 | | | | | |
1024 | | | | | |
1025 o---+---+ | changeset: 18:1aa84d96232a
1025 o---+---+ | changeset: 18:1aa84d96232a
1026 | | | | | parent: 1:6db2ef61d156
1026 | | | | | parent: 1:6db2ef61d156
1027 / / / / / parent: 15:1dda3f72782d
1027 / / / / / parent: 15:1dda3f72782d
1028 | | | | | user: test
1028 | | | | | user: test
1029 | | | | | date: Thu Jan 01 00:00:18 1970 +0000
1029 | | | | | date: Thu Jan 01 00:00:18 1970 +0000
1030 | | | | | summary: (18) merge two known; two far left
1030 | | | | | summary: (18) merge two known; two far left
1031 | | | | |
1031 | | | | |
1032 | | | | o changeset: 17:44765d7c06e0
1032 | | | | o changeset: 17:44765d7c06e0
1033 | | | | |\ parent: 12:86b91144a6e9
1033 | | | | |\ parent: 12:86b91144a6e9
1034 | | | | | | parent: 16:3677d192927d
1034 | | | | | | parent: 16:3677d192927d
1035 | | | | | | user: test
1035 | | | | | | user: test
1036 | | | | | | date: Thu Jan 01 00:00:17 1970 +0000
1036 | | | | | | date: Thu Jan 01 00:00:17 1970 +0000
1037 | | | | | | summary: (17) expand
1037 | | | | | | summary: (17) expand
1038 | | | | | |
1038 | | | | | |
1039 +-+-------o changeset: 16:3677d192927d
1039 +-+-------o changeset: 16:3677d192927d
1040 | | | | | parent: 0:e6eb3150255d
1040 | | | | | parent: 0:e6eb3150255d
1041 | | | | | parent: 1:6db2ef61d156
1041 | | | | | parent: 1:6db2ef61d156
1042 | | | | | user: test
1042 | | | | | user: test
1043 | | | | | date: Thu Jan 01 00:00:16 1970 +0000
1043 | | | | | date: Thu Jan 01 00:00:16 1970 +0000
1044 | | | | | summary: (16) merge two known; one immediate right, one near right
1044 | | | | | summary: (16) merge two known; one immediate right, one near right
1045 | | | | |
1045 | | | | |
1046 | | | o | changeset: 15:1dda3f72782d
1046 | | | o | changeset: 15:1dda3f72782d
1047 | | | |\ \ parent: 13:22d8966a97e3
1047 | | | |\ \ parent: 13:22d8966a97e3
1048 | | | | | | parent: 14:8eac370358ef
1048 | | | | | | parent: 14:8eac370358ef
1049 | | | | | | user: test
1049 | | | | | | user: test
1050 | | | | | | date: Thu Jan 01 00:00:15 1970 +0000
1050 | | | | | | date: Thu Jan 01 00:00:15 1970 +0000
1051 | | | | | | summary: (15) expand
1051 | | | | | | summary: (15) expand
1052 | | | | | |
1052 | | | | | |
1053 +-------o | changeset: 14:8eac370358ef
1053 +-------o | changeset: 14:8eac370358ef
1054 | | | | |/ parent: 0:e6eb3150255d
1054 | | | | |/ parent: 0:e6eb3150255d
1055 | | | | | parent: 12:86b91144a6e9
1055 | | | | | parent: 12:86b91144a6e9
1056 | | | | | user: test
1056 | | | | | user: test
1057 | | | | | date: Thu Jan 01 00:00:14 1970 +0000
1057 | | | | | date: Thu Jan 01 00:00:14 1970 +0000
1058 | | | | | summary: (14) merge two known; one immediate right, one far right
1058 | | | | | summary: (14) merge two known; one immediate right, one far right
1059 | | | | |
1059 | | | | |
1060 | | | o | changeset: 13:22d8966a97e3
1060 | | | o | changeset: 13:22d8966a97e3
1061 | | | |\ \ parent: 9:7010c0af0a35
1061 | | | |\ \ parent: 9:7010c0af0a35
1062 | | | | | | parent: 11:832d76e6bdf2
1062 | | | | | | parent: 11:832d76e6bdf2
1063 | | | | | | user: test
1063 | | | | | | user: test
1064 | | | | | | date: Thu Jan 01 00:00:13 1970 +0000
1064 | | | | | | date: Thu Jan 01 00:00:13 1970 +0000
1065 | | | | | | summary: (13) expand
1065 | | | | | | summary: (13) expand
1066 | | | | | |
1066 | | | | | |
1067 | +---+---o changeset: 12:86b91144a6e9
1067 | +---+---o changeset: 12:86b91144a6e9
1068 | | | | | parent: 1:6db2ef61d156
1068 | | | | | parent: 1:6db2ef61d156
1069 | | | | | parent: 9:7010c0af0a35
1069 | | | | | parent: 9:7010c0af0a35
1070 | | | | | user: test
1070 | | | | | user: test
1071 | | | | | date: Thu Jan 01 00:00:12 1970 +0000
1071 | | | | | date: Thu Jan 01 00:00:12 1970 +0000
1072 | | | | | summary: (12) merge two known; one immediate right, one far left
1072 | | | | | summary: (12) merge two known; one immediate right, one far left
1073 | | | | |
1073 | | | | |
1074 | | | | o changeset: 11:832d76e6bdf2
1074 | | | | o changeset: 11:832d76e6bdf2
1075 | | | | |\ parent: 6:b105a072e251
1075 | | | | |\ parent: 6:b105a072e251
1076 | | | | | | parent: 10:74c64d036d72
1076 | | | | | | parent: 10:74c64d036d72
1077 | | | | | | user: test
1077 | | | | | | user: test
1078 | | | | | | date: Thu Jan 01 00:00:11 1970 +0000
1078 | | | | | | date: Thu Jan 01 00:00:11 1970 +0000
1079 | | | | | | summary: (11) expand
1079 | | | | | | summary: (11) expand
1080 | | | | | |
1080 | | | | | |
1081 +---------o changeset: 10:74c64d036d72
1081 +---------o changeset: 10:74c64d036d72
1082 | | | | |/ parent: 0:e6eb3150255d
1082 | | | | |/ parent: 0:e6eb3150255d
1083 | | | | | parent: 6:b105a072e251
1083 | | | | | parent: 6:b105a072e251
1084 | | | | | user: test
1084 | | | | | user: test
1085 | | | | | date: Thu Jan 01 00:00:10 1970 +0000
1085 | | | | | date: Thu Jan 01 00:00:10 1970 +0000
1086 | | | | | summary: (10) merge two known; one immediate left, one near right
1086 | | | | | summary: (10) merge two known; one immediate left, one near right
1087 | | | | |
1087 | | | | |
1088 | | | o | changeset: 9:7010c0af0a35
1088 | | | o | changeset: 9:7010c0af0a35
1089 | | | |\ \ parent: 7:b632bb1b1224
1089 | | | |\ \ parent: 7:b632bb1b1224
1090 | | | | | | parent: 8:7a0b11f71937
1090 | | | | | | parent: 8:7a0b11f71937
1091 | | | | | | user: test
1091 | | | | | | user: test
1092 | | | | | | date: Thu Jan 01 00:00:09 1970 +0000
1092 | | | | | | date: Thu Jan 01 00:00:09 1970 +0000
1093 | | | | | | summary: (9) expand
1093 | | | | | | summary: (9) expand
1094 | | | | | |
1094 | | | | | |
1095 +-------o | changeset: 8:7a0b11f71937
1095 +-------o | changeset: 8:7a0b11f71937
1096 | | | |/ / parent: 0:e6eb3150255d
1096 | | | |/ / parent: 0:e6eb3150255d
1097 | | | | | parent: 7:b632bb1b1224
1097 | | | | | parent: 7:b632bb1b1224
1098 | | | | | user: test
1098 | | | | | user: test
1099 | | | | | date: Thu Jan 01 00:00:08 1970 +0000
1099 | | | | | date: Thu Jan 01 00:00:08 1970 +0000
1100 | | | | | summary: (8) merge two known; one immediate left, one far right
1100 | | | | | summary: (8) merge two known; one immediate left, one far right
1101 | | | | |
1101 | | | | |
1102 | | | o | changeset: 7:b632bb1b1224
1102 | | | o | changeset: 7:b632bb1b1224
1103 | | | |\ \ parent: 2:3d9a33b8d1e1
1103 | | | |\ \ parent: 2:3d9a33b8d1e1
1104 | | | | | | parent: 5:4409d547b708
1104 | | | | | | parent: 5:4409d547b708
1105 | | | | | | user: test
1105 | | | | | | user: test
1106 | | | | | | date: Thu Jan 01 00:00:07 1970 +0000
1106 | | | | | | date: Thu Jan 01 00:00:07 1970 +0000
1107 | | | | | | summary: (7) expand
1107 | | | | | | summary: (7) expand
1108 | | | | | |
1108 | | | | | |
1109 | | | +---o changeset: 6:b105a072e251
1109 | | | +---o changeset: 6:b105a072e251
1110 | | | | |/ parent: 2:3d9a33b8d1e1
1110 | | | | |/ parent: 2:3d9a33b8d1e1
1111 | | | | | parent: 5:4409d547b708
1111 | | | | | parent: 5:4409d547b708
1112 | | | | | user: test
1112 | | | | | user: test
1113 | | | | | date: Thu Jan 01 00:00:06 1970 +0000
1113 | | | | | date: Thu Jan 01 00:00:06 1970 +0000
1114 | | | | | summary: (6) merge two known; one immediate left, one far left
1114 | | | | | summary: (6) merge two known; one immediate left, one far left
1115 | | | | |
1115 | | | | |
1116 | | | o | changeset: 5:4409d547b708
1116 | | | o | changeset: 5:4409d547b708
1117 | | | |\ \ parent: 3:27eef8ed80b4
1117 | | | |\ \ parent: 3:27eef8ed80b4
1118 | | | | | | parent: 4:26a8bac39d9f
1118 | | | | | | parent: 4:26a8bac39d9f
1119 | | | | | | user: test
1119 | | | | | | user: test
1120 | | | | | | date: Thu Jan 01 00:00:05 1970 +0000
1120 | | | | | | date: Thu Jan 01 00:00:05 1970 +0000
1121 | | | | | | summary: (5) expand
1121 | | | | | | summary: (5) expand
1122 | | | | | |
1122 | | | | | |
1123 | +---o | | changeset: 4:26a8bac39d9f
1123 | +---o | | changeset: 4:26a8bac39d9f
1124 | | | |/ / parent: 1:6db2ef61d156
1124 | | | |/ / parent: 1:6db2ef61d156
1125 | | | | | parent: 3:27eef8ed80b4
1125 | | | | | parent: 3:27eef8ed80b4
1126 | | | | | user: test
1126 | | | | | user: test
1127 | | | | | date: Thu Jan 01 00:00:04 1970 +0000
1127 | | | | | date: Thu Jan 01 00:00:04 1970 +0000
1128 | | | | | summary: (4) merge two known; one immediate left, one immediate right
1128 | | | | | summary: (4) merge two known; one immediate left, one immediate right
1129 | | | | |
1129 | | | | |
1130
1130
1131
1131
1132 Empty revision range - display nothing:
1132 Empty revision range - display nothing:
1133 $ hg log -G -r 1..0
1133 $ hg log -G -r 1..0
1134
1134
1135 $ cd ..
1135 $ cd ..
1136
1136
1137 #if no-outer-repo
1137 #if no-outer-repo
1138
1138
1139 From outer space:
1139 From outer space:
1140 $ hg log -G -l1 repo
1140 $ hg log -G -l1 repo
1141 @ changeset: 34:fea3ac5810e0
1141 @ changeset: 34:fea3ac5810e0
1142 | tag: tip
1142 | tag: tip
1143 | parent: 32:d06dffa21a31
1143 | parent: 32:d06dffa21a31
1144 | user: test
1144 | user: test
1145 | date: Thu Jan 01 00:00:34 1970 +0000
1145 | date: Thu Jan 01 00:00:34 1970 +0000
1146 | summary: (34) head
1146 | summary: (34) head
1147 |
1147 |
1148 $ hg log -G -l1 repo/a
1148 $ hg log -G -l1 repo/a
1149 @ changeset: 34:fea3ac5810e0
1149 @ changeset: 34:fea3ac5810e0
1150 | tag: tip
1150 | tag: tip
1151 | parent: 32:d06dffa21a31
1151 | parent: 32:d06dffa21a31
1152 | user: test
1152 | user: test
1153 | date: Thu Jan 01 00:00:34 1970 +0000
1153 | date: Thu Jan 01 00:00:34 1970 +0000
1154 | summary: (34) head
1154 | summary: (34) head
1155 |
1155 |
1156 $ hg log -G -l1 repo/missing
1156 $ hg log -G -l1 repo/missing
1157
1157
1158 #endif
1158 #endif
1159
1159
1160 File log with revs != cset revs:
1160 File log with revs != cset revs:
1161 $ hg init flog
1161 $ hg init flog
1162 $ cd flog
1162 $ cd flog
1163 $ echo one >one
1163 $ echo one >one
1164 $ hg add one
1164 $ hg add one
1165 $ hg commit -mone
1165 $ hg commit -mone
1166 $ echo two >two
1166 $ echo two >two
1167 $ hg add two
1167 $ hg add two
1168 $ hg commit -mtwo
1168 $ hg commit -mtwo
1169 $ echo more >two
1169 $ echo more >two
1170 $ hg commit -mmore
1170 $ hg commit -mmore
1171 $ hg log -G two
1171 $ hg log -G two
1172 @ changeset: 2:12c28321755b
1172 @ changeset: 2:12c28321755b
1173 | tag: tip
1173 | tag: tip
1174 | user: test
1174 | user: test
1175 | date: Thu Jan 01 00:00:00 1970 +0000
1175 | date: Thu Jan 01 00:00:00 1970 +0000
1176 | summary: more
1176 | summary: more
1177 |
1177 |
1178 o changeset: 1:5ac72c0599bf
1178 o changeset: 1:5ac72c0599bf
1179 | user: test
1179 | user: test
1180 | date: Thu Jan 01 00:00:00 1970 +0000
1180 | date: Thu Jan 01 00:00:00 1970 +0000
1181 | summary: two
1181 | summary: two
1182 |
1182 |
1183
1183
1184 Issue1896: File log with explicit style
1184 Issue1896: File log with explicit style
1185 $ hg log -G --style=default one
1185 $ hg log -G --style=default one
1186 o changeset: 0:3d578b4a1f53
1186 o changeset: 0:3d578b4a1f53
1187 user: test
1187 user: test
1188 date: Thu Jan 01 00:00:00 1970 +0000
1188 date: Thu Jan 01 00:00:00 1970 +0000
1189 summary: one
1189 summary: one
1190
1190
1191 Issue2395: glog --style header and footer
1191 Issue2395: glog --style header and footer
1192 $ hg log -G --style=xml one
1192 $ hg log -G --style=xml one
1193 <?xml version="1.0"?>
1193 <?xml version="1.0"?>
1194 <log>
1194 <log>
1195 o <logentry revision="0" node="3d578b4a1f537d5fcf7301bfa9c0b97adfaa6fb1">
1195 o <logentry revision="0" node="3d578b4a1f537d5fcf7301bfa9c0b97adfaa6fb1">
1196 <author email="test">test</author>
1196 <author email="test">test</author>
1197 <date>1970-01-01T00:00:00+00:00</date>
1197 <date>1970-01-01T00:00:00+00:00</date>
1198 <msg xml:space="preserve">one</msg>
1198 <msg xml:space="preserve">one</msg>
1199 </logentry>
1199 </logentry>
1200 </log>
1200 </log>
1201
1201
1202 $ cd ..
1202 $ cd ..
1203
1203
1204 Incoming and outgoing:
1204 Incoming and outgoing:
1205
1205
1206 $ hg clone -U -r31 repo repo2
1206 $ hg clone -U -r31 repo repo2
1207 adding changesets
1207 adding changesets
1208 adding manifests
1208 adding manifests
1209 adding file changes
1209 adding file changes
1210 added 31 changesets with 31 changes to 1 files
1210 added 31 changesets with 31 changes to 1 files
1211 $ cd repo2
1211 $ cd repo2
1212
1212
1213 $ hg incoming --graph ../repo
1213 $ hg incoming --graph ../repo
1214 comparing with ../repo
1214 comparing with ../repo
1215 searching for changes
1215 searching for changes
1216 o changeset: 34:fea3ac5810e0
1216 o changeset: 34:fea3ac5810e0
1217 | tag: tip
1217 | tag: tip
1218 | parent: 32:d06dffa21a31
1218 | parent: 32:d06dffa21a31
1219 | user: test
1219 | user: test
1220 | date: Thu Jan 01 00:00:34 1970 +0000
1220 | date: Thu Jan 01 00:00:34 1970 +0000
1221 | summary: (34) head
1221 | summary: (34) head
1222 |
1222 |
1223 | o changeset: 33:68608f5145f9
1223 | o changeset: 33:68608f5145f9
1224 | parent: 18:1aa84d96232a
1224 | parent: 18:1aa84d96232a
1225 | user: test
1225 | user: test
1226 | date: Thu Jan 01 00:00:33 1970 +0000
1226 | date: Thu Jan 01 00:00:33 1970 +0000
1227 | summary: (33) head
1227 | summary: (33) head
1228 |
1228 |
1229 o changeset: 32:d06dffa21a31
1229 o changeset: 32:d06dffa21a31
1230 | parent: 27:886ed638191b
1230 | parent: 27:886ed638191b
1231 | parent: 31:621d83e11f67
1231 | parent: 31:621d83e11f67
1232 | user: test
1232 | user: test
1233 | date: Thu Jan 01 00:00:32 1970 +0000
1233 | date: Thu Jan 01 00:00:32 1970 +0000
1234 | summary: (32) expand
1234 | summary: (32) expand
1235 |
1235 |
1236 o changeset: 27:886ed638191b
1236 o changeset: 27:886ed638191b
1237 parent: 21:d42a756af44d
1237 parent: 21:d42a756af44d
1238 user: test
1238 user: test
1239 date: Thu Jan 01 00:00:27 1970 +0000
1239 date: Thu Jan 01 00:00:27 1970 +0000
1240 summary: (27) collapse
1240 summary: (27) collapse
1241
1241
1242 $ cd ..
1242 $ cd ..
1243
1243
1244 $ hg -R repo outgoing --graph repo2
1244 $ hg -R repo outgoing --graph repo2
1245 comparing with repo2
1245 comparing with repo2
1246 searching for changes
1246 searching for changes
1247 @ changeset: 34:fea3ac5810e0
1247 @ changeset: 34:fea3ac5810e0
1248 | tag: tip
1248 | tag: tip
1249 | parent: 32:d06dffa21a31
1249 | parent: 32:d06dffa21a31
1250 | user: test
1250 | user: test
1251 | date: Thu Jan 01 00:00:34 1970 +0000
1251 | date: Thu Jan 01 00:00:34 1970 +0000
1252 | summary: (34) head
1252 | summary: (34) head
1253 |
1253 |
1254 | o changeset: 33:68608f5145f9
1254 | o changeset: 33:68608f5145f9
1255 | parent: 18:1aa84d96232a
1255 | parent: 18:1aa84d96232a
1256 | user: test
1256 | user: test
1257 | date: Thu Jan 01 00:00:33 1970 +0000
1257 | date: Thu Jan 01 00:00:33 1970 +0000
1258 | summary: (33) head
1258 | summary: (33) head
1259 |
1259 |
1260 o changeset: 32:d06dffa21a31
1260 o changeset: 32:d06dffa21a31
1261 | parent: 27:886ed638191b
1261 | parent: 27:886ed638191b
1262 | parent: 31:621d83e11f67
1262 | parent: 31:621d83e11f67
1263 | user: test
1263 | user: test
1264 | date: Thu Jan 01 00:00:32 1970 +0000
1264 | date: Thu Jan 01 00:00:32 1970 +0000
1265 | summary: (32) expand
1265 | summary: (32) expand
1266 |
1266 |
1267 o changeset: 27:886ed638191b
1267 o changeset: 27:886ed638191b
1268 parent: 21:d42a756af44d
1268 parent: 21:d42a756af44d
1269 user: test
1269 user: test
1270 date: Thu Jan 01 00:00:27 1970 +0000
1270 date: Thu Jan 01 00:00:27 1970 +0000
1271 summary: (27) collapse
1271 summary: (27) collapse
1272
1272
1273
1273
1274 File + limit with revs != cset revs:
1274 File + limit with revs != cset revs:
1275 $ cd repo
1275 $ cd repo
1276 $ touch b
1276 $ touch b
1277 $ hg ci -Aqm0
1277 $ hg ci -Aqm0
1278 $ hg log -G -l2 a
1278 $ hg log -G -l2 a
1279 o changeset: 34:fea3ac5810e0
1279 o changeset: 34:fea3ac5810e0
1280 | parent: 32:d06dffa21a31
1280 | parent: 32:d06dffa21a31
1281 | user: test
1281 | user: test
1282 | date: Thu Jan 01 00:00:34 1970 +0000
1282 | date: Thu Jan 01 00:00:34 1970 +0000
1283 | summary: (34) head
1283 | summary: (34) head
1284 |
1284 |
1285 | o changeset: 33:68608f5145f9
1285 | o changeset: 33:68608f5145f9
1286 | | parent: 18:1aa84d96232a
1286 | | parent: 18:1aa84d96232a
1287 | | user: test
1287 | | user: test
1288 | | date: Thu Jan 01 00:00:33 1970 +0000
1288 | | date: Thu Jan 01 00:00:33 1970 +0000
1289 | | summary: (33) head
1289 | | summary: (33) head
1290 | |
1290 | |
1291
1291
1292 File + limit + -ra:b, (b - a) < limit:
1292 File + limit + -ra:b, (b - a) < limit:
1293 $ hg log -G -l3000 -r32:tip a
1293 $ hg log -G -l3000 -r32:tip a
1294 o changeset: 34:fea3ac5810e0
1294 o changeset: 34:fea3ac5810e0
1295 | parent: 32:d06dffa21a31
1295 | parent: 32:d06dffa21a31
1296 | user: test
1296 | user: test
1297 | date: Thu Jan 01 00:00:34 1970 +0000
1297 | date: Thu Jan 01 00:00:34 1970 +0000
1298 | summary: (34) head
1298 | summary: (34) head
1299 |
1299 |
1300 | o changeset: 33:68608f5145f9
1300 | o changeset: 33:68608f5145f9
1301 | | parent: 18:1aa84d96232a
1301 | | parent: 18:1aa84d96232a
1302 | | user: test
1302 | | user: test
1303 | | date: Thu Jan 01 00:00:33 1970 +0000
1303 | | date: Thu Jan 01 00:00:33 1970 +0000
1304 | | summary: (33) head
1304 | | summary: (33) head
1305 | |
1305 | |
1306 o | changeset: 32:d06dffa21a31
1306 o | changeset: 32:d06dffa21a31
1307 |\ \ parent: 27:886ed638191b
1307 |\ \ parent: 27:886ed638191b
1308 | | | parent: 31:621d83e11f67
1308 | | | parent: 31:621d83e11f67
1309 | | | user: test
1309 | | | user: test
1310 | | | date: Thu Jan 01 00:00:32 1970 +0000
1310 | | | date: Thu Jan 01 00:00:32 1970 +0000
1311 | | | summary: (32) expand
1311 | | | summary: (32) expand
1312 | | |
1312 | | |
1313
1313
1314 Point out a common and an uncommon unshown parent
1314 Point out a common and an uncommon unshown parent
1315
1315
1316 $ hg log -G -r 'rev(8) or rev(9)'
1316 $ hg log -G -r 'rev(8) or rev(9)'
1317 o changeset: 9:7010c0af0a35
1317 o changeset: 9:7010c0af0a35
1318 |\ parent: 7:b632bb1b1224
1318 |\ parent: 7:b632bb1b1224
1319 | | parent: 8:7a0b11f71937
1319 | | parent: 8:7a0b11f71937
1320 | | user: test
1320 | | user: test
1321 | | date: Thu Jan 01 00:00:09 1970 +0000
1321 | | date: Thu Jan 01 00:00:09 1970 +0000
1322 | | summary: (9) expand
1322 | | summary: (9) expand
1323 | |
1323 | |
1324 o | changeset: 8:7a0b11f71937
1324 o | changeset: 8:7a0b11f71937
1325 |\| parent: 0:e6eb3150255d
1325 |\| parent: 0:e6eb3150255d
1326 | | parent: 7:b632bb1b1224
1326 | | parent: 7:b632bb1b1224
1327 | | user: test
1327 | | user: test
1328 | | date: Thu Jan 01 00:00:08 1970 +0000
1328 | | date: Thu Jan 01 00:00:08 1970 +0000
1329 | | summary: (8) merge two known; one immediate left, one far right
1329 | | summary: (8) merge two known; one immediate left, one far right
1330 | |
1330 | |
1331
1331
1332 File + limit + -ra:b, b < tip:
1332 File + limit + -ra:b, b < tip:
1333
1333
1334 $ hg log -G -l1 -r32:34 a
1334 $ hg log -G -l1 -r32:34 a
1335 o changeset: 34:fea3ac5810e0
1335 o changeset: 34:fea3ac5810e0
1336 | parent: 32:d06dffa21a31
1336 | parent: 32:d06dffa21a31
1337 | user: test
1337 | user: test
1338 | date: Thu Jan 01 00:00:34 1970 +0000
1338 | date: Thu Jan 01 00:00:34 1970 +0000
1339 | summary: (34) head
1339 | summary: (34) head
1340 |
1340 |
1341
1341
1342 file(File) + limit + -ra:b, b < tip:
1342 file(File) + limit + -ra:b, b < tip:
1343
1343
1344 $ hg log -G -l1 -r32:34 -r 'file("a")'
1344 $ hg log -G -l1 -r32:34 -r 'file("a")'
1345 o changeset: 34:fea3ac5810e0
1345 o changeset: 34:fea3ac5810e0
1346 | parent: 32:d06dffa21a31
1346 | parent: 32:d06dffa21a31
1347 | user: test
1347 | user: test
1348 | date: Thu Jan 01 00:00:34 1970 +0000
1348 | date: Thu Jan 01 00:00:34 1970 +0000
1349 | summary: (34) head
1349 | summary: (34) head
1350 |
1350 |
1351
1351
1352 limit(file(File) and a::b), b < tip:
1352 limit(file(File) and a::b), b < tip:
1353
1353
1354 $ hg log -G -r 'limit(file("a") and 32::34, 1)'
1354 $ hg log -G -r 'limit(file("a") and 32::34, 1)'
1355 o changeset: 32:d06dffa21a31
1355 o changeset: 32:d06dffa21a31
1356 |\ parent: 27:886ed638191b
1356 |\ parent: 27:886ed638191b
1357 | | parent: 31:621d83e11f67
1357 | | parent: 31:621d83e11f67
1358 | | user: test
1358 | | user: test
1359 | | date: Thu Jan 01 00:00:32 1970 +0000
1359 | | date: Thu Jan 01 00:00:32 1970 +0000
1360 | | summary: (32) expand
1360 | | summary: (32) expand
1361 | |
1361 | |
1362
1362
1363 File + limit + -ra:b, b < tip:
1363 File + limit + -ra:b, b < tip:
1364
1364
1365 $ hg log -G -r 'limit(file("a") and 34::32, 1)'
1365 $ hg log -G -r 'limit(file("a") and 34::32, 1)'
1366
1366
1367 File + limit + -ra:b, b < tip, (b - a) < limit:
1367 File + limit + -ra:b, b < tip, (b - a) < limit:
1368
1368
1369 $ hg log -G -l10 -r33:34 a
1369 $ hg log -G -l10 -r33:34 a
1370 o changeset: 34:fea3ac5810e0
1370 o changeset: 34:fea3ac5810e0
1371 | parent: 32:d06dffa21a31
1371 | parent: 32:d06dffa21a31
1372 | user: test
1372 | user: test
1373 | date: Thu Jan 01 00:00:34 1970 +0000
1373 | date: Thu Jan 01 00:00:34 1970 +0000
1374 | summary: (34) head
1374 | summary: (34) head
1375 |
1375 |
1376 | o changeset: 33:68608f5145f9
1376 | o changeset: 33:68608f5145f9
1377 | | parent: 18:1aa84d96232a
1377 | | parent: 18:1aa84d96232a
1378 | | user: test
1378 | | user: test
1379 | | date: Thu Jan 01 00:00:33 1970 +0000
1379 | | date: Thu Jan 01 00:00:33 1970 +0000
1380 | | summary: (33) head
1380 | | summary: (33) head
1381 | |
1381 | |
1382
1382
1383 Do not crash or produce strange graphs if history is buggy
1383 Do not crash or produce strange graphs if history is buggy
1384
1384
1385 $ hg branch branch
1385 $ hg branch branch
1386 marked working directory as branch branch
1386 marked working directory as branch branch
1387 (branches are permanent and global, did you want a bookmark?)
1387 (branches are permanent and global, did you want a bookmark?)
1388 $ commit 36 "buggy merge: identical parents" 35 35
1388 $ commit 36 "buggy merge: identical parents" 35 35
1389 $ hg log -G -l5
1389 $ hg log -G -l5
1390 @ changeset: 36:08a19a744424
1390 @ changeset: 36:08a19a744424
1391 | branch: branch
1391 | branch: branch
1392 | tag: tip
1392 | tag: tip
1393 | parent: 35:9159c3644c5e
1393 | parent: 35:9159c3644c5e
1394 | parent: 35:9159c3644c5e
1394 | parent: 35:9159c3644c5e
1395 | user: test
1395 | user: test
1396 | date: Thu Jan 01 00:00:36 1970 +0000
1396 | date: Thu Jan 01 00:00:36 1970 +0000
1397 | summary: (36) buggy merge: identical parents
1397 | summary: (36) buggy merge: identical parents
1398 |
1398 |
1399 o changeset: 35:9159c3644c5e
1399 o changeset: 35:9159c3644c5e
1400 | user: test
1400 | user: test
1401 | date: Thu Jan 01 00:00:00 1970 +0000
1401 | date: Thu Jan 01 00:00:00 1970 +0000
1402 | summary: 0
1402 | summary: 0
1403 |
1403 |
1404 o changeset: 34:fea3ac5810e0
1404 o changeset: 34:fea3ac5810e0
1405 | parent: 32:d06dffa21a31
1405 | parent: 32:d06dffa21a31
1406 | user: test
1406 | user: test
1407 | date: Thu Jan 01 00:00:34 1970 +0000
1407 | date: Thu Jan 01 00:00:34 1970 +0000
1408 | summary: (34) head
1408 | summary: (34) head
1409 |
1409 |
1410 | o changeset: 33:68608f5145f9
1410 | o changeset: 33:68608f5145f9
1411 | | parent: 18:1aa84d96232a
1411 | | parent: 18:1aa84d96232a
1412 | | user: test
1412 | | user: test
1413 | | date: Thu Jan 01 00:00:33 1970 +0000
1413 | | date: Thu Jan 01 00:00:33 1970 +0000
1414 | | summary: (33) head
1414 | | summary: (33) head
1415 | |
1415 | |
1416 o | changeset: 32:d06dffa21a31
1416 o | changeset: 32:d06dffa21a31
1417 |\ \ parent: 27:886ed638191b
1417 |\ \ parent: 27:886ed638191b
1418 | | | parent: 31:621d83e11f67
1418 | | | parent: 31:621d83e11f67
1419 | | | user: test
1419 | | | user: test
1420 | | | date: Thu Jan 01 00:00:32 1970 +0000
1420 | | | date: Thu Jan 01 00:00:32 1970 +0000
1421 | | | summary: (32) expand
1421 | | | summary: (32) expand
1422 | | |
1422 | | |
1423
1423
1424 Test log -G options
1424 Test log -G options
1425
1425
1426 $ testlog() {
1426 $ testlog() {
1427 > hg log -G --print-revset "$@"
1427 > hg log -G --print-revset "$@"
1428 > hg log --template 'nodetag {rev}\n' "$@" | grep nodetag \
1428 > hg log --template 'nodetag {rev}\n' "$@" | grep nodetag \
1429 > | sed 's/.*nodetag/nodetag/' > log.nodes
1429 > | sed 's/.*nodetag/nodetag/' > log.nodes
1430 > hg log -G --template 'nodetag {rev}\n' "$@" | grep nodetag \
1430 > hg log -G --template 'nodetag {rev}\n' "$@" | grep nodetag \
1431 > | sed 's/.*nodetag/nodetag/' > glog.nodes
1431 > | sed 's/.*nodetag/nodetag/' > glog.nodes
1432 > diff -u log.nodes glog.nodes | grep '^[-+@ ]' || :
1432 > diff -u log.nodes glog.nodes | grep '^[-+@ ]' || :
1433 > }
1433 > }
1434
1434
1435 glog always reorders nodes which explains the difference with log
1435 glog always reorders nodes which explains the difference with log
1436
1436
1437 $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31
1437 $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31
1438 ['27', '25', '21', '34', '32', '31']
1438 ['27', '25', '21', '34', '32', '31']
1439 []
1439 []
1440 --- log.nodes * (glob)
1440 --- log.nodes * (glob)
1441 +++ glog.nodes * (glob)
1441 +++ glog.nodes * (glob)
1442 @@ -1,6 +1,6 @@
1442 @@ -1,6 +1,6 @@
1443 -nodetag 27
1443 -nodetag 27
1444 -nodetag 25
1444 -nodetag 25
1445 -nodetag 21
1445 -nodetag 21
1446 nodetag 34
1446 nodetag 34
1447 nodetag 32
1447 nodetag 32
1448 nodetag 31
1448 nodetag 31
1449 +nodetag 27
1449 +nodetag 27
1450 +nodetag 25
1450 +nodetag 25
1451 +nodetag 21
1451 +nodetag 21
1452 $ testlog -u test -u not-a-user
1452 $ testlog -u test -u not-a-user
1453 []
1453 []
1454 (group
1454 (group
1455 (group
1455 (group
1456 (or
1456 (or
1457 (func
1457 (func
1458 ('symbol', 'user')
1458 ('symbol', 'user')
1459 ('string', 'test'))
1459 ('string', 'test'))
1460 (func
1460 (func
1461 ('symbol', 'user')
1461 ('symbol', 'user')
1462 ('string', 'not-a-user')))))
1462 ('string', 'not-a-user')))))
1463 $ testlog -b not-a-branch
1463 $ testlog -b not-a-branch
1464 abort: unknown revision 'not-a-branch'!
1464 abort: unknown revision 'not-a-branch'!
1465 abort: unknown revision 'not-a-branch'!
1465 abort: unknown revision 'not-a-branch'!
1466 abort: unknown revision 'not-a-branch'!
1466 abort: unknown revision 'not-a-branch'!
1467 $ testlog -b 35 -b 36 --only-branch branch
1467 $ testlog -b 35 -b 36 --only-branch branch
1468 []
1468 []
1469 (group
1469 (group
1470 (group
1470 (group
1471 (or
1471 (or
1472 (or
1472 (or
1473 (func
1473 (func
1474 ('symbol', 'branch')
1474 ('symbol', 'branch')
1475 ('string', 'default'))
1475 ('string', 'default'))
1476 (func
1476 (func
1477 ('symbol', 'branch')
1477 ('symbol', 'branch')
1478 ('string', 'branch')))
1478 ('string', 'branch')))
1479 (func
1479 (func
1480 ('symbol', 'branch')
1480 ('symbol', 'branch')
1481 ('string', 'branch')))))
1481 ('string', 'branch')))))
1482 $ testlog -k expand -k merge
1482 $ testlog -k expand -k merge
1483 []
1483 []
1484 (group
1484 (group
1485 (group
1485 (group
1486 (or
1486 (or
1487 (func
1487 (func
1488 ('symbol', 'keyword')
1488 ('symbol', 'keyword')
1489 ('string', 'expand'))
1489 ('string', 'expand'))
1490 (func
1490 (func
1491 ('symbol', 'keyword')
1491 ('symbol', 'keyword')
1492 ('string', 'merge')))))
1492 ('string', 'merge')))))
1493 $ testlog --only-merges
1493 $ testlog --only-merges
1494 []
1494 []
1495 (group
1495 (group
1496 (func
1496 (func
1497 ('symbol', 'merge')
1497 ('symbol', 'merge')
1498 None))
1498 None))
1499 $ testlog --no-merges
1499 $ testlog --no-merges
1500 []
1500 []
1501 (group
1501 (group
1502 (not
1502 (not
1503 (func
1503 (func
1504 ('symbol', 'merge')
1504 ('symbol', 'merge')
1505 None)))
1505 None)))
1506 $ testlog --date '2 0 to 4 0'
1506 $ testlog --date '2 0 to 4 0'
1507 []
1507 []
1508 (group
1508 (group
1509 (func
1509 (func
1510 ('symbol', 'date')
1510 ('symbol', 'date')
1511 ('string', '2 0 to 4 0')))
1511 ('string', '2 0 to 4 0')))
1512 $ hg log -G -d 'brace ) in a date'
1512 $ hg log -G -d 'brace ) in a date'
1513 abort: invalid date: 'brace ) in a date'
1513 abort: invalid date: 'brace ) in a date'
1514 [255]
1514 [255]
1515 $ testlog --prune 31 --prune 32
1515 $ testlog --prune 31 --prune 32
1516 []
1516 []
1517 (group
1517 (group
1518 (group
1518 (group
1519 (and
1519 (and
1520 (not
1520 (not
1521 (group
1521 (group
1522 (or
1522 (or
1523 ('string', '31')
1523 ('string', '31')
1524 (func
1524 (func
1525 ('symbol', 'ancestors')
1525 ('symbol', 'ancestors')
1526 ('string', '31')))))
1526 ('string', '31')))))
1527 (not
1527 (not
1528 (group
1528 (group
1529 (or
1529 (or
1530 ('string', '32')
1530 ('string', '32')
1531 (func
1531 (func
1532 ('symbol', 'ancestors')
1532 ('symbol', 'ancestors')
1533 ('string', '32'))))))))
1533 ('string', '32'))))))))
1534
1534
1535 Dedicated repo for --follow and paths filtering. The g is crafted to
1535 Dedicated repo for --follow and paths filtering. The g is crafted to
1536 have 2 filelog topological heads in a linear changeset graph.
1536 have 2 filelog topological heads in a linear changeset graph.
1537
1537
1538 $ cd ..
1538 $ cd ..
1539 $ hg init follow
1539 $ hg init follow
1540 $ cd follow
1540 $ cd follow
1541 $ testlog --follow
1541 $ testlog --follow
1542 []
1542 []
1543 []
1543 []
1544 $ testlog -rnull
1544 $ testlog -rnull
1545 ['null']
1545 ['null']
1546 []
1546 []
1547 $ echo a > a
1547 $ echo a > a
1548 $ echo aa > aa
1548 $ echo aa > aa
1549 $ echo f > f
1549 $ echo f > f
1550 $ hg ci -Am "add a" a aa f
1550 $ hg ci -Am "add a" a aa f
1551 $ hg cp a b
1551 $ hg cp a b
1552 $ hg cp f g
1552 $ hg cp f g
1553 $ hg ci -m "copy a b"
1553 $ hg ci -m "copy a b"
1554 $ mkdir dir
1554 $ mkdir dir
1555 $ hg mv b dir
1555 $ hg mv b dir
1556 $ echo g >> g
1556 $ echo g >> g
1557 $ echo f >> f
1557 $ echo f >> f
1558 $ hg ci -m "mv b dir/b"
1558 $ hg ci -m "mv b dir/b"
1559 $ hg mv a b
1559 $ hg mv a b
1560 $ hg cp -f f g
1560 $ hg cp -f f g
1561 $ echo a > d
1561 $ echo a > d
1562 $ hg add d
1562 $ hg add d
1563 $ hg ci -m "mv a b; add d"
1563 $ hg ci -m "mv a b; add d"
1564 $ hg mv dir/b e
1564 $ hg mv dir/b e
1565 $ hg ci -m "mv dir/b e"
1565 $ hg ci -m "mv dir/b e"
1566 $ hg log -G --template '({rev}) {desc|firstline}\n'
1566 $ hg log -G --template '({rev}) {desc|firstline}\n'
1567 @ (4) mv dir/b e
1567 @ (4) mv dir/b e
1568 |
1568 |
1569 o (3) mv a b; add d
1569 o (3) mv a b; add d
1570 |
1570 |
1571 o (2) mv b dir/b
1571 o (2) mv b dir/b
1572 |
1572 |
1573 o (1) copy a b
1573 o (1) copy a b
1574 |
1574 |
1575 o (0) add a
1575 o (0) add a
1576
1576
1577
1577
1578 $ testlog a
1578 $ testlog a
1579 []
1579 []
1580 (group
1580 (group
1581 (group
1581 (group
1582 (func
1582 (func
1583 ('symbol', 'filelog')
1583 ('symbol', 'filelog')
1584 ('string', 'a'))))
1584 ('string', 'a'))))
1585 $ testlog a b
1585 $ testlog a b
1586 []
1586 []
1587 (group
1587 (group
1588 (group
1588 (group
1589 (or
1589 (or
1590 (func
1590 (func
1591 ('symbol', 'filelog')
1591 ('symbol', 'filelog')
1592 ('string', 'a'))
1592 ('string', 'a'))
1593 (func
1593 (func
1594 ('symbol', 'filelog')
1594 ('symbol', 'filelog')
1595 ('string', 'b')))))
1595 ('string', 'b')))))
1596
1596
1597 Test falling back to slow path for non-existing files
1597 Test falling back to slow path for non-existing files
1598
1598
1599 $ testlog a c
1599 $ testlog a c
1600 []
1600 []
1601 (group
1601 (group
1602 (func
1602 (func
1603 ('symbol', '_matchfiles')
1603 ('symbol', '_matchfiles')
1604 (list
1604 (list
1605 (list
1605 (list
1606 (list
1606 (list
1607 ('string', 'r:')
1607 ('string', 'r:')
1608 ('string', 'd:relpath'))
1608 ('string', 'd:relpath'))
1609 ('string', 'p:a'))
1609 ('string', 'p:a'))
1610 ('string', 'p:c'))))
1610 ('string', 'p:c'))))
1611
1611
1612 Test multiple --include/--exclude/paths
1612 Test multiple --include/--exclude/paths
1613
1613
1614 $ testlog --include a --include e --exclude b --exclude e a e
1614 $ testlog --include a --include e --exclude b --exclude e a e
1615 []
1615 []
1616 (group
1616 (group
1617 (func
1617 (func
1618 ('symbol', '_matchfiles')
1618 ('symbol', '_matchfiles')
1619 (list
1619 (list
1620 (list
1620 (list
1621 (list
1621 (list
1622 (list
1622 (list
1623 (list
1623 (list
1624 (list
1624 (list
1625 (list
1625 (list
1626 ('string', 'r:')
1626 ('string', 'r:')
1627 ('string', 'd:relpath'))
1627 ('string', 'd:relpath'))
1628 ('string', 'p:a'))
1628 ('string', 'p:a'))
1629 ('string', 'p:e'))
1629 ('string', 'p:e'))
1630 ('string', 'i:a'))
1630 ('string', 'i:a'))
1631 ('string', 'i:e'))
1631 ('string', 'i:e'))
1632 ('string', 'x:b'))
1632 ('string', 'x:b'))
1633 ('string', 'x:e'))))
1633 ('string', 'x:e'))))
1634
1634
1635 Test glob expansion of pats
1635 Test glob expansion of pats
1636
1636
1637 $ expandglobs=`$PYTHON -c "import mercurial.util; \
1637 $ expandglobs=`$PYTHON -c "import mercurial.util; \
1638 > print mercurial.util.expandglobs and 'true' or 'false'"`
1638 > print mercurial.util.expandglobs and 'true' or 'false'"`
1639 $ if [ $expandglobs = "true" ]; then
1639 $ if [ $expandglobs = "true" ]; then
1640 > testlog 'a*';
1640 > testlog 'a*';
1641 > else
1641 > else
1642 > testlog a*;
1642 > testlog a*;
1643 > fi;
1643 > fi;
1644 []
1644 []
1645 (group
1645 (group
1646 (group
1646 (group
1647 (func
1647 (func
1648 ('symbol', 'filelog')
1648 ('symbol', 'filelog')
1649 ('string', 'aa'))))
1649 ('string', 'aa'))))
1650
1650
1651 Test --follow on a non-existent directory
1651 Test --follow on a non-existent directory
1652
1652
1653 $ testlog -f dir
1653 $ testlog -f dir
1654 abort: cannot follow file not in parent revision: "dir"
1654 abort: cannot follow file not in parent revision: "dir"
1655 abort: cannot follow file not in parent revision: "dir"
1655 abort: cannot follow file not in parent revision: "dir"
1656 abort: cannot follow file not in parent revision: "dir"
1656 abort: cannot follow file not in parent revision: "dir"
1657
1657
1658 Test --follow on a directory
1658 Test --follow on a directory
1659
1659
1660 $ hg up -q '.^'
1660 $ hg up -q '.^'
1661 $ testlog -f dir
1661 $ testlog -f dir
1662 []
1662 []
1663 (group
1663 (group
1664 (and
1664 (and
1665 (func
1665 (func
1666 ('symbol', 'ancestors')
1666 ('symbol', 'ancestors')
1667 ('symbol', '.'))
1667 ('symbol', '.'))
1668 (func
1668 (func
1669 ('symbol', '_matchfiles')
1669 ('symbol', '_matchfiles')
1670 (list
1670 (list
1671 (list
1671 (list
1672 ('string', 'r:')
1672 ('string', 'r:')
1673 ('string', 'd:relpath'))
1673 ('string', 'd:relpath'))
1674 ('string', 'p:dir')))))
1674 ('string', 'p:dir')))))
1675 $ hg up -q tip
1675 $ hg up -q tip
1676
1676
1677 Test --follow on file not in parent revision
1677 Test --follow on file not in parent revision
1678
1678
1679 $ testlog -f a
1679 $ testlog -f a
1680 abort: cannot follow file not in parent revision: "a"
1680 abort: cannot follow file not in parent revision: "a"
1681 abort: cannot follow file not in parent revision: "a"
1681 abort: cannot follow file not in parent revision: "a"
1682 abort: cannot follow file not in parent revision: "a"
1682 abort: cannot follow file not in parent revision: "a"
1683
1683
1684 Test --follow and patterns
1684 Test --follow and patterns
1685
1685
1686 $ testlog -f 'glob:*'
1686 $ testlog -f 'glob:*'
1687 []
1687 []
1688 (group
1688 (group
1689 (and
1689 (and
1690 (func
1690 (func
1691 ('symbol', 'ancestors')
1691 ('symbol', 'ancestors')
1692 ('symbol', '.'))
1692 ('symbol', '.'))
1693 (func
1693 (func
1694 ('symbol', '_matchfiles')
1694 ('symbol', '_matchfiles')
1695 (list
1695 (list
1696 (list
1696 (list
1697 ('string', 'r:')
1697 ('string', 'r:')
1698 ('string', 'd:relpath'))
1698 ('string', 'd:relpath'))
1699 ('string', 'p:glob:*')))))
1699 ('string', 'p:glob:*')))))
1700
1700
1701 Test --follow on a single rename
1701 Test --follow on a single rename
1702
1702
1703 $ hg up -q 2
1703 $ hg up -q 2
1704 $ testlog -f a
1704 $ testlog -f a
1705 []
1705 []
1706 (group
1706 (group
1707 (group
1707 (group
1708 (func
1708 (func
1709 ('symbol', 'follow')
1709 ('symbol', 'follow')
1710 ('string', 'a'))))
1710 ('string', 'a'))))
1711
1711
1712 Test --follow and multiple renames
1712 Test --follow and multiple renames
1713
1713
1714 $ hg up -q tip
1714 $ hg up -q tip
1715 $ testlog -f e
1715 $ testlog -f e
1716 []
1716 []
1717 (group
1717 (group
1718 (group
1718 (group
1719 (func
1719 (func
1720 ('symbol', 'follow')
1720 ('symbol', 'follow')
1721 ('string', 'e'))))
1721 ('string', 'e'))))
1722
1722
1723 Test --follow and multiple filelog heads
1723 Test --follow and multiple filelog heads
1724
1724
1725 $ hg up -q 2
1725 $ hg up -q 2
1726 $ testlog -f g
1726 $ testlog -f g
1727 []
1727 []
1728 (group
1728 (group
1729 (group
1729 (group
1730 (func
1730 (func
1731 ('symbol', 'follow')
1731 ('symbol', 'follow')
1732 ('string', 'g'))))
1732 ('string', 'g'))))
1733 $ cat log.nodes
1733 $ cat log.nodes
1734 nodetag 2
1734 nodetag 2
1735 nodetag 1
1735 nodetag 1
1736 nodetag 0
1736 nodetag 0
1737 $ hg up -q tip
1737 $ hg up -q tip
1738 $ testlog -f g
1738 $ testlog -f g
1739 []
1739 []
1740 (group
1740 (group
1741 (group
1741 (group
1742 (func
1742 (func
1743 ('symbol', 'follow')
1743 ('symbol', 'follow')
1744 ('string', 'g'))))
1744 ('string', 'g'))))
1745 $ cat log.nodes
1745 $ cat log.nodes
1746 nodetag 3
1746 nodetag 3
1747 nodetag 2
1747 nodetag 2
1748 nodetag 0
1748 nodetag 0
1749
1749
1750 Test --follow and multiple files
1750 Test --follow and multiple files
1751
1751
1752 $ testlog -f g e
1752 $ testlog -f g e
1753 []
1753 []
1754 (group
1754 (group
1755 (group
1755 (group
1756 (or
1756 (or
1757 (func
1757 (func
1758 ('symbol', 'follow')
1758 ('symbol', 'follow')
1759 ('string', 'g'))
1759 ('string', 'g'))
1760 (func
1760 (func
1761 ('symbol', 'follow')
1761 ('symbol', 'follow')
1762 ('string', 'e')))))
1762 ('string', 'e')))))
1763 $ cat log.nodes
1763 $ cat log.nodes
1764 nodetag 4
1764 nodetag 4
1765 nodetag 3
1765 nodetag 3
1766 nodetag 2
1766 nodetag 2
1767 nodetag 1
1767 nodetag 1
1768 nodetag 0
1768 nodetag 0
1769
1769
1770 Test --follow null parent
1770 Test --follow null parent
1771
1771
1772 $ hg up -q null
1772 $ hg up -q null
1773 $ testlog -f
1773 $ testlog -f
1774 []
1774 []
1775 []
1775 []
1776
1776
1777 Test --follow-first
1777 Test --follow-first
1778
1778
1779 $ hg up -q 3
1779 $ hg up -q 3
1780 $ echo ee > e
1780 $ echo ee > e
1781 $ hg ci -Am "add another e" e
1781 $ hg ci -Am "add another e" e
1782 created new head
1782 created new head
1783 $ hg merge --tool internal:other 4
1783 $ hg merge --tool internal:other 4
1784 0 files updated, 1 files merged, 1 files removed, 0 files unresolved
1784 0 files updated, 1 files merged, 1 files removed, 0 files unresolved
1785 (branch merge, don't forget to commit)
1785 (branch merge, don't forget to commit)
1786 $ echo merge > e
1786 $ echo merge > e
1787 $ hg ci -m "merge 5 and 4"
1787 $ hg ci -m "merge 5 and 4"
1788 $ testlog --follow-first
1788 $ testlog --follow-first
1789 []
1789 []
1790 (group
1790 (group
1791 (func
1791 (func
1792 ('symbol', '_firstancestors')
1792 ('symbol', '_firstancestors')
1793 (func
1793 (func
1794 ('symbol', 'rev')
1794 ('symbol', 'rev')
1795 ('symbol', '6'))))
1795 ('symbol', '6'))))
1796
1796
1797 Cannot compare with log --follow-first FILE as it never worked
1797 Cannot compare with log --follow-first FILE as it never worked
1798
1798
1799 $ hg log -G --print-revset --follow-first e
1799 $ hg log -G --print-revset --follow-first e
1800 []
1800 []
1801 (group
1801 (group
1802 (group
1802 (group
1803 (func
1803 (func
1804 ('symbol', '_followfirst')
1804 ('symbol', '_followfirst')
1805 ('string', 'e'))))
1805 ('string', 'e'))))
1806 $ hg log -G --follow-first e --template '{rev} {desc|firstline}\n'
1806 $ hg log -G --follow-first e --template '{rev} {desc|firstline}\n'
1807 @ 6 merge 5 and 4
1807 @ 6 merge 5 and 4
1808 |\
1808 |\
1809 o | 5 add another e
1809 o | 5 add another e
1810 | |
1810 | |
1811
1811
1812 Test --copies
1812 Test --copies
1813
1813
1814 $ hg log -G --copies --template "{rev} {desc|firstline} \
1814 $ hg log -G --copies --template "{rev} {desc|firstline} \
1815 > copies: {file_copies_switch}\n"
1815 > copies: {file_copies_switch}\n"
1816 @ 6 merge 5 and 4 copies:
1816 @ 6 merge 5 and 4 copies:
1817 |\
1817 |\
1818 | o 5 add another e copies:
1818 | o 5 add another e copies:
1819 | |
1819 | |
1820 o | 4 mv dir/b e copies: e (dir/b)
1820 o | 4 mv dir/b e copies: e (dir/b)
1821 |/
1821 |/
1822 o 3 mv a b; add d copies: b (a)g (f)
1822 o 3 mv a b; add d copies: b (a)g (f)
1823 |
1823 |
1824 o 2 mv b dir/b copies: dir/b (b)
1824 o 2 mv b dir/b copies: dir/b (b)
1825 |
1825 |
1826 o 1 copy a b copies: b (a)g (f)
1826 o 1 copy a b copies: b (a)g (f)
1827 |
1827 |
1828 o 0 add a copies:
1828 o 0 add a copies:
1829
1829
1830 Test "set:..." and parent revision
1830 Test "set:..." and parent revision
1831
1831
1832 $ hg up -q 4
1832 $ hg up -q 4
1833 $ testlog "set:copied()"
1833 $ testlog "set:copied()"
1834 []
1834 []
1835 (group
1835 (group
1836 (func
1836 (func
1837 ('symbol', '_matchfiles')
1837 ('symbol', '_matchfiles')
1838 (list
1838 (list
1839 (list
1839 (list
1840 ('string', 'r:')
1840 ('string', 'r:')
1841 ('string', 'd:relpath'))
1841 ('string', 'd:relpath'))
1842 ('string', 'p:set:copied()'))))
1842 ('string', 'p:set:copied()'))))
1843 $ testlog --include "set:copied()"
1843 $ testlog --include "set:copied()"
1844 []
1844 []
1845 (group
1845 (group
1846 (func
1846 (func
1847 ('symbol', '_matchfiles')
1847 ('symbol', '_matchfiles')
1848 (list
1848 (list
1849 (list
1849 (list
1850 ('string', 'r:')
1850 ('string', 'r:')
1851 ('string', 'd:relpath'))
1851 ('string', 'd:relpath'))
1852 ('string', 'i:set:copied()'))))
1852 ('string', 'i:set:copied()'))))
1853 $ testlog -r "sort(file('set:copied()'), -rev)"
1853 $ testlog -r "sort(file('set:copied()'), -rev)"
1854 ["sort(file('set:copied()'), -rev)"]
1854 ["sort(file('set:copied()'), -rev)"]
1855 []
1855 []
1856
1856
1857 Test --removed
1857 Test --removed
1858
1858
1859 $ testlog --removed
1859 $ testlog --removed
1860 []
1860 []
1861 []
1861 []
1862 $ testlog --removed a
1862 $ testlog --removed a
1863 []
1863 []
1864 (group
1864 (group
1865 (func
1865 (func
1866 ('symbol', '_matchfiles')
1866 ('symbol', '_matchfiles')
1867 (list
1867 (list
1868 (list
1868 (list
1869 ('string', 'r:')
1869 ('string', 'r:')
1870 ('string', 'd:relpath'))
1870 ('string', 'd:relpath'))
1871 ('string', 'p:a'))))
1871 ('string', 'p:a'))))
1872 $ testlog --removed --follow a
1872 $ testlog --removed --follow a
1873 []
1873 []
1874 (group
1874 (group
1875 (and
1875 (and
1876 (func
1876 (func
1877 ('symbol', 'ancestors')
1877 ('symbol', 'ancestors')
1878 ('symbol', '.'))
1878 ('symbol', '.'))
1879 (func
1879 (func
1880 ('symbol', '_matchfiles')
1880 ('symbol', '_matchfiles')
1881 (list
1881 (list
1882 (list
1882 (list
1883 ('string', 'r:')
1883 ('string', 'r:')
1884 ('string', 'd:relpath'))
1884 ('string', 'd:relpath'))
1885 ('string', 'p:a')))))
1885 ('string', 'p:a')))))
1886
1886
1887 Test --patch and --stat with --follow and --follow-first
1887 Test --patch and --stat with --follow and --follow-first
1888
1888
1889 $ hg up -q 3
1889 $ hg up -q 3
1890 $ hg log -G --git --patch b
1890 $ hg log -G --git --patch b
1891 o changeset: 1:216d4c92cf98
1891 o changeset: 1:216d4c92cf98
1892 | user: test
1892 | user: test
1893 | date: Thu Jan 01 00:00:00 1970 +0000
1893 | date: Thu Jan 01 00:00:00 1970 +0000
1894 | summary: copy a b
1894 | summary: copy a b
1895 |
1895 |
1896 | diff --git a/a b/b
1896 | diff --git a/a b/b
1897 | copy from a
1897 | copy from a
1898 | copy to b
1898 | copy to b
1899 |
1899 |
1900
1900
1901 $ hg log -G --git --stat b
1901 $ hg log -G --git --stat b
1902 o changeset: 1:216d4c92cf98
1902 o changeset: 1:216d4c92cf98
1903 | user: test
1903 | user: test
1904 | date: Thu Jan 01 00:00:00 1970 +0000
1904 | date: Thu Jan 01 00:00:00 1970 +0000
1905 | summary: copy a b
1905 | summary: copy a b
1906 |
1906 |
1907 | b | 0
1907 | b | 0
1908 | 1 files changed, 0 insertions(+), 0 deletions(-)
1908 | 1 files changed, 0 insertions(+), 0 deletions(-)
1909 |
1909 |
1910
1910
1911 $ hg log -G --git --patch --follow b
1911 $ hg log -G --git --patch --follow b
1912 o changeset: 1:216d4c92cf98
1912 o changeset: 1:216d4c92cf98
1913 | user: test
1913 | user: test
1914 | date: Thu Jan 01 00:00:00 1970 +0000
1914 | date: Thu Jan 01 00:00:00 1970 +0000
1915 | summary: copy a b
1915 | summary: copy a b
1916 |
1916 |
1917 | diff --git a/a b/b
1917 | diff --git a/a b/b
1918 | copy from a
1918 | copy from a
1919 | copy to b
1919 | copy to b
1920 |
1920 |
1921 o changeset: 0:f8035bb17114
1921 o changeset: 0:f8035bb17114
1922 user: test
1922 user: test
1923 date: Thu Jan 01 00:00:00 1970 +0000
1923 date: Thu Jan 01 00:00:00 1970 +0000
1924 summary: add a
1924 summary: add a
1925
1925
1926 diff --git a/a b/a
1926 diff --git a/a b/a
1927 new file mode 100644
1927 new file mode 100644
1928 --- /dev/null
1928 --- /dev/null
1929 +++ b/a
1929 +++ b/a
1930 @@ -0,0 +1,1 @@
1930 @@ -0,0 +1,1 @@
1931 +a
1931 +a
1932
1932
1933
1933
1934 $ hg log -G --git --stat --follow b
1934 $ hg log -G --git --stat --follow b
1935 o changeset: 1:216d4c92cf98
1935 o changeset: 1:216d4c92cf98
1936 | user: test
1936 | user: test
1937 | date: Thu Jan 01 00:00:00 1970 +0000
1937 | date: Thu Jan 01 00:00:00 1970 +0000
1938 | summary: copy a b
1938 | summary: copy a b
1939 |
1939 |
1940 | b | 0
1940 | b | 0
1941 | 1 files changed, 0 insertions(+), 0 deletions(-)
1941 | 1 files changed, 0 insertions(+), 0 deletions(-)
1942 |
1942 |
1943 o changeset: 0:f8035bb17114
1943 o changeset: 0:f8035bb17114
1944 user: test
1944 user: test
1945 date: Thu Jan 01 00:00:00 1970 +0000
1945 date: Thu Jan 01 00:00:00 1970 +0000
1946 summary: add a
1946 summary: add a
1947
1947
1948 a | 1 +
1948 a | 1 +
1949 1 files changed, 1 insertions(+), 0 deletions(-)
1949 1 files changed, 1 insertions(+), 0 deletions(-)
1950
1950
1951
1951
1952 $ hg up -q 6
1952 $ hg up -q 6
1953 $ hg log -G --git --patch --follow-first e
1953 $ hg log -G --git --patch --follow-first e
1954 @ changeset: 6:fc281d8ff18d
1954 @ changeset: 6:fc281d8ff18d
1955 |\ tag: tip
1955 |\ tag: tip
1956 | | parent: 5:99b31f1c2782
1956 | | parent: 5:99b31f1c2782
1957 | | parent: 4:17d952250a9d
1957 | | parent: 4:17d952250a9d
1958 | | user: test
1958 | | user: test
1959 | | date: Thu Jan 01 00:00:00 1970 +0000
1959 | | date: Thu Jan 01 00:00:00 1970 +0000
1960 | | summary: merge 5 and 4
1960 | | summary: merge 5 and 4
1961 | |
1961 | |
1962 | | diff --git a/e b/e
1962 | | diff --git a/e b/e
1963 | | --- a/e
1963 | | --- a/e
1964 | | +++ b/e
1964 | | +++ b/e
1965 | | @@ -1,1 +1,1 @@
1965 | | @@ -1,1 +1,1 @@
1966 | | -ee
1966 | | -ee
1967 | | +merge
1967 | | +merge
1968 | |
1968 | |
1969 o | changeset: 5:99b31f1c2782
1969 o | changeset: 5:99b31f1c2782
1970 | | parent: 3:5918b8d165d1
1970 | | parent: 3:5918b8d165d1
1971 | | user: test
1971 | | user: test
1972 | | date: Thu Jan 01 00:00:00 1970 +0000
1972 | | date: Thu Jan 01 00:00:00 1970 +0000
1973 | | summary: add another e
1973 | | summary: add another e
1974 | |
1974 | |
1975 | | diff --git a/e b/e
1975 | | diff --git a/e b/e
1976 | | new file mode 100644
1976 | | new file mode 100644
1977 | | --- /dev/null
1977 | | --- /dev/null
1978 | | +++ b/e
1978 | | +++ b/e
1979 | | @@ -0,0 +1,1 @@
1979 | | @@ -0,0 +1,1 @@
1980 | | +ee
1980 | | +ee
1981 | |
1981 | |
1982
1982
1983 Test old-style --rev
1983 Test old-style --rev
1984
1984
1985 $ hg tag 'foo-bar'
1985 $ hg tag 'foo-bar'
1986 $ testlog -r 'foo-bar'
1986 $ testlog -r 'foo-bar'
1987 ['foo-bar']
1987 ['foo-bar']
1988 []
1988 []
1989
1989
1990 Test --follow and forward --rev
1990 Test --follow and forward --rev
1991
1991
1992 $ hg up -q 6
1992 $ hg up -q 6
1993 $ echo g > g
1993 $ echo g > g
1994 $ hg ci -Am 'add g' g
1994 $ hg ci -Am 'add g' g
1995 created new head
1995 created new head
1996 $ hg up -q 2
1996 $ hg up -q 2
1997 $ hg log -G --template "{rev} {desc|firstline}\n"
1997 $ hg log -G --template "{rev} {desc|firstline}\n"
1998 o 8 add g
1998 o 8 add g
1999 |
1999 |
2000 | o 7 Added tag foo-bar for changeset fc281d8ff18d
2000 | o 7 Added tag foo-bar for changeset fc281d8ff18d
2001 |/
2001 |/
2002 o 6 merge 5 and 4
2002 o 6 merge 5 and 4
2003 |\
2003 |\
2004 | o 5 add another e
2004 | o 5 add another e
2005 | |
2005 | |
2006 o | 4 mv dir/b e
2006 o | 4 mv dir/b e
2007 |/
2007 |/
2008 o 3 mv a b; add d
2008 o 3 mv a b; add d
2009 |
2009 |
2010 @ 2 mv b dir/b
2010 @ 2 mv b dir/b
2011 |
2011 |
2012 o 1 copy a b
2012 o 1 copy a b
2013 |
2013 |
2014 o 0 add a
2014 o 0 add a
2015
2015
2016 $ hg export 'all()'
2016 $ hg export 'all()'
2017 # HG changeset patch
2017 # HG changeset patch
2018 # User test
2018 # User test
2019 # Date 0 0
2019 # Date 0 0
2020 # Thu Jan 01 00:00:00 1970 +0000
2020 # Thu Jan 01 00:00:00 1970 +0000
2021 # Node ID f8035bb17114da16215af3436ec5222428ace8ee
2021 # Node ID f8035bb17114da16215af3436ec5222428ace8ee
2022 # Parent 0000000000000000000000000000000000000000
2022 # Parent 0000000000000000000000000000000000000000
2023 add a
2023 add a
2024
2024
2025 diff -r 000000000000 -r f8035bb17114 a
2025 diff -r 000000000000 -r f8035bb17114 a
2026 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2026 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2027 +++ b/a Thu Jan 01 00:00:00 1970 +0000
2027 +++ b/a Thu Jan 01 00:00:00 1970 +0000
2028 @@ -0,0 +1,1 @@
2028 @@ -0,0 +1,1 @@
2029 +a
2029 +a
2030 diff -r 000000000000 -r f8035bb17114 aa
2030 diff -r 000000000000 -r f8035bb17114 aa
2031 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2031 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2032 +++ b/aa Thu Jan 01 00:00:00 1970 +0000
2032 +++ b/aa Thu Jan 01 00:00:00 1970 +0000
2033 @@ -0,0 +1,1 @@
2033 @@ -0,0 +1,1 @@
2034 +aa
2034 +aa
2035 diff -r 000000000000 -r f8035bb17114 f
2035 diff -r 000000000000 -r f8035bb17114 f
2036 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2036 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2037 +++ b/f Thu Jan 01 00:00:00 1970 +0000
2037 +++ b/f Thu Jan 01 00:00:00 1970 +0000
2038 @@ -0,0 +1,1 @@
2038 @@ -0,0 +1,1 @@
2039 +f
2039 +f
2040 # HG changeset patch
2040 # HG changeset patch
2041 # User test
2041 # User test
2042 # Date 0 0
2042 # Date 0 0
2043 # Thu Jan 01 00:00:00 1970 +0000
2043 # Thu Jan 01 00:00:00 1970 +0000
2044 # Node ID 216d4c92cf98ff2b4641d508b76b529f3d424c92
2044 # Node ID 216d4c92cf98ff2b4641d508b76b529f3d424c92
2045 # Parent f8035bb17114da16215af3436ec5222428ace8ee
2045 # Parent f8035bb17114da16215af3436ec5222428ace8ee
2046 copy a b
2046 copy a b
2047
2047
2048 diff -r f8035bb17114 -r 216d4c92cf98 b
2048 diff -r f8035bb17114 -r 216d4c92cf98 b
2049 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2049 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2050 +++ b/b Thu Jan 01 00:00:00 1970 +0000
2050 +++ b/b Thu Jan 01 00:00:00 1970 +0000
2051 @@ -0,0 +1,1 @@
2051 @@ -0,0 +1,1 @@
2052 +a
2052 +a
2053 diff -r f8035bb17114 -r 216d4c92cf98 g
2053 diff -r f8035bb17114 -r 216d4c92cf98 g
2054 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2054 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2055 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2055 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2056 @@ -0,0 +1,1 @@
2056 @@ -0,0 +1,1 @@
2057 +f
2057 +f
2058 # HG changeset patch
2058 # HG changeset patch
2059 # User test
2059 # User test
2060 # Date 0 0
2060 # Date 0 0
2061 # Thu Jan 01 00:00:00 1970 +0000
2061 # Thu Jan 01 00:00:00 1970 +0000
2062 # Node ID bb573313a9e8349099b6ea2b2fb1fc7f424446f3
2062 # Node ID bb573313a9e8349099b6ea2b2fb1fc7f424446f3
2063 # Parent 216d4c92cf98ff2b4641d508b76b529f3d424c92
2063 # Parent 216d4c92cf98ff2b4641d508b76b529f3d424c92
2064 mv b dir/b
2064 mv b dir/b
2065
2065
2066 diff -r 216d4c92cf98 -r bb573313a9e8 b
2066 diff -r 216d4c92cf98 -r bb573313a9e8 b
2067 --- a/b Thu Jan 01 00:00:00 1970 +0000
2067 --- a/b Thu Jan 01 00:00:00 1970 +0000
2068 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2068 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2069 @@ -1,1 +0,0 @@
2069 @@ -1,1 +0,0 @@
2070 -a
2070 -a
2071 diff -r 216d4c92cf98 -r bb573313a9e8 dir/b
2071 diff -r 216d4c92cf98 -r bb573313a9e8 dir/b
2072 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2072 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2073 +++ b/dir/b Thu Jan 01 00:00:00 1970 +0000
2073 +++ b/dir/b Thu Jan 01 00:00:00 1970 +0000
2074 @@ -0,0 +1,1 @@
2074 @@ -0,0 +1,1 @@
2075 +a
2075 +a
2076 diff -r 216d4c92cf98 -r bb573313a9e8 f
2076 diff -r 216d4c92cf98 -r bb573313a9e8 f
2077 --- a/f Thu Jan 01 00:00:00 1970 +0000
2077 --- a/f Thu Jan 01 00:00:00 1970 +0000
2078 +++ b/f Thu Jan 01 00:00:00 1970 +0000
2078 +++ b/f Thu Jan 01 00:00:00 1970 +0000
2079 @@ -1,1 +1,2 @@
2079 @@ -1,1 +1,2 @@
2080 f
2080 f
2081 +f
2081 +f
2082 diff -r 216d4c92cf98 -r bb573313a9e8 g
2082 diff -r 216d4c92cf98 -r bb573313a9e8 g
2083 --- a/g Thu Jan 01 00:00:00 1970 +0000
2083 --- a/g Thu Jan 01 00:00:00 1970 +0000
2084 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2084 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2085 @@ -1,1 +1,2 @@
2085 @@ -1,1 +1,2 @@
2086 f
2086 f
2087 +g
2087 +g
2088 # HG changeset patch
2088 # HG changeset patch
2089 # User test
2089 # User test
2090 # Date 0 0
2090 # Date 0 0
2091 # Thu Jan 01 00:00:00 1970 +0000
2091 # Thu Jan 01 00:00:00 1970 +0000
2092 # Node ID 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2092 # Node ID 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2093 # Parent bb573313a9e8349099b6ea2b2fb1fc7f424446f3
2093 # Parent bb573313a9e8349099b6ea2b2fb1fc7f424446f3
2094 mv a b; add d
2094 mv a b; add d
2095
2095
2096 diff -r bb573313a9e8 -r 5918b8d165d1 a
2096 diff -r bb573313a9e8 -r 5918b8d165d1 a
2097 --- a/a Thu Jan 01 00:00:00 1970 +0000
2097 --- a/a Thu Jan 01 00:00:00 1970 +0000
2098 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2098 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2099 @@ -1,1 +0,0 @@
2099 @@ -1,1 +0,0 @@
2100 -a
2100 -a
2101 diff -r bb573313a9e8 -r 5918b8d165d1 b
2101 diff -r bb573313a9e8 -r 5918b8d165d1 b
2102 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2102 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2103 +++ b/b Thu Jan 01 00:00:00 1970 +0000
2103 +++ b/b Thu Jan 01 00:00:00 1970 +0000
2104 @@ -0,0 +1,1 @@
2104 @@ -0,0 +1,1 @@
2105 +a
2105 +a
2106 diff -r bb573313a9e8 -r 5918b8d165d1 d
2106 diff -r bb573313a9e8 -r 5918b8d165d1 d
2107 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2107 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2108 +++ b/d Thu Jan 01 00:00:00 1970 +0000
2108 +++ b/d Thu Jan 01 00:00:00 1970 +0000
2109 @@ -0,0 +1,1 @@
2109 @@ -0,0 +1,1 @@
2110 +a
2110 +a
2111 diff -r bb573313a9e8 -r 5918b8d165d1 g
2111 diff -r bb573313a9e8 -r 5918b8d165d1 g
2112 --- a/g Thu Jan 01 00:00:00 1970 +0000
2112 --- a/g Thu Jan 01 00:00:00 1970 +0000
2113 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2113 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2114 @@ -1,2 +1,2 @@
2114 @@ -1,2 +1,2 @@
2115 f
2115 f
2116 -g
2116 -g
2117 +f
2117 +f
2118 # HG changeset patch
2118 # HG changeset patch
2119 # User test
2119 # User test
2120 # Date 0 0
2120 # Date 0 0
2121 # Thu Jan 01 00:00:00 1970 +0000
2121 # Thu Jan 01 00:00:00 1970 +0000
2122 # Node ID 17d952250a9d03cc3dc77b199ab60e959b9b0260
2122 # Node ID 17d952250a9d03cc3dc77b199ab60e959b9b0260
2123 # Parent 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2123 # Parent 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2124 mv dir/b e
2124 mv dir/b e
2125
2125
2126 diff -r 5918b8d165d1 -r 17d952250a9d dir/b
2126 diff -r 5918b8d165d1 -r 17d952250a9d dir/b
2127 --- a/dir/b Thu Jan 01 00:00:00 1970 +0000
2127 --- a/dir/b Thu Jan 01 00:00:00 1970 +0000
2128 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2128 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2129 @@ -1,1 +0,0 @@
2129 @@ -1,1 +0,0 @@
2130 -a
2130 -a
2131 diff -r 5918b8d165d1 -r 17d952250a9d e
2131 diff -r 5918b8d165d1 -r 17d952250a9d e
2132 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2132 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2133 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2133 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2134 @@ -0,0 +1,1 @@
2134 @@ -0,0 +1,1 @@
2135 +a
2135 +a
2136 # HG changeset patch
2136 # HG changeset patch
2137 # User test
2137 # User test
2138 # Date 0 0
2138 # Date 0 0
2139 # Thu Jan 01 00:00:00 1970 +0000
2139 # Thu Jan 01 00:00:00 1970 +0000
2140 # Node ID 99b31f1c2782e2deb1723cef08930f70fc84b37b
2140 # Node ID 99b31f1c2782e2deb1723cef08930f70fc84b37b
2141 # Parent 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2141 # Parent 5918b8d165d1364e78a66d02e66caa0133c5d1ed
2142 add another e
2142 add another e
2143
2143
2144 diff -r 5918b8d165d1 -r 99b31f1c2782 e
2144 diff -r 5918b8d165d1 -r 99b31f1c2782 e
2145 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2145 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2146 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2146 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2147 @@ -0,0 +1,1 @@
2147 @@ -0,0 +1,1 @@
2148 +ee
2148 +ee
2149 # HG changeset patch
2149 # HG changeset patch
2150 # User test
2150 # User test
2151 # Date 0 0
2151 # Date 0 0
2152 # Thu Jan 01 00:00:00 1970 +0000
2152 # Thu Jan 01 00:00:00 1970 +0000
2153 # Node ID fc281d8ff18d999ad6497b3d27390bcd695dcc73
2153 # Node ID fc281d8ff18d999ad6497b3d27390bcd695dcc73
2154 # Parent 99b31f1c2782e2deb1723cef08930f70fc84b37b
2154 # Parent 99b31f1c2782e2deb1723cef08930f70fc84b37b
2155 # Parent 17d952250a9d03cc3dc77b199ab60e959b9b0260
2155 # Parent 17d952250a9d03cc3dc77b199ab60e959b9b0260
2156 merge 5 and 4
2156 merge 5 and 4
2157
2157
2158 diff -r 99b31f1c2782 -r fc281d8ff18d dir/b
2158 diff -r 99b31f1c2782 -r fc281d8ff18d dir/b
2159 --- a/dir/b Thu Jan 01 00:00:00 1970 +0000
2159 --- a/dir/b Thu Jan 01 00:00:00 1970 +0000
2160 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2160 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2161 @@ -1,1 +0,0 @@
2161 @@ -1,1 +0,0 @@
2162 -a
2162 -a
2163 diff -r 99b31f1c2782 -r fc281d8ff18d e
2163 diff -r 99b31f1c2782 -r fc281d8ff18d e
2164 --- a/e Thu Jan 01 00:00:00 1970 +0000
2164 --- a/e Thu Jan 01 00:00:00 1970 +0000
2165 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2165 +++ b/e Thu Jan 01 00:00:00 1970 +0000
2166 @@ -1,1 +1,1 @@
2166 @@ -1,1 +1,1 @@
2167 -ee
2167 -ee
2168 +merge
2168 +merge
2169 # HG changeset patch
2169 # HG changeset patch
2170 # User test
2170 # User test
2171 # Date 0 0
2171 # Date 0 0
2172 # Thu Jan 01 00:00:00 1970 +0000
2172 # Thu Jan 01 00:00:00 1970 +0000
2173 # Node ID 02dbb8e276b8ab7abfd07cab50c901647e75c2dd
2173 # Node ID 02dbb8e276b8ab7abfd07cab50c901647e75c2dd
2174 # Parent fc281d8ff18d999ad6497b3d27390bcd695dcc73
2174 # Parent fc281d8ff18d999ad6497b3d27390bcd695dcc73
2175 Added tag foo-bar for changeset fc281d8ff18d
2175 Added tag foo-bar for changeset fc281d8ff18d
2176
2176
2177 diff -r fc281d8ff18d -r 02dbb8e276b8 .hgtags
2177 diff -r fc281d8ff18d -r 02dbb8e276b8 .hgtags
2178 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2178 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2179 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
2179 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
2180 @@ -0,0 +1,1 @@
2180 @@ -0,0 +1,1 @@
2181 +fc281d8ff18d999ad6497b3d27390bcd695dcc73 foo-bar
2181 +fc281d8ff18d999ad6497b3d27390bcd695dcc73 foo-bar
2182 # HG changeset patch
2182 # HG changeset patch
2183 # User test
2183 # User test
2184 # Date 0 0
2184 # Date 0 0
2185 # Thu Jan 01 00:00:00 1970 +0000
2185 # Thu Jan 01 00:00:00 1970 +0000
2186 # Node ID 24c2e826ddebf80f9dcd60b856bdb8e6715c5449
2186 # Node ID 24c2e826ddebf80f9dcd60b856bdb8e6715c5449
2187 # Parent fc281d8ff18d999ad6497b3d27390bcd695dcc73
2187 # Parent fc281d8ff18d999ad6497b3d27390bcd695dcc73
2188 add g
2188 add g
2189
2189
2190 diff -r fc281d8ff18d -r 24c2e826ddeb g
2190 diff -r fc281d8ff18d -r 24c2e826ddeb g
2191 --- a/g Thu Jan 01 00:00:00 1970 +0000
2191 --- a/g Thu Jan 01 00:00:00 1970 +0000
2192 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2192 +++ b/g Thu Jan 01 00:00:00 1970 +0000
2193 @@ -1,2 +1,1 @@
2193 @@ -1,2 +1,1 @@
2194 -f
2194 -f
2195 -f
2195 -f
2196 +g
2196 +g
2197 $ testlog --follow -r6 -r8 -r5 -r7 -r4
2197 $ testlog --follow -r6 -r8 -r5 -r7 -r4
2198 ['6', '8', '5', '7', '4']
2198 ['6', '8', '5', '7', '4']
2199 (group
2199 (group
2200 (func
2200 (func
2201 ('symbol', 'descendants')
2201 ('symbol', 'descendants')
2202 (func
2202 (func
2203 ('symbol', 'rev')
2203 ('symbol', 'rev')
2204 ('symbol', '6'))))
2204 ('symbol', '6'))))
2205
2205
2206 Test --follow-first and forward --rev
2206 Test --follow-first and forward --rev
2207
2207
2208 $ testlog --follow-first -r6 -r8 -r5 -r7 -r4
2208 $ testlog --follow-first -r6 -r8 -r5 -r7 -r4
2209 ['6', '8', '5', '7', '4']
2209 ['6', '8', '5', '7', '4']
2210 (group
2210 (group
2211 (func
2211 (func
2212 ('symbol', '_firstdescendants')
2212 ('symbol', '_firstdescendants')
2213 (func
2213 (func
2214 ('symbol', 'rev')
2214 ('symbol', 'rev')
2215 ('symbol', '6'))))
2215 ('symbol', '6'))))
2216 --- log.nodes * (glob)
2216 --- log.nodes * (glob)
2217 +++ glog.nodes * (glob)
2217 +++ glog.nodes * (glob)
2218 @@ -1,3 +1,3 @@
2218 @@ -1,3 +1,3 @@
2219 -nodetag 6
2219 -nodetag 6
2220 nodetag 8
2220 nodetag 8
2221 nodetag 7
2221 nodetag 7
2222 +nodetag 6
2222 +nodetag 6
2223
2223
2224 Test --follow and backward --rev
2224 Test --follow and backward --rev
2225
2225
2226 $ testlog --follow -r6 -r5 -r7 -r8 -r4
2226 $ testlog --follow -r6 -r5 -r7 -r8 -r4
2227 ['6', '5', '7', '8', '4']
2227 ['6', '5', '7', '8', '4']
2228 (group
2228 (group
2229 (func
2229 (func
2230 ('symbol', 'ancestors')
2230 ('symbol', 'ancestors')
2231 (func
2231 (func
2232 ('symbol', 'rev')
2232 ('symbol', 'rev')
2233 ('symbol', '6'))))
2233 ('symbol', '6'))))
2234
2234
2235 Test --follow-first and backward --rev
2235 Test --follow-first and backward --rev
2236
2236
2237 $ testlog --follow-first -r6 -r5 -r7 -r8 -r4
2237 $ testlog --follow-first -r6 -r5 -r7 -r8 -r4
2238 ['6', '5', '7', '8', '4']
2238 ['6', '5', '7', '8', '4']
2239 (group
2239 (group
2240 (func
2240 (func
2241 ('symbol', '_firstancestors')
2241 ('symbol', '_firstancestors')
2242 (func
2242 (func
2243 ('symbol', 'rev')
2243 ('symbol', 'rev')
2244 ('symbol', '6'))))
2244 ('symbol', '6'))))
2245
2245
2246 Test --follow with --rev of graphlog extension
2246 Test --follow with --rev of graphlog extension
2247
2247
2248 $ hg --config extensions.graphlog= glog -qfr1
2248 $ hg --config extensions.graphlog= glog -qfr1
2249 o 1:216d4c92cf98
2249 o 1:216d4c92cf98
2250 |
2250 |
2251 o 0:f8035bb17114
2251 o 0:f8035bb17114
2252
2252
2253
2253
2254 Test subdir
2254 Test subdir
2255
2255
2256 $ hg up -q 3
2256 $ hg up -q 3
2257 $ cd dir
2257 $ cd dir
2258 $ testlog .
2258 $ testlog .
2259 []
2259 []
2260 (group
2260 (group
2261 (func
2261 (func
2262 ('symbol', '_matchfiles')
2262 ('symbol', '_matchfiles')
2263 (list
2263 (list
2264 (list
2264 (list
2265 ('string', 'r:')
2265 ('string', 'r:')
2266 ('string', 'd:relpath'))
2266 ('string', 'd:relpath'))
2267 ('string', 'p:.'))))
2267 ('string', 'p:.'))))
2268 $ testlog ../b
2268 $ testlog ../b
2269 []
2269 []
2270 (group
2270 (group
2271 (group
2271 (group
2272 (func
2272 (func
2273 ('symbol', 'filelog')
2273 ('symbol', 'filelog')
2274 ('string', '../b'))))
2274 ('string', '../b'))))
2275 $ testlog -f ../b
2275 $ testlog -f ../b
2276 []
2276 []
2277 (group
2277 (group
2278 (group
2278 (group
2279 (func
2279 (func
2280 ('symbol', 'follow')
2280 ('symbol', 'follow')
2281 ('string', 'b'))))
2281 ('string', 'b'))))
2282 $ cd ..
2282 $ cd ..
2283
2283
2284 Test --hidden
2284 Test --hidden
2285 (enable obsolete)
2285 (enable obsolete)
2286
2286
2287 $ cat >> $HGRCPATH << EOF
2287 $ cat >> $HGRCPATH << EOF
2288 > [experimental]
2288 > [experimental]
2289 > evolution=createmarkers
2289 > evolution=createmarkers
2290 > EOF
2290 > EOF
2291
2291
2292 $ hg debugobsolete `hg id --debug -i -r 8`
2292 $ hg debugobsolete `hg id --debug -i -r 8`
2293 $ testlog
2293 $ testlog
2294 []
2294 []
2295 []
2295 []
2296 $ testlog --hidden
2296 $ testlog --hidden
2297 []
2297 []
2298 []
2298 []
2299 $ hg log -G --template '{rev} {desc}\n'
2299 $ hg log -G --template '{rev} {desc}\n'
2300 o 7 Added tag foo-bar for changeset fc281d8ff18d
2300 o 7 Added tag foo-bar for changeset fc281d8ff18d
2301 |
2301 |
2302 o 6 merge 5 and 4
2302 o 6 merge 5 and 4
2303 |\
2303 |\
2304 | o 5 add another e
2304 | o 5 add another e
2305 | |
2305 | |
2306 o | 4 mv dir/b e
2306 o | 4 mv dir/b e
2307 |/
2307 |/
2308 @ 3 mv a b; add d
2308 @ 3 mv a b; add d
2309 |
2309 |
2310 o 2 mv b dir/b
2310 o 2 mv b dir/b
2311 |
2311 |
2312 o 1 copy a b
2312 o 1 copy a b
2313 |
2313 |
2314 o 0 add a
2314 o 0 add a
2315
2315
2316
2316
2317 A template without trailing newline should do something sane
2317 A template without trailing newline should do something sane
2318
2318
2319 $ hg log -G -r ::2 --template '{rev} {desc}'
2319 $ hg log -G -r ::2 --template '{rev} {desc}'
2320 o 2 mv b dir/b
2320 o 2 mv b dir/b
2321 |
2321 |
2322 o 1 copy a b
2322 o 1 copy a b
2323 |
2323 |
2324 o 0 add a
2324 o 0 add a
2325
2325
2326
2326
2327 Extra newlines must be preserved
2327 Extra newlines must be preserved
2328
2328
2329 $ hg log -G -r ::2 --template '\n{rev} {desc}\n\n'
2329 $ hg log -G -r ::2 --template '\n{rev} {desc}\n\n'
2330 o
2330 o
2331 | 2 mv b dir/b
2331 | 2 mv b dir/b
2332 |
2332 |
2333 o
2333 o
2334 | 1 copy a b
2334 | 1 copy a b
2335 |
2335 |
2336 o
2336 o
2337 0 add a
2337 0 add a
2338
2338
2339
2339
2340 The almost-empty template should do something sane too ...
2340 The almost-empty template should do something sane too ...
2341
2341
2342 $ hg log -G -r ::2 --template '\n'
2342 $ hg log -G -r ::2 --template '\n'
2343 o
2343 o
2344 |
2344 |
2345 o
2345 o
2346 |
2346 |
2347 o
2347 o
2348
2348
2349
2349
2350 issue3772
2350 issue3772
2351
2351
2352 $ hg log -G -r :null
2352 $ hg log -G -r :null
2353 o changeset: 0:f8035bb17114
2353 o changeset: 0:f8035bb17114
2354 | user: test
2354 | user: test
2355 | date: Thu Jan 01 00:00:00 1970 +0000
2355 | date: Thu Jan 01 00:00:00 1970 +0000
2356 | summary: add a
2356 | summary: add a
2357 |
2357 |
2358 o changeset: -1:000000000000
2358 o changeset: -1:000000000000
2359 user:
2359 user:
2360 date: Thu Jan 01 00:00:00 1970 +0000
2360 date: Thu Jan 01 00:00:00 1970 +0000
2361
2361
2362 $ hg log -G -r null:null
2362 $ hg log -G -r null:null
2363 o changeset: -1:000000000000
2363 o changeset: -1:000000000000
2364 user:
2364 user:
2365 date: Thu Jan 01 00:00:00 1970 +0000
2365 date: Thu Jan 01 00:00:00 1970 +0000
2366
2366
2367
2367
2368 should not draw line down to null due to the magic of fullreposet
2368 should not draw line down to null due to the magic of fullreposet
2369
2369
2370 $ hg log -G -r 'all()' | tail -6
2370 $ hg log -G -r 'all()' | tail -6
2371 |
2371 |
2372 o changeset: 0:f8035bb17114
2372 o changeset: 0:f8035bb17114
2373 user: test
2373 user: test
2374 date: Thu Jan 01 00:00:00 1970 +0000
2374 date: Thu Jan 01 00:00:00 1970 +0000
2375 summary: add a
2375 summary: add a
2376
2376
2377
2377
2378 $ hg log -G -r 'branch(default)' | tail -6
2379 |
2380 o changeset: 0:f8035bb17114
2381 user: test
2382 date: Thu Jan 01 00:00:00 1970 +0000
2383 summary: add a
2384
2385
2378 $ cd ..
2386 $ cd ..
@@ -1,697 +1,697 b''
1 commit hooks can see env vars
1 commit hooks can see env vars
2 (and post-transaction one are run unlocked)
2 (and post-transaction one are run unlocked)
3
3
4 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
4 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
5 > def showargs(ui, repo, hooktype, **kwargs):
5 > def showargs(ui, repo, hooktype, **kwargs):
6 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
6 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
7 > EOF
7 > EOF
8
8
9 $ hg init a
9 $ hg init a
10 $ cd a
10 $ cd a
11 $ cat > .hg/hgrc <<EOF
11 $ cat > .hg/hgrc <<EOF
12 > [hooks]
12 > [hooks]
13 > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
13 > commit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit"
14 > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
14 > commit.b = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" commit.b"
15 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
15 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= python \"$TESTDIR/printenv.py\" precommit"
16 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
16 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxncommit"
17 > pretxncommit.tip = hg -q tip
17 > pretxncommit.tip = hg -q tip
18 > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
18 > pre-identify = python "$TESTDIR/printenv.py" pre-identify 1
19 > pre-cat = python "$TESTDIR/printenv.py" pre-cat
19 > pre-cat = python "$TESTDIR/printenv.py" pre-cat
20 > post-cat = python "$TESTDIR/printenv.py" post-cat
20 > post-cat = python "$TESTDIR/printenv.py" post-cat
21 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen"
21 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen"
22 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose"
22 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose"
23 > txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose"
23 > txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose"
24 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
24 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
25 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
25 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
26 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
26 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
27 > EOF
27 > EOF
28 $ echo a > a
28 $ echo a > a
29 $ hg add a
29 $ hg add a
30 $ hg commit -m a
30 $ hg commit -m a
31 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
31 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
32 pretxnopen hook: HG_TXNNAME=commit
32 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
33 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
33 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
34 0:cb9a9f314b8b
34 0:cb9a9f314b8b
35 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
35 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
36 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
36 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
37 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
37 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
38 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
38 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
39
39
40 $ hg clone . ../b
40 $ hg clone . ../b
41 updating to branch default
41 updating to branch default
42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
42 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 $ cd ../b
43 $ cd ../b
44
44
45 changegroup hooks can see env vars
45 changegroup hooks can see env vars
46
46
47 $ cat > .hg/hgrc <<EOF
47 $ cat > .hg/hgrc <<EOF
48 > [hooks]
48 > [hooks]
49 > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
49 > prechangegroup = python "$TESTDIR/printenv.py" prechangegroup
50 > changegroup = python "$TESTDIR/printenv.py" changegroup
50 > changegroup = python "$TESTDIR/printenv.py" changegroup
51 > incoming = python "$TESTDIR/printenv.py" incoming
51 > incoming = python "$TESTDIR/printenv.py" incoming
52 > EOF
52 > EOF
53
53
54 pretxncommit and commit hooks can see both parents of merge
54 pretxncommit and commit hooks can see both parents of merge
55
55
56 $ cd ../a
56 $ cd ../a
57 $ echo b >> a
57 $ echo b >> a
58 $ hg commit -m a1 -d "1 0"
58 $ hg commit -m a1 -d "1 0"
59 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
59 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
60 pretxnopen hook: HG_TXNNAME=commit
60 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
61 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
61 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
62 1:ab228980c14d
62 1:ab228980c14d
63 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
63 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
64 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
64 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
65 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
65 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
66 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
66 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 $ hg update -C 0
67 $ hg update -C 0
68 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
68 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 $ echo b > b
69 $ echo b > b
70 $ hg add b
70 $ hg add b
71 $ hg commit -m b -d '1 0'
71 $ hg commit -m b -d '1 0'
72 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
72 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
73 pretxnopen hook: HG_TXNNAME=commit
73 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
74 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
74 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
75 2:ee9deb46ab31
75 2:ee9deb46ab31
76 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
76 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
77 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
77 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
78 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
78 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
79 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
79 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
80 created new head
80 created new head
81 $ hg merge 1
81 $ hg merge 1
82 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 (branch merge, don't forget to commit)
83 (branch merge, don't forget to commit)
84 $ hg commit -m merge -d '2 0'
84 $ hg commit -m merge -d '2 0'
85 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
85 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
86 pretxnopen hook: HG_TXNNAME=commit
86 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
87 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
87 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
88 3:07f3376c1e65
88 3:07f3376c1e65
89 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
89 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
90 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
90 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
91 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
91 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
92 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
92 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93
93
94 test generic hooks
94 test generic hooks
95
95
96 $ hg id
96 $ hg id
97 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
97 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
98 abort: pre-identify hook exited with status 1
98 abort: pre-identify hook exited with status 1
99 [255]
99 [255]
100 $ hg cat b
100 $ hg cat b
101 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
101 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
102 b
102 b
103 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
103 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
104
104
105 $ cd ../b
105 $ cd ../b
106 $ hg pull ../a
106 $ hg pull ../a
107 pulling from ../a
107 pulling from ../a
108 searching for changes
108 searching for changes
109 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
109 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
110 adding changesets
110 adding changesets
111 adding manifests
111 adding manifests
112 adding file changes
112 adding file changes
113 added 3 changesets with 2 changes to 2 files
113 added 3 changesets with 2 changes to 2 files
114 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
114 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
115 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
115 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
116 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
116 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
118 (run 'hg update' to get a working copy)
118 (run 'hg update' to get a working copy)
119
119
120 tag hooks can see env vars
120 tag hooks can see env vars
121
121
122 $ cd ../a
122 $ cd ../a
123 $ cat >> .hg/hgrc <<EOF
123 $ cat >> .hg/hgrc <<EOF
124 > pretag = python "$TESTDIR/printenv.py" pretag
124 > pretag = python "$TESTDIR/printenv.py" pretag
125 > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag"
125 > tag = sh -c "HG_PARENT1= HG_PARENT2= python \"$TESTDIR/printenv.py\" tag"
126 > EOF
126 > EOF
127 $ hg tag -d '3 0' a
127 $ hg tag -d '3 0' a
128 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
128 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
129 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
129 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
130 pretxnopen hook: HG_TXNNAME=commit
130 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
131 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
131 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
132 4:539e4b31b6dc
132 4:539e4b31b6dc
133 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
133 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
134 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
134 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
135 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
135 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
136 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
136 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
137 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
137 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
138 $ hg tag -l la
138 $ hg tag -l la
139 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
139 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
140 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
140 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
141
141
142 pretag hook can forbid tagging
142 pretag hook can forbid tagging
143
143
144 $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc
144 $ echo "pretag.forbid = python \"$TESTDIR/printenv.py\" pretag.forbid 1" >> .hg/hgrc
145 $ hg tag -d '4 0' fa
145 $ hg tag -d '4 0' fa
146 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
146 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
147 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
147 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
148 abort: pretag.forbid hook exited with status 1
148 abort: pretag.forbid hook exited with status 1
149 [255]
149 [255]
150 $ hg tag -l fla
150 $ hg tag -l fla
151 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
151 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
152 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
152 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
153 abort: pretag.forbid hook exited with status 1
153 abort: pretag.forbid hook exited with status 1
154 [255]
154 [255]
155
155
156 pretxncommit hook can see changeset, can roll back txn, changeset no
156 pretxncommit hook can see changeset, can roll back txn, changeset no
157 more there after
157 more there after
158
158
159 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
159 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
160 $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
160 $ echo "pretxncommit.forbid1 = python \"$TESTDIR/printenv.py\" pretxncommit.forbid 1" >> .hg/hgrc
161 $ echo z > z
161 $ echo z > z
162 $ hg add z
162 $ hg add z
163 $ hg -q tip
163 $ hg -q tip
164 4:539e4b31b6dc
164 4:539e4b31b6dc
165 $ hg commit -m 'fail' -d '4 0'
165 $ hg commit -m 'fail' -d '4 0'
166 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
166 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
167 pretxnopen hook: HG_TXNNAME=commit
167 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
168 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
168 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
169 5:6f611f8018c1
169 5:6f611f8018c1
170 5:6f611f8018c1
170 5:6f611f8018c1
171 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
171 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
172 transaction abort!
172 transaction abort!
173 txnabort python hook: txnid,txnname
173 txnabort python hook: txnid,txnname
174 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
174 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
175 rollback completed
175 rollback completed
176 abort: pretxncommit.forbid1 hook exited with status 1
176 abort: pretxncommit.forbid1 hook exited with status 1
177 [255]
177 [255]
178 $ hg -q tip
178 $ hg -q tip
179 4:539e4b31b6dc
179 4:539e4b31b6dc
180
180
181 (Check that no 'changelog.i.a' file were left behind)
181 (Check that no 'changelog.i.a' file were left behind)
182
182
183 $ ls -1 .hg/store/
183 $ ls -1 .hg/store/
184 00changelog.i
184 00changelog.i
185 00manifest.i
185 00manifest.i
186 data
186 data
187 fncache
187 fncache
188 journal.phaseroots
188 journal.phaseroots
189 phaseroots
189 phaseroots
190 undo
190 undo
191 undo.backup.fncache
191 undo.backup.fncache
192 undo.backupfiles
192 undo.backupfiles
193 undo.phaseroots
193 undo.phaseroots
194
194
195
195
196 precommit hook can prevent commit
196 precommit hook can prevent commit
197
197
198 $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc
198 $ echo "precommit.forbid = python \"$TESTDIR/printenv.py\" precommit.forbid 1" >> .hg/hgrc
199 $ hg commit -m 'fail' -d '4 0'
199 $ hg commit -m 'fail' -d '4 0'
200 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
200 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
201 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
201 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
202 abort: precommit.forbid hook exited with status 1
202 abort: precommit.forbid hook exited with status 1
203 [255]
203 [255]
204 $ hg -q tip
204 $ hg -q tip
205 4:539e4b31b6dc
205 4:539e4b31b6dc
206
206
207 preupdate hook can prevent update
207 preupdate hook can prevent update
208
208
209 $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc
209 $ echo "preupdate = python \"$TESTDIR/printenv.py\" preupdate" >> .hg/hgrc
210 $ hg update 1
210 $ hg update 1
211 preupdate hook: HG_PARENT1=ab228980c14d
211 preupdate hook: HG_PARENT1=ab228980c14d
212 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
212 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
213
213
214 update hook
214 update hook
215
215
216 $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc
216 $ echo "update = python \"$TESTDIR/printenv.py\" update" >> .hg/hgrc
217 $ hg update
217 $ hg update
218 preupdate hook: HG_PARENT1=539e4b31b6dc
218 preupdate hook: HG_PARENT1=539e4b31b6dc
219 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
219 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
220 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
220 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
221
221
222 pushkey hook
222 pushkey hook
223
223
224 $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc
224 $ echo "pushkey = python \"$TESTDIR/printenv.py\" pushkey" >> .hg/hgrc
225 $ cd ../b
225 $ cd ../b
226 $ hg bookmark -r null foo
226 $ hg bookmark -r null foo
227 $ hg push -B foo ../a
227 $ hg push -B foo ../a
228 pushing to ../a
228 pushing to ../a
229 searching for changes
229 searching for changes
230 no changes found
230 no changes found
231 pretxnopen hook: HG_TXNNAME=bookmarks
231 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
232 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
232 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
233 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
233 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmarks (glob)
234 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
234 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
235 exporting bookmark foo
235 exporting bookmark foo
236 [1]
236 [1]
237 $ cd ../a
237 $ cd ../a
238
238
239 listkeys hook
239 listkeys hook
240
240
241 $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc
241 $ echo "listkeys = python \"$TESTDIR/printenv.py\" listkeys" >> .hg/hgrc
242 $ hg bookmark -r null bar
242 $ hg bookmark -r null bar
243 $ cd ../b
243 $ cd ../b
244 $ hg pull -B bar ../a
244 $ hg pull -B bar ../a
245 pulling from ../a
245 pulling from ../a
246 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
246 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
247 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
247 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
248 no changes found
248 no changes found
249 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
249 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
250 adding remote bookmark bar
250 adding remote bookmark bar
251 $ cd ../a
251 $ cd ../a
252
252
253 test that prepushkey can prevent incoming keys
253 test that prepushkey can prevent incoming keys
254
254
255 $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc
255 $ echo "prepushkey = python \"$TESTDIR/printenv.py\" prepushkey.forbid 1" >> .hg/hgrc
256 $ cd ../b
256 $ cd ../b
257 $ hg bookmark -r null baz
257 $ hg bookmark -r null baz
258 $ hg push -B baz ../a
258 $ hg push -B baz ../a
259 pushing to ../a
259 pushing to ../a
260 searching for changes
260 searching for changes
261 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
261 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
262 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
262 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
263 no changes found
263 no changes found
264 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
264 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
265 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
265 prepushkey.forbid hook: HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000
266 pushkey-abort: prepushkey hook exited with status 1
266 pushkey-abort: prepushkey hook exited with status 1
267 exporting bookmark baz failed!
267 exporting bookmark baz failed!
268 [1]
268 [1]
269 $ cd ../a
269 $ cd ../a
270
270
271 test that prelistkeys can prevent listing keys
271 test that prelistkeys can prevent listing keys
272
272
273 $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc
273 $ echo "prelistkeys = python \"$TESTDIR/printenv.py\" prelistkeys.forbid 1" >> .hg/hgrc
274 $ hg bookmark -r null quux
274 $ hg bookmark -r null quux
275 $ cd ../b
275 $ cd ../b
276 $ hg pull -B quux ../a
276 $ hg pull -B quux ../a
277 pulling from ../a
277 pulling from ../a
278 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
278 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
279 abort: prelistkeys hook exited with status 1
279 abort: prelistkeys hook exited with status 1
280 [255]
280 [255]
281 $ cd ../a
281 $ cd ../a
282 $ rm .hg/hgrc
282 $ rm .hg/hgrc
283
283
284 prechangegroup hook can prevent incoming changes
284 prechangegroup hook can prevent incoming changes
285
285
286 $ cd ../b
286 $ cd ../b
287 $ hg -q tip
287 $ hg -q tip
288 3:07f3376c1e65
288 3:07f3376c1e65
289 $ cat > .hg/hgrc <<EOF
289 $ cat > .hg/hgrc <<EOF
290 > [hooks]
290 > [hooks]
291 > prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1
291 > prechangegroup.forbid = python "$TESTDIR/printenv.py" prechangegroup.forbid 1
292 > EOF
292 > EOF
293 $ hg pull ../a
293 $ hg pull ../a
294 pulling from ../a
294 pulling from ../a
295 searching for changes
295 searching for changes
296 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
296 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
297 abort: prechangegroup.forbid hook exited with status 1
297 abort: prechangegroup.forbid hook exited with status 1
298 [255]
298 [255]
299
299
300 pretxnchangegroup hook can see incoming changes, can roll back txn,
300 pretxnchangegroup hook can see incoming changes, can roll back txn,
301 incoming changes no longer there after
301 incoming changes no longer there after
302
302
303 $ cat > .hg/hgrc <<EOF
303 $ cat > .hg/hgrc <<EOF
304 > [hooks]
304 > [hooks]
305 > pretxnchangegroup.forbid0 = hg tip -q
305 > pretxnchangegroup.forbid0 = hg tip -q
306 > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
306 > pretxnchangegroup.forbid1 = python "$TESTDIR/printenv.py" pretxnchangegroup.forbid 1
307 > EOF
307 > EOF
308 $ hg pull ../a
308 $ hg pull ../a
309 pulling from ../a
309 pulling from ../a
310 searching for changes
310 searching for changes
311 adding changesets
311 adding changesets
312 adding manifests
312 adding manifests
313 adding file changes
313 adding file changes
314 added 1 changesets with 1 changes to 1 files
314 added 1 changesets with 1 changes to 1 files
315 4:539e4b31b6dc
315 4:539e4b31b6dc
316 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
316 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
317 transaction abort!
317 transaction abort!
318 rollback completed
318 rollback completed
319 abort: pretxnchangegroup.forbid1 hook exited with status 1
319 abort: pretxnchangegroup.forbid1 hook exited with status 1
320 [255]
320 [255]
321 $ hg -q tip
321 $ hg -q tip
322 3:07f3376c1e65
322 3:07f3376c1e65
323
323
324 outgoing hooks can see env vars
324 outgoing hooks can see env vars
325
325
326 $ rm .hg/hgrc
326 $ rm .hg/hgrc
327 $ cat > ../a/.hg/hgrc <<EOF
327 $ cat > ../a/.hg/hgrc <<EOF
328 > [hooks]
328 > [hooks]
329 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
329 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
330 > outgoing = python "$TESTDIR/printenv.py" outgoing
330 > outgoing = python "$TESTDIR/printenv.py" outgoing
331 > EOF
331 > EOF
332 $ hg pull ../a
332 $ hg pull ../a
333 pulling from ../a
333 pulling from ../a
334 searching for changes
334 searching for changes
335 preoutgoing hook: HG_SOURCE=pull
335 preoutgoing hook: HG_SOURCE=pull
336 adding changesets
336 adding changesets
337 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
337 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
338 adding manifests
338 adding manifests
339 adding file changes
339 adding file changes
340 added 1 changesets with 1 changes to 1 files
340 added 1 changesets with 1 changes to 1 files
341 adding remote bookmark quux
341 adding remote bookmark quux
342 (run 'hg update' to get a working copy)
342 (run 'hg update' to get a working copy)
343 $ hg rollback
343 $ hg rollback
344 repository tip rolled back to revision 3 (undo pull)
344 repository tip rolled back to revision 3 (undo pull)
345
345
346 preoutgoing hook can prevent outgoing changes
346 preoutgoing hook can prevent outgoing changes
347
347
348 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc
348 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> ../a/.hg/hgrc
349 $ hg pull ../a
349 $ hg pull ../a
350 pulling from ../a
350 pulling from ../a
351 searching for changes
351 searching for changes
352 preoutgoing hook: HG_SOURCE=pull
352 preoutgoing hook: HG_SOURCE=pull
353 preoutgoing.forbid hook: HG_SOURCE=pull
353 preoutgoing.forbid hook: HG_SOURCE=pull
354 abort: preoutgoing.forbid hook exited with status 1
354 abort: preoutgoing.forbid hook exited with status 1
355 [255]
355 [255]
356
356
357 outgoing hooks work for local clones
357 outgoing hooks work for local clones
358
358
359 $ cd ..
359 $ cd ..
360 $ cat > a/.hg/hgrc <<EOF
360 $ cat > a/.hg/hgrc <<EOF
361 > [hooks]
361 > [hooks]
362 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
362 > preoutgoing = python "$TESTDIR/printenv.py" preoutgoing
363 > outgoing = python "$TESTDIR/printenv.py" outgoing
363 > outgoing = python "$TESTDIR/printenv.py" outgoing
364 > EOF
364 > EOF
365 $ hg clone a c
365 $ hg clone a c
366 preoutgoing hook: HG_SOURCE=clone
366 preoutgoing hook: HG_SOURCE=clone
367 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
367 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
368 updating to branch default
368 updating to branch default
369 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
369 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
370 $ rm -rf c
370 $ rm -rf c
371
371
372 preoutgoing hook can prevent outgoing changes for local clones
372 preoutgoing hook can prevent outgoing changes for local clones
373
373
374 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc
374 $ echo "preoutgoing.forbid = python \"$TESTDIR/printenv.py\" preoutgoing.forbid 1" >> a/.hg/hgrc
375 $ hg clone a zzz
375 $ hg clone a zzz
376 preoutgoing hook: HG_SOURCE=clone
376 preoutgoing hook: HG_SOURCE=clone
377 preoutgoing.forbid hook: HG_SOURCE=clone
377 preoutgoing.forbid hook: HG_SOURCE=clone
378 abort: preoutgoing.forbid hook exited with status 1
378 abort: preoutgoing.forbid hook exited with status 1
379 [255]
379 [255]
380
380
381 $ cd "$TESTTMP/b"
381 $ cd "$TESTTMP/b"
382
382
383 $ cat > hooktests.py <<EOF
383 $ cat > hooktests.py <<EOF
384 > from mercurial import util
384 > from mercurial import util
385 >
385 >
386 > uncallable = 0
386 > uncallable = 0
387 >
387 >
388 > def printargs(args):
388 > def printargs(args):
389 > args.pop('ui', None)
389 > args.pop('ui', None)
390 > args.pop('repo', None)
390 > args.pop('repo', None)
391 > a = list(args.items())
391 > a = list(args.items())
392 > a.sort()
392 > a.sort()
393 > print 'hook args:'
393 > print 'hook args:'
394 > for k, v in a:
394 > for k, v in a:
395 > print ' ', k, v
395 > print ' ', k, v
396 >
396 >
397 > def passhook(**args):
397 > def passhook(**args):
398 > printargs(args)
398 > printargs(args)
399 >
399 >
400 > def failhook(**args):
400 > def failhook(**args):
401 > printargs(args)
401 > printargs(args)
402 > return True
402 > return True
403 >
403 >
404 > class LocalException(Exception):
404 > class LocalException(Exception):
405 > pass
405 > pass
406 >
406 >
407 > def raisehook(**args):
407 > def raisehook(**args):
408 > raise LocalException('exception from hook')
408 > raise LocalException('exception from hook')
409 >
409 >
410 > def aborthook(**args):
410 > def aborthook(**args):
411 > raise util.Abort('raise abort from hook')
411 > raise util.Abort('raise abort from hook')
412 >
412 >
413 > def brokenhook(**args):
413 > def brokenhook(**args):
414 > return 1 + {}
414 > return 1 + {}
415 >
415 >
416 > def verbosehook(ui, **args):
416 > def verbosehook(ui, **args):
417 > ui.note('verbose output from hook\n')
417 > ui.note('verbose output from hook\n')
418 >
418 >
419 > def printtags(ui, repo, **args):
419 > def printtags(ui, repo, **args):
420 > print sorted(repo.tags())
420 > print sorted(repo.tags())
421 >
421 >
422 > class container:
422 > class container:
423 > unreachable = 1
423 > unreachable = 1
424 > EOF
424 > EOF
425
425
426 test python hooks
426 test python hooks
427
427
428 #if windows
428 #if windows
429 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
429 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
430 #else
430 #else
431 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
431 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
432 #endif
432 #endif
433 $ export PYTHONPATH
433 $ export PYTHONPATH
434
434
435 $ echo '[hooks]' > ../a/.hg/hgrc
435 $ echo '[hooks]' > ../a/.hg/hgrc
436 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
436 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
437 $ hg pull ../a 2>&1 | grep 'raised an exception'
437 $ hg pull ../a 2>&1 | grep 'raised an exception'
438 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
438 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
439
439
440 $ echo '[hooks]' > ../a/.hg/hgrc
440 $ echo '[hooks]' > ../a/.hg/hgrc
441 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
441 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
442 $ hg pull ../a 2>&1 | grep 'raised an exception'
442 $ hg pull ../a 2>&1 | grep 'raised an exception'
443 error: preoutgoing.raise hook raised an exception: exception from hook
443 error: preoutgoing.raise hook raised an exception: exception from hook
444
444
445 $ echo '[hooks]' > ../a/.hg/hgrc
445 $ echo '[hooks]' > ../a/.hg/hgrc
446 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
446 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
447 $ hg pull ../a
447 $ hg pull ../a
448 pulling from ../a
448 pulling from ../a
449 searching for changes
449 searching for changes
450 error: preoutgoing.abort hook failed: raise abort from hook
450 error: preoutgoing.abort hook failed: raise abort from hook
451 abort: raise abort from hook
451 abort: raise abort from hook
452 [255]
452 [255]
453
453
454 $ echo '[hooks]' > ../a/.hg/hgrc
454 $ echo '[hooks]' > ../a/.hg/hgrc
455 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
455 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
456 $ hg pull ../a
456 $ hg pull ../a
457 pulling from ../a
457 pulling from ../a
458 searching for changes
458 searching for changes
459 hook args:
459 hook args:
460 hooktype preoutgoing
460 hooktype preoutgoing
461 source pull
461 source pull
462 abort: preoutgoing.fail hook failed
462 abort: preoutgoing.fail hook failed
463 [255]
463 [255]
464
464
465 $ echo '[hooks]' > ../a/.hg/hgrc
465 $ echo '[hooks]' > ../a/.hg/hgrc
466 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
466 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
467 $ hg pull ../a
467 $ hg pull ../a
468 pulling from ../a
468 pulling from ../a
469 searching for changes
469 searching for changes
470 abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
470 abort: preoutgoing.uncallable hook is invalid ("hooktests.uncallable" is not callable)
471 [255]
471 [255]
472
472
473 $ echo '[hooks]' > ../a/.hg/hgrc
473 $ echo '[hooks]' > ../a/.hg/hgrc
474 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
474 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
475 $ hg pull ../a
475 $ hg pull ../a
476 pulling from ../a
476 pulling from ../a
477 searching for changes
477 searching for changes
478 abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
478 abort: preoutgoing.nohook hook is invalid ("hooktests.nohook" is not defined)
479 [255]
479 [255]
480
480
481 $ echo '[hooks]' > ../a/.hg/hgrc
481 $ echo '[hooks]' > ../a/.hg/hgrc
482 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
482 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
483 $ hg pull ../a
483 $ hg pull ../a
484 pulling from ../a
484 pulling from ../a
485 searching for changes
485 searching for changes
486 abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
486 abort: preoutgoing.nomodule hook is invalid ("nomodule" not in a module)
487 [255]
487 [255]
488
488
489 $ echo '[hooks]' > ../a/.hg/hgrc
489 $ echo '[hooks]' > ../a/.hg/hgrc
490 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
490 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
491 $ hg pull ../a
491 $ hg pull ../a
492 pulling from ../a
492 pulling from ../a
493 searching for changes
493 searching for changes
494 abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
494 abort: preoutgoing.badmodule hook is invalid (import of "nomodule" failed)
495 [255]
495 [255]
496
496
497 $ echo '[hooks]' > ../a/.hg/hgrc
497 $ echo '[hooks]' > ../a/.hg/hgrc
498 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
498 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
499 $ hg pull ../a
499 $ hg pull ../a
500 pulling from ../a
500 pulling from ../a
501 searching for changes
501 searching for changes
502 abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
502 abort: preoutgoing.unreachable hook is invalid (import of "hooktests.container" failed)
503 [255]
503 [255]
504
504
505 $ echo '[hooks]' > ../a/.hg/hgrc
505 $ echo '[hooks]' > ../a/.hg/hgrc
506 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
506 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
507 $ hg pull ../a
507 $ hg pull ../a
508 pulling from ../a
508 pulling from ../a
509 searching for changes
509 searching for changes
510 hook args:
510 hook args:
511 hooktype preoutgoing
511 hooktype preoutgoing
512 source pull
512 source pull
513 adding changesets
513 adding changesets
514 adding manifests
514 adding manifests
515 adding file changes
515 adding file changes
516 added 1 changesets with 1 changes to 1 files
516 added 1 changesets with 1 changes to 1 files
517 adding remote bookmark quux
517 adding remote bookmark quux
518 (run 'hg update' to get a working copy)
518 (run 'hg update' to get a working copy)
519
519
520 make sure --traceback works
520 make sure --traceback works
521
521
522 $ echo '[hooks]' > .hg/hgrc
522 $ echo '[hooks]' > .hg/hgrc
523 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
523 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
524
524
525 $ echo aa > a
525 $ echo aa > a
526 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
526 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
527 Traceback (most recent call last):
527 Traceback (most recent call last):
528
528
529 $ cd ..
529 $ cd ..
530 $ hg init c
530 $ hg init c
531 $ cd c
531 $ cd c
532
532
533 $ cat > hookext.py <<EOF
533 $ cat > hookext.py <<EOF
534 > def autohook(**args):
534 > def autohook(**args):
535 > print "Automatically installed hook"
535 > print "Automatically installed hook"
536 >
536 >
537 > def reposetup(ui, repo):
537 > def reposetup(ui, repo):
538 > repo.ui.setconfig("hooks", "commit.auto", autohook)
538 > repo.ui.setconfig("hooks", "commit.auto", autohook)
539 > EOF
539 > EOF
540 $ echo '[extensions]' >> .hg/hgrc
540 $ echo '[extensions]' >> .hg/hgrc
541 $ echo 'hookext = hookext.py' >> .hg/hgrc
541 $ echo 'hookext = hookext.py' >> .hg/hgrc
542
542
543 $ touch foo
543 $ touch foo
544 $ hg add foo
544 $ hg add foo
545 $ hg ci -d '0 0' -m 'add foo'
545 $ hg ci -d '0 0' -m 'add foo'
546 Automatically installed hook
546 Automatically installed hook
547 $ echo >> foo
547 $ echo >> foo
548 $ hg ci --debug -d '0 0' -m 'change foo'
548 $ hg ci --debug -d '0 0' -m 'change foo'
549 committing files:
549 committing files:
550 foo
550 foo
551 committing manifest
551 committing manifest
552 committing changelog
552 committing changelog
553 calling hook commit.auto: hgext_hookext.autohook
553 calling hook commit.auto: hgext_hookext.autohook
554 Automatically installed hook
554 Automatically installed hook
555 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
555 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
556
556
557 $ hg showconfig hooks
557 $ hg showconfig hooks
558 hooks.commit.auto=<function autohook at *> (glob)
558 hooks.commit.auto=<function autohook at *> (glob)
559
559
560 test python hook configured with python:[file]:[hook] syntax
560 test python hook configured with python:[file]:[hook] syntax
561
561
562 $ cd ..
562 $ cd ..
563 $ mkdir d
563 $ mkdir d
564 $ cd d
564 $ cd d
565 $ hg init repo
565 $ hg init repo
566 $ mkdir hooks
566 $ mkdir hooks
567
567
568 $ cd hooks
568 $ cd hooks
569 $ cat > testhooks.py <<EOF
569 $ cat > testhooks.py <<EOF
570 > def testhook(**args):
570 > def testhook(**args):
571 > print 'hook works'
571 > print 'hook works'
572 > EOF
572 > EOF
573 $ echo '[hooks]' > ../repo/.hg/hgrc
573 $ echo '[hooks]' > ../repo/.hg/hgrc
574 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
574 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
575
575
576 $ cd ../repo
576 $ cd ../repo
577 $ hg commit -d '0 0'
577 $ hg commit -d '0 0'
578 hook works
578 hook works
579 nothing changed
579 nothing changed
580 [1]
580 [1]
581
581
582 $ echo '[hooks]' > .hg/hgrc
582 $ echo '[hooks]' > .hg/hgrc
583 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
583 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
584 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
584 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
585
585
586 $ hg up null
586 $ hg up null
587 loading update.ne hook failed:
587 loading update.ne hook failed:
588 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
588 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
589 [255]
589 [255]
590
590
591 $ hg id
591 $ hg id
592 loading pre-identify.npmd hook failed:
592 loading pre-identify.npmd hook failed:
593 abort: No module named repo!
593 abort: No module named repo!
594 [255]
594 [255]
595
595
596 $ cd ../../b
596 $ cd ../../b
597
597
598 make sure --traceback works on hook import failure
598 make sure --traceback works on hook import failure
599
599
600 $ cat > importfail.py <<EOF
600 $ cat > importfail.py <<EOF
601 > import somebogusmodule
601 > import somebogusmodule
602 > # dereference something in the module to force demandimport to load it
602 > # dereference something in the module to force demandimport to load it
603 > somebogusmodule.whatever
603 > somebogusmodule.whatever
604 > EOF
604 > EOF
605
605
606 $ echo '[hooks]' > .hg/hgrc
606 $ echo '[hooks]' > .hg/hgrc
607 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
607 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
608
608
609 $ echo a >> a
609 $ echo a >> a
610 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
610 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
611 exception from first failed import attempt:
611 exception from first failed import attempt:
612 Traceback (most recent call last):
612 Traceback (most recent call last):
613 ImportError: No module named somebogusmodule
613 ImportError: No module named somebogusmodule
614 exception from second failed import attempt:
614 exception from second failed import attempt:
615 Traceback (most recent call last):
615 Traceback (most recent call last):
616 ImportError: No module named hgext_importfail
616 ImportError: No module named hgext_importfail
617 Traceback (most recent call last):
617 Traceback (most recent call last):
618 Abort: precommit.importfail hook is invalid (import of "importfail" failed)
618 Abort: precommit.importfail hook is invalid (import of "importfail" failed)
619 abort: precommit.importfail hook is invalid (import of "importfail" failed)
619 abort: precommit.importfail hook is invalid (import of "importfail" failed)
620
620
621 Issue1827: Hooks Update & Commit not completely post operation
621 Issue1827: Hooks Update & Commit not completely post operation
622
622
623 commit and update hooks should run after command completion. The largefiles
623 commit and update hooks should run after command completion. The largefiles
624 use demonstrates a recursive wlock, showing the hook doesn't run until the
624 use demonstrates a recursive wlock, showing the hook doesn't run until the
625 final release (and dirstate flush).
625 final release (and dirstate flush).
626
626
627 $ echo '[hooks]' > .hg/hgrc
627 $ echo '[hooks]' > .hg/hgrc
628 $ echo 'commit = hg id' >> .hg/hgrc
628 $ echo 'commit = hg id' >> .hg/hgrc
629 $ echo 'update = hg id' >> .hg/hgrc
629 $ echo 'update = hg id' >> .hg/hgrc
630 $ echo bb > a
630 $ echo bb > a
631 $ hg ci -ma
631 $ hg ci -ma
632 223eafe2750c tip
632 223eafe2750c tip
633 $ hg up 0 --config extensions.largefiles=
633 $ hg up 0 --config extensions.largefiles=
634 cb9a9f314b8b
634 cb9a9f314b8b
635 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
635 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
636
636
637 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
637 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
638 that is passed to pre/post hooks
638 that is passed to pre/post hooks
639
639
640 $ echo '[hooks]' > .hg/hgrc
640 $ echo '[hooks]' > .hg/hgrc
641 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
641 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
642 $ hg id
642 $ hg id
643 cb9a9f314b8b
643 cb9a9f314b8b
644 $ hg id --verbose
644 $ hg id --verbose
645 calling hook pre-identify: hooktests.verbosehook
645 calling hook pre-identify: hooktests.verbosehook
646 verbose output from hook
646 verbose output from hook
647 cb9a9f314b8b
647 cb9a9f314b8b
648
648
649 Ensure hooks can be prioritized
649 Ensure hooks can be prioritized
650
650
651 $ echo '[hooks]' > .hg/hgrc
651 $ echo '[hooks]' > .hg/hgrc
652 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
652 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
653 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
653 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
654 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
654 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
655 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
655 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
656 $ hg id --verbose
656 $ hg id --verbose
657 calling hook pre-identify.b: hooktests.verbosehook
657 calling hook pre-identify.b: hooktests.verbosehook
658 verbose output from hook
658 verbose output from hook
659 calling hook pre-identify.a: hooktests.verbosehook
659 calling hook pre-identify.a: hooktests.verbosehook
660 verbose output from hook
660 verbose output from hook
661 calling hook pre-identify.c: hooktests.verbosehook
661 calling hook pre-identify.c: hooktests.verbosehook
662 verbose output from hook
662 verbose output from hook
663 cb9a9f314b8b
663 cb9a9f314b8b
664
664
665 new tags must be visible in pretxncommit (issue3210)
665 new tags must be visible in pretxncommit (issue3210)
666
666
667 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
667 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
668 $ hg tag -f foo
668 $ hg tag -f foo
669 ['a', 'foo', 'tip']
669 ['a', 'foo', 'tip']
670
670
671 new commits must be visible in pretxnchangegroup (issue3428)
671 new commits must be visible in pretxnchangegroup (issue3428)
672
672
673 $ cd ..
673 $ cd ..
674 $ hg init to
674 $ hg init to
675 $ echo '[hooks]' >> to/.hg/hgrc
675 $ echo '[hooks]' >> to/.hg/hgrc
676 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
676 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
677 $ echo a >> to/a
677 $ echo a >> to/a
678 $ hg --cwd to ci -Ama
678 $ hg --cwd to ci -Ama
679 adding a
679 adding a
680 $ hg clone to from
680 $ hg clone to from
681 updating to branch default
681 updating to branch default
682 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
682 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
683 $ echo aa >> from/a
683 $ echo aa >> from/a
684 $ hg --cwd from ci -mb
684 $ hg --cwd from ci -mb
685 $ hg --cwd from push
685 $ hg --cwd from push
686 pushing to $TESTTMP/to (glob)
686 pushing to $TESTTMP/to (glob)
687 searching for changes
687 searching for changes
688 adding changesets
688 adding changesets
689 adding manifests
689 adding manifests
690 adding file changes
690 adding file changes
691 added 1 changesets with 1 changes to 1 files
691 added 1 changesets with 1 changes to 1 files
692 changeset: 1:9836a07b9b9d
692 changeset: 1:9836a07b9b9d
693 tag: tip
693 tag: tip
694 user: test
694 user: test
695 date: Thu Jan 01 00:00:00 1970 +0000
695 date: Thu Jan 01 00:00:00 1970 +0000
696 summary: b
696 summary: b
697
697
@@ -1,1764 +1,1804 b''
1 $ HGENCODING=utf-8
1 $ HGENCODING=utf-8
2 $ export HGENCODING
2 $ export HGENCODING
3 $ cat > testrevset.py << EOF
3 $ cat > testrevset.py << EOF
4 > import mercurial.revset
4 > import mercurial.revset
5 >
5 >
6 > baseset = mercurial.revset.baseset
6 > baseset = mercurial.revset.baseset
7 >
7 >
8 > def r3232(repo, subset, x):
8 > def r3232(repo, subset, x):
9 > """"simple revset that return [3,2,3,2]
9 > """"simple revset that return [3,2,3,2]
10 >
10 >
11 > revisions duplicated on purpose.
11 > revisions duplicated on purpose.
12 > """
12 > """
13 > if 3 not in subset:
13 > if 3 not in subset:
14 > if 2 in subset:
14 > if 2 in subset:
15 > return baseset([2,2])
15 > return baseset([2,2])
16 > return baseset()
16 > return baseset()
17 > return baseset([3,3,2,2])
17 > return baseset([3,3,2,2])
18 >
18 >
19 > mercurial.revset.symbols['r3232'] = r3232
19 > mercurial.revset.symbols['r3232'] = r3232
20 > EOF
20 > EOF
21 $ cat >> $HGRCPATH << EOF
21 $ cat >> $HGRCPATH << EOF
22 > [extensions]
22 > [extensions]
23 > testrevset=$TESTTMP/testrevset.py
23 > testrevset=$TESTTMP/testrevset.py
24 > EOF
24 > EOF
25
25
26 $ try() {
26 $ try() {
27 > hg debugrevspec --debug "$@"
27 > hg debugrevspec --debug "$@"
28 > }
28 > }
29
29
30 $ log() {
30 $ log() {
31 > hg log --template '{rev}\n' -r "$1"
31 > hg log --template '{rev}\n' -r "$1"
32 > }
32 > }
33
33
34 $ hg init repo
34 $ hg init repo
35 $ cd repo
35 $ cd repo
36
36
37 $ echo a > a
37 $ echo a > a
38 $ hg branch a
38 $ hg branch a
39 marked working directory as branch a
39 marked working directory as branch a
40 (branches are permanent and global, did you want a bookmark?)
40 (branches are permanent and global, did you want a bookmark?)
41 $ hg ci -Aqm0
41 $ hg ci -Aqm0
42
42
43 $ echo b > b
43 $ echo b > b
44 $ hg branch b
44 $ hg branch b
45 marked working directory as branch b
45 marked working directory as branch b
46 (branches are permanent and global, did you want a bookmark?)
46 (branches are permanent and global, did you want a bookmark?)
47 $ hg ci -Aqm1
47 $ hg ci -Aqm1
48
48
49 $ rm a
49 $ rm a
50 $ hg branch a-b-c-
50 $ hg branch a-b-c-
51 marked working directory as branch a-b-c-
51 marked working directory as branch a-b-c-
52 (branches are permanent and global, did you want a bookmark?)
52 (branches are permanent and global, did you want a bookmark?)
53 $ hg ci -Aqm2 -u Bob
53 $ hg ci -Aqm2 -u Bob
54
54
55 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
55 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
56 2
56 2
57 $ hg log -r "extra('branch')" --template '{rev}\n'
57 $ hg log -r "extra('branch')" --template '{rev}\n'
58 0
58 0
59 1
59 1
60 2
60 2
61 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
61 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
62 0 a
62 0 a
63 2 a-b-c-
63 2 a-b-c-
64
64
65 $ hg co 1
65 $ hg co 1
66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 $ hg branch +a+b+c+
67 $ hg branch +a+b+c+
68 marked working directory as branch +a+b+c+
68 marked working directory as branch +a+b+c+
69 (branches are permanent and global, did you want a bookmark?)
69 (branches are permanent and global, did you want a bookmark?)
70 $ hg ci -Aqm3
70 $ hg ci -Aqm3
71
71
72 $ hg co 2 # interleave
72 $ hg co 2 # interleave
73 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
73 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
74 $ echo bb > b
74 $ echo bb > b
75 $ hg branch -- -a-b-c-
75 $ hg branch -- -a-b-c-
76 marked working directory as branch -a-b-c-
76 marked working directory as branch -a-b-c-
77 (branches are permanent and global, did you want a bookmark?)
77 (branches are permanent and global, did you want a bookmark?)
78 $ hg ci -Aqm4 -d "May 12 2005"
78 $ hg ci -Aqm4 -d "May 12 2005"
79
79
80 $ hg co 3
80 $ hg co 3
81 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
81 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 $ hg branch !a/b/c/
82 $ hg branch !a/b/c/
83 marked working directory as branch !a/b/c/
83 marked working directory as branch !a/b/c/
84 (branches are permanent and global, did you want a bookmark?)
84 (branches are permanent and global, did you want a bookmark?)
85 $ hg ci -Aqm"5 bug"
85 $ hg ci -Aqm"5 bug"
86
86
87 $ hg merge 4
87 $ hg merge 4
88 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
88 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
89 (branch merge, don't forget to commit)
89 (branch merge, don't forget to commit)
90 $ hg branch _a_b_c_
90 $ hg branch _a_b_c_
91 marked working directory as branch _a_b_c_
91 marked working directory as branch _a_b_c_
92 (branches are permanent and global, did you want a bookmark?)
92 (branches are permanent and global, did you want a bookmark?)
93 $ hg ci -Aqm"6 issue619"
93 $ hg ci -Aqm"6 issue619"
94
94
95 $ hg branch .a.b.c.
95 $ hg branch .a.b.c.
96 marked working directory as branch .a.b.c.
96 marked working directory as branch .a.b.c.
97 (branches are permanent and global, did you want a bookmark?)
97 (branches are permanent and global, did you want a bookmark?)
98 $ hg ci -Aqm7
98 $ hg ci -Aqm7
99
99
100 $ hg branch all
100 $ hg branch all
101 marked working directory as branch all
101 marked working directory as branch all
102 (branches are permanent and global, did you want a bookmark?)
102 (branches are permanent and global, did you want a bookmark?)
103
103
104 $ hg co 4
104 $ hg co 4
105 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
105 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
106 $ hg branch Γ©
106 $ hg branch Γ©
107 marked working directory as branch \xc3\xa9 (esc)
107 marked working directory as branch \xc3\xa9 (esc)
108 (branches are permanent and global, did you want a bookmark?)
108 (branches are permanent and global, did you want a bookmark?)
109 $ hg ci -Aqm9
109 $ hg ci -Aqm9
110
110
111 $ hg tag -r6 1.0
111 $ hg tag -r6 1.0
112 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
112 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
113
113
114 $ hg clone --quiet -U -r 7 . ../remote1
114 $ hg clone --quiet -U -r 7 . ../remote1
115 $ hg clone --quiet -U -r 8 . ../remote2
115 $ hg clone --quiet -U -r 8 . ../remote2
116 $ echo "[paths]" >> .hg/hgrc
116 $ echo "[paths]" >> .hg/hgrc
117 $ echo "default = ../remote1" >> .hg/hgrc
117 $ echo "default = ../remote1" >> .hg/hgrc
118
118
119 trivial
119 trivial
120
120
121 $ try 0:1
121 $ try 0:1
122 (range
122 (range
123 ('symbol', '0')
123 ('symbol', '0')
124 ('symbol', '1'))
124 ('symbol', '1'))
125 * set:
125 * set:
126 <spanset+ 0:1>
126 <spanset+ 0:1>
127 0
127 0
128 1
128 1
129 $ try 3::6
129 $ try 3::6
130 (dagrange
130 (dagrange
131 ('symbol', '3')
131 ('symbol', '3')
132 ('symbol', '6'))
132 ('symbol', '6'))
133 * set:
133 * set:
134 <baseset [3, 5, 6]>
134 <baseset [3, 5, 6]>
135 3
135 3
136 5
136 5
137 6
137 6
138 $ try '0|1|2'
138 $ try '0|1|2'
139 (or
139 (or
140 (or
140 (or
141 ('symbol', '0')
141 ('symbol', '0')
142 ('symbol', '1'))
142 ('symbol', '1'))
143 ('symbol', '2'))
143 ('symbol', '2'))
144 * set:
144 * set:
145 <addset
145 <addset
146 <addset
146 <addset
147 <baseset [0]>,
147 <baseset [0]>,
148 <baseset [1]>>,
148 <baseset [1]>>,
149 <baseset [2]>>
149 <baseset [2]>>
150 0
150 0
151 1
151 1
152 2
152 2
153
153
154 names that should work without quoting
154 names that should work without quoting
155
155
156 $ try a
156 $ try a
157 ('symbol', 'a')
157 ('symbol', 'a')
158 * set:
158 * set:
159 <baseset [0]>
159 <baseset [0]>
160 0
160 0
161 $ try b-a
161 $ try b-a
162 (minus
162 (minus
163 ('symbol', 'b')
163 ('symbol', 'b')
164 ('symbol', 'a'))
164 ('symbol', 'a'))
165 * set:
165 * set:
166 <filteredset
166 <filteredset
167 <baseset [1]>>
167 <baseset [1]>>
168 1
168 1
169 $ try _a_b_c_
169 $ try _a_b_c_
170 ('symbol', '_a_b_c_')
170 ('symbol', '_a_b_c_')
171 * set:
171 * set:
172 <baseset [6]>
172 <baseset [6]>
173 6
173 6
174 $ try _a_b_c_-a
174 $ try _a_b_c_-a
175 (minus
175 (minus
176 ('symbol', '_a_b_c_')
176 ('symbol', '_a_b_c_')
177 ('symbol', 'a'))
177 ('symbol', 'a'))
178 * set:
178 * set:
179 <filteredset
179 <filteredset
180 <baseset [6]>>
180 <baseset [6]>>
181 6
181 6
182 $ try .a.b.c.
182 $ try .a.b.c.
183 ('symbol', '.a.b.c.')
183 ('symbol', '.a.b.c.')
184 * set:
184 * set:
185 <baseset [7]>
185 <baseset [7]>
186 7
186 7
187 $ try .a.b.c.-a
187 $ try .a.b.c.-a
188 (minus
188 (minus
189 ('symbol', '.a.b.c.')
189 ('symbol', '.a.b.c.')
190 ('symbol', 'a'))
190 ('symbol', 'a'))
191 * set:
191 * set:
192 <filteredset
192 <filteredset
193 <baseset [7]>>
193 <baseset [7]>>
194 7
194 7
195 $ try -- '-a-b-c-' # complains
195 $ try -- '-a-b-c-' # complains
196 hg: parse error at 7: not a prefix: end
196 hg: parse error at 7: not a prefix: end
197 [255]
197 [255]
198 $ log -a-b-c- # succeeds with fallback
198 $ log -a-b-c- # succeeds with fallback
199 4
199 4
200
200
201 $ try -- -a-b-c--a # complains
201 $ try -- -a-b-c--a # complains
202 (minus
202 (minus
203 (minus
203 (minus
204 (minus
204 (minus
205 (negate
205 (negate
206 ('symbol', 'a'))
206 ('symbol', 'a'))
207 ('symbol', 'b'))
207 ('symbol', 'b'))
208 ('symbol', 'c'))
208 ('symbol', 'c'))
209 (negate
209 (negate
210 ('symbol', 'a')))
210 ('symbol', 'a')))
211 abort: unknown revision '-a'!
211 abort: unknown revision '-a'!
212 [255]
212 [255]
213 $ try Γ©
213 $ try Γ©
214 ('symbol', '\xc3\xa9')
214 ('symbol', '\xc3\xa9')
215 * set:
215 * set:
216 <baseset [9]>
216 <baseset [9]>
217 9
217 9
218
218
219 no quoting needed
219 no quoting needed
220
220
221 $ log ::a-b-c-
221 $ log ::a-b-c-
222 0
222 0
223 1
223 1
224 2
224 2
225
225
226 quoting needed
226 quoting needed
227
227
228 $ try '"-a-b-c-"-a'
228 $ try '"-a-b-c-"-a'
229 (minus
229 (minus
230 ('string', '-a-b-c-')
230 ('string', '-a-b-c-')
231 ('symbol', 'a'))
231 ('symbol', 'a'))
232 * set:
232 * set:
233 <filteredset
233 <filteredset
234 <baseset [4]>>
234 <baseset [4]>>
235 4
235 4
236
236
237 $ log '1 or 2'
237 $ log '1 or 2'
238 1
238 1
239 2
239 2
240 $ log '1|2'
240 $ log '1|2'
241 1
241 1
242 2
242 2
243 $ log '1 and 2'
243 $ log '1 and 2'
244 $ log '1&2'
244 $ log '1&2'
245 $ try '1&2|3' # precedence - and is higher
245 $ try '1&2|3' # precedence - and is higher
246 (or
246 (or
247 (and
247 (and
248 ('symbol', '1')
248 ('symbol', '1')
249 ('symbol', '2'))
249 ('symbol', '2'))
250 ('symbol', '3'))
250 ('symbol', '3'))
251 * set:
251 * set:
252 <addset
252 <addset
253 <baseset []>,
253 <baseset []>,
254 <baseset [3]>>
254 <baseset [3]>>
255 3
255 3
256 $ try '1|2&3'
256 $ try '1|2&3'
257 (or
257 (or
258 ('symbol', '1')
258 ('symbol', '1')
259 (and
259 (and
260 ('symbol', '2')
260 ('symbol', '2')
261 ('symbol', '3')))
261 ('symbol', '3')))
262 * set:
262 * set:
263 <addset
263 <addset
264 <baseset [1]>,
264 <baseset [1]>,
265 <baseset []>>
265 <baseset []>>
266 1
266 1
267 $ try '1&2&3' # associativity
267 $ try '1&2&3' # associativity
268 (and
268 (and
269 (and
269 (and
270 ('symbol', '1')
270 ('symbol', '1')
271 ('symbol', '2'))
271 ('symbol', '2'))
272 ('symbol', '3'))
272 ('symbol', '3'))
273 * set:
273 * set:
274 <baseset []>
274 <baseset []>
275 $ try '1|(2|3)'
275 $ try '1|(2|3)'
276 (or
276 (or
277 ('symbol', '1')
277 ('symbol', '1')
278 (group
278 (group
279 (or
279 (or
280 ('symbol', '2')
280 ('symbol', '2')
281 ('symbol', '3'))))
281 ('symbol', '3'))))
282 * set:
282 * set:
283 <addset
283 <addset
284 <baseset [1]>,
284 <baseset [1]>,
285 <addset
285 <addset
286 <baseset [2]>,
286 <baseset [2]>,
287 <baseset [3]>>>
287 <baseset [3]>>>
288 1
288 1
289 2
289 2
290 3
290 3
291 $ log '1.0' # tag
291 $ log '1.0' # tag
292 6
292 6
293 $ log 'a' # branch
293 $ log 'a' # branch
294 0
294 0
295 $ log '2785f51ee'
295 $ log '2785f51ee'
296 0
296 0
297 $ log 'date(2005)'
297 $ log 'date(2005)'
298 4
298 4
299 $ log 'date(this is a test)'
299 $ log 'date(this is a test)'
300 hg: parse error at 10: unexpected token: symbol
300 hg: parse error at 10: unexpected token: symbol
301 [255]
301 [255]
302 $ log 'date()'
302 $ log 'date()'
303 hg: parse error: date requires a string
303 hg: parse error: date requires a string
304 [255]
304 [255]
305 $ log 'date'
305 $ log 'date'
306 abort: unknown revision 'date'!
306 abort: unknown revision 'date'!
307 [255]
307 [255]
308 $ log 'date('
308 $ log 'date('
309 hg: parse error at 5: not a prefix: end
309 hg: parse error at 5: not a prefix: end
310 [255]
310 [255]
311 $ log 'date(tip)'
311 $ log 'date(tip)'
312 abort: invalid date: 'tip'
312 abort: invalid date: 'tip'
313 [255]
313 [255]
314 $ log '0:date'
314 $ log '0:date'
315 abort: unknown revision 'date'!
315 abort: unknown revision 'date'!
316 [255]
316 [255]
317 $ log '::"date"'
317 $ log '::"date"'
318 abort: unknown revision 'date'!
318 abort: unknown revision 'date'!
319 [255]
319 [255]
320 $ hg book date -r 4
320 $ hg book date -r 4
321 $ log '0:date'
321 $ log '0:date'
322 0
322 0
323 1
323 1
324 2
324 2
325 3
325 3
326 4
326 4
327 $ log '::date'
327 $ log '::date'
328 0
328 0
329 1
329 1
330 2
330 2
331 4
331 4
332 $ log '::"date"'
332 $ log '::"date"'
333 0
333 0
334 1
334 1
335 2
335 2
336 4
336 4
337 $ log 'date(2005) and 1::'
337 $ log 'date(2005) and 1::'
338 4
338 4
339 $ hg book -d date
339 $ hg book -d date
340
340
341 Test that symbols only get parsed as functions if there's an opening
341 Test that symbols only get parsed as functions if there's an opening
342 parenthesis.
342 parenthesis.
343
343
344 $ hg book only -r 9
344 $ hg book only -r 9
345 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
345 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
346 8
346 8
347 9
347 9
348
348
349 ancestor can accept 0 or more arguments
349 ancestor can accept 0 or more arguments
350
350
351 $ log 'ancestor()'
351 $ log 'ancestor()'
352 $ log 'ancestor(1)'
352 $ log 'ancestor(1)'
353 1
353 1
354 $ log 'ancestor(4,5)'
354 $ log 'ancestor(4,5)'
355 1
355 1
356 $ log 'ancestor(4,5) and 4'
356 $ log 'ancestor(4,5) and 4'
357 $ log 'ancestor(0,0,1,3)'
357 $ log 'ancestor(0,0,1,3)'
358 0
358 0
359 $ log 'ancestor(3,1,5,3,5,1)'
359 $ log 'ancestor(3,1,5,3,5,1)'
360 1
360 1
361 $ log 'ancestor(0,1,3,5)'
361 $ log 'ancestor(0,1,3,5)'
362 0
362 0
363 $ log 'ancestor(1,2,3,4,5)'
363 $ log 'ancestor(1,2,3,4,5)'
364 1
364 1
365
365
366 test ancestors
366 test ancestors
367
367
368 $ log 'ancestors(5)'
368 $ log 'ancestors(5)'
369 0
369 0
370 1
370 1
371 3
371 3
372 5
372 5
373 $ log 'ancestor(ancestors(5))'
373 $ log 'ancestor(ancestors(5))'
374 0
374 0
375 $ log '::r3232()'
375 $ log '::r3232()'
376 0
376 0
377 1
377 1
378 2
378 2
379 3
379 3
380
380
381 $ log 'author(bob)'
381 $ log 'author(bob)'
382 2
382 2
383 $ log 'author("re:bob|test")'
383 $ log 'author("re:bob|test")'
384 0
384 0
385 1
385 1
386 2
386 2
387 3
387 3
388 4
388 4
389 5
389 5
390 6
390 6
391 7
391 7
392 8
392 8
393 9
393 9
394 $ log 'branch(Γ©)'
394 $ log 'branch(Γ©)'
395 8
395 8
396 9
396 9
397 $ log 'branch(a)'
397 $ log 'branch(a)'
398 0
398 0
399 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
399 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
400 0 a
400 0 a
401 2 a-b-c-
401 2 a-b-c-
402 3 +a+b+c+
402 3 +a+b+c+
403 4 -a-b-c-
403 4 -a-b-c-
404 5 !a/b/c/
404 5 !a/b/c/
405 6 _a_b_c_
405 6 _a_b_c_
406 7 .a.b.c.
406 7 .a.b.c.
407 $ log 'children(ancestor(4,5))'
407 $ log 'children(ancestor(4,5))'
408 2
408 2
409 3
409 3
410 $ log 'closed()'
410 $ log 'closed()'
411 $ log 'contains(a)'
411 $ log 'contains(a)'
412 0
412 0
413 1
413 1
414 3
414 3
415 5
415 5
416 $ log 'contains("../repo/a")'
416 $ log 'contains("../repo/a")'
417 0
417 0
418 1
418 1
419 3
419 3
420 5
420 5
421 $ log 'desc(B)'
421 $ log 'desc(B)'
422 5
422 5
423 $ log 'descendants(2 or 3)'
423 $ log 'descendants(2 or 3)'
424 2
424 2
425 3
425 3
426 4
426 4
427 5
427 5
428 6
428 6
429 7
429 7
430 8
430 8
431 9
431 9
432 $ log 'file("b*")'
432 $ log 'file("b*")'
433 1
433 1
434 4
434 4
435 $ log 'filelog("b")'
435 $ log 'filelog("b")'
436 1
436 1
437 4
437 4
438 $ log 'filelog("../repo/b")'
438 $ log 'filelog("../repo/b")'
439 1
439 1
440 4
440 4
441 $ log 'follow()'
441 $ log 'follow()'
442 0
442 0
443 1
443 1
444 2
444 2
445 4
445 4
446 8
446 8
447 9
447 9
448 $ log 'grep("issue\d+")'
448 $ log 'grep("issue\d+")'
449 6
449 6
450 $ try 'grep("(")' # invalid regular expression
450 $ try 'grep("(")' # invalid regular expression
451 (func
451 (func
452 ('symbol', 'grep')
452 ('symbol', 'grep')
453 ('string', '('))
453 ('string', '('))
454 hg: parse error: invalid match pattern: unbalanced parenthesis
454 hg: parse error: invalid match pattern: unbalanced parenthesis
455 [255]
455 [255]
456 $ try 'grep("\bissue\d+")'
456 $ try 'grep("\bissue\d+")'
457 (func
457 (func
458 ('symbol', 'grep')
458 ('symbol', 'grep')
459 ('string', '\x08issue\\d+'))
459 ('string', '\x08issue\\d+'))
460 * set:
460 * set:
461 <filteredset
461 <filteredset
462 <fullreposet+ 0:9>>
462 <fullreposet+ 0:9>>
463 $ try 'grep(r"\bissue\d+")'
463 $ try 'grep(r"\bissue\d+")'
464 (func
464 (func
465 ('symbol', 'grep')
465 ('symbol', 'grep')
466 ('string', '\\bissue\\d+'))
466 ('string', '\\bissue\\d+'))
467 * set:
467 * set:
468 <filteredset
468 <filteredset
469 <fullreposet+ 0:9>>
469 <fullreposet+ 0:9>>
470 6
470 6
471 $ try 'grep(r"\")'
471 $ try 'grep(r"\")'
472 hg: parse error at 7: unterminated string
472 hg: parse error at 7: unterminated string
473 [255]
473 [255]
474 $ log 'head()'
474 $ log 'head()'
475 0
475 0
476 1
476 1
477 2
477 2
478 3
478 3
479 4
479 4
480 5
480 5
481 6
481 6
482 7
482 7
483 9
483 9
484 $ log 'heads(6::)'
484 $ log 'heads(6::)'
485 7
485 7
486 $ log 'keyword(issue)'
486 $ log 'keyword(issue)'
487 6
487 6
488 $ log 'keyword("test a")'
488 $ log 'keyword("test a")'
489 $ log 'limit(head(), 1)'
489 $ log 'limit(head(), 1)'
490 0
490 0
491 $ log 'matching(6)'
491 $ log 'matching(6)'
492 6
492 6
493 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
493 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
494 6
494 6
495 7
495 7
496
496
497 Testing min and max
497 Testing min and max
498
498
499 max: simple
499 max: simple
500
500
501 $ log 'max(contains(a))'
501 $ log 'max(contains(a))'
502 5
502 5
503
503
504 max: simple on unordered set)
504 max: simple on unordered set)
505
505
506 $ log 'max((4+0+2+5+7) and contains(a))'
506 $ log 'max((4+0+2+5+7) and contains(a))'
507 5
507 5
508
508
509 max: no result
509 max: no result
510
510
511 $ log 'max(contains(stringthatdoesnotappearanywhere))'
511 $ log 'max(contains(stringthatdoesnotappearanywhere))'
512
512
513 max: no result on unordered set
513 max: no result on unordered set
514
514
515 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
515 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
516
516
517 min: simple
517 min: simple
518
518
519 $ log 'min(contains(a))'
519 $ log 'min(contains(a))'
520 0
520 0
521
521
522 min: simple on unordered set
522 min: simple on unordered set
523
523
524 $ log 'min((4+0+2+5+7) and contains(a))'
524 $ log 'min((4+0+2+5+7) and contains(a))'
525 0
525 0
526
526
527 min: empty
527 min: empty
528
528
529 $ log 'min(contains(stringthatdoesnotappearanywhere))'
529 $ log 'min(contains(stringthatdoesnotappearanywhere))'
530
530
531 min: empty on unordered set
531 min: empty on unordered set
532
532
533 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
533 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
534
534
535
535
536 $ log 'merge()'
536 $ log 'merge()'
537 6
537 6
538 $ log 'branchpoint()'
538 $ log 'branchpoint()'
539 1
539 1
540 4
540 4
541 $ log 'modifies(b)'
541 $ log 'modifies(b)'
542 4
542 4
543 $ log 'modifies("path:b")'
543 $ log 'modifies("path:b")'
544 4
544 4
545 $ log 'modifies("*")'
545 $ log 'modifies("*")'
546 4
546 4
547 6
547 6
548 $ log 'modifies("set:modified()")'
548 $ log 'modifies("set:modified()")'
549 4
549 4
550 $ log 'id(5)'
550 $ log 'id(5)'
551 2
551 2
552 $ log 'only(9)'
552 $ log 'only(9)'
553 8
553 8
554 9
554 9
555 $ log 'only(8)'
555 $ log 'only(8)'
556 8
556 8
557 $ log 'only(9, 5)'
557 $ log 'only(9, 5)'
558 2
558 2
559 4
559 4
560 8
560 8
561 9
561 9
562 $ log 'only(7 + 9, 5 + 2)'
562 $ log 'only(7 + 9, 5 + 2)'
563 4
563 4
564 6
564 6
565 7
565 7
566 8
566 8
567 9
567 9
568
568
569 Test empty set input
569 Test empty set input
570 $ log 'only(p2())'
570 $ log 'only(p2())'
571 $ log 'only(p1(), p2())'
571 $ log 'only(p1(), p2())'
572 0
572 0
573 1
573 1
574 2
574 2
575 4
575 4
576 8
576 8
577 9
577 9
578
578
579 Test '%' operator
579 Test '%' operator
580
580
581 $ log '9%'
581 $ log '9%'
582 8
582 8
583 9
583 9
584 $ log '9%5'
584 $ log '9%5'
585 2
585 2
586 4
586 4
587 8
587 8
588 9
588 9
589 $ log '(7 + 9)%(5 + 2)'
589 $ log '(7 + 9)%(5 + 2)'
590 4
590 4
591 6
591 6
592 7
592 7
593 8
593 8
594 9
594 9
595
595
596 Test opreand of '%' is optimized recursively (issue4670)
596 Test opreand of '%' is optimized recursively (issue4670)
597
597
598 $ try --optimize '8:9-8%'
598 $ try --optimize '8:9-8%'
599 (onlypost
599 (onlypost
600 (minus
600 (minus
601 (range
601 (range
602 ('symbol', '8')
602 ('symbol', '8')
603 ('symbol', '9'))
603 ('symbol', '9'))
604 ('symbol', '8')))
604 ('symbol', '8')))
605 * optimized:
605 * optimized:
606 (func
606 (func
607 ('symbol', 'only')
607 ('symbol', 'only')
608 (and
608 (and
609 (range
609 (range
610 ('symbol', '8')
610 ('symbol', '8')
611 ('symbol', '9'))
611 ('symbol', '9'))
612 (not
612 (not
613 ('symbol', '8'))))
613 ('symbol', '8'))))
614 * set:
614 * set:
615 <baseset+ [8, 9]>
615 <baseset+ [8, 9]>
616 8
616 8
617 9
617 9
618 $ try --optimize '(9)%(5)'
618 $ try --optimize '(9)%(5)'
619 (only
619 (only
620 (group
620 (group
621 ('symbol', '9'))
621 ('symbol', '9'))
622 (group
622 (group
623 ('symbol', '5')))
623 ('symbol', '5')))
624 * optimized:
624 * optimized:
625 (func
625 (func
626 ('symbol', 'only')
626 ('symbol', 'only')
627 (list
627 (list
628 ('symbol', '9')
628 ('symbol', '9')
629 ('symbol', '5')))
629 ('symbol', '5')))
630 * set:
630 * set:
631 <baseset+ [8, 9, 2, 4]>
631 <baseset+ [8, 9, 2, 4]>
632 2
632 2
633 4
633 4
634 8
634 8
635 9
635 9
636
636
637 Test the order of operations
637 Test the order of operations
638
638
639 $ log '7 + 9%5 + 2'
639 $ log '7 + 9%5 + 2'
640 7
640 7
641 2
641 2
642 4
642 4
643 8
643 8
644 9
644 9
645
645
646 Test explicit numeric revision
646 Test explicit numeric revision
647 $ log 'rev(-2)'
647 $ log 'rev(-2)'
648 $ log 'rev(-1)'
648 $ log 'rev(-1)'
649 -1
649 -1
650 $ log 'rev(0)'
650 $ log 'rev(0)'
651 0
651 0
652 $ log 'rev(9)'
652 $ log 'rev(9)'
653 9
653 9
654 $ log 'rev(10)'
654 $ log 'rev(10)'
655 $ log 'rev(tip)'
655 $ log 'rev(tip)'
656 hg: parse error: rev expects a number
656 hg: parse error: rev expects a number
657 [255]
657 [255]
658
658
659 Test hexadecimal revision
659 Test hexadecimal revision
660 $ log 'id(2)'
660 $ log 'id(2)'
661 abort: 00changelog.i@2: ambiguous identifier!
661 abort: 00changelog.i@2: ambiguous identifier!
662 [255]
662 [255]
663 $ log 'id(23268)'
663 $ log 'id(23268)'
664 4
664 4
665 $ log 'id(2785f51eece)'
665 $ log 'id(2785f51eece)'
666 0
666 0
667 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
667 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
668 8
668 8
669 $ log 'id(d5d0dcbdc4a)'
669 $ log 'id(d5d0dcbdc4a)'
670 $ log 'id(d5d0dcbdc4w)'
670 $ log 'id(d5d0dcbdc4w)'
671 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
671 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
672 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
672 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
673 $ log 'id(1.0)'
673 $ log 'id(1.0)'
674 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
674 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
675
675
676 Test null revision
676 Test null revision
677 $ log '(null)'
677 $ log '(null)'
678 -1
678 -1
679 $ log '(null:0)'
679 $ log '(null:0)'
680 -1
680 -1
681 0
681 0
682 $ log '(0:null)'
682 $ log '(0:null)'
683 0
683 0
684 -1
684 -1
685 $ log 'null::0'
685 $ log 'null::0'
686 -1
686 -1
687 0
687 0
688 $ log 'null:tip - 0:'
688 $ log 'null:tip - 0:'
689 -1
689 -1
690 $ log 'null: and null::' | head -1
690 $ log 'null: and null::' | head -1
691 -1
691 -1
692 $ log 'null: or 0:' | head -2
692 $ log 'null: or 0:' | head -2
693 -1
693 -1
694 0
694 0
695 $ log 'ancestors(null)'
695 $ log 'ancestors(null)'
696 -1
696 -1
697 $ log 'reverse(null:)' | tail -2
697 $ log 'reverse(null:)' | tail -2
698 0
698 0
699 -1
699 -1
700 BROKEN: should be '-1'
700 $ log 'first(null:)'
701 $ log 'first(null:)'
701 -1
702 BROKEN: should be '-1'
702 $ log 'min(null:)'
703 $ log 'min(null:)'
703 -1
704 $ log 'tip:null and all()' | tail -2
704 $ log 'tip:null and all()' | tail -2
705 1
705 1
706 0
706 0
707
707
708 Test working-directory revision
708 Test working-directory revision
709 $ hg debugrevspec 'wdir()'
709 $ hg debugrevspec 'wdir()'
710 None
710 None
711 BROKEN: should include 'None'
711 $ hg debugrevspec 'tip or wdir()'
712 $ hg debugrevspec 'tip or wdir()'
712 9
713 9
713 None
714 $ hg debugrevspec '0:tip and wdir()'
714 $ hg debugrevspec '0:tip and wdir()'
715
715
716 $ log 'outgoing()'
716 $ log 'outgoing()'
717 8
717 8
718 9
718 9
719 $ log 'outgoing("../remote1")'
719 $ log 'outgoing("../remote1")'
720 8
720 8
721 9
721 9
722 $ log 'outgoing("../remote2")'
722 $ log 'outgoing("../remote2")'
723 3
723 3
724 5
724 5
725 6
725 6
726 7
726 7
727 9
727 9
728 $ log 'p1(merge())'
728 $ log 'p1(merge())'
729 5
729 5
730 $ log 'p2(merge())'
730 $ log 'p2(merge())'
731 4
731 4
732 $ log 'parents(merge())'
732 $ log 'parents(merge())'
733 4
733 4
734 5
734 5
735 $ log 'p1(branchpoint())'
735 $ log 'p1(branchpoint())'
736 0
736 0
737 2
737 2
738 $ log 'p2(branchpoint())'
738 $ log 'p2(branchpoint())'
739 $ log 'parents(branchpoint())'
739 $ log 'parents(branchpoint())'
740 0
740 0
741 2
741 2
742 $ log 'removes(a)'
742 $ log 'removes(a)'
743 2
743 2
744 6
744 6
745 $ log 'roots(all())'
745 $ log 'roots(all())'
746 0
746 0
747 $ log 'reverse(2 or 3 or 4 or 5)'
747 $ log 'reverse(2 or 3 or 4 or 5)'
748 5
748 5
749 4
749 4
750 3
750 3
751 2
751 2
752 $ log 'reverse(all())'
752 $ log 'reverse(all())'
753 9
753 9
754 8
754 8
755 7
755 7
756 6
756 6
757 5
757 5
758 4
758 4
759 3
759 3
760 2
760 2
761 1
761 1
762 0
762 0
763 $ log 'reverse(all()) & filelog(b)'
763 $ log 'reverse(all()) & filelog(b)'
764 4
764 4
765 1
765 1
766 $ log 'rev(5)'
766 $ log 'rev(5)'
767 5
767 5
768 $ log 'sort(limit(reverse(all()), 3))'
768 $ log 'sort(limit(reverse(all()), 3))'
769 7
769 7
770 8
770 8
771 9
771 9
772 $ log 'sort(2 or 3 or 4 or 5, date)'
772 $ log 'sort(2 or 3 or 4 or 5, date)'
773 2
773 2
774 3
774 3
775 5
775 5
776 4
776 4
777 $ log 'tagged()'
777 $ log 'tagged()'
778 6
778 6
779 $ log 'tag()'
779 $ log 'tag()'
780 6
780 6
781 $ log 'tag(1.0)'
781 $ log 'tag(1.0)'
782 6
782 6
783 $ log 'tag(tip)'
783 $ log 'tag(tip)'
784 9
784 9
785
785
786 test sort revset
786 test sort revset
787 --------------------------------------------
787 --------------------------------------------
788
788
789 test when adding two unordered revsets
789 test when adding two unordered revsets
790
790
791 $ log 'sort(keyword(issue) or modifies(b))'
791 $ log 'sort(keyword(issue) or modifies(b))'
792 4
792 4
793 6
793 6
794
794
795 test when sorting a reversed collection in the same way it is
795 test when sorting a reversed collection in the same way it is
796
796
797 $ log 'sort(reverse(all()), -rev)'
797 $ log 'sort(reverse(all()), -rev)'
798 9
798 9
799 8
799 8
800 7
800 7
801 6
801 6
802 5
802 5
803 4
803 4
804 3
804 3
805 2
805 2
806 1
806 1
807 0
807 0
808
808
809 test when sorting a reversed collection
809 test when sorting a reversed collection
810
810
811 $ log 'sort(reverse(all()), rev)'
811 $ log 'sort(reverse(all()), rev)'
812 0
812 0
813 1
813 1
814 2
814 2
815 3
815 3
816 4
816 4
817 5
817 5
818 6
818 6
819 7
819 7
820 8
820 8
821 9
821 9
822
822
823
823
824 test sorting two sorted collections in different orders
824 test sorting two sorted collections in different orders
825
825
826 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
826 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
827 2
827 2
828 6
828 6
829 8
829 8
830 9
830 9
831
831
832 test sorting two sorted collections in different orders backwards
832 test sorting two sorted collections in different orders backwards
833
833
834 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
834 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
835 9
835 9
836 8
836 8
837 6
837 6
838 2
838 2
839
839
840 test subtracting something from an addset
840 test subtracting something from an addset
841
841
842 $ log '(outgoing() or removes(a)) - removes(a)'
842 $ log '(outgoing() or removes(a)) - removes(a)'
843 8
843 8
844 9
844 9
845
845
846 test intersecting something with an addset
846 test intersecting something with an addset
847
847
848 $ log 'parents(outgoing() or removes(a))'
848 $ log 'parents(outgoing() or removes(a))'
849 1
849 1
850 4
850 4
851 5
851 5
852 8
852 8
853
853
854 test that `or` operation combines elements in the right order:
854 test that `or` operation combines elements in the right order:
855
855
856 $ log '3:4 or 2:5'
856 $ log '3:4 or 2:5'
857 3
857 3
858 4
858 4
859 2
859 2
860 5
860 5
861 $ log '3:4 or 5:2'
861 $ log '3:4 or 5:2'
862 3
862 3
863 4
863 4
864 5
864 5
865 2
865 2
866 $ log 'sort(3:4 or 2:5)'
866 $ log 'sort(3:4 or 2:5)'
867 2
867 2
868 3
868 3
869 4
869 4
870 5
870 5
871 $ log 'sort(3:4 or 5:2)'
871 $ log 'sort(3:4 or 5:2)'
872 2
872 2
873 3
873 3
874 4
874 4
875 5
875 5
876
876
877 test that `or` operation skips duplicated revisions from right-hand side
877 test that `or` operation skips duplicated revisions from right-hand side
878
878
879 $ try 'reverse(1::5) or ancestors(4)'
879 $ try 'reverse(1::5) or ancestors(4)'
880 (or
880 (or
881 (func
881 (func
882 ('symbol', 'reverse')
882 ('symbol', 'reverse')
883 (dagrange
883 (dagrange
884 ('symbol', '1')
884 ('symbol', '1')
885 ('symbol', '5')))
885 ('symbol', '5')))
886 (func
886 (func
887 ('symbol', 'ancestors')
887 ('symbol', 'ancestors')
888 ('symbol', '4')))
888 ('symbol', '4')))
889 * set:
889 * set:
890 <addset
890 <addset
891 <baseset [5, 3, 1]>,
891 <baseset [5, 3, 1]>,
892 <generatorset+>>
892 <generatorset+>>
893 5
893 5
894 3
894 3
895 1
895 1
896 0
896 0
897 2
897 2
898 4
898 4
899 $ try 'sort(ancestors(4) or reverse(1::5))'
899 $ try 'sort(ancestors(4) or reverse(1::5))'
900 (func
900 (func
901 ('symbol', 'sort')
901 ('symbol', 'sort')
902 (or
902 (or
903 (func
903 (func
904 ('symbol', 'ancestors')
904 ('symbol', 'ancestors')
905 ('symbol', '4'))
905 ('symbol', '4'))
906 (func
906 (func
907 ('symbol', 'reverse')
907 ('symbol', 'reverse')
908 (dagrange
908 (dagrange
909 ('symbol', '1')
909 ('symbol', '1')
910 ('symbol', '5')))))
910 ('symbol', '5')))))
911 * set:
911 * set:
912 <addset+
912 <addset+
913 <generatorset+>,
913 <generatorset+>,
914 <baseset [5, 3, 1]>>
914 <baseset [5, 3, 1]>>
915 0
915 0
916 1
916 1
917 2
917 2
918 3
918 3
919 4
919 4
920 5
920 5
921
921
922 check that conversion to only works
922 check that conversion to only works
923 $ try --optimize '::3 - ::1'
923 $ try --optimize '::3 - ::1'
924 (minus
924 (minus
925 (dagrangepre
925 (dagrangepre
926 ('symbol', '3'))
926 ('symbol', '3'))
927 (dagrangepre
927 (dagrangepre
928 ('symbol', '1')))
928 ('symbol', '1')))
929 * optimized:
929 * optimized:
930 (func
930 (func
931 ('symbol', 'only')
931 ('symbol', 'only')
932 (list
932 (list
933 ('symbol', '3')
933 ('symbol', '3')
934 ('symbol', '1')))
934 ('symbol', '1')))
935 * set:
935 * set:
936 <baseset+ [3]>
936 <baseset+ [3]>
937 3
937 3
938 $ try --optimize 'ancestors(1) - ancestors(3)'
938 $ try --optimize 'ancestors(1) - ancestors(3)'
939 (minus
939 (minus
940 (func
940 (func
941 ('symbol', 'ancestors')
941 ('symbol', 'ancestors')
942 ('symbol', '1'))
942 ('symbol', '1'))
943 (func
943 (func
944 ('symbol', 'ancestors')
944 ('symbol', 'ancestors')
945 ('symbol', '3')))
945 ('symbol', '3')))
946 * optimized:
946 * optimized:
947 (func
947 (func
948 ('symbol', 'only')
948 ('symbol', 'only')
949 (list
949 (list
950 ('symbol', '1')
950 ('symbol', '1')
951 ('symbol', '3')))
951 ('symbol', '3')))
952 * set:
952 * set:
953 <baseset+ []>
953 <baseset+ []>
954 $ try --optimize 'not ::2 and ::6'
954 $ try --optimize 'not ::2 and ::6'
955 (and
955 (and
956 (not
956 (not
957 (dagrangepre
957 (dagrangepre
958 ('symbol', '2')))
958 ('symbol', '2')))
959 (dagrangepre
959 (dagrangepre
960 ('symbol', '6')))
960 ('symbol', '6')))
961 * optimized:
961 * optimized:
962 (func
962 (func
963 ('symbol', 'only')
963 ('symbol', 'only')
964 (list
964 (list
965 ('symbol', '6')
965 ('symbol', '6')
966 ('symbol', '2')))
966 ('symbol', '2')))
967 * set:
967 * set:
968 <baseset+ [3, 4, 5, 6]>
968 <baseset+ [3, 4, 5, 6]>
969 3
969 3
970 4
970 4
971 5
971 5
972 6
972 6
973 $ try --optimize 'ancestors(6) and not ancestors(4)'
973 $ try --optimize 'ancestors(6) and not ancestors(4)'
974 (and
974 (and
975 (func
975 (func
976 ('symbol', 'ancestors')
976 ('symbol', 'ancestors')
977 ('symbol', '6'))
977 ('symbol', '6'))
978 (not
978 (not
979 (func
979 (func
980 ('symbol', 'ancestors')
980 ('symbol', 'ancestors')
981 ('symbol', '4'))))
981 ('symbol', '4'))))
982 * optimized:
982 * optimized:
983 (func
983 (func
984 ('symbol', 'only')
984 ('symbol', 'only')
985 (list
985 (list
986 ('symbol', '6')
986 ('symbol', '6')
987 ('symbol', '4')))
987 ('symbol', '4')))
988 * set:
988 * set:
989 <baseset+ [3, 5, 6]>
989 <baseset+ [3, 5, 6]>
990 3
990 3
991 5
991 5
992 6
992 6
993
993
994 we can use patterns when searching for tags
994 we can use patterns when searching for tags
995
995
996 $ log 'tag("1..*")'
996 $ log 'tag("1..*")'
997 abort: tag '1..*' does not exist!
997 abort: tag '1..*' does not exist!
998 [255]
998 [255]
999 $ log 'tag("re:1..*")'
999 $ log 'tag("re:1..*")'
1000 6
1000 6
1001 $ log 'tag("re:[0-9].[0-9]")'
1001 $ log 'tag("re:[0-9].[0-9]")'
1002 6
1002 6
1003 $ log 'tag("literal:1.0")'
1003 $ log 'tag("literal:1.0")'
1004 6
1004 6
1005 $ log 'tag("re:0..*")'
1005 $ log 'tag("re:0..*")'
1006
1006
1007 $ log 'tag(unknown)'
1007 $ log 'tag(unknown)'
1008 abort: tag 'unknown' does not exist!
1008 abort: tag 'unknown' does not exist!
1009 [255]
1009 [255]
1010 $ log 'tag("re:unknown")'
1010 $ log 'tag("re:unknown")'
1011 $ log 'present(tag("unknown"))'
1011 $ log 'present(tag("unknown"))'
1012 $ log 'present(tag("re:unknown"))'
1012 $ log 'present(tag("re:unknown"))'
1013 $ log 'branch(unknown)'
1013 $ log 'branch(unknown)'
1014 abort: unknown revision 'unknown'!
1014 abort: unknown revision 'unknown'!
1015 [255]
1015 [255]
1016 $ log 'branch("re:unknown")'
1016 $ log 'branch("re:unknown")'
1017 $ log 'present(branch("unknown"))'
1017 $ log 'present(branch("unknown"))'
1018 $ log 'present(branch("re:unknown"))'
1018 $ log 'present(branch("re:unknown"))'
1019 $ log 'user(bob)'
1019 $ log 'user(bob)'
1020 2
1020 2
1021
1021
1022 $ log '4::8'
1022 $ log '4::8'
1023 4
1023 4
1024 8
1024 8
1025 $ log '4:8'
1025 $ log '4:8'
1026 4
1026 4
1027 5
1027 5
1028 6
1028 6
1029 7
1029 7
1030 8
1030 8
1031
1031
1032 $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
1032 $ log 'sort(!merge() & (modifies(b) | user(bob) | keyword(bug) | keyword(issue) & 1::9), "-date")'
1033 4
1033 4
1034 2
1034 2
1035 5
1035 5
1036
1036
1037 $ log 'not 0 and 0:2'
1037 $ log 'not 0 and 0:2'
1038 1
1038 1
1039 2
1039 2
1040 $ log 'not 1 and 0:2'
1040 $ log 'not 1 and 0:2'
1041 0
1041 0
1042 2
1042 2
1043 $ log 'not 2 and 0:2'
1043 $ log 'not 2 and 0:2'
1044 0
1044 0
1045 1
1045 1
1046 $ log '(1 and 2)::'
1046 $ log '(1 and 2)::'
1047 $ log '(1 and 2):'
1047 $ log '(1 and 2):'
1048 $ log '(1 and 2):3'
1048 $ log '(1 and 2):3'
1049 $ log 'sort(head(), -rev)'
1049 $ log 'sort(head(), -rev)'
1050 9
1050 9
1051 7
1051 7
1052 6
1052 6
1053 5
1053 5
1054 4
1054 4
1055 3
1055 3
1056 2
1056 2
1057 1
1057 1
1058 0
1058 0
1059 $ log '4::8 - 8'
1059 $ log '4::8 - 8'
1060 4
1060 4
1061 $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)'
1061 $ log 'matching(1 or 2 or 3) and (2 or 3 or 1)'
1062 2
1062 2
1063 3
1063 3
1064 1
1064 1
1065
1065
1066 $ log 'named("unknown")'
1066 $ log 'named("unknown")'
1067 abort: namespace 'unknown' does not exist!
1067 abort: namespace 'unknown' does not exist!
1068 [255]
1068 [255]
1069 $ log 'named("re:unknown")'
1069 $ log 'named("re:unknown")'
1070 abort: no namespace exists that match 'unknown'!
1070 abort: no namespace exists that match 'unknown'!
1071 [255]
1071 [255]
1072 $ log 'present(named("unknown"))'
1072 $ log 'present(named("unknown"))'
1073 $ log 'present(named("re:unknown"))'
1073 $ log 'present(named("re:unknown"))'
1074
1074
1075 $ log 'tag()'
1075 $ log 'tag()'
1076 6
1076 6
1077 $ log 'named("tags")'
1077 $ log 'named("tags")'
1078 6
1078 6
1079
1079
1080 issue2437
1080 issue2437
1081
1081
1082 $ log '3 and p1(5)'
1082 $ log '3 and p1(5)'
1083 3
1083 3
1084 $ log '4 and p2(6)'
1084 $ log '4 and p2(6)'
1085 4
1085 4
1086 $ log '1 and parents(:2)'
1086 $ log '1 and parents(:2)'
1087 1
1087 1
1088 $ log '2 and children(1:)'
1088 $ log '2 and children(1:)'
1089 2
1089 2
1090 $ log 'roots(all()) or roots(all())'
1090 $ log 'roots(all()) or roots(all())'
1091 0
1091 0
1092 $ hg debugrevspec 'roots(all()) or roots(all())'
1092 $ hg debugrevspec 'roots(all()) or roots(all())'
1093 0
1093 0
1094 $ log 'heads(branch(Γ©)) or heads(branch(Γ©))'
1094 $ log 'heads(branch(Γ©)) or heads(branch(Γ©))'
1095 9
1095 9
1096 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))'
1096 $ log 'ancestors(8) and (heads(branch("-a-b-c-")) or heads(branch(Γ©)))'
1097 4
1097 4
1098
1098
1099 issue2654: report a parse error if the revset was not completely parsed
1099 issue2654: report a parse error if the revset was not completely parsed
1100
1100
1101 $ log '1 OR 2'
1101 $ log '1 OR 2'
1102 hg: parse error at 2: invalid token
1102 hg: parse error at 2: invalid token
1103 [255]
1103 [255]
1104
1104
1105 or operator should preserve ordering:
1105 or operator should preserve ordering:
1106 $ log 'reverse(2::4) or tip'
1106 $ log 'reverse(2::4) or tip'
1107 4
1107 4
1108 2
1108 2
1109 9
1109 9
1110
1110
1111 parentrevspec
1111 parentrevspec
1112
1112
1113 $ log 'merge()^0'
1113 $ log 'merge()^0'
1114 6
1114 6
1115 $ log 'merge()^'
1115 $ log 'merge()^'
1116 5
1116 5
1117 $ log 'merge()^1'
1117 $ log 'merge()^1'
1118 5
1118 5
1119 $ log 'merge()^2'
1119 $ log 'merge()^2'
1120 4
1120 4
1121 $ log 'merge()^^'
1121 $ log 'merge()^^'
1122 3
1122 3
1123 $ log 'merge()^1^'
1123 $ log 'merge()^1^'
1124 3
1124 3
1125 $ log 'merge()^^^'
1125 $ log 'merge()^^^'
1126 1
1126 1
1127
1127
1128 $ log 'merge()~0'
1128 $ log 'merge()~0'
1129 6
1129 6
1130 $ log 'merge()~1'
1130 $ log 'merge()~1'
1131 5
1131 5
1132 $ log 'merge()~2'
1132 $ log 'merge()~2'
1133 3
1133 3
1134 $ log 'merge()~2^1'
1134 $ log 'merge()~2^1'
1135 1
1135 1
1136 $ log 'merge()~3'
1136 $ log 'merge()~3'
1137 1
1137 1
1138
1138
1139 $ log '(-3:tip)^'
1139 $ log '(-3:tip)^'
1140 4
1140 4
1141 6
1141 6
1142 8
1142 8
1143
1143
1144 $ log 'tip^foo'
1144 $ log 'tip^foo'
1145 hg: parse error: ^ expects a number 0, 1, or 2
1145 hg: parse error: ^ expects a number 0, 1, or 2
1146 [255]
1146 [255]
1147
1147
1148 Bogus function gets suggestions
1148 Bogus function gets suggestions
1149 $ log 'add()'
1149 $ log 'add()'
1150 hg: parse error: unknown identifier: add
1150 hg: parse error: unknown identifier: add
1151 (did you mean 'adds'?)
1151 (did you mean 'adds'?)
1152 [255]
1152 [255]
1153 $ log 'added()'
1153 $ log 'added()'
1154 hg: parse error: unknown identifier: added
1154 hg: parse error: unknown identifier: added
1155 (did you mean 'adds'?)
1155 (did you mean 'adds'?)
1156 [255]
1156 [255]
1157 $ log 'remo()'
1157 $ log 'remo()'
1158 hg: parse error: unknown identifier: remo
1158 hg: parse error: unknown identifier: remo
1159 (did you mean one of remote, removes?)
1159 (did you mean one of remote, removes?)
1160 [255]
1160 [255]
1161 $ log 'babar()'
1161 $ log 'babar()'
1162 hg: parse error: unknown identifier: babar
1162 hg: parse error: unknown identifier: babar
1163 [255]
1163 [255]
1164
1164
1165 multiple revspecs
1165 multiple revspecs
1166
1166
1167 $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
1167 $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
1168 8
1168 8
1169 9
1169 9
1170 4
1170 4
1171 5
1171 5
1172 6
1172 6
1173 7
1173 7
1174
1174
1175 test usage in revpair (with "+")
1175 test usage in revpair (with "+")
1176
1176
1177 (real pair)
1177 (real pair)
1178
1178
1179 $ hg diff -r 'tip^^' -r 'tip'
1179 $ hg diff -r 'tip^^' -r 'tip'
1180 diff -r 2326846efdab -r 24286f4ae135 .hgtags
1180 diff -r 2326846efdab -r 24286f4ae135 .hgtags
1181 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1181 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1182 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
1182 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
1183 @@ -0,0 +1,1 @@
1183 @@ -0,0 +1,1 @@
1184 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1184 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1185 $ hg diff -r 'tip^^::tip'
1185 $ hg diff -r 'tip^^::tip'
1186 diff -r 2326846efdab -r 24286f4ae135 .hgtags
1186 diff -r 2326846efdab -r 24286f4ae135 .hgtags
1187 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1187 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1188 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
1188 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
1189 @@ -0,0 +1,1 @@
1189 @@ -0,0 +1,1 @@
1190 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1190 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1191
1191
1192 (single rev)
1192 (single rev)
1193
1193
1194 $ hg diff -r 'tip^' -r 'tip^'
1194 $ hg diff -r 'tip^' -r 'tip^'
1195 $ hg diff -r 'tip^::tip^ or tip^'
1195 $ hg diff -r 'tip^::tip^ or tip^'
1196
1196
1197 (single rev that does not looks like a range)
1197 (single rev that does not looks like a range)
1198
1198
1199 $ hg diff -r 'tip^ or tip^'
1199 $ hg diff -r 'tip^ or tip^'
1200 diff -r d5d0dcbdc4d9 .hgtags
1200 diff -r d5d0dcbdc4d9 .hgtags
1201 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1201 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1202 +++ b/.hgtags * (glob)
1202 +++ b/.hgtags * (glob)
1203 @@ -0,0 +1,1 @@
1203 @@ -0,0 +1,1 @@
1204 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1204 +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0
1205
1205
1206 (no rev)
1206 (no rev)
1207
1207
1208 $ hg diff -r 'author("babar") or author("celeste")'
1208 $ hg diff -r 'author("babar") or author("celeste")'
1209 abort: empty revision range
1209 abort: empty revision range
1210 [255]
1210 [255]
1211
1211
1212 aliases:
1212 aliases:
1213
1213
1214 $ echo '[revsetalias]' >> .hg/hgrc
1214 $ echo '[revsetalias]' >> .hg/hgrc
1215 $ echo 'm = merge()' >> .hg/hgrc
1215 $ echo 'm = merge()' >> .hg/hgrc
1216 (revset aliases can override builtin revsets)
1216 (revset aliases can override builtin revsets)
1217 $ echo 'p2($1) = p1($1)' >> .hg/hgrc
1217 $ echo 'p2($1) = p1($1)' >> .hg/hgrc
1218 $ echo 'sincem = descendants(m)' >> .hg/hgrc
1218 $ echo 'sincem = descendants(m)' >> .hg/hgrc
1219 $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
1219 $ echo 'd($1) = reverse(sort($1, date))' >> .hg/hgrc
1220 $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
1220 $ echo 'rs(ARG1, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
1221 $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
1221 $ echo 'rs4(ARG1, ARGA, ARGB, ARG2) = reverse(sort(ARG1, ARG2))' >> .hg/hgrc
1222
1222
1223 $ try m
1223 $ try m
1224 ('symbol', 'm')
1224 ('symbol', 'm')
1225 (func
1225 (func
1226 ('symbol', 'merge')
1226 ('symbol', 'merge')
1227 None)
1227 None)
1228 * set:
1228 * set:
1229 <filteredset
1229 <filteredset
1230 <fullreposet+ 0:9>>
1230 <fullreposet+ 0:9>>
1231 6
1231 6
1232
1232
1233 $ HGPLAIN=1
1233 $ HGPLAIN=1
1234 $ export HGPLAIN
1234 $ export HGPLAIN
1235 $ try m
1235 $ try m
1236 ('symbol', 'm')
1236 ('symbol', 'm')
1237 abort: unknown revision 'm'!
1237 abort: unknown revision 'm'!
1238 [255]
1238 [255]
1239
1239
1240 $ HGPLAINEXCEPT=revsetalias
1240 $ HGPLAINEXCEPT=revsetalias
1241 $ export HGPLAINEXCEPT
1241 $ export HGPLAINEXCEPT
1242 $ try m
1242 $ try m
1243 ('symbol', 'm')
1243 ('symbol', 'm')
1244 (func
1244 (func
1245 ('symbol', 'merge')
1245 ('symbol', 'merge')
1246 None)
1246 None)
1247 * set:
1247 * set:
1248 <filteredset
1248 <filteredset
1249 <fullreposet+ 0:9>>
1249 <fullreposet+ 0:9>>
1250 6
1250 6
1251
1251
1252 $ unset HGPLAIN
1252 $ unset HGPLAIN
1253 $ unset HGPLAINEXCEPT
1253 $ unset HGPLAINEXCEPT
1254
1254
1255 $ try 'p2(.)'
1255 $ try 'p2(.)'
1256 (func
1256 (func
1257 ('symbol', 'p2')
1257 ('symbol', 'p2')
1258 ('symbol', '.'))
1258 ('symbol', '.'))
1259 (func
1259 (func
1260 ('symbol', 'p1')
1260 ('symbol', 'p1')
1261 ('symbol', '.'))
1261 ('symbol', '.'))
1262 * set:
1262 * set:
1263 <baseset+ [8]>
1263 <baseset+ [8]>
1264 8
1264 8
1265
1265
1266 $ HGPLAIN=1
1266 $ HGPLAIN=1
1267 $ export HGPLAIN
1267 $ export HGPLAIN
1268 $ try 'p2(.)'
1268 $ try 'p2(.)'
1269 (func
1269 (func
1270 ('symbol', 'p2')
1270 ('symbol', 'p2')
1271 ('symbol', '.'))
1271 ('symbol', '.'))
1272 * set:
1272 * set:
1273 <baseset+ []>
1273 <baseset+ []>
1274
1274
1275 $ HGPLAINEXCEPT=revsetalias
1275 $ HGPLAINEXCEPT=revsetalias
1276 $ export HGPLAINEXCEPT
1276 $ export HGPLAINEXCEPT
1277 $ try 'p2(.)'
1277 $ try 'p2(.)'
1278 (func
1278 (func
1279 ('symbol', 'p2')
1279 ('symbol', 'p2')
1280 ('symbol', '.'))
1280 ('symbol', '.'))
1281 (func
1281 (func
1282 ('symbol', 'p1')
1282 ('symbol', 'p1')
1283 ('symbol', '.'))
1283 ('symbol', '.'))
1284 * set:
1284 * set:
1285 <baseset+ [8]>
1285 <baseset+ [8]>
1286 8
1286 8
1287
1287
1288 $ unset HGPLAIN
1288 $ unset HGPLAIN
1289 $ unset HGPLAINEXCEPT
1289 $ unset HGPLAINEXCEPT
1290
1290
1291 test alias recursion
1291 test alias recursion
1292
1292
1293 $ try sincem
1293 $ try sincem
1294 ('symbol', 'sincem')
1294 ('symbol', 'sincem')
1295 (func
1295 (func
1296 ('symbol', 'descendants')
1296 ('symbol', 'descendants')
1297 (func
1297 (func
1298 ('symbol', 'merge')
1298 ('symbol', 'merge')
1299 None))
1299 None))
1300 * set:
1300 * set:
1301 <addset+
1301 <addset+
1302 <filteredset
1302 <filteredset
1303 <fullreposet+ 0:9>>,
1303 <fullreposet+ 0:9>>,
1304 <generatorset+>>
1304 <generatorset+>>
1305 6
1305 6
1306 7
1306 7
1307
1307
1308 test infinite recursion
1308 test infinite recursion
1309
1309
1310 $ echo 'recurse1 = recurse2' >> .hg/hgrc
1310 $ echo 'recurse1 = recurse2' >> .hg/hgrc
1311 $ echo 'recurse2 = recurse1' >> .hg/hgrc
1311 $ echo 'recurse2 = recurse1' >> .hg/hgrc
1312 $ try recurse1
1312 $ try recurse1
1313 ('symbol', 'recurse1')
1313 ('symbol', 'recurse1')
1314 hg: parse error: infinite expansion of revset alias "recurse1" detected
1314 hg: parse error: infinite expansion of revset alias "recurse1" detected
1315 [255]
1315 [255]
1316
1316
1317 $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc
1317 $ echo 'level1($1, $2) = $1 or $2' >> .hg/hgrc
1318 $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc
1318 $ echo 'level2($1, $2) = level1($2, $1)' >> .hg/hgrc
1319 $ try "level2(level1(1, 2), 3)"
1319 $ try "level2(level1(1, 2), 3)"
1320 (func
1320 (func
1321 ('symbol', 'level2')
1321 ('symbol', 'level2')
1322 (list
1322 (list
1323 (func
1323 (func
1324 ('symbol', 'level1')
1324 ('symbol', 'level1')
1325 (list
1325 (list
1326 ('symbol', '1')
1326 ('symbol', '1')
1327 ('symbol', '2')))
1327 ('symbol', '2')))
1328 ('symbol', '3')))
1328 ('symbol', '3')))
1329 (or
1329 (or
1330 ('symbol', '3')
1330 ('symbol', '3')
1331 (or
1331 (or
1332 ('symbol', '1')
1332 ('symbol', '1')
1333 ('symbol', '2')))
1333 ('symbol', '2')))
1334 * set:
1334 * set:
1335 <addset
1335 <addset
1336 <baseset [3]>,
1336 <baseset [3]>,
1337 <addset
1337 <addset
1338 <baseset [1]>,
1338 <baseset [1]>,
1339 <baseset [2]>>>
1339 <baseset [2]>>>
1340 3
1340 3
1341 1
1341 1
1342 2
1342 2
1343
1343
1344 test nesting and variable passing
1344 test nesting and variable passing
1345
1345
1346 $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
1346 $ echo 'nested($1) = nested2($1)' >> .hg/hgrc
1347 $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
1347 $ echo 'nested2($1) = nested3($1)' >> .hg/hgrc
1348 $ echo 'nested3($1) = max($1)' >> .hg/hgrc
1348 $ echo 'nested3($1) = max($1)' >> .hg/hgrc
1349 $ try 'nested(2:5)'
1349 $ try 'nested(2:5)'
1350 (func
1350 (func
1351 ('symbol', 'nested')
1351 ('symbol', 'nested')
1352 (range
1352 (range
1353 ('symbol', '2')
1353 ('symbol', '2')
1354 ('symbol', '5')))
1354 ('symbol', '5')))
1355 (func
1355 (func
1356 ('symbol', 'max')
1356 ('symbol', 'max')
1357 (range
1357 (range
1358 ('symbol', '2')
1358 ('symbol', '2')
1359 ('symbol', '5')))
1359 ('symbol', '5')))
1360 * set:
1360 * set:
1361 <baseset [5]>
1361 <baseset [5]>
1362 5
1362 5
1363
1363
1364 test variable isolation, variable placeholders are rewritten as string
1364 test variable isolation, variable placeholders are rewritten as string
1365 then parsed and matched again as string. Check they do not leak too
1365 then parsed and matched again as string. Check they do not leak too
1366 far away.
1366 far away.
1367
1367
1368 $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
1368 $ echo 'injectparamasstring = max("$1")' >> .hg/hgrc
1369 $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
1369 $ echo 'callinjection($1) = descendants(injectparamasstring)' >> .hg/hgrc
1370 $ try 'callinjection(2:5)'
1370 $ try 'callinjection(2:5)'
1371 (func
1371 (func
1372 ('symbol', 'callinjection')
1372 ('symbol', 'callinjection')
1373 (range
1373 (range
1374 ('symbol', '2')
1374 ('symbol', '2')
1375 ('symbol', '5')))
1375 ('symbol', '5')))
1376 (func
1376 (func
1377 ('symbol', 'descendants')
1377 ('symbol', 'descendants')
1378 (func
1378 (func
1379 ('symbol', 'max')
1379 ('symbol', 'max')
1380 ('string', '$1')))
1380 ('string', '$1')))
1381 abort: unknown revision '$1'!
1381 abort: unknown revision '$1'!
1382 [255]
1382 [255]
1383
1383
1384 $ echo 'injectparamasstring2 = max(_aliasarg("$1"))' >> .hg/hgrc
1384 $ echo 'injectparamasstring2 = max(_aliasarg("$1"))' >> .hg/hgrc
1385 $ echo 'callinjection2($1) = descendants(injectparamasstring2)' >> .hg/hgrc
1385 $ echo 'callinjection2($1) = descendants(injectparamasstring2)' >> .hg/hgrc
1386 $ try 'callinjection2(2:5)'
1386 $ try 'callinjection2(2:5)'
1387 (func
1387 (func
1388 ('symbol', 'callinjection2')
1388 ('symbol', 'callinjection2')
1389 (range
1389 (range
1390 ('symbol', '2')
1390 ('symbol', '2')
1391 ('symbol', '5')))
1391 ('symbol', '5')))
1392 abort: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1392 abort: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1393 [255]
1393 [255]
1394 $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
1394 $ hg debugrevspec --debug --config revsetalias.anotherbadone='branch(' "tip"
1395 ('symbol', 'tip')
1395 ('symbol', 'tip')
1396 warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end
1396 warning: failed to parse the definition of revset alias "anotherbadone": at 7: not a prefix: end
1397 warning: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1397 warning: failed to parse the definition of revset alias "injectparamasstring2": unknown identifier: _aliasarg
1398 * set:
1398 * set:
1399 <baseset [9]>
1399 <baseset [9]>
1400 9
1400 9
1401 >>> data = file('.hg/hgrc', 'rb').read()
1401 >>> data = file('.hg/hgrc', 'rb').read()
1402 >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', ''))
1402 >>> file('.hg/hgrc', 'wb').write(data.replace('_aliasarg', ''))
1403
1403
1404 $ try 'tip'
1404 $ try 'tip'
1405 ('symbol', 'tip')
1405 ('symbol', 'tip')
1406 * set:
1406 * set:
1407 <baseset [9]>
1407 <baseset [9]>
1408 9
1408 9
1409
1409
1410 $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
1410 $ hg debugrevspec --debug --config revsetalias.'bad name'='tip' "tip"
1411 ('symbol', 'tip')
1411 ('symbol', 'tip')
1412 warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token
1412 warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token
1413 * set:
1413 * set:
1414 <baseset [9]>
1414 <baseset [9]>
1415 9
1415 9
1416 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
1416 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
1417 $ try 'strictreplacing("foo", tip)'
1417 $ try 'strictreplacing("foo", tip)'
1418 (func
1418 (func
1419 ('symbol', 'strictreplacing')
1419 ('symbol', 'strictreplacing')
1420 (list
1420 (list
1421 ('string', 'foo')
1421 ('string', 'foo')
1422 ('symbol', 'tip')))
1422 ('symbol', 'tip')))
1423 (or
1423 (or
1424 ('symbol', 'tip')
1424 ('symbol', 'tip')
1425 (func
1425 (func
1426 ('symbol', 'desc')
1426 ('symbol', 'desc')
1427 ('string', '$1')))
1427 ('string', '$1')))
1428 * set:
1428 * set:
1429 <addset
1429 <addset
1430 <baseset [9]>,
1430 <baseset [9]>,
1431 <filteredset
1431 <filteredset
1432 <fullreposet+ 0:9>>>
1432 <fullreposet+ 0:9>>>
1433 9
1433 9
1434
1434
1435 $ try 'd(2:5)'
1435 $ try 'd(2:5)'
1436 (func
1436 (func
1437 ('symbol', 'd')
1437 ('symbol', 'd')
1438 (range
1438 (range
1439 ('symbol', '2')
1439 ('symbol', '2')
1440 ('symbol', '5')))
1440 ('symbol', '5')))
1441 (func
1441 (func
1442 ('symbol', 'reverse')
1442 ('symbol', 'reverse')
1443 (func
1443 (func
1444 ('symbol', 'sort')
1444 ('symbol', 'sort')
1445 (list
1445 (list
1446 (range
1446 (range
1447 ('symbol', '2')
1447 ('symbol', '2')
1448 ('symbol', '5'))
1448 ('symbol', '5'))
1449 ('symbol', 'date'))))
1449 ('symbol', 'date'))))
1450 * set:
1450 * set:
1451 <baseset [4, 5, 3, 2]>
1451 <baseset [4, 5, 3, 2]>
1452 4
1452 4
1453 5
1453 5
1454 3
1454 3
1455 2
1455 2
1456 $ try 'rs(2 or 3, date)'
1456 $ try 'rs(2 or 3, date)'
1457 (func
1457 (func
1458 ('symbol', 'rs')
1458 ('symbol', 'rs')
1459 (list
1459 (list
1460 (or
1460 (or
1461 ('symbol', '2')
1461 ('symbol', '2')
1462 ('symbol', '3'))
1462 ('symbol', '3'))
1463 ('symbol', 'date')))
1463 ('symbol', 'date')))
1464 (func
1464 (func
1465 ('symbol', 'reverse')
1465 ('symbol', 'reverse')
1466 (func
1466 (func
1467 ('symbol', 'sort')
1467 ('symbol', 'sort')
1468 (list
1468 (list
1469 (or
1469 (or
1470 ('symbol', '2')
1470 ('symbol', '2')
1471 ('symbol', '3'))
1471 ('symbol', '3'))
1472 ('symbol', 'date'))))
1472 ('symbol', 'date'))))
1473 * set:
1473 * set:
1474 <baseset [3, 2]>
1474 <baseset [3, 2]>
1475 3
1475 3
1476 2
1476 2
1477 $ try 'rs()'
1477 $ try 'rs()'
1478 (func
1478 (func
1479 ('symbol', 'rs')
1479 ('symbol', 'rs')
1480 None)
1480 None)
1481 hg: parse error: invalid number of arguments: 0
1481 hg: parse error: invalid number of arguments: 0
1482 [255]
1482 [255]
1483 $ try 'rs(2)'
1483 $ try 'rs(2)'
1484 (func
1484 (func
1485 ('symbol', 'rs')
1485 ('symbol', 'rs')
1486 ('symbol', '2'))
1486 ('symbol', '2'))
1487 hg: parse error: invalid number of arguments: 1
1487 hg: parse error: invalid number of arguments: 1
1488 [255]
1488 [255]
1489 $ try 'rs(2, data, 7)'
1489 $ try 'rs(2, data, 7)'
1490 (func
1490 (func
1491 ('symbol', 'rs')
1491 ('symbol', 'rs')
1492 (list
1492 (list
1493 (list
1493 (list
1494 ('symbol', '2')
1494 ('symbol', '2')
1495 ('symbol', 'data'))
1495 ('symbol', 'data'))
1496 ('symbol', '7')))
1496 ('symbol', '7')))
1497 hg: parse error: invalid number of arguments: 3
1497 hg: parse error: invalid number of arguments: 3
1498 [255]
1498 [255]
1499 $ try 'rs4(2 or 3, x, x, date)'
1499 $ try 'rs4(2 or 3, x, x, date)'
1500 (func
1500 (func
1501 ('symbol', 'rs4')
1501 ('symbol', 'rs4')
1502 (list
1502 (list
1503 (list
1503 (list
1504 (list
1504 (list
1505 (or
1505 (or
1506 ('symbol', '2')
1506 ('symbol', '2')
1507 ('symbol', '3'))
1507 ('symbol', '3'))
1508 ('symbol', 'x'))
1508 ('symbol', 'x'))
1509 ('symbol', 'x'))
1509 ('symbol', 'x'))
1510 ('symbol', 'date')))
1510 ('symbol', 'date')))
1511 (func
1511 (func
1512 ('symbol', 'reverse')
1512 ('symbol', 'reverse')
1513 (func
1513 (func
1514 ('symbol', 'sort')
1514 ('symbol', 'sort')
1515 (list
1515 (list
1516 (or
1516 (or
1517 ('symbol', '2')
1517 ('symbol', '2')
1518 ('symbol', '3'))
1518 ('symbol', '3'))
1519 ('symbol', 'date'))))
1519 ('symbol', 'date'))))
1520 * set:
1520 * set:
1521 <baseset [3, 2]>
1521 <baseset [3, 2]>
1522 3
1522 3
1523 2
1523 2
1524
1524
1525 issue4553: check that revset aliases override existing hash prefix
1525 issue4553: check that revset aliases override existing hash prefix
1526
1526
1527 $ hg log -qr e
1527 $ hg log -qr e
1528 6:e0cc66ef77e8
1528 6:e0cc66ef77e8
1529
1529
1530 $ hg log -qr e --config revsetalias.e="all()"
1530 $ hg log -qr e --config revsetalias.e="all()"
1531 0:2785f51eece5
1531 0:2785f51eece5
1532 1:d75937da8da0
1532 1:d75937da8da0
1533 2:5ed5505e9f1c
1533 2:5ed5505e9f1c
1534 3:8528aa5637f2
1534 3:8528aa5637f2
1535 4:2326846efdab
1535 4:2326846efdab
1536 5:904fa392b941
1536 5:904fa392b941
1537 6:e0cc66ef77e8
1537 6:e0cc66ef77e8
1538 7:013af1973af4
1538 7:013af1973af4
1539 8:d5d0dcbdc4d9
1539 8:d5d0dcbdc4d9
1540 9:24286f4ae135
1540 9:24286f4ae135
1541
1541
1542 $ hg log -qr e: --config revsetalias.e="0"
1542 $ hg log -qr e: --config revsetalias.e="0"
1543 0:2785f51eece5
1543 0:2785f51eece5
1544 1:d75937da8da0
1544 1:d75937da8da0
1545 2:5ed5505e9f1c
1545 2:5ed5505e9f1c
1546 3:8528aa5637f2
1546 3:8528aa5637f2
1547 4:2326846efdab
1547 4:2326846efdab
1548 5:904fa392b941
1548 5:904fa392b941
1549 6:e0cc66ef77e8
1549 6:e0cc66ef77e8
1550 7:013af1973af4
1550 7:013af1973af4
1551 8:d5d0dcbdc4d9
1551 8:d5d0dcbdc4d9
1552 9:24286f4ae135
1552 9:24286f4ae135
1553
1553
1554 $ hg log -qr :e --config revsetalias.e="9"
1554 $ hg log -qr :e --config revsetalias.e="9"
1555 0:2785f51eece5
1555 0:2785f51eece5
1556 1:d75937da8da0
1556 1:d75937da8da0
1557 2:5ed5505e9f1c
1557 2:5ed5505e9f1c
1558 3:8528aa5637f2
1558 3:8528aa5637f2
1559 4:2326846efdab
1559 4:2326846efdab
1560 5:904fa392b941
1560 5:904fa392b941
1561 6:e0cc66ef77e8
1561 6:e0cc66ef77e8
1562 7:013af1973af4
1562 7:013af1973af4
1563 8:d5d0dcbdc4d9
1563 8:d5d0dcbdc4d9
1564 9:24286f4ae135
1564 9:24286f4ae135
1565
1565
1566 $ hg log -qr e:
1566 $ hg log -qr e:
1567 6:e0cc66ef77e8
1567 6:e0cc66ef77e8
1568 7:013af1973af4
1568 7:013af1973af4
1569 8:d5d0dcbdc4d9
1569 8:d5d0dcbdc4d9
1570 9:24286f4ae135
1570 9:24286f4ae135
1571
1571
1572 $ hg log -qr :e
1572 $ hg log -qr :e
1573 0:2785f51eece5
1573 0:2785f51eece5
1574 1:d75937da8da0
1574 1:d75937da8da0
1575 2:5ed5505e9f1c
1575 2:5ed5505e9f1c
1576 3:8528aa5637f2
1576 3:8528aa5637f2
1577 4:2326846efdab
1577 4:2326846efdab
1578 5:904fa392b941
1578 5:904fa392b941
1579 6:e0cc66ef77e8
1579 6:e0cc66ef77e8
1580
1580
1581 issue2549 - correct optimizations
1581 issue2549 - correct optimizations
1582
1582
1583 $ log 'limit(1 or 2 or 3, 2) and not 2'
1583 $ log 'limit(1 or 2 or 3, 2) and not 2'
1584 1
1584 1
1585 $ log 'max(1 or 2) and not 2'
1585 $ log 'max(1 or 2) and not 2'
1586 $ log 'min(1 or 2) and not 1'
1586 $ log 'min(1 or 2) and not 1'
1587 $ log 'last(1 or 2, 1) and not 2'
1587 $ log 'last(1 or 2, 1) and not 2'
1588
1588
1589 issue4289 - ordering of built-ins
1589 issue4289 - ordering of built-ins
1590 $ hg log -M -q -r 3:2
1590 $ hg log -M -q -r 3:2
1591 3:8528aa5637f2
1591 3:8528aa5637f2
1592 2:5ed5505e9f1c
1592 2:5ed5505e9f1c
1593
1593
1594 test revsets started with 40-chars hash (issue3669)
1594 test revsets started with 40-chars hash (issue3669)
1595
1595
1596 $ ISSUE3669_TIP=`hg tip --template '{node}'`
1596 $ ISSUE3669_TIP=`hg tip --template '{node}'`
1597 $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n'
1597 $ hg log -r "${ISSUE3669_TIP}" --template '{rev}\n'
1598 9
1598 9
1599 $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n'
1599 $ hg log -r "${ISSUE3669_TIP}^" --template '{rev}\n'
1600 8
1600 8
1601
1601
1602 test or-ed indirect predicates (issue3775)
1602 test or-ed indirect predicates (issue3775)
1603
1603
1604 $ log '6 or 6^1' | sort
1604 $ log '6 or 6^1' | sort
1605 5
1605 5
1606 6
1606 6
1607 $ log '6^1 or 6' | sort
1607 $ log '6^1 or 6' | sort
1608 5
1608 5
1609 6
1609 6
1610 $ log '4 or 4~1' | sort
1610 $ log '4 or 4~1' | sort
1611 2
1611 2
1612 4
1612 4
1613 $ log '4~1 or 4' | sort
1613 $ log '4~1 or 4' | sort
1614 2
1614 2
1615 4
1615 4
1616 $ log '(0 or 2):(4 or 6) or 0 or 6' | sort
1616 $ log '(0 or 2):(4 or 6) or 0 or 6' | sort
1617 0
1617 0
1618 1
1618 1
1619 2
1619 2
1620 3
1620 3
1621 4
1621 4
1622 5
1622 5
1623 6
1623 6
1624 $ log '0 or 6 or (0 or 2):(4 or 6)' | sort
1624 $ log '0 or 6 or (0 or 2):(4 or 6)' | sort
1625 0
1625 0
1626 1
1626 1
1627 2
1627 2
1628 3
1628 3
1629 4
1629 4
1630 5
1630 5
1631 6
1631 6
1632
1632
1633 tests for 'remote()' predicate:
1633 tests for 'remote()' predicate:
1634 #. (csets in remote) (id) (remote)
1634 #. (csets in remote) (id) (remote)
1635 1. less than local current branch "default"
1635 1. less than local current branch "default"
1636 2. same with local specified "default"
1636 2. same with local specified "default"
1637 3. more than local specified specified
1637 3. more than local specified specified
1638
1638
1639 $ hg clone --quiet -U . ../remote3
1639 $ hg clone --quiet -U . ../remote3
1640 $ cd ../remote3
1640 $ cd ../remote3
1641 $ hg update -q 7
1641 $ hg update -q 7
1642 $ echo r > r
1642 $ echo r > r
1643 $ hg ci -Aqm 10
1643 $ hg ci -Aqm 10
1644 $ log 'remote()'
1644 $ log 'remote()'
1645 7
1645 7
1646 $ log 'remote("a-b-c-")'
1646 $ log 'remote("a-b-c-")'
1647 2
1647 2
1648 $ cd ../repo
1648 $ cd ../repo
1649 $ log 'remote(".a.b.c.", "../remote3")'
1649 $ log 'remote(".a.b.c.", "../remote3")'
1650
1650
1651 tests for concatenation of strings/symbols by "##"
1651 tests for concatenation of strings/symbols by "##"
1652
1652
1653 $ try "278 ## '5f5' ## 1ee ## 'ce5'"
1653 $ try "278 ## '5f5' ## 1ee ## 'ce5'"
1654 (_concat
1654 (_concat
1655 (_concat
1655 (_concat
1656 (_concat
1656 (_concat
1657 ('symbol', '278')
1657 ('symbol', '278')
1658 ('string', '5f5'))
1658 ('string', '5f5'))
1659 ('symbol', '1ee'))
1659 ('symbol', '1ee'))
1660 ('string', 'ce5'))
1660 ('string', 'ce5'))
1661 ('string', '2785f51eece5')
1661 ('string', '2785f51eece5')
1662 * set:
1662 * set:
1663 <baseset [0]>
1663 <baseset [0]>
1664 0
1664 0
1665
1665
1666 $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc
1666 $ echo 'cat4($1, $2, $3, $4) = $1 ## $2 ## $3 ## $4' >> .hg/hgrc
1667 $ try "cat4(278, '5f5', 1ee, 'ce5')"
1667 $ try "cat4(278, '5f5', 1ee, 'ce5')"
1668 (func
1668 (func
1669 ('symbol', 'cat4')
1669 ('symbol', 'cat4')
1670 (list
1670 (list
1671 (list
1671 (list
1672 (list
1672 (list
1673 ('symbol', '278')
1673 ('symbol', '278')
1674 ('string', '5f5'))
1674 ('string', '5f5'))
1675 ('symbol', '1ee'))
1675 ('symbol', '1ee'))
1676 ('string', 'ce5')))
1676 ('string', 'ce5')))
1677 (_concat
1677 (_concat
1678 (_concat
1678 (_concat
1679 (_concat
1679 (_concat
1680 ('symbol', '278')
1680 ('symbol', '278')
1681 ('string', '5f5'))
1681 ('string', '5f5'))
1682 ('symbol', '1ee'))
1682 ('symbol', '1ee'))
1683 ('string', 'ce5'))
1683 ('string', 'ce5'))
1684 ('string', '2785f51eece5')
1684 ('string', '2785f51eece5')
1685 * set:
1685 * set:
1686 <baseset [0]>
1686 <baseset [0]>
1687 0
1687 0
1688
1688
1689 (check concatenation in alias nesting)
1689 (check concatenation in alias nesting)
1690
1690
1691 $ echo 'cat2($1, $2) = $1 ## $2' >> .hg/hgrc
1691 $ echo 'cat2($1, $2) = $1 ## $2' >> .hg/hgrc
1692 $ echo 'cat2x2($1, $2, $3, $4) = cat2($1 ## $2, $3 ## $4)' >> .hg/hgrc
1692 $ echo 'cat2x2($1, $2, $3, $4) = cat2($1 ## $2, $3 ## $4)' >> .hg/hgrc
1693 $ log "cat2x2(278, '5f5', 1ee, 'ce5')"
1693 $ log "cat2x2(278, '5f5', 1ee, 'ce5')"
1694 0
1694 0
1695
1695
1696 (check operator priority)
1696 (check operator priority)
1697
1697
1698 $ echo 'cat2n2($1, $2, $3, $4) = $1 ## $2 or $3 ## $4~2' >> .hg/hgrc
1698 $ echo 'cat2n2($1, $2, $3, $4) = $1 ## $2 or $3 ## $4~2' >> .hg/hgrc
1699 $ log "cat2n2(2785f5, 1eece5, 24286f, 4ae135)"
1699 $ log "cat2n2(2785f5, 1eece5, 24286f, 4ae135)"
1700 0
1700 0
1701 4
1701 4
1702
1702
1703 $ cd ..
1703 $ cd ..
1704
1704
1705 prepare repository that has "default" branches of multiple roots
1706
1707 $ hg init namedbranch
1708 $ cd namedbranch
1709
1710 $ echo default0 >> a
1711 $ hg ci -Aqm0
1712 $ echo default1 >> a
1713 $ hg ci -m1
1714
1715 $ hg branch -q stable
1716 $ echo stable2 >> a
1717 $ hg ci -m2
1718 $ echo stable3 >> a
1719 $ hg ci -m3
1720
1721 $ hg update -q null
1722 $ echo default4 >> a
1723 $ hg ci -Aqm4
1724 $ echo default5 >> a
1725 $ hg ci -m5
1726
1727 "null" revision belongs to "default" branch (issue4683)
1728
1729 $ log 'branch(null)'
1730 0
1731 1
1732 4
1733 5
1734
1735 "null" revision belongs to "default" branch, but it shouldn't appear in set
1736 unless explicitly specified (issue4682)
1737
1738 $ log 'children(branch(default))'
1739 1
1740 2
1741 5
1742
1743 $ cd ..
1744
1705 test author/desc/keyword in problematic encoding
1745 test author/desc/keyword in problematic encoding
1706 # unicode: cp932:
1746 # unicode: cp932:
1707 # u30A2 0x83 0x41(= 'A')
1747 # u30A2 0x83 0x41(= 'A')
1708 # u30C2 0x83 0x61(= 'a')
1748 # u30C2 0x83 0x61(= 'a')
1709
1749
1710 $ hg init problematicencoding
1750 $ hg init problematicencoding
1711 $ cd problematicencoding
1751 $ cd problematicencoding
1712
1752
1713 $ python > setup.sh <<EOF
1753 $ python > setup.sh <<EOF
1714 > print u'''
1754 > print u'''
1715 > echo a > text
1755 > echo a > text
1716 > hg add text
1756 > hg add text
1717 > hg --encoding utf-8 commit -u '\u30A2' -m none
1757 > hg --encoding utf-8 commit -u '\u30A2' -m none
1718 > echo b > text
1758 > echo b > text
1719 > hg --encoding utf-8 commit -u '\u30C2' -m none
1759 > hg --encoding utf-8 commit -u '\u30C2' -m none
1720 > echo c > text
1760 > echo c > text
1721 > hg --encoding utf-8 commit -u none -m '\u30A2'
1761 > hg --encoding utf-8 commit -u none -m '\u30A2'
1722 > echo d > text
1762 > echo d > text
1723 > hg --encoding utf-8 commit -u none -m '\u30C2'
1763 > hg --encoding utf-8 commit -u none -m '\u30C2'
1724 > '''.encode('utf-8')
1764 > '''.encode('utf-8')
1725 > EOF
1765 > EOF
1726 $ sh < setup.sh
1766 $ sh < setup.sh
1727
1767
1728 test in problematic encoding
1768 test in problematic encoding
1729 $ python > test.sh <<EOF
1769 $ python > test.sh <<EOF
1730 > print u'''
1770 > print u'''
1731 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
1771 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30A2)'
1732 > echo ====
1772 > echo ====
1733 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
1773 > hg --encoding cp932 log --template '{rev}\\n' -r 'author(\u30C2)'
1734 > echo ====
1774 > echo ====
1735 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
1775 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30A2)'
1736 > echo ====
1776 > echo ====
1737 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
1777 > hg --encoding cp932 log --template '{rev}\\n' -r 'desc(\u30C2)'
1738 > echo ====
1778 > echo ====
1739 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
1779 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30A2)'
1740 > echo ====
1780 > echo ====
1741 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
1781 > hg --encoding cp932 log --template '{rev}\\n' -r 'keyword(\u30C2)'
1742 > '''.encode('cp932')
1782 > '''.encode('cp932')
1743 > EOF
1783 > EOF
1744 $ sh < test.sh
1784 $ sh < test.sh
1745 0
1785 0
1746 ====
1786 ====
1747 1
1787 1
1748 ====
1788 ====
1749 2
1789 2
1750 ====
1790 ====
1751 3
1791 3
1752 ====
1792 ====
1753 0
1793 0
1754 2
1794 2
1755 ====
1795 ====
1756 1
1796 1
1757 3
1797 3
1758
1798
1759 test error message of bad revset
1799 test error message of bad revset
1760 $ hg log -r 'foo\\'
1800 $ hg log -r 'foo\\'
1761 hg: parse error at 3: syntax error in revset 'foo\\'
1801 hg: parse error at 3: syntax error in revset 'foo\\'
1762 [255]
1802 [255]
1763
1803
1764 $ cd ..
1804 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now