Browse code

Avoid some duplicate effort, refresh embedded repositories better.

Nat! authored on 14/03/2016 23:01:27
Showing 4 changed files
... ...
@@ -12,6 +12,8 @@
12 12
 *  Started mulle-bootstrap project. The general idea is to do also manage
13 13
    the project that contains the .bootstrap folder (at least a little bit). So
14 14
    `mulle-bootstrap clone` is now `mulle-bootstrap project clone
15
+*  Better deep fetch and refresh avoids redoing repositories (could be
16
+   better though still)
15 17
 
16 18
 0.19
17 19
 ===
... ...
@@ -49,13 +49,15 @@ bootstrap_auto_update()
49 49
    local name
50 50
    local url
51 51
    local directory
52
-   local settings
53 52
 
54 53
 
55 54
    name="$1"
56 55
    url="$2"
57 56
    directory="$3"
58
-   settings="$4"
57
+
58
+   local settings
59
+
60
+   settings="$INHERIT_SETTINGS"
59 61
 
60 62
    [ ! -z "${directory}" ]        || internal_fail "src was empty"
61 63
    [ "${PWD}" != "${directory}" ] || internal_fail "configuration error"
... ...
@@ -365,14 +365,6 @@ ask_symlink_it()
365 365
 }
366 366
 
367 367
 
368
-INHERIT_SETTINGS='taps
369
-brews
370
-repositories
371
-pips
372
-gems
373
-settings/build_order
374
-settings/build_ignore'
375
-
376 368
 
377 369
 log_fetch_action()
378 370
 {
... ...
@@ -563,7 +555,7 @@ checkout_repository()
563 563
          install_embedded_repositories "${dstdir}/"
564 564
          BOOTSTRAP_SUBDIR="${old}"
565 565
 
566
-         bootstrap_auto_update "${name}" "${url}" "${dstdir}" "$INHERIT_SETTINGS"
566
+         bootstrap_auto_update "${name}" "${url}" "${dstdir}"
567 567
          flag=$?
568 568
       fi
569 569
 
... ...
@@ -628,9 +620,13 @@ clone_repositories()
628 628
    local old
629 629
    local name
630 630
    local url
631
+   local fetched
632
+   local match
631 633
 
632 634
    old="${IFS:-" "}"
633 635
 
636
+   fetched=""
637
+
634 638
    stop=0
635 639
    while [ $stop -eq 0 ]
636 640
    do
... ...
@@ -646,22 +642,32 @@ clone_repositories()
646 646
          for clone in ${clones}
647 647
          do
648 648
             IFS="${old}"
649
-            name="`canonical_name_from_clone "${clone}"`"
650
-            url="`url_from_clone "${clone}"`"
651
-            clone_repository "${name}" "${url}"
652
-            if [ $? -eq 1 ]
649
+
650
+            # avoid superflous updates
651
+            match="`echo "${fetched}" | grep "${clone}"`"
652
+            # could remove prefixes here https:// http://
653
+
654
+            if [ "${match}" != "${clone}" ]
653 655
             then
654
-               stop=0
655
-               break
656
+               fetched="${fetched}
657
+${clone}"
658
+
659
+               name="`canonical_name_from_clone "${clone}"`"
660
+               url="`url_from_clone "${clone}"`"
661
+               clone_repository "${name}" "${url}"
662
+               if [ $? -eq 1 ]
663
+               then
664
+                  stop=0
665
+                  break
666
+               fi
656 667
             fi
657 668
          done
658 669
       fi
659 670
    done
660 671
 
661
-   clones="`read_fetch_setting "repositories"`"
662 672
    IFS="
663 673
 "
664
-   for clone in ${clones}
674
+   for clone in ${fetched}
665 675
    do
666 676
       IFS="${old}"
667 677
       name="`canonical_name_from_clone "${clone}"`"
... ...
@@ -92,31 +92,60 @@ refresh_repositories_settings()
92 92
    local clones
93 93
    local clone
94 94
    local old
95
+   local stop
96
+   local refreshed
97
+   local match
95 98
 
96 99
    old="${IFS:-" "}"
97 100
 
98
-   clones="`read_fetch_setting "repositories"`"
99
-   if [ "${clones}" != "" ]
100
-   then
101
-      IFS="
102
-"
103
-      for clone in ${clones}
104
-      do
105
-         IFS="${old}"
101
+   refreshed=""
106 102
 
107
-         local name
108
-         local url
109
-         local tag
110
-         local dstdir
103
+   stop=0
104
+   while [ $stop -eq 0 ]
105
+   do
106
+      stop=1
111 107
 
112
-         name="`canonical_name_from_clone "${clone}"`"
113
-         url="`url_from_clone "${clone}"`"
114
-         tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
115
-         dstdir="${CLONESFETCH_SUBDIR}/${name}"
108
+      clones="`read_fetch_setting "repositories"`"
109
+      if [ "${clones}" != "" ]
110
+      then
111
+         IFS="
112
+   "
113
+         for clone in ${clones}
114
+         do
115
+            IFS="${old}"
116 116
 
117
-         bootstrap_auto_update "${name}" "${url}" "${dstdir}" "$INHERIT_SETTINGS"
118
-      done
119
-   fi
117
+            # avoid superflous updates
118
+            match="`echo "${refreshed}" | grep "${clone}"`"
119
+            # could remove prefixes here https:// http://
120
+
121
+            if [ "${match}" != "${clone}" ]
122
+            then
123
+               refreshed="${refreshed}
124
+${clone}"
125
+
126
+               local name
127
+               local url
128
+               local tag
129
+               local dstdir
130
+               local flag
131
+
132
+               name="`canonical_name_from_clone "${clone}"`"
133
+               url="`url_from_clone "${clone}"`"
134
+               tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
135
+               dstdir="${CLONESFETCH_SUBDIR}/${name}"
136
+
137
+               bootstrap_auto_update "${name}" "${url}" "${dstdir}"
138
+               flag=$?
139
+
140
+               if [ $flag -eq 0 ]
141
+               then
142
+                  stop=0
143
+                  break
144
+               fi
145
+            fi
146
+         done
147
+      fi
148
+   done
120 149
 
121 150
    IFS="${old}"
122 151
 }
... ...
@@ -383,6 +412,10 @@ refresh_repositories()
383 383
 
384 384
 _refresh_embedded_repositories()
385 385
 {
386
+   local dstprefix
387
+
388
+   dstprefix="$1"
389
+
386 390
    local clones
387 391
    local clone
388 392
    local old
... ...
@@ -403,7 +436,7 @@ _refresh_embedded_repositories()
403 403
          ensure_clones_directory
404 404
 
405 405
          name="`canonical_name_from_clone "${clone}"`"
406
-         dstdir="${name}"
406
+         dstdir="${dstprefix}${name}"
407 407
          mark_embedded_repository_alive "${name}" "${dstdir}"
408 408
       done
409 409
    fi
... ...
@@ -416,7 +449,7 @@ refresh_embedded_repositories()
416 416
 {
417 417
    mark_all_embedded_repositories_zombies
418 418
 
419
-   _refresh_embedded_repositories
419
+   _refresh_embedded_repositories "$@"
420 420
 
421 421
    bury_embedded_zombies
422 422
 }
... ...
@@ -451,7 +484,7 @@ refresh_deeply_embedded_repositories()
451 451
          BOOTSTRAP_SUBDIR="${dstprefix}.bootstrap"
452 452
          CLONESFETCH_SUBDIR="${dstprefix}${CLONESFETCH_SUBDIR}"
453 453
 
454
-         refresh_embedded_repositories
454
+         refresh_embedded_repositories "${dstprefix}"
455 455
 
456 456
          BOOTSTRAP_SUBDIR="${previous_bootstrap}"
457 457
          CLONESFETCH_SUBDIR="${previous_clones}"