##// END OF EJS Templates
amend: add config option to update time to current in hg amend (issue5828)...
Taapas Agrawal -
r41155:79f8f032 default
parent child Browse files
Show More
@@ -2443,6 +2443,12 b' def amend(ui, repo, old, extra, pats, op'
2443 user = opts.get('user') or old.user()
2443 user = opts.get('user') or old.user()
2444 date = opts.get('date') or old.date()
2444 date = opts.get('date') or old.date()
2445
2445
2446 if ui.configbool('rewrite', 'update-timestamp'):
2447 if opts.get('date'):
2448 pass
2449 else:
2450 date = dateutil.makedate()
2451
2446 # Parse the date to allow comparison between date and old.date()
2452 # Parse the date to allow comparison between date and old.date()
2447 date = dateutil.parsedate(date)
2453 date = dateutil.parsedate(date)
2448
2454
@@ -2558,13 +2564,15 b' def amend(ui, repo, old, extra, pats, op'
2558 if ((not changes)
2564 if ((not changes)
2559 and newdesc == old.description()
2565 and newdesc == old.description()
2560 and user == old.user()
2566 and user == old.user()
2561 and date == old.date()
2562 and pureextra == old.extra()):
2567 and pureextra == old.extra()):
2563 # nothing changed. continuing here would create a new node
2568 # nothing changed. continuing here would create a new node
2564 # anyway because of the amend_source noise.
2569 # anyway because of the amend_source noise.
2565 #
2570 #
2566 # This not what we expect from amend.
2571 # This not what we expect from amend.
2567 return old.node()
2572 if (date == old.date() or
2573 (ui.configbool('rewrite', 'update-timestamp') and
2574 not opts.get('date'))):
2575 return old.node()
2568
2576
2569 commitphase = None
2577 commitphase = None
2570 if opts.get('secret'):
2578 if opts.get('secret'):
@@ -991,6 +991,9 b" coreconfigitem('storage', 'mmap-threshol"
991 default='1MB',
991 default='1MB',
992 alias=[('experimental', 'mmapindexthreshold')],
992 alias=[('experimental', 'mmapindexthreshold')],
993 )
993 )
994 coreconfigitem('rewrite', 'update-timestamp',
995 default=False,
996 )
994 coreconfigitem('storage', 'new-repo-backend',
997 coreconfigitem('storage', 'new-repo-backend',
995 default='revlogv1',
998 default='revlogv1',
996 )
999 )
@@ -1806,6 +1806,13 b' have a definite end point.'
1806
1806
1807 Alias definitions for revsets. See :hg:`help revsets` for details.
1807 Alias definitions for revsets. See :hg:`help revsets` for details.
1808
1808
1809 ``rewrite``
1810 -----------
1811
1812 ``update-timestamp``
1813 If true, updates the date and time of the changeset to current. It is only
1814 applicable for hg amend in current version.
1815
1809 ``storage``
1816 ``storage``
1810 -----------
1817 -----------
1811
1818
@@ -365,3 +365,128 b' When history-editing-backup config optio'
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
General Comments 0
You need to be logged in to leave comments. Login now