comparison tests/test-clone.t @ 25761:0d37b9b21467

hg: support for auto sharing stores when cloning Many 3rd party consumers of Mercurial have created wrappers to essentially perform clone+share as a single operation. This is especially popular in automated processes like continuous integration systems. The Jenkins CI software and Mozilla's Firefox release automation infrastructure have both implemented custom code that effectively perform clone+share. The common use case here is that clients want to obtain N>1 checkouts while minimizing disk space and network requirements. Furthermore, they often don't care that a clone is an exact mirror of a remote: they are simply looking to obtain checkouts of specific revisions. When multiple third parties implement a similar feature, it's a good sign that the feature is worth adding to the core product. This patch adds support for an easy-to-use clone+share feature. The internal "clone" function now accepts options to control auto sharing during clone. When the auto share mode is active, a store will be created/updated under the base directory specified and a new repository pointing to the shared store will be created at the path specified by the user. The share extension has grown the ability to pass these options into the clone command/function. No command line options for this feature are added because we don't feel the feature will be popular enough to warrant their existence. There are two modes for auto share mode. In the default mode, the shared repo is derived from the first changeset (rev 0) in the remote repository. This enables related repositories existing at different URLs to automatically use the same storage. In environments that operate several repositories (separate repo for branch/head/bookmark or separate repo per user), this has the potential to drastically reduce storage and network requirements. In the other mode, the name is derived from the remote's path/URL.
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 08 Jul 2015 16:19:09 -0700
parents 701df761aa94
children 84074e4fc80f
comparison
equal deleted inserted replaced
25760:648323f41a89 25761:0d37b9b21467
672 $ hg -R src log -q 672 $ hg -R src log -q
673 0:e1bab28bca43 673 0:e1bab28bca43
674 $ hg clone -U -q src dst 674 $ hg clone -U -q src dst
675 $ hg -R dst log -q 675 $ hg -R dst log -q
676 0:e1bab28bca43 676 0:e1bab28bca43
677
678 Create repositories to test auto sharing functionality
679
680 $ cat >> $HGRCPATH << EOF
681 > [extensions]
682 > share=
683 > EOF
684
685 $ hg init empty
686 $ hg init source1a
687 $ cd source1a
688 $ echo initial1 > foo
689 $ hg -q commit -A -m initial
690 $ echo second > foo
691 $ hg commit -m second
677 $ cd .. 692 $ cd ..
693
694 $ hg init filteredrev0
695 $ cd filteredrev0
696 $ cat >> .hg/hgrc << EOF
697 > [experimental]
698 > evolution=createmarkers
699 > EOF
700 $ echo initial1 > foo
701 $ hg -q commit -A -m initial0
702 $ hg -q up -r null
703 $ echo initial2 > foo
704 $ hg -q commit -A -m initial1
705 $ hg debugobsolete c05d5c47a5cf81401869999f3d05f7d699d2b29a e082c1832e09a7d1e78b7fd49a592d372de854c8
706 $ cd ..
707
708 $ hg -q clone --pull source1a source1b
709 $ cd source1a
710 $ hg bookmark bookA
711 $ echo 1a > foo
712 $ hg commit -m 1a
713 $ cd ../source1b
714 $ hg -q up -r 0
715 $ echo head1 > foo
716 $ hg commit -m head1
717 created new head
718 $ hg bookmark head1
719 $ hg -q up -r 0
720 $ echo head2 > foo
721 $ hg commit -m head2
722 created new head
723 $ hg bookmark head2
724 $ hg -q up -r 0
725 $ hg branch branch1
726 marked working directory as branch branch1
727 (branches are permanent and global, did you want a bookmark?)
728 $ echo branch1 > foo
729 $ hg commit -m branch1
730 $ hg -q up -r 0
731 $ hg branch branch2
732 marked working directory as branch branch2
733 $ echo branch2 > foo
734 $ hg commit -m branch2
735 $ cd ..
736 $ hg init source2
737 $ cd source2
738 $ echo initial2 > foo
739 $ hg -q commit -A -m initial2
740 $ echo second > foo
741 $ hg commit -m second
742 $ cd ..
743
744 Clone with auto share from an empty repo should not result in share
745
746 $ mkdir share
747 $ hg --config share.pool=share clone empty share-empty
748 (not using pooled storage: remote appears to be empty)
749 updating to branch default
750 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
751 $ ls share
752 $ test -d share-empty/.hg/store
753 $ test -f share-empty/.hg/sharedpath
754 [1]
755
756 Clone with auto share from a repo with filtered revision 0 should not result in share
757
758 $ hg --config share.pool=share clone filteredrev0 share-filtered
759 (not using pooled storage: unable to resolve identity of remote)
760 requesting all changes
761 adding changesets
762 adding manifests
763 adding file changes
764 added 1 changesets with 1 changes to 1 files
765 updating to branch default
766 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
767
768 Clone from repo with content should result in shared store being created
769
770 $ hg --config share.pool=share clone source1a share-dest1a
771 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
772 requesting all changes
773 adding changesets
774 adding manifests
775 adding file changes
776 added 3 changesets with 3 changes to 1 files
777 updating working directory
778 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
779 searching for changes
780 no changes found
781 adding remote bookmark bookA
782
783 The shared repo should have been created
784
785 $ ls share
786 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
787
788 The destination should point to it
789
790 $ cat share-dest1a/.hg/sharedpath; echo
791 $TESTTMP/share/b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1/.hg
792
793 The destination should have bookmarks
794
795 $ hg -R share-dest1a bookmarks
796 bookA 2:e5bfe23c0b47
797
798 The default path should be the remote, not the share
799
800 $ hg -R share-dest1a config paths.default
801 $TESTTMP/source1a
802
803 Clone with existing share dir should result in pull + share
804
805 $ hg --config share.pool=share clone source1b share-dest1b
806 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
807 updating working directory
808 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
809 searching for changes
810 adding changesets
811 adding manifests
812 adding file changes
813 added 4 changesets with 4 changes to 1 files (+4 heads)
814 adding remote bookmark head1
815 adding remote bookmark head2
816
817 $ ls share
818 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
819
820 $ cat share-dest1b/.hg/sharedpath; echo
821 $TESTTMP/share/b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1/.hg
822
823 We only get bookmarks from the remote, not everything in the share
824
825 $ hg -R share-dest1b bookmarks
826 head1 3:4a8dc1ab4c13
827 head2 4:99f71071f117
828
829 Default path should be source, not share.
830
831 $ hg -R share-dest1b config paths.default
832 $TESTTMP/source1a
833
834 Clone from unrelated repo should result in new share
835
836 $ hg --config share.pool=share clone source2 share-dest2
837 (sharing from new pooled repository 22aeff664783fd44c6d9b435618173c118c3448e)
838 requesting all changes
839 adding changesets
840 adding manifests
841 adding file changes
842 added 2 changesets with 2 changes to 1 files
843 updating working directory
844 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
845 searching for changes
846 no changes found
847
848 $ ls share
849 22aeff664783fd44c6d9b435618173c118c3448e
850 b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
851
852 remote naming mode works as advertised
853
854 $ hg --config share.pool=shareremote --config share.poolnaming=remote clone source1a share-remote1a
855 (sharing from new pooled repository 195bb1fcdb595c14a6c13e0269129ed78f6debde)
856 requesting all changes
857 adding changesets
858 adding manifests
859 adding file changes
860 added 3 changesets with 3 changes to 1 files
861 updating working directory
862 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
863 searching for changes
864 no changes found
865 adding remote bookmark bookA
866
867 $ ls shareremote
868 195bb1fcdb595c14a6c13e0269129ed78f6debde
869
870 $ hg --config share.pool=shareremote --config share.poolnaming=remote clone source1b share-remote1b
871 (sharing from new pooled repository c0d4f83847ca2a873741feb7048a45085fd47c46)
872 requesting all changes
873 adding changesets
874 adding manifests
875 adding file changes
876 added 6 changesets with 6 changes to 1 files (+4 heads)
877 updating working directory
878 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
879 searching for changes
880 no changes found
881 adding remote bookmark head1
882 adding remote bookmark head2
883
884 $ ls shareremote
885 195bb1fcdb595c14a6c13e0269129ed78f6debde
886 c0d4f83847ca2a873741feb7048a45085fd47c46
887
888 request to clone a single revision is respected in sharing mode
889
890 $ hg --config share.pool=sharerevs clone -r 4a8dc1ab4c13 source1b share-1arev
891 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
892 adding changesets
893 adding manifests
894 adding file changes
895 added 2 changesets with 2 changes to 1 files
896 updating working directory
897 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
898 no changes found
899 adding remote bookmark head1
900
901 $ hg -R share-1arev log -G
902 @ changeset: 1:4a8dc1ab4c13
903 | bookmark: head1
904 | tag: tip
905 | user: test
906 | date: Thu Jan 01 00:00:00 1970 +0000
907 | summary: head1
908 |
909 o changeset: 0:b5f04eac9d8f
910 user: test
911 date: Thu Jan 01 00:00:00 1970 +0000
912 summary: initial
913
914
915 making another clone should only pull down requested rev
916
917 $ hg --config share.pool=sharerevs clone -r 99f71071f117 source1b share-1brev
918 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
919 updating working directory
920 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
921 searching for changes
922 adding changesets
923 adding manifests
924 adding file changes
925 added 1 changesets with 1 changes to 1 files (+1 heads)
926 adding remote bookmark head1
927 adding remote bookmark head2
928
929 $ hg -R share-1brev log -G
930 o changeset: 2:99f71071f117
931 | bookmark: head2
932 | tag: tip
933 | parent: 0:b5f04eac9d8f
934 | user: test
935 | date: Thu Jan 01 00:00:00 1970 +0000
936 | summary: head2
937 |
938 | @ changeset: 1:4a8dc1ab4c13
939 |/ bookmark: head1
940 | user: test
941 | date: Thu Jan 01 00:00:00 1970 +0000
942 | summary: head1
943 |
944 o changeset: 0:b5f04eac9d8f
945 user: test
946 date: Thu Jan 01 00:00:00 1970 +0000
947 summary: initial
948
949
950 Request to clone a single branch is respected in sharing mode
951
952 $ hg --config share.pool=sharebranch clone -b branch1 source1b share-1bbranch1
953 (sharing from new pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
954 adding changesets
955 adding manifests
956 adding file changes
957 added 2 changesets with 2 changes to 1 files
958 updating working directory
959 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
960 no changes found
961
962 $ hg -R share-1bbranch1 log -G
963 o changeset: 1:5f92a6c1a1b1
964 | branch: branch1
965 | tag: tip
966 | user: test
967 | date: Thu Jan 01 00:00:00 1970 +0000
968 | summary: branch1
969 |
970 @ changeset: 0:b5f04eac9d8f
971 user: test
972 date: Thu Jan 01 00:00:00 1970 +0000
973 summary: initial
974
975
976 $ hg --config share.pool=sharebranch clone -b branch2 source1b share-1bbranch2
977 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
978 updating working directory
979 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
980 searching for changes
981 adding changesets
982 adding manifests
983 adding file changes
984 added 1 changesets with 1 changes to 1 files (+1 heads)
985
986 $ hg -R share-1bbranch2 log -G
987 o changeset: 2:6bacf4683960
988 | branch: branch2
989 | tag: tip
990 | parent: 0:b5f04eac9d8f
991 | user: test
992 | date: Thu Jan 01 00:00:00 1970 +0000
993 | summary: branch2
994 |
995 | o changeset: 1:5f92a6c1a1b1
996 |/ branch: branch1
997 | user: test
998 | date: Thu Jan 01 00:00:00 1970 +0000
999 | summary: branch1
1000 |
1001 @ changeset: 0:b5f04eac9d8f
1002 user: test
1003 date: Thu Jan 01 00:00:00 1970 +0000
1004 summary: initial
1005
1006
1007 -U is respected in share clone mode
1008
1009 $ hg --config share.pool=share clone -U source1a share-1anowc
1010 (sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
1011 searching for changes
1012 no changes found
1013 adding remote bookmark bookA
1014
1015 $ ls share-1anowc