##// END OF EJS Templates
hgweb: ignore filtered revision in revnav...
Pierre-Yves David -
r18426:01638b51 default
parent child Browse files
Show More
@@ -1,402 +1,404 b''
1 1 # hgweb/webutil.py - utility library for the web interface.
2 2 #
3 3 # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
4 4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 5 #
6 6 # This software may be used and distributed according to the terms of the
7 7 # GNU General Public License version 2 or any later version.
8 8
9 9 import os, copy
10 10 from mercurial import match, patch, scmutil, error, ui, util
11 11 from mercurial.i18n import _
12 12 from mercurial.node import hex, nullid
13 13 from common import ErrorResponse
14 14 from common import HTTP_NOT_FOUND
15 15 import difflib
16 16
17 17 def up(p):
18 18 if p[0] != "/":
19 19 p = "/" + p
20 20 if p[-1] == "/":
21 21 p = p[:-1]
22 22 up = os.path.dirname(p)
23 23 if up == "/":
24 24 return "/"
25 25 return up + "/"
26 26
27 27 def _navseq(step, firststep=None):
28 28 if firststep:
29 29 yield firststep
30 30 if firststep >= 20 and firststep <= 40:
31 31 firststep = 50
32 32 yield firststep
33 33 assert step > 0
34 34 assert firststep > 0
35 35 while step <= firststep:
36 36 step *= 10
37 37 while True:
38 38 yield 1 * step
39 39 yield 3 * step
40 40 step *= 10
41 41
42 42 class revnav(object):
43 43
44 44 def __init__(self, repo):
45 45 """Navigation generation object
46 46
47 47 :repo: repo object we generate nav for
48 48 """
49 49 # used for hex generation
50 50 self._revlog = repo.changelog
51 51
52 52 def __nonzero__(self):
53 53 """return True if any revision to navigate over"""
54 54 try:
55 55 self._revlog.node(0)
56 56 return True
57 57 except error.RepoError:
58 58 return False
59 59
60 60 def hex(self, rev):
61 61 return hex(self._revlog.node(rev))
62 62
63 63 def gen(self, pos, pagelen, limit):
64 64 """computes label and revision id for navigation link
65 65
66 66 :pos: is the revision relative to which we generate navigation.
67 67 :pagelen: the size of each navigation page
68 68 :limit: how far shall we link
69 69
70 70 The return is:
71 71 - a single element tuple
72 72 - containing a dictionary with a `before` and `after` key
73 73 - values are generator functions taking arbitrary number of kwargs
74 74 - yield items are dictionaries with `label` and `node` keys
75 75 """
76 76 if not self:
77 77 # empty repo
78 78 return ({'before': (), 'after': ()},)
79 79
80 80 targets = []
81 81 for f in _navseq(1, pagelen):
82 82 if f > limit:
83 83 break
84 84 targets.append(pos + f)
85 85 targets.append(pos - f)
86 86 targets.sort()
87 87
88 88 navbefore = [("(0)", self.hex(0))]
89 89 navafter = []
90 90 for rev in targets:
91 if rev not in self._revlog:
92 continue
91 93 if pos < rev < limit:
92 94 navafter.append(("+%d" % f, self.hex(rev)))
93 95 if 0 < rev < pos:
94 96 navbefore.append(("-%d" % f, self.hex(rev)))
95 97
96 98
97 99 navafter.append(("tip", "tip"))
98 100
99 101 data = lambda i: {"label": i[0], "node": i[1]}
100 102 return ({'before': lambda **map: (data(i) for i in navbefore),
101 103 'after': lambda **map: (data(i) for i in navafter)},)
102 104
103 105 class filerevnav(revnav):
104 106
105 107 def __init__(self, repo, path):
106 108 """Navigation generation object
107 109
108 110 :repo: repo object we generate nav for
109 111 :path: path of the file we generate nav for
110 112 """
111 113 # used for iteration
112 114 self._changelog = repo.unfiltered().changelog
113 115 # used for hex generation
114 116 self._revlog = repo.file(path)
115 117
116 118 def hex(self, rev):
117 119 return hex(self._changelog.node(self._revlog.linkrev(rev)))
118 120
119 121
120 122 def _siblings(siblings=[], hiderev=None):
121 123 siblings = [s for s in siblings if s.node() != nullid]
122 124 if len(siblings) == 1 and siblings[0].rev() == hiderev:
123 125 return
124 126 for s in siblings:
125 127 d = {'node': s.hex(), 'rev': s.rev()}
126 128 d['user'] = s.user()
127 129 d['date'] = s.date()
128 130 d['description'] = s.description()
129 131 d['branch'] = s.branch()
130 132 if util.safehasattr(s, 'path'):
131 133 d['file'] = s.path()
132 134 yield d
133 135
134 136 def parents(ctx, hide=None):
135 137 return _siblings(ctx.parents(), hide)
136 138
137 139 def children(ctx, hide=None):
138 140 return _siblings(ctx.children(), hide)
139 141
140 142 def renamelink(fctx):
141 143 r = fctx.renamed()
142 144 if r:
143 145 return [dict(file=r[0], node=hex(r[1]))]
144 146 return []
145 147
146 148 def nodetagsdict(repo, node):
147 149 return [{"name": i} for i in repo.nodetags(node)]
148 150
149 151 def nodebookmarksdict(repo, node):
150 152 return [{"name": i} for i in repo.nodebookmarks(node)]
151 153
152 154 def nodebranchdict(repo, ctx):
153 155 branches = []
154 156 branch = ctx.branch()
155 157 # If this is an empty repo, ctx.node() == nullid,
156 158 # ctx.branch() == 'default'.
157 159 try:
158 160 branchnode = repo.branchtip(branch)
159 161 except error.RepoLookupError:
160 162 branchnode = None
161 163 if branchnode == ctx.node():
162 164 branches.append({"name": branch})
163 165 return branches
164 166
165 167 def nodeinbranch(repo, ctx):
166 168 branches = []
167 169 branch = ctx.branch()
168 170 try:
169 171 branchnode = repo.branchtip(branch)
170 172 except error.RepoLookupError:
171 173 branchnode = None
172 174 if branch != 'default' and branchnode != ctx.node():
173 175 branches.append({"name": branch})
174 176 return branches
175 177
176 178 def nodebranchnodefault(ctx):
177 179 branches = []
178 180 branch = ctx.branch()
179 181 if branch != 'default':
180 182 branches.append({"name": branch})
181 183 return branches
182 184
183 185 def showtag(repo, tmpl, t1, node=nullid, **args):
184 186 for t in repo.nodetags(node):
185 187 yield tmpl(t1, tag=t, **args)
186 188
187 189 def showbookmark(repo, tmpl, t1, node=nullid, **args):
188 190 for t in repo.nodebookmarks(node):
189 191 yield tmpl(t1, bookmark=t, **args)
190 192
191 193 def cleanpath(repo, path):
192 194 path = path.lstrip('/')
193 195 return scmutil.canonpath(repo.root, '', path)
194 196
195 197 def changeidctx (repo, changeid):
196 198 try:
197 199 ctx = repo[changeid]
198 200 except error.RepoError:
199 201 man = repo.manifest
200 202 ctx = repo[man.linkrev(man.rev(man.lookup(changeid)))]
201 203
202 204 return ctx
203 205
204 206 def changectx (repo, req):
205 207 changeid = "tip"
206 208 if 'node' in req.form:
207 209 changeid = req.form['node'][0]
208 210 ipos=changeid.find(':')
209 211 if ipos != -1:
210 212 changeid = changeid[(ipos + 1):]
211 213 elif 'manifest' in req.form:
212 214 changeid = req.form['manifest'][0]
213 215
214 216 return changeidctx(repo, changeid)
215 217
216 218 def basechangectx(repo, req):
217 219 if 'node' in req.form:
218 220 changeid = req.form['node'][0]
219 221 ipos=changeid.find(':')
220 222 if ipos != -1:
221 223 changeid = changeid[:ipos]
222 224 return changeidctx(repo, changeid)
223 225
224 226 return None
225 227
226 228 def filectx(repo, req):
227 229 if 'file' not in req.form:
228 230 raise ErrorResponse(HTTP_NOT_FOUND, 'file not given')
229 231 path = cleanpath(repo, req.form['file'][0])
230 232 if 'node' in req.form:
231 233 changeid = req.form['node'][0]
232 234 elif 'filenode' in req.form:
233 235 changeid = req.form['filenode'][0]
234 236 else:
235 237 raise ErrorResponse(HTTP_NOT_FOUND, 'node or filenode not given')
236 238 try:
237 239 fctx = repo[changeid][path]
238 240 except error.RepoError:
239 241 fctx = repo.filectx(path, fileid=changeid)
240 242
241 243 return fctx
242 244
243 245 def listfilediffs(tmpl, files, node, max):
244 246 for f in files[:max]:
245 247 yield tmpl('filedifflink', node=hex(node), file=f)
246 248 if len(files) > max:
247 249 yield tmpl('fileellipses')
248 250
249 251 def diffs(repo, tmpl, ctx, basectx, files, parity, style):
250 252
251 253 def countgen():
252 254 start = 1
253 255 while True:
254 256 yield start
255 257 start += 1
256 258
257 259 blockcount = countgen()
258 260 def prettyprintlines(diff, blockno):
259 261 for lineno, l in enumerate(diff.splitlines(True)):
260 262 lineno = "%d.%d" % (blockno, lineno + 1)
261 263 if l.startswith('+'):
262 264 ltype = "difflineplus"
263 265 elif l.startswith('-'):
264 266 ltype = "difflineminus"
265 267 elif l.startswith('@'):
266 268 ltype = "difflineat"
267 269 else:
268 270 ltype = "diffline"
269 271 yield tmpl(ltype,
270 272 line=l,
271 273 lineid="l%s" % lineno,
272 274 linenumber="% 8s" % lineno)
273 275
274 276 if files:
275 277 m = match.exact(repo.root, repo.getcwd(), files)
276 278 else:
277 279 m = match.always(repo.root, repo.getcwd())
278 280
279 281 diffopts = patch.diffopts(repo.ui, untrusted=True)
280 282 if basectx is None:
281 283 parents = ctx.parents()
282 284 node1 = parents and parents[0].node() or nullid
283 285 else:
284 286 node1 = basectx.node()
285 287 node2 = ctx.node()
286 288
287 289 block = []
288 290 for chunk in patch.diff(repo, node1, node2, m, opts=diffopts):
289 291 if chunk.startswith('diff') and block:
290 292 blockno = blockcount.next()
291 293 yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
292 294 lines=prettyprintlines(''.join(block), blockno))
293 295 block = []
294 296 if chunk.startswith('diff') and style != 'raw':
295 297 chunk = ''.join(chunk.splitlines(True)[1:])
296 298 block.append(chunk)
297 299 blockno = blockcount.next()
298 300 yield tmpl('diffblock', parity=parity.next(), blockno=blockno,
299 301 lines=prettyprintlines(''.join(block), blockno))
300 302
301 303 def compare(tmpl, context, leftlines, rightlines):
302 304 '''Generator function that provides side-by-side comparison data.'''
303 305
304 306 def compline(type, leftlineno, leftline, rightlineno, rightline):
305 307 lineid = leftlineno and ("l%s" % leftlineno) or ''
306 308 lineid += rightlineno and ("r%s" % rightlineno) or ''
307 309 return tmpl('comparisonline',
308 310 type=type,
309 311 lineid=lineid,
310 312 leftlinenumber="% 6s" % (leftlineno or ''),
311 313 leftline=leftline or '',
312 314 rightlinenumber="% 6s" % (rightlineno or ''),
313 315 rightline=rightline or '')
314 316
315 317 def getblock(opcodes):
316 318 for type, llo, lhi, rlo, rhi in opcodes:
317 319 len1 = lhi - llo
318 320 len2 = rhi - rlo
319 321 count = min(len1, len2)
320 322 for i in xrange(count):
321 323 yield compline(type=type,
322 324 leftlineno=llo + i + 1,
323 325 leftline=leftlines[llo + i],
324 326 rightlineno=rlo + i + 1,
325 327 rightline=rightlines[rlo + i])
326 328 if len1 > len2:
327 329 for i in xrange(llo + count, lhi):
328 330 yield compline(type=type,
329 331 leftlineno=i + 1,
330 332 leftline=leftlines[i],
331 333 rightlineno=None,
332 334 rightline=None)
333 335 elif len2 > len1:
334 336 for i in xrange(rlo + count, rhi):
335 337 yield compline(type=type,
336 338 leftlineno=None,
337 339 leftline=None,
338 340 rightlineno=i + 1,
339 341 rightline=rightlines[i])
340 342
341 343 s = difflib.SequenceMatcher(None, leftlines, rightlines)
342 344 if context < 0:
343 345 yield tmpl('comparisonblock', lines=getblock(s.get_opcodes()))
344 346 else:
345 347 for oc in s.get_grouped_opcodes(n=context):
346 348 yield tmpl('comparisonblock', lines=getblock(oc))
347 349
348 350 def diffstatgen(ctx, basectx):
349 351 '''Generator function that provides the diffstat data.'''
350 352
351 353 stats = patch.diffstatdata(util.iterlines(ctx.diff(basectx)))
352 354 maxname, maxtotal, addtotal, removetotal, binary = patch.diffstatsum(stats)
353 355 while True:
354 356 yield stats, maxname, maxtotal, addtotal, removetotal, binary
355 357
356 358 def diffsummary(statgen):
357 359 '''Return a short summary of the diff.'''
358 360
359 361 stats, maxname, maxtotal, addtotal, removetotal, binary = statgen.next()
360 362 return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % (
361 363 len(stats), addtotal, removetotal)
362 364
363 365 def diffstat(tmpl, ctx, statgen, parity):
364 366 '''Return a diffstat template for each file in the diff.'''
365 367
366 368 stats, maxname, maxtotal, addtotal, removetotal, binary = statgen.next()
367 369 files = ctx.files()
368 370
369 371 def pct(i):
370 372 if maxtotal == 0:
371 373 return 0
372 374 return (float(i) / maxtotal) * 100
373 375
374 376 fileno = 0
375 377 for filename, adds, removes, isbinary in stats:
376 378 template = filename in files and 'diffstatlink' or 'diffstatnolink'
377 379 total = adds + removes
378 380 fileno += 1
379 381 yield tmpl(template, node=ctx.hex(), file=filename, fileno=fileno,
380 382 total=total, addpct=pct(adds), removepct=pct(removes),
381 383 parity=parity.next())
382 384
383 385 class sessionvars(object):
384 386 def __init__(self, vars, start='?'):
385 387 self.start = start
386 388 self.vars = vars
387 389 def __getitem__(self, key):
388 390 return self.vars[key]
389 391 def __setitem__(self, key, value):
390 392 self.vars[key] = value
391 393 def __copy__(self):
392 394 return sessionvars(copy.copy(self.vars), self.start)
393 395 def __iter__(self):
394 396 separator = self.start
395 397 for key, value in sorted(self.vars.iteritems()):
396 398 yield {'name': key, 'value': str(value), 'separator': separator}
397 399 separator = '&'
398 400
399 401 class wsgiui(ui.ui):
400 402 # default termwidth breaks under mod_wsgi
401 403 def termwidth(self):
402 404 return 80
@@ -1,711 +1,710 b''
1 1 $ cat >> $HGRCPATH << EOF
2 2 > [extensions]
3 3 > graphlog=
4 4 > [phases]
5 5 > # public changeset are not obsolete
6 6 > publish=false
7 7 > EOF
8 8 $ mkcommit() {
9 9 > echo "$1" > "$1"
10 10 > hg add "$1"
11 11 > hg ci -m "add $1"
12 12 > }
13 13 $ getid() {
14 14 > hg id --debug --hidden -ir "desc('$1')"
15 15 > }
16 16
17 17 $ cat > debugkeys.py <<EOF
18 18 > def reposetup(ui, repo):
19 19 > class debugkeysrepo(repo.__class__):
20 20 > def listkeys(self, namespace):
21 21 > ui.write('listkeys %s\n' % (namespace,))
22 22 > return super(debugkeysrepo, self).listkeys(namespace)
23 23 >
24 24 > if repo.local():
25 25 > repo.__class__ = debugkeysrepo
26 26 > EOF
27 27
28 28 $ hg init tmpa
29 29 $ cd tmpa
30 30 $ mkcommit kill_me
31 31
32 32 Checking that the feature is properly disabled
33 33
34 34 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
35 35 abort: obsolete feature is not enabled on this repo
36 36 [255]
37 37
38 38 Enabling it
39 39
40 40 $ cat > ../obs.py << EOF
41 41 > import mercurial.obsolete
42 42 > mercurial.obsolete._enabled = True
43 43 > EOF
44 44 $ echo '[extensions]' >> $HGRCPATH
45 45 $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
46 46
47 47 Killing a single changeset without replacement
48 48
49 49 $ hg debugobsolete 0
50 50 abort: changeset references must be full hexadecimal node identifiers
51 51 [255]
52 52 $ hg debugobsolete '00'
53 53 abort: changeset references must be full hexadecimal node identifiers
54 54 [255]
55 55 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
56 56 $ hg debugobsolete
57 57 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 {'date': '0 0', 'user': 'babar'}
58 58 $ cd ..
59 59
60 60 Killing a single changeset with replacement
61 61
62 62 $ hg init tmpb
63 63 $ cd tmpb
64 64 $ mkcommit a
65 65 $ mkcommit b
66 66 $ mkcommit original_c
67 67 $ hg up "desc('b')"
68 68 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
69 69 $ mkcommit new_c
70 70 created new head
71 71 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
72 72 $ hg debugobsolete --flag 12 `getid original_c` `getid new_c` -d '56 12'
73 73 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
74 74 2:245bde4270cd add original_c
75 75 $ hg debugobsolete
76 76 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
77 77
78 78 do it again (it read the obsstore before adding new changeset)
79 79
80 80 $ hg up '.^'
81 81 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
82 82 $ mkcommit new_2_c
83 83 created new head
84 84 $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
85 85 $ hg debugobsolete
86 86 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
87 87 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
88 88
89 89 Register two markers with a missing node
90 90
91 91 $ hg up '.^'
92 92 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
93 93 $ mkcommit new_3_c
94 94 created new head
95 95 $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
96 96 $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
97 97 $ hg debugobsolete
98 98 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
99 99 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
100 100 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
101 101 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
102 102
103 103 Refuse pathological nullid successors
104 104 $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
105 105 transaction abort!
106 106 rollback completed
107 107 abort: bad obsolescence marker detected: invalid successors nullid
108 108 [255]
109 109
110 110 Check that graphlog detect that a changeset is obsolete:
111 111
112 112 $ hg glog
113 113 @ changeset: 5:5601fb93a350
114 114 | tag: tip
115 115 | parent: 1:7c3bad9141dc
116 116 | user: test
117 117 | date: Thu Jan 01 00:00:00 1970 +0000
118 118 | summary: add new_3_c
119 119 |
120 120 o changeset: 1:7c3bad9141dc
121 121 | user: test
122 122 | date: Thu Jan 01 00:00:00 1970 +0000
123 123 | summary: add b
124 124 |
125 125 o changeset: 0:1f0dee641bb7
126 126 user: test
127 127 date: Thu Jan 01 00:00:00 1970 +0000
128 128 summary: add a
129 129
130 130
131 131 check that heads does not report them
132 132
133 133 $ hg heads
134 134 changeset: 5:5601fb93a350
135 135 tag: tip
136 136 parent: 1:7c3bad9141dc
137 137 user: test
138 138 date: Thu Jan 01 00:00:00 1970 +0000
139 139 summary: add new_3_c
140 140
141 141 $ hg heads --hidden
142 142 changeset: 5:5601fb93a350
143 143 tag: tip
144 144 parent: 1:7c3bad9141dc
145 145 user: test
146 146 date: Thu Jan 01 00:00:00 1970 +0000
147 147 summary: add new_3_c
148 148
149 149 changeset: 4:ca819180edb9
150 150 parent: 1:7c3bad9141dc
151 151 user: test
152 152 date: Thu Jan 01 00:00:00 1970 +0000
153 153 summary: add new_2_c
154 154
155 155 changeset: 3:cdbce2fbb163
156 156 parent: 1:7c3bad9141dc
157 157 user: test
158 158 date: Thu Jan 01 00:00:00 1970 +0000
159 159 summary: add new_c
160 160
161 161 changeset: 2:245bde4270cd
162 162 user: test
163 163 date: Thu Jan 01 00:00:00 1970 +0000
164 164 summary: add original_c
165 165
166 166
167 167
168 168 check that summary does not report them
169 169
170 170 $ hg init ../sink
171 171 $ echo '[paths]' >> .hg/hgrc
172 172 $ echo 'default=../sink' >> .hg/hgrc
173 173 $ hg summary --remote
174 174 parent: 5:5601fb93a350 tip
175 175 add new_3_c
176 176 branch: default
177 177 commit: (clean)
178 178 update: (current)
179 179 remote: 3 outgoing
180 180
181 181 $ hg summary --remote --hidden
182 182 parent: 5:5601fb93a350 tip
183 183 add new_3_c
184 184 branch: default
185 185 commit: (clean)
186 186 update: 3 new changesets, 4 branch heads (merge)
187 187 remote: 3 outgoing
188 188
189 189 check that various commands work well with filtering
190 190
191 191 $ hg tip
192 192 changeset: 5:5601fb93a350
193 193 tag: tip
194 194 parent: 1:7c3bad9141dc
195 195 user: test
196 196 date: Thu Jan 01 00:00:00 1970 +0000
197 197 summary: add new_3_c
198 198
199 199 $ hg log -r 6
200 200 abort: unknown revision '6'!
201 201 [255]
202 202 $ hg log -r 4
203 203 abort: unknown revision '4'!
204 204 [255]
205 205
206 206 Check that public changeset are not accounted as obsolete:
207 207
208 208 $ hg --hidden phase --public 2
209 209 $ hg --config 'extensions.graphlog=' glog
210 210 @ changeset: 5:5601fb93a350
211 211 | tag: tip
212 212 | parent: 1:7c3bad9141dc
213 213 | user: test
214 214 | date: Thu Jan 01 00:00:00 1970 +0000
215 215 | summary: add new_3_c
216 216 |
217 217 | o changeset: 2:245bde4270cd
218 218 |/ user: test
219 219 | date: Thu Jan 01 00:00:00 1970 +0000
220 220 | summary: add original_c
221 221 |
222 222 o changeset: 1:7c3bad9141dc
223 223 | user: test
224 224 | date: Thu Jan 01 00:00:00 1970 +0000
225 225 | summary: add b
226 226 |
227 227 o changeset: 0:1f0dee641bb7
228 228 user: test
229 229 date: Thu Jan 01 00:00:00 1970 +0000
230 230 summary: add a
231 231
232 232
233 233 And that bumped changeset are detected
234 234 --------------------------------------
235 235
236 236 If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also
237 237 note that the bumped changeset (5:5601fb93a350) is not a direct successor of
238 238 the public changeset
239 239
240 240 $ hg log --hidden -r 'bumped()'
241 241 changeset: 5:5601fb93a350
242 242 tag: tip
243 243 parent: 1:7c3bad9141dc
244 244 user: test
245 245 date: Thu Jan 01 00:00:00 1970 +0000
246 246 summary: add new_3_c
247 247
248 248
249 249 And that we can't push bumped changeset
250 250
251 251 $ hg push ../tmpa -r 0 --force #(make repo related)
252 252 pushing to ../tmpa
253 253 searching for changes
254 254 warning: repository is unrelated
255 255 adding changesets
256 256 adding manifests
257 257 adding file changes
258 258 added 1 changesets with 1 changes to 1 files (+1 heads)
259 259 $ hg push ../tmpa
260 260 pushing to ../tmpa
261 261 searching for changes
262 262 abort: push includes bumped changeset: 5601fb93a350!
263 263 [255]
264 264
265 265 Fixing "bumped" situation
266 266 We need to create a clone of 5 and add a special marker with a flag
267 267
268 268 $ hg up '5^'
269 269 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
270 270 $ hg revert -ar 5
271 271 adding new_3_c
272 272 $ hg ci -m 'add n3w_3_c'
273 273 created new head
274 274 $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c`
275 275 $ hg log -r 'bumped()'
276 276 $ hg log -G
277 277 @ changeset: 6:6f9641995072
278 278 | tag: tip
279 279 | parent: 1:7c3bad9141dc
280 280 | user: test
281 281 | date: Thu Jan 01 00:00:00 1970 +0000
282 282 | summary: add n3w_3_c
283 283 |
284 284 | o changeset: 2:245bde4270cd
285 285 |/ user: test
286 286 | date: Thu Jan 01 00:00:00 1970 +0000
287 287 | summary: add original_c
288 288 |
289 289 o changeset: 1:7c3bad9141dc
290 290 | user: test
291 291 | date: Thu Jan 01 00:00:00 1970 +0000
292 292 | summary: add b
293 293 |
294 294 o changeset: 0:1f0dee641bb7
295 295 user: test
296 296 date: Thu Jan 01 00:00:00 1970 +0000
297 297 summary: add a
298 298
299 299
300 300
301 301
302 302 $ cd ..
303 303
304 304 Exchange Test
305 305 ============================
306 306
307 307 Destination repo does not have any data
308 308 ---------------------------------------
309 309
310 310 Try to pull markers
311 311 (extinct changeset are excluded but marker are pushed)
312 312
313 313 $ hg init tmpc
314 314 $ cd tmpc
315 315 $ hg pull ../tmpb
316 316 pulling from ../tmpb
317 317 requesting all changes
318 318 adding changesets
319 319 adding manifests
320 320 adding file changes
321 321 added 4 changesets with 4 changes to 4 files (+1 heads)
322 322 (run 'hg heads' to see heads, 'hg merge' to merge)
323 323 $ hg debugobsolete
324 324 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
325 325 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
326 326 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
327 327 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
328 328 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
329 329
330 330 Rollback//Transaction support
331 331
332 332 $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
333 333 $ hg debugobsolete
334 334 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
335 335 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
336 336 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
337 337 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
338 338 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
339 339 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 {'date': '1340 0', 'user': 'test'}
340 340 $ hg rollback -n
341 341 repository tip rolled back to revision 3 (undo debugobsolete)
342 342 $ hg rollback
343 343 repository tip rolled back to revision 3 (undo debugobsolete)
344 344 $ hg debugobsolete
345 345 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
346 346 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
347 347 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
348 348 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
349 349 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
350 350
351 351 $ cd ..
352 352
353 353 Try to pull markers
354 354
355 355 $ hg init tmpd
356 356 $ hg -R tmpb push tmpd
357 357 pushing to tmpd
358 358 searching for changes
359 359 adding changesets
360 360 adding manifests
361 361 adding file changes
362 362 added 4 changesets with 4 changes to 4 files (+1 heads)
363 363 $ hg -R tmpd debugobsolete
364 364 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
365 365 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
366 366 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
367 367 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
368 368 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
369 369
370 370 Check obsolete keys are exchanged only if source has an obsolete store
371 371
372 372 $ hg init empty
373 373 $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
374 374 pushing to tmpd
375 375 no changes found
376 376 listkeys phases
377 377 listkeys bookmarks
378 378 [1]
379 379
380 380 clone support
381 381 (markers are copied and extinct changesets are included to allow hardlinks)
382 382
383 383 $ hg clone tmpb clone-dest
384 384 updating to branch default
385 385 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
386 386 $ hg -R clone-dest log -G --hidden
387 387 @ changeset: 6:6f9641995072
388 388 | tag: tip
389 389 | parent: 1:7c3bad9141dc
390 390 | user: test
391 391 | date: Thu Jan 01 00:00:00 1970 +0000
392 392 | summary: add n3w_3_c
393 393 |
394 394 | x changeset: 5:5601fb93a350
395 395 |/ parent: 1:7c3bad9141dc
396 396 | user: test
397 397 | date: Thu Jan 01 00:00:00 1970 +0000
398 398 | summary: add new_3_c
399 399 |
400 400 | x changeset: 4:ca819180edb9
401 401 |/ parent: 1:7c3bad9141dc
402 402 | user: test
403 403 | date: Thu Jan 01 00:00:00 1970 +0000
404 404 | summary: add new_2_c
405 405 |
406 406 | x changeset: 3:cdbce2fbb163
407 407 |/ parent: 1:7c3bad9141dc
408 408 | user: test
409 409 | date: Thu Jan 01 00:00:00 1970 +0000
410 410 | summary: add new_c
411 411 |
412 412 | o changeset: 2:245bde4270cd
413 413 |/ user: test
414 414 | date: Thu Jan 01 00:00:00 1970 +0000
415 415 | summary: add original_c
416 416 |
417 417 o changeset: 1:7c3bad9141dc
418 418 | user: test
419 419 | date: Thu Jan 01 00:00:00 1970 +0000
420 420 | summary: add b
421 421 |
422 422 o changeset: 0:1f0dee641bb7
423 423 user: test
424 424 date: Thu Jan 01 00:00:00 1970 +0000
425 425 summary: add a
426 426
427 427 $ hg -R clone-dest debugobsolete
428 428 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
429 429 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
430 430 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
431 431 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
432 432 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
433 433
434 434
435 435 Destination repo have existing data
436 436 ---------------------------------------
437 437
438 438 On pull
439 439
440 440 $ hg init tmpe
441 441 $ cd tmpe
442 442 $ hg debugobsolete -d '1339 0' 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339
443 443 $ hg pull ../tmpb
444 444 pulling from ../tmpb
445 445 requesting all changes
446 446 adding changesets
447 447 adding manifests
448 448 adding file changes
449 449 added 4 changesets with 4 changes to 4 files (+1 heads)
450 450 (run 'hg heads' to see heads, 'hg merge' to merge)
451 451 $ hg debugobsolete
452 452 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'}
453 453 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
454 454 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
455 455 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
456 456 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
457 457 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
458 458
459 459
460 460 On push
461 461
462 462 $ hg push ../tmpc
463 463 pushing to ../tmpc
464 464 searching for changes
465 465 no changes found
466 466 [1]
467 467 $ hg -R ../tmpc debugobsolete
468 468 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C {'date': '56 12', 'user': 'test'}
469 469 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
470 470 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
471 471 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
472 472 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 {'date': '1338 0', 'user': 'test'}
473 473 2448244824482448244824482448244824482448 1339133913391339133913391339133913391339 0 {'date': '1339 0', 'user': 'test'}
474 474
475 475 detect outgoing obsolete and unstable
476 476 ---------------------------------------
477 477
478 478
479 479 $ hg glog
480 480 o changeset: 3:6f9641995072
481 481 | tag: tip
482 482 | parent: 1:7c3bad9141dc
483 483 | user: test
484 484 | date: Thu Jan 01 00:00:00 1970 +0000
485 485 | summary: add n3w_3_c
486 486 |
487 487 | o changeset: 2:245bde4270cd
488 488 |/ user: test
489 489 | date: Thu Jan 01 00:00:00 1970 +0000
490 490 | summary: add original_c
491 491 |
492 492 o changeset: 1:7c3bad9141dc
493 493 | user: test
494 494 | date: Thu Jan 01 00:00:00 1970 +0000
495 495 | summary: add b
496 496 |
497 497 o changeset: 0:1f0dee641bb7
498 498 user: test
499 499 date: Thu Jan 01 00:00:00 1970 +0000
500 500 summary: add a
501 501
502 502 $ hg up 'desc("n3w_3_c")'
503 503 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
504 504 $ mkcommit original_d
505 505 $ mkcommit original_e
506 506 $ hg debugobsolete `getid original_d` -d '0 0'
507 507 $ hg log -r 'obsolete()'
508 508 changeset: 4:94b33453f93b
509 509 user: test
510 510 date: Thu Jan 01 00:00:00 1970 +0000
511 511 summary: add original_d
512 512
513 513 $ hg glog -r '::unstable()'
514 514 @ changeset: 5:cda648ca50f5
515 515 | tag: tip
516 516 | user: test
517 517 | date: Thu Jan 01 00:00:00 1970 +0000
518 518 | summary: add original_e
519 519 |
520 520 x changeset: 4:94b33453f93b
521 521 | user: test
522 522 | date: Thu Jan 01 00:00:00 1970 +0000
523 523 | summary: add original_d
524 524 |
525 525 o changeset: 3:6f9641995072
526 526 | parent: 1:7c3bad9141dc
527 527 | user: test
528 528 | date: Thu Jan 01 00:00:00 1970 +0000
529 529 | summary: add n3w_3_c
530 530 |
531 531 o changeset: 1:7c3bad9141dc
532 532 | user: test
533 533 | date: Thu Jan 01 00:00:00 1970 +0000
534 534 | summary: add b
535 535 |
536 536 o changeset: 0:1f0dee641bb7
537 537 user: test
538 538 date: Thu Jan 01 00:00:00 1970 +0000
539 539 summary: add a
540 540
541 541
542 542 refuse to push obsolete changeset
543 543
544 544 $ hg push ../tmpc/ -r 'desc("original_d")'
545 545 pushing to ../tmpc/
546 546 searching for changes
547 547 abort: push includes obsolete changeset: 94b33453f93b!
548 548 [255]
549 549
550 550 refuse to push unstable changeset
551 551
552 552 $ hg push ../tmpc/
553 553 pushing to ../tmpc/
554 554 searching for changes
555 555 abort: push includes unstable changeset: cda648ca50f5!
556 556 [255]
557 557
558 558 Test that extinct changeset are properly detected
559 559
560 560 $ hg log -r 'extinct()'
561 561
562 562 Don't try to push extinct changeset
563 563
564 564 $ hg init ../tmpf
565 565 $ hg out ../tmpf
566 566 comparing with ../tmpf
567 567 searching for changes
568 568 changeset: 0:1f0dee641bb7
569 569 user: test
570 570 date: Thu Jan 01 00:00:00 1970 +0000
571 571 summary: add a
572 572
573 573 changeset: 1:7c3bad9141dc
574 574 user: test
575 575 date: Thu Jan 01 00:00:00 1970 +0000
576 576 summary: add b
577 577
578 578 changeset: 2:245bde4270cd
579 579 user: test
580 580 date: Thu Jan 01 00:00:00 1970 +0000
581 581 summary: add original_c
582 582
583 583 changeset: 3:6f9641995072
584 584 parent: 1:7c3bad9141dc
585 585 user: test
586 586 date: Thu Jan 01 00:00:00 1970 +0000
587 587 summary: add n3w_3_c
588 588
589 589 changeset: 4:94b33453f93b
590 590 user: test
591 591 date: Thu Jan 01 00:00:00 1970 +0000
592 592 summary: add original_d
593 593
594 594 changeset: 5:cda648ca50f5
595 595 tag: tip
596 596 user: test
597 597 date: Thu Jan 01 00:00:00 1970 +0000
598 598 summary: add original_e
599 599
600 600 $ hg push ../tmpf -f # -f because be push unstable too
601 601 pushing to ../tmpf
602 602 searching for changes
603 603 adding changesets
604 604 adding manifests
605 605 adding file changes
606 606 added 6 changesets with 6 changes to 6 files (+1 heads)
607 607
608 608 no warning displayed
609 609
610 610 $ hg push ../tmpf
611 611 pushing to ../tmpf
612 612 searching for changes
613 613 no changes found
614 614 [1]
615 615
616 616 Do not warn about new head when the new head is a successors of a remote one
617 617
618 618 $ hg glog
619 619 @ changeset: 5:cda648ca50f5
620 620 | tag: tip
621 621 | user: test
622 622 | date: Thu Jan 01 00:00:00 1970 +0000
623 623 | summary: add original_e
624 624 |
625 625 x changeset: 4:94b33453f93b
626 626 | user: test
627 627 | date: Thu Jan 01 00:00:00 1970 +0000
628 628 | summary: add original_d
629 629 |
630 630 o changeset: 3:6f9641995072
631 631 | parent: 1:7c3bad9141dc
632 632 | user: test
633 633 | date: Thu Jan 01 00:00:00 1970 +0000
634 634 | summary: add n3w_3_c
635 635 |
636 636 | o changeset: 2:245bde4270cd
637 637 |/ user: test
638 638 | date: Thu Jan 01 00:00:00 1970 +0000
639 639 | summary: add original_c
640 640 |
641 641 o changeset: 1:7c3bad9141dc
642 642 | user: test
643 643 | date: Thu Jan 01 00:00:00 1970 +0000
644 644 | summary: add b
645 645 |
646 646 o changeset: 0:1f0dee641bb7
647 647 user: test
648 648 date: Thu Jan 01 00:00:00 1970 +0000
649 649 summary: add a
650 650
651 651 $ hg up -q 'desc(n3w_3_c)'
652 652 $ mkcommit obsolete_e
653 653 created new head
654 654 $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'`
655 655 $ hg push ../tmpf
656 656 pushing to ../tmpf
657 657 searching for changes
658 658 adding changesets
659 659 adding manifests
660 660 adding file changes
661 661 added 1 changesets with 1 changes to 1 files (+1 heads)
662 662
663 663 check hgweb does not explode
664 664 ====================================
665 665
666 666 $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg
667 667 adding changesets
668 668 adding manifests
669 669 adding file changes
670 670 added 62 changesets with 63 changes to 9 files (+60 heads)
671 671 (run 'hg heads .' to see heads, 'hg merge' to merge)
672 672 $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`;
673 673 > do
674 674 > hg debugobsolete $node
675 675 > done
676 676 $ hg up tip
677 677 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
678 678
679 679 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
680 680 $ cat hg.pid >> $DAEMON_PIDS
681 681
682 #check changelog view
683 #
684 # $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'shortlog/'
685 # 200 Script output follows
682 check changelog view
683
684 $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'shortlog/'
685 200 Script output follows
686 686
687 687 #check graph view
688 688 #
689 689 # $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'graph'
690 690 # 200 Script output follows
691
692 691 check filelog view
693 692
694 693 $ "$TESTDIR/get-with-headers.py" --headeronly localhost:$HGPORT 'log/'`hg id --debug --id`/'babar'
695 694 200 Script output follows
696 695
697 696 $ kill `cat hg.pid`
698 697
699 698 Checking _enable=False warning if obsolete marker exists
700 699
701 700 $ echo '[extensions]' >> $HGRCPATH
702 701 $ echo "obs=!" >> $HGRCPATH
703 702 $ hg log -r tip
704 703 obsolete feature not enabled but 68 markers found!
705 704 changeset: 68:c15e9edfca13
706 705 tag: tip
707 706 parent: 7:50c51b361e60
708 707 user: test
709 708 date: Thu Jan 01 00:00:00 1970 +0000
710 709 summary: add celestine
711 710
General Comments 0
You need to be logged in to leave comments. Login now