##// END OF EJS Templates
fix: add a -s option to format a revision and its descendants...
Martin von Zweigbergk -
r45449:5205b46b default
parent child Browse files
Show More
@@ -214,6 +214,13 b' baseopt = ('
214 214 _(b'REV'),
215 215 )
216 216 revopt = (b'r', b'rev', [], _(b'revisions to fix'), _(b'REV'))
217 sourceopt = (
218 b's',
219 b'source',
220 [],
221 _(b'fix the specified revisions and their descendants'),
222 _(b'REV'),
223 )
217 224 wdiropt = (b'w', b'working-dir', False, _(b'fix the working directory'))
218 225 wholeopt = (b'', b'whole', False, _(b'always fix every line of a file'))
219 226 usage = _(b'[OPTION]... [FILE]...')
@@ -221,7 +228,7 b" usage = _(b'[OPTION]... [FILE]...')"
221 228
222 229 @command(
223 230 b'fix',
224 [allopt, baseopt, revopt, wdiropt, wholeopt],
231 [allopt, baseopt, revopt, sourceopt, wdiropt, wholeopt],
225 232 usage,
226 233 helpcategory=command.CATEGORY_FILE_CONTENTS,
227 234 )
@@ -249,8 +256,10 b' def fix(ui, repo, *pats, **opts):'
249 256 override this default behavior, though it is not usually desirable to do so.
250 257 """
251 258 opts = pycompat.byteskwargs(opts)
252 cmdutil.check_at_most_one_arg(opts, b'all', b'rev')
253 cmdutil.check_incompatible_arguments(opts, b'working_dir', [b'all'])
259 cmdutil.check_at_most_one_arg(opts, b'all', b'source', b'rev')
260 cmdutil.check_incompatible_arguments(
261 opts, b'working_dir', [b'all', b'source']
262 )
254 263
255 264 with repo.wlock(), repo.lock(), repo.transaction(b'fix'):
256 265 revstofix = getrevstofix(ui, repo, opts)
@@ -399,6 +408,14 b' def getrevstofix(ui, repo, opts):'
399 408 """Returns the set of revision numbers that should be fixed"""
400 409 if opts[b'all']:
401 410 revs = repo.revs(b'(not public() and not obsolete()) or wdir()')
411 elif opts[b'source']:
412 source_revs = scmutil.revrange(repo, opts[b'source'])
413 revs = set(repo.revs(b'%ld::', source_revs))
414 if wdirrev in source_revs:
415 # `wdir()::` is currently empty, so manually add wdir
416 revs.add(wdirrev)
417 if repo[b'.'].rev() in revs:
418 revs.add(wdirrev)
402 419 else:
403 420 revs = set(scmutil.revrange(repo, opts[b'rev']))
404 421 if opts.get(b'working_dir'):
@@ -21,6 +21,7 b' relationships. We indicate fixed file co'
21 21 $ cat >> $HGRCPATH <<EOF
22 22 > [extensions]
23 23 > fix =
24 > strip =
24 25 > [fix]
25 26 > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
26 27 > uppercase-whole-file:pattern=set:**
@@ -262,6 +263,111 b' Change A was never a baserev because non'
262 263
263 264 $ cd ..
264 265
266
267 Test the --source option. We only do this with obsstore on to avoid duplicating
268 test code. We rely on the other tests to prove that obsolescence is not an
269 important factor here.
270
271 #if obsstore-on
272 $ hg init source-arg
273 $ cd source-arg
274 $ printf "aaaa\n" > a
275 $ hg commit -Am "change A"
276 adding a
277 $ printf "bbbb\n" > b
278 $ hg commit -Am "change B"
279 adding b
280 $ printf "cccc\n" > c
281 $ hg commit -Am "change C"
282 adding c
283 $ hg checkout 0
284 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
285 $ printf "dddd\n" > d
286 $ hg commit -Am "change D"
287 adding d
288 created new head
289 $ hg log --graph --template '{rev} {desc}\n'
290 @ 3 change D
291 |
292 | o 2 change C
293 | |
294 | o 1 change B
295 |/
296 o 0 change A
297
298
299 Test passing 'wdir()' to --source
300 $ printf "xxxx\n" > x
301 $ hg add x
302 $ hg fix -s 'wdir()'
303 $ cat *
304 aaaa
305 dddd
306 XXXX
307
308 Test passing '.' to --source
309 $ printf "xxxx\n" > x
310 $ hg fix -s .
311 $ hg log --graph --template '{rev} {desc}\n'
312 @ 4 change D
313 |
314 | o 2 change C
315 | |
316 | o 1 change B
317 |/
318 o 0 change A
319
320 $ cat *
321 aaaa
322 DDDD
323 XXXX
324 $ hg strip -qf 4
325 $ hg co -q 3
326
327 Test passing other branch to --source
328 $ printf "xxxx\n" > x
329 $ hg add x
330 $ hg fix -s 2
331 $ hg log --graph --template '{rev} {desc}\n'
332 o 4 change C
333 |
334 | @ 3 change D
335 | |
336 o | 1 change B
337 |/
338 o 0 change A
339
340 $ hg cat -r 4 b c
341 bbbb
342 CCCC
343 $ cat *
344 aaaa
345 dddd
346 xxxx
347 $ hg strip -qf 4
348
349 Test passing multiple revisions to --source
350 $ hg fix -s '2 + .'
351 $ hg log --graph --template '{rev} {desc}\n'
352 @ 5 change D
353 |
354 | o 4 change C
355 | |
356 | o 1 change B
357 |/
358 o 0 change A
359
360 $ hg cat -r 4 b c
361 bbbb
362 CCCC
363 $ cat *
364 aaaa
365 DDDD
366 XXXX
367
368 $ cd ..
369 #endif
370
265 371 The --all flag should fix anything that wouldn't cause a problem if you fixed
266 372 it, including the working copy. Obsolete revisions are not fixed because that
267 373 could cause divergence. Public revisions would cause an abort because they are
@@ -108,6 +108,7 b' Help text for fix.'
108 108 --base REV [+] revisions to diff against (overrides automatic selection,
109 109 and applies to every revision being fixed)
110 110 -r --rev REV [+] revisions to fix
111 -s --source REV [+] fix the specified revisions and their descendants
111 112 -w --working-dir fix the working directory
112 113 --whole always fix every line of a file
113 114
General Comments 0
You need to be logged in to leave comments. Login now