comparison tests/test-amend.t @ 41120:79f8f032c706

amend: add config option to update time to current in hg amend (issue5828) The given config option i.e. `rewrite.update-timestamp` updates date to current when //True//. However when only date is to be updated to current with the working directory clean and no other attributes changing then it does not amend as stated in issue 5828. Further when `--date` flag is specified along with the new config option then `--date` is given priority over the config option. Differential Revision: https://phab.mercurial-scm.org/D5491
author Taapas Agrawal <taapas2897@gmail.com>
date Fri, 04 Jan 2019 20:27:17 +0530
parents 5abc47d4ca6b
children 14271b524d76
comparison
equal deleted inserted replaced
41119:685cf59a134f 41120:79f8f032c706
363 > EOF 363 > EOF
364 $ echo fixed > b 364 $ echo fixed > b
365 $ hg amend 365 $ hg amend
366 366
367 #endif 367 #endif
368 ==========================================
369 Test update-timestamp config option|
370 ==========================================
371 $ cat >> testmocks.py << EOF
372 > # mock out util.makedate() to supply testable values
373 > import os
374 > from mercurial import pycompat, util
375 > from mercurial.utils import dateutil
376 >
377 > def mockmakedate():
378 > filename = os.path.join(os.environ['TESTTMP'], 'testtime')
379 > try:
380 > with open(filename, 'rb') as timef:
381 > time = float(timef.read()) + 1
382 > except IOError:
383 > time = 0.0
384 > with open(filename, 'wb') as timef:
385 > timef.write(pycompat.bytestr(time))
386 > return (time, 0)
387 >
388 > dateutil.makedate = mockmakedate
389 > EOF
390
391 $ cat >> $HGRCPATH << EOF
392 > [extensions]
393 > amend=
394 > testmocks=`pwd`/testmocks.py
395 > EOF
396
397 $ hg init $TESTTMP/repo5
398 $ cd $TESTTMP/repo5
399 $ echo a>a
400 $ hg ci -Am 'commit 1'
401 adding a
402 #if obsstore-on
403
404 When updatetimestamp is False
405
406 $ hg amend --date '1997-1-1 0:1'
407 $ hg log --limit 1
408 changeset: 1:036a159be19d
409 tag: tip
410 parent: -1:000000000000
411 user: test
412 date: Wed Jan 01 00:01:00 1997 +0000
413 summary: commit 1
414
415 When update-timestamp is True and no other change than the date
416
417 $ hg amend --config rewrite.update-timestamp=True
418 nothing changed
419 [1]
420 $ hg log --limit 1
421 changeset: 1:036a159be19d
422 tag: tip
423 parent: -1:000000000000
424 user: test
425 date: Wed Jan 01 00:01:00 1997 +0000
426 summary: commit 1
427
428 When update-timestamp is True and there is other change than the date
429 $ hg amend --user foobar --config rewrite.update-timestamp=True
430 $ hg log --limit 1
431 changeset: 2:3ba48b892280
432 tag: tip
433 parent: -1:000000000000
434 user: foobar
435 date: Thu Jan 01 00:00:02 1970 +0000
436 summary: commit 1
437
438
439 When date option is applicable and update-timestamp is True
440 $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True
441 $ hg log --limit 1
442 changeset: 3:626aee031885
443 tag: tip
444 parent: -1:000000000000
445 user: foobar
446 date: Thu Jan 01 00:01:00 1998 +0000
447 summary: commit 1
448
449 #else
450
451 When updatetimestamp is False
452
453 $ hg amend --date '1997-1-1 0:1'
454 $ hg log --limit 1
455 changeset: 0:036a159be19d
456 tag: tip
457 user: test
458 date: Wed Jan 01 00:01:00 1997 +0000
459 summary: commit 1
460
461 When update-timestamp is True and no other change than the date
462
463 $ hg amend --config rewrite.update-timestamp=True
464 nothing changed
465 [1]
466 $ hg log --limit 1
467 changeset: 0:036a159be19d
468 tag: tip
469 user: test
470 date: Wed Jan 01 00:01:00 1997 +0000
471 summary: commit 1
472
473 When update-timestamp is True and there is other change than the date
474 $ hg amend --user foobar --config rewrite.update-timestamp=True
475 $ hg log --limit 1
476 changeset: 0:3ba48b892280
477 tag: tip
478 user: foobar
479 date: Thu Jan 01 00:00:02 1970 +0000
480 summary: commit 1
481
482
483 When date option is applicable and update-timestamp is True
484 $ hg amend --date '1998-1-1 0:1' --config rewrite.update-timestamp=True
485 $ hg log --limit 1
486 changeset: 0:626aee031885
487 tag: tip
488 user: foobar
489 date: Thu Jan 01 00:01:00 1998 +0000
490 summary: commit 1
491
492 #endif