##// END OF EJS Templates
subrepo: rewrite handling of subrepo state at commit (issue2403)...
Matt Mackall -
r16073:b254f827 default
parent child Browse files
Show More
@@ -1096,37 +1096,58 b' class localrepository(repo.repository):'
1096 1096
1097 1097 # check subrepos
1098 1098 subs = []
1099 removedsubs = set()
1099 commitsubs = set()
1100 newstate = wctx.substate.copy()
1101 # only manage subrepos and .hgsubstate if .hgsub is present
1100 1102 if '.hgsub' in wctx:
1101 # only manage subrepos and .hgsubstate if .hgsub is present
1103 # we'll decide whether to track this ourselves, thanks
1104 if '.hgsubstate' in changes[0]:
1105 changes[0].remove('.hgsubstate')
1106 if '.hgsubstate' in changes[2]:
1107 changes[2].remove('.hgsubstate')
1108
1109 # compare current state to last committed state
1110 # build new substate based on last committed state
1111 oldstate = wctx.p1().substate
1112 for s in sorted(newstate.keys()):
1113 if not match(s):
1114 # ignore working copy, use old state if present
1115 if s in oldstate:
1116 newstate[s] = oldstate[s]
1117 continue
1118 if not force:
1119 raise util.Abort(
1120 _("commit with new subrepo %s excluded") % s)
1121 if wctx.sub(s).dirty(True):
1122 if not self.ui.configbool('ui', 'commitsubrepos'):
1123 raise util.Abort(
1124 _("uncommitted changes in subrepo %s") % s,
1125 hint=_("use --subrepos for recursive commit"))
1126 subs.append(s)
1127 commitsubs.add(s)
1128 else:
1129 bs = wctx.sub(s).basestate()
1130 newstate[s] = (newstate[s][0], bs, newstate[s][2])
1131 if oldstate.get(s, (None, None, None))[1] != bs:
1132 subs.append(s)
1133
1134 # check for removed subrepos
1102 1135 for p in wctx.parents():
1103 removedsubs.update(s for s in p.substate if match(s))
1104 for s in wctx.substate:
1105 removedsubs.discard(s)
1106 if match(s) and wctx.sub(s).dirty():
1107 subs.append(s)
1108 if (subs or removedsubs):
1136 r = [s for s in p.substate if s not in newstate]
1137 subs += [s for s in r if match(s)]
1138 if subs:
1109 1139 if (not match('.hgsub') and
1110 1140 '.hgsub' in (wctx.modified() + wctx.added())):
1111 1141 raise util.Abort(
1112 1142 _("can't commit subrepos without .hgsub"))
1113 if '.hgsubstate' not in changes[0]:
1114 changes[0].insert(0, '.hgsubstate')
1115 if '.hgsubstate' in changes[2]:
1116 changes[2].remove('.hgsubstate')
1143 changes[0].insert(0, '.hgsubstate')
1144
1117 1145 elif '.hgsub' in changes[2]:
1118 1146 # clean up .hgsubstate when .hgsub is removed
1119 1147 if ('.hgsubstate' in wctx and
1120 1148 '.hgsubstate' not in changes[0] + changes[1] + changes[2]):
1121 1149 changes[2].insert(0, '.hgsubstate')
1122 1150
1123 if subs and not self.ui.configbool('ui', 'commitsubrepos', False):
1124 changedsubs = [s for s in subs if wctx.sub(s).dirty(True)]
1125 if changedsubs:
1126 raise util.Abort(_("uncommitted changes in subrepo %s")
1127 % changedsubs[0],
1128 hint=_("use --subrepos for recursive commit"))
1129
1130 1151 # make sure all explicit patterns are matched
1131 1152 if not force and match.files():
1132 1153 matched = set(changes[0] + changes[1] + changes[2])
@@ -1162,16 +1183,15 b' class localrepository(repo.repository):'
1162 1183 cctx._text = editor(self, cctx, subs)
1163 1184 edited = (text != cctx._text)
1164 1185
1165 # commit subs
1166 if subs or removedsubs:
1167 state = wctx.substate.copy()
1168 for s in sorted(subs):
1186 # commit subs and write new state
1187 if subs:
1188 for s in sorted(commitsubs):
1169 1189 sub = wctx.sub(s)
1170 1190 self.ui.status(_('committing subrepository %s\n') %
1171 1191 subrepo.subrelpath(sub))
1172 1192 sr = sub.commit(cctx._text, user, date)
1173 state[s] = (state[s][0], sr)
1174 subrepo.writestate(self, state)
1193 newstate[s] = (newstate[s][0], sr)
1194 subrepo.writestate(self, newstate)
1175 1195
1176 1196 # Save commit message in case this transaction gets rolled back
1177 1197 # (e.g. by a pretxncommit hook). Leave the content alone on
@@ -474,9 +474,6 b''
474 474 > except:
475 475 warning: naked except clause
476 476 mercurial/localrepo.py:0:
477 > hint=_("use --subrepos for recursive commit"))
478 warning: line over 80 characters
479 mercurial/localrepo.py:0:
480 477 > # we return an integer indicating remote head count change
481 478 warning: line over 80 characters
482 479 mercurial/localrepo.py:0:
@@ -37,7 +37,6 b' qnew on repo w/svn subrepo'
37 37 $ hg status -S -X '**/format'
38 38 A .hgsub
39 39 $ hg qnew -m0 0.diff
40 committing subrepository sub
41 40 $ cd sub
42 41 $ echo a > a
43 42 $ svn add a
@@ -105,7 +105,6 b' handle subrepos safely on qnew'
105 105 % update substate when adding .hgsub w/clean updated subrepo
106 106 A .hgsub
107 107 % qnew -m0 0.diff
108 committing subrepository sub
109 108 path sub
110 109 source sub
111 110 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -121,7 +120,6 b' handle subrepos safely on qnew'
121 120 % update substate when modifying .hgsub w/clean updated subrepo
122 121 M .hgsub
123 122 % qnew -m1 1.diff
124 committing subrepository sub2
125 123 path sub
126 124 source sub
127 125 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -166,7 +164,6 b' handle subrepos safely on qrefresh'
166 164 % update substate when adding .hgsub w/clean updated subrepo
167 165 A .hgsub
168 166 % qrefresh
169 committing subrepository sub
170 167 path sub
171 168 source sub
172 169 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -183,7 +180,6 b' handle subrepos safely on qrefresh'
183 180 % update substate when modifying .hgsub w/clean updated subrepo
184 181 M .hgsub
185 182 % qrefresh
186 committing subrepository sub2
187 183 path sub
188 184 source sub
189 185 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -225,7 +221,6 b' handle subrepos safely on qpush/qpop'
225 221 $ echo sub = sub > .hgsub
226 222 $ hg add .hgsub
227 223 $ hg qnew -m0 0.diff
228 committing subrepository sub
229 224 $ hg debugsub
230 225 path sub
231 226 source sub
@@ -277,7 +272,6 b' handle subrepos safely on qrecord'
277 272 diff --git a/.hgsub b/.hgsub
278 273 new file mode 100644
279 274 examine changes to '.hgsub'? [Ynsfdaq?]
280 committing subrepository sub
281 275 path sub
282 276 source sub
283 277 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -310,7 +304,6 b' handle subrepos safely on qrecord'
310 304 sub = sub
311 305 +sub2 = sub2
312 306 record this change to '.hgsub'? [Ynsfdaq?]
313 committing subrepository sub2
314 307 path sub
315 308 source sub
316 309 revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
@@ -360,4 +353,3 b' correctly handle subrepos with patch que'
360 353 $ echo sub = sub >> .hgsub
361 354 $ hg add .hgsub
362 355 $ hg qnew 0.diff
363 committing subrepository sub
@@ -18,7 +18,6 b" Preparing the 'sub1' repo which depends "
18 18 adding sub1/.hgsub (glob)
19 19 adding sub1/sub1 (glob)
20 20 $ hg commit -R sub1 -m "sub1 import"
21 committing subrepository sub2
22 21
23 22 Preparing the 'main' repo which depends on the subrepo 'sub1'
24 23
@@ -33,7 +32,6 b" Preparing the 'main' repo which depends "
33 32 adding main/.hgsub (glob)
34 33 adding main/main (glob)
35 34 $ hg commit -R main -m "main import"
36 committing subrepository sub1
37 35
38 36 Cleaning both repositories, just as a clone -U
39 37
@@ -34,7 +34,6 b' add subrepo clone'
34 34 $ git clone -q ../gitroot s
35 35 $ hg add .hgsub
36 36 $ hg commit -m 'new git subrepo'
37 committing subrepository s
38 37 $ hg debugsub
39 38 path s
40 39 source ../gitroot
@@ -55,7 +54,6 b' record a new commit from upstream from a'
55 54 $ hg status --subrepos
56 55 M s/g
57 56 $ hg commit -m 'update git subrepo'
58 committing subrepository s
59 57 $ hg debugsub
60 58 path s
61 59 source ../gitroot
@@ -222,7 +220,6 b' sync to upstream git, distribute changes'
222 220 $ git pull -q >/dev/null 2>/dev/null
223 221 $ cd ..
224 222 $ hg commit -m 'git upstream sync'
225 committing subrepository s
226 223 $ hg debugsub
227 224 path s
228 225 source ../gitroot
@@ -287,7 +284,6 b' create nested repo'
287 284 $ echo inner = inner > .hgsub
288 285 $ hg add .hgsub
289 286 $ hg commit -m 'nested sub'
290 committing subrepository inner
291 287
292 288 nested commit
293 289
@@ -339,27 +335,32 b" Don't crash if the .hgsubstate entry is "
339 335 $ hg update 1 -q
340 336 $ hg rm .hgsubstate
341 337 $ hg commit .hgsubstate -m 'no substate'
342 created new head
338 nothing changed
339 [1]
343 340 $ hg tag -l nosubstate
344 341 $ hg manifest
345 342 .hgsub
343 .hgsubstate
346 344 a
347 345
348 346 $ hg status -S
347 R .hgsubstate
349 348 $ hg sum | grep commit
350 commit: 1 subrepos
349 commit: 1 removed, 1 subrepos (new branch head)
351 350
352 351 $ hg commit -m 'restore substate'
353 committing subrepository s
352 nothing changed
353 [1]
354 354 $ hg manifest
355 355 .hgsub
356 356 .hgsubstate
357 357 a
358 358 $ hg sum | grep commit
359 commit: (clean)
359 commit: 1 removed, 1 subrepos (new branch head)
360 360
361 361 $ hg update -qC nosubstate
362 362 $ ls s
363 g
363 364
364 365 issue3109: false positives in git diff-index
365 366
@@ -7,12 +7,10 b''
7 7 $ echo 'subrepo = subrepo' > .hgsub
8 8 $ hg ci -Am addsubrepo
9 9 adding .hgsub
10 committing subrepository subrepo
11 10 $ echo b > subrepo/b
12 11 $ hg -R subrepo ci -Am addb
13 12 adding b
14 13 $ hg ci -m updatedsub
15 committing subrepository subrepo
16 14
17 15 delete .hgsub and revert it
18 16
@@ -79,11 +79,9 b' The --subrepos flag overwrite the config'
79 79
80 80 $ cd ..
81 81 $ hg commit -m 0-2-1
82 committing subrepository bar
83 82
84 83 $ cd ..
85 84 $ hg commit -m 1-2-1
86 committing subrepository foo
87 85
88 86 Change working directory:
89 87
@@ -20,7 +20,6 b" Preparing the 'main' repo which depends "
20 20 adding main/.hgsub (glob)
21 21 adding main/main (glob)
22 22 $ hg commit -R main -m "main import"
23 committing subrepository sub
24 23
25 24 Cleaning both repositories, just as a clone -U
26 25
@@ -69,8 +69,6 b' add first svn sub with leading whitespac'
69 69 $ svn co --quiet "$SVNREPO"/src subdir/s
70 70 $ hg add .hgsub
71 71 $ hg ci -m1
72 committing subrepository s
73 committing subrepository subdir/s
74 72
75 73 make sure we avoid empty commits (issue2445)
76 74
@@ -432,7 +430,6 b' are unknown directories being replaced b'
432 430 $ echo "s = [svn] $SVNREPO/src" >> .hgsub
433 431 $ hg add .hgsub
434 432 $ hg ci -m addsub
435 committing subrepository s
436 433 $ echo a > a
437 434 $ hg ci -Am adda
438 435 adding a
@@ -440,7 +437,6 b' are unknown directories being replaced b'
440 437 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
441 438 $ svn up -qr6 s
442 439 $ hg ci -m updatesub
443 committing subrepository s
444 440 created new head
445 441 $ echo pyc > s/dir/epsilon.pyc
446 442 $ hg up 1
@@ -462,14 +458,12 b' test having obstructions when switching '
462 458 $ echo "obstruct = [svn] $SVNREPO/externals" >> .hgsub
463 459 $ svn co -r5 --quiet "$SVNREPO"/externals obstruct
464 460 $ hg commit -m 'Start making obstructed working copy'
465 committing subrepository obstruct
466 461 $ hg book other
467 462 $ hg co -r 'p1(tip)'
468 463 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
469 464 $ echo "obstruct = [svn] $SVNREPO/src" >> .hgsub
470 465 $ svn co -r5 --quiet "$SVNREPO"/src obstruct
471 466 $ hg commit -m 'Other branch which will be obstructed'
472 committing subrepository obstruct
473 467 created new head
474 468
475 469 Switching back to the head where we have another path mapped to the
@@ -530,12 +524,10 b' First, create that condition in the repo'
530 524 Checked out revision 10.
531 525 $ echo "recreated = [svn] $SVNREPO/branch" >> .hgsub
532 526 $ hg ci -m addsub
533 committing subrepository recreated
534 527 $ cd recreated
535 528 $ svn up -q
536 529 $ cd ..
537 530 $ hg ci -m updatesub
538 committing subrepository recreated
539 531 $ hg up -r-2
540 532 D *recreated/somethingnew (glob)
541 533 A *recreated/somethingold (glob)
@@ -37,7 +37,6 b' Issue2232: committing a subrepo without '
37 37 commit: 1 added, 1 subrepos
38 38 update: (current)
39 39 $ hg ci -m1
40 committing subrepository s
41 40
42 41 Revert can't (yet) revert subrepos:
43 42
@@ -105,7 +104,6 b' bump sub rev (and check it is ignored by'
105 104 $ echo b > s/a
106 105 $ hg -R s ci -ms1
107 106 $ hg --config ui.commitsubrepos=no ci -m3
108 committing subrepository s
109 107
110 108 leave sub dirty (and check ui.commitsubrepos=no aborts the commit)
111 109
@@ -455,7 +453,6 b" shouldn't need merging"
455 453 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
456 454 $ hg ci -Am1
457 455 adding .hgsub
458 committing subrepository s
459 456 $ hg branch br
460 457 marked working directory as branch br
461 458 (branches are permanent and global, did you want a bookmark?)
@@ -464,7 +461,6 b" shouldn't need merging"
464 461 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
465 462 $ hg ci -Am1
466 463 adding b
467 committing subrepository s
468 464 $ hg up default
469 465 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
470 466 $ echo c > c
@@ -483,7 +479,6 b" shouldn't need merging"
483 479 $ echo d > d
484 480 $ hg ci -Am1
485 481 adding d
486 committing subrepository s
487 482 $ hg up 3
488 483 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
489 484 $ hg -R s up 5
@@ -491,7 +486,6 b" shouldn't need merging"
491 486 $ echo e > e
492 487 $ hg ci -Am1
493 488 adding e
494 committing subrepository s
495 489
496 490 $ hg up 5
497 491 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -519,8 +513,6 b' test subrepo delete from .hgsubstate'
519 513 $ hg -R testdelete add
520 514 adding testdelete/.hgsub (glob)
521 515 $ hg -R testdelete ci -m "nested 1 & 2 added"
522 committing subrepository nested
523 committing subrepository nested2
524 516 $ echo nested = nested > testdelete/.hgsub
525 517 $ hg -R testdelete ci -m "nested 2 deleted"
526 518 $ cat testdelete/.hgsubstate
@@ -550,8 +542,6 b' test repository cloning'
550 542 $ hg -R main add
551 543 adding main/.hgsub (glob)
552 544 $ hg -R main ci -m "add subrepos"
553 committing subrepository nested_absolute
554 committing subrepository nested_relative
555 545 $ cd ..
556 546 $ hg clone mercurial/main mercurial2/main
557 547 updating to branch default
@@ -574,7 +564,6 b' Issue1977: multirepo push should fail if'
574 564 $ echo s = s > repo/.hgsub
575 565 $ hg -R repo ci -Am1
576 566 adding .hgsub
577 committing subrepository s
578 567 $ hg clone repo repo2
579 568 updating to branch default
580 569 cloning subrepo s from $TESTTMP/sub/repo/s (glob)
@@ -590,7 +579,6 b' Issue1977: multirepo push should fail if'
590 579 $ hg -R repo2/s ci -m3
591 580 created new head
592 581 $ hg -R repo2 ci -m3
593 committing subrepository s
594 582 $ hg -q -R repo2 push
595 583 abort: push creates new remote head 9d66565e64e1!
596 584 (did you forget to merge? use push -f to force)
@@ -701,7 +689,6 b' subrepository:'
701 689 $ echo subrepo-2 = subrepo-2 >> .hgsub
702 690 $ hg add .hgsub
703 691 $ hg ci -m 'Added subrepos'
704 committing subrepository subrepo-1
705 692 committing subrepository subrepo-2
706 693 $ hg st subrepo-2/file
707 694
@@ -859,17 +846,16 b" Test that removing .hgsubstate doesn't b"
859 846
860 847 $ hg rm -f .hgsubstate
861 848 $ hg ci -mrm
862 committing subrepository s
863 committing subrepository t
864 created new head
849 nothing changed
850 [1]
865 851 $ hg log -vr tip
866 changeset: 14:3941e0aa5236
852 changeset: 13:925c17564ef8
867 853 tag: tip
868 parent: 11:365661e5936a
869 854 user: test
870 855 date: Thu Jan 01 00:00:00 1970 +0000
856 files: .hgsubstate
871 857 description:
872 rm
858 13
873 859
874 860
875 861
@@ -877,9 +863,11 b' Test that removing .hgsub removes .hgsub'
877 863
878 864 $ hg rm .hgsub
879 865 $ hg ci -mrm2
866 created new head
880 867 $ hg log -vr tip
881 changeset: 15:8b31de9d13d1
868 changeset: 14:2400bccd50af
882 869 tag: tip
870 parent: 11:365661e5936a
883 871 user: test
884 872 date: Thu Jan 01 00:00:00 1970 +0000
885 873 files: .hgsub .hgsubstate
@@ -890,13 +878,13 b' Test that removing .hgsub removes .hgsub'
890 878 Test issue3153: diff -S with deleted subrepos
891 879
892 880 $ hg diff --nodates -S -c .
893 diff -r 3941e0aa5236 -r 8b31de9d13d1 .hgsub
881 diff -r 365661e5936a -r 2400bccd50af .hgsub
894 882 --- a/.hgsub
895 883 +++ /dev/null
896 884 @@ -1,2 +0,0 @@
897 885 -s = s
898 886 -t = t
899 diff -r 3941e0aa5236 -r 8b31de9d13d1 .hgsubstate
887 diff -r 365661e5936a -r 2400bccd50af .hgsubstate
900 888 --- a/.hgsubstate
901 889 +++ /dev/null
902 890 @@ -1,2 +0,0 @@
@@ -911,7 +899,6 b' Test behavior of add for explicit path i'
911 899 $ hg add .hgsub
912 900 $ hg init s
913 901 $ hg ci -m0
914 committing subrepository s
915 902 Adding with an explicit path in a subrepo adds the file
916 903 $ echo c1 > f1
917 904 $ echo c2 > s/f2
@@ -925,7 +912,6 b' Adding with an explicit path in a subrep'
925 912 $ hg ci -R s -m0
926 913 $ hg ci -Am1
927 914 adding f1
928 committing subrepository s
929 915 Adding with an explicit path in a subrepo with -S has the same behavior
930 916 $ echo c3 > f3
931 917 $ echo c4 > s/f4
@@ -939,7 +925,6 b' Adding with an explicit path in a subrep'
939 925 $ hg ci -R s -m1
940 926 $ hg ci -Ama2
941 927 adding f3
942 committing subrepository s
943 928 Adding without a path or pattern silently ignores subrepos
944 929 $ echo c5 > f5
945 930 $ echo c6 > s/f6
@@ -958,7 +943,6 b' Adding without a path or pattern silentl'
958 943 adding f6
959 944 adding f7
960 945 $ hg ci -m3
961 committing subrepository s
962 946 Adding without a path or pattern with -S also adds files in subrepos
963 947 $ echo c8 > f8
964 948 $ echo c9 > s/f9
@@ -977,7 +961,6 b' Adding without a path or pattern with -S'
977 961 A s/f9
978 962 $ hg ci -R s -m3
979 963 $ hg ci -m4
980 committing subrepository s
981 964 Adding with a pattern silently ignores subrepos
982 965 $ echo c11 > fm11
983 966 $ echo c12 > fn12
@@ -1000,7 +983,6 b' Adding with a pattern silently ignores s'
1000 983 adding fn14
1001 984 $ hg ci -Am5
1002 985 adding fn12
1003 committing subrepository s
1004 986 Adding with a pattern with -S also adds matches in subrepos
1005 987 $ echo c15 > fm15
1006 988 $ echo c16 > fn16
@@ -1023,7 +1005,6 b' Adding with a pattern with -S also adds '
1023 1005 adding fn18
1024 1006 $ hg ci -Am6
1025 1007 adding fn16
1026 committing subrepository s
1027 1008
1028 1009 Test behavior of forget for explicit path in subrepo:
1029 1010 Forgetting an explicit path in a subrepo untracks the file
General Comments 0
You need to be logged in to leave comments. Login now