##// END OF EJS Templates
histedit: add rewrite.update-timestamp support to fold and mess...
Taapas Agrawal -
r41249:704a3aa3 default
parent child Browse files
Show More
@@ -0,0 +1,21 b''
1 # mock out util.makedate() to supply testable values
2
3 from __future__ import absolute_import
4
5 import os
6
7 from mercurial import pycompat
8 from mercurial.utils import dateutil
9
10 def mockmakedate():
11 filename = os.path.join(os.environ['TESTTMP'], 'testtime')
12 try:
13 with open(filename, 'rb') as timef:
14 time = float(timef.read()) + 1
15 except IOError:
16 time = 0.0
17 with open(filename, 'wb') as timef:
18 timef.write(pycompat.bytestr(time))
19 return (time, 0)
20
21 dateutil.makedate = mockmakedate
@@ -220,6 +220,7 b' from mercurial import ('
220 util,
220 util,
221 )
221 )
222 from mercurial.utils import (
222 from mercurial.utils import (
223 dateutil,
223 stringutil,
224 stringutil,
224 )
225 )
225
226
@@ -527,9 +528,12 b' class histeditaction(object):'
527
528
528 editor = self.commiteditor()
529 editor = self.commiteditor()
529 commit = commitfuncfor(repo, rulectx)
530 commit = commitfuncfor(repo, rulectx)
530
531 if repo.ui.configbool('rewrite', 'update-timestamp'):
532 date = dateutil.makedate()
533 else:
534 date = rulectx.date()
531 commit(text=rulectx.description(), user=rulectx.user(),
535 commit(text=rulectx.description(), user=rulectx.user(),
532 date=rulectx.date(), extra=rulectx.extra(), editor=editor)
536 date=date, extra=rulectx.extra(), editor=editor)
533
537
534 def commiteditor(self):
538 def commiteditor(self):
535 """The editor to be used to edit the commit message."""
539 """The editor to be used to edit the commit message."""
@@ -810,6 +814,10 b' class fold(histeditaction):'
810 commitopts['date'] = ctx.date()
814 commitopts['date'] = ctx.date()
811 else:
815 else:
812 commitopts['date'] = max(ctx.date(), oldctx.date())
816 commitopts['date'] = max(ctx.date(), oldctx.date())
817 # if date is to be updated to current
818 if ui.configbool('rewrite', 'update-timestamp'):
819 commitopts['date'] = dateutil.makedate()
820
813 extra = ctx.extra().copy()
821 extra = ctx.extra().copy()
814 # histedit_source
822 # histedit_source
815 # note: ctx is likely a temporary commit but that the best we can do
823 # note: ctx is likely a temporary commit but that the best we can do
@@ -4,6 +4,7 b''
4 > [extensions]
4 > [extensions]
5 > histedit=
5 > histedit=
6 > strip=
6 > strip=
7 > mockmakedate = $TESTDIR/mockmakedate.py
7 > EOF
8 > EOF
8
9
9 $ initrepo ()
10 $ initrepo ()
@@ -484,6 +485,56 b' Attempting to fold a change into a publi'
484
485
485 $ cd ..
486 $ cd ..
486
487
488 ============================================
489 Test update-timestamp config option in mess|
490 ============================================
491
492 $ addwithdate ()
493 > {
494 > echo $1 > $1
495 > hg add $1
496 > hg ci -m $1 -d "$2 0"
497 > }
498
499 $ initrepo ()
500 > {
501 > hg init r2
502 > cd r2
503 > addwithdate a 1
504 > addwithdate b 2
505 > addwithdate c 3
506 > addwithdate d 4
507 > addwithdate e 5
508 > addwithdate f 6
509 > }
510
511 $ initrepo
512
513 log before edit
514
515 $ hg log --limit 1
516 changeset: 5:178e35e0ce73
517 tag: tip
518 user: test
519 date: Thu Jan 01 00:00:06 1970 +0000
520 summary: f
521
522 $ hg histedit tip --commands - 2>&1 --config rewrite.update-timestamp=True << EOF | fixbundle
523 > mess 178e35e0ce73 f
524 > EOF
525
526 log after edit
527
528 $ hg log --limit 1
529 changeset: 5:98bf456d476b
530 tag: tip
531 user: test
532 date: Thu Jan 01 00:00:00 1970 +0000
533 summary: f
534
535
536 $ cd ..
537
487 warn the user on editing tagged commits
538 warn the user on editing tagged commits
488
539
489 $ hg init issue4017
540 $ hg init issue4017
@@ -15,6 +15,7 b' Initialization'
15 > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
15 > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
16 > [extensions]
16 > [extensions]
17 > histedit=
17 > histedit=
18 > mockmakedate = $TESTDIR/mockmakedate.py
18 > EOF
19 > EOF
19
20
20
21
@@ -597,3 +598,110 b' Test rolling into a commit with multiple'
597 o 8f0162e483d0 aa
598 o 8f0162e483d0 aa
598
599
599
600
601 $ cd ..
602
603 ====================================
604 Test update-timestamp config option|
605 ====================================
606
607 $ addwithdate ()
608 > {
609 > echo $1 > $1
610 > hg add $1
611 > hg ci -m $1 -d "$2 0"
612 > }
613
614 $ initrepo ()
615 > {
616 > hg init r
617 > cd r
618 > addwithdate a 1
619 > addwithdate b 2
620 > addwithdate c 3
621 > addwithdate d 4
622 > addwithdate e 5
623 > addwithdate f 6
624 > }
625
626 $ initrepo
627
628 log before edit
629
630 $ hg log
631 changeset: 5:178e35e0ce73
632 tag: tip
633 user: test
634 date: Thu Jan 01 00:00:06 1970 +0000
635 summary: f
636
637 changeset: 4:1ddb6c90f2ee
638 user: test
639 date: Thu Jan 01 00:00:05 1970 +0000
640 summary: e
641
642 changeset: 3:532247a8969b
643 user: test
644 date: Thu Jan 01 00:00:04 1970 +0000
645 summary: d
646
647 changeset: 2:ff2c9fa2018b
648 user: test
649 date: Thu Jan 01 00:00:03 1970 +0000
650 summary: c
651
652 changeset: 1:97d72e5f12c7
653 user: test
654 date: Thu Jan 01 00:00:02 1970 +0000
655 summary: b
656
657 changeset: 0:8580ff50825a
658 user: test
659 date: Thu Jan 01 00:00:01 1970 +0000
660 summary: a
661
662
663 $ hg histedit 1ddb6c90f2ee --commands - 2>&1 --config rewrite.update-timestamp=True <<EOF | fixbundle
664 > pick 178e35e0ce73 f
665 > fold 1ddb6c90f2ee e
666 > EOF
667
668 log after edit
669 observe time from f is updated
670
671 $ hg log
672 changeset: 4:f7909b1863a2
673 tag: tip
674 user: test
675 date: Thu Jan 01 00:00:01 1970 +0000
676 summary: f
677
678 changeset: 3:532247a8969b
679 user: test
680 date: Thu Jan 01 00:00:04 1970 +0000
681 summary: d
682
683 changeset: 2:ff2c9fa2018b
684 user: test
685 date: Thu Jan 01 00:00:03 1970 +0000
686 summary: c
687
688 changeset: 1:97d72e5f12c7
689 user: test
690 date: Thu Jan 01 00:00:02 1970 +0000
691 summary: b
692
693 changeset: 0:8580ff50825a
694 user: test
695 date: Thu Jan 01 00:00:01 1970 +0000
696 summary: a
697
698 post-fold manifest
699 $ hg manifest
700 a
701 b
702 c
703 d
704 e
705 f
706
707 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now