##// END OF EJS Templates
subrepos: prompt on conflicts on update with dirty subrepos...
Erik Zielke -
r13417:0748e18b default
parent child Browse files
Show More
@@ -163,6 +163,17 b' def submerge(repo, wctx, mctx, actx, ove'
163 # record merged .hgsubstate
163 # record merged .hgsubstate
164 writestate(repo, sm)
164 writestate(repo, sm)
165
165
166 def _updateprompt(ui, sub, dirty, local, remote):
167 if dirty:
168 msg = (_(' subrepository sources for %s differ\n'
169 'use (l)ocal source (%s) or (r)emote source (%s)?\n')
170 % (subrelpath(sub), local, remote))
171 else:
172 msg = (_(' subrepository sources for %s differ (in checked out version)\n'
173 'use (l)ocal source (%s) or (r)emote source (%s)?\n')
174 % (subrelpath(sub), local, remote))
175 return ui.promptchoice(msg, (_('&Local'), _('&Remote')), 0)
176
166 def reporelpath(repo):
177 def reporelpath(repo):
167 """return path to this (sub)repo as seen from outermost repo"""
178 """return path to this (sub)repo as seen from outermost repo"""
168 parent = repo
179 parent = repo
@@ -442,6 +453,8 b' class hgsubrepo(abstractsubrepo):'
442 cur = self._repo['.']
453 cur = self._repo['.']
443 dst = self._repo[state[1]]
454 dst = self._repo[state[1]]
444 anc = dst.ancestor(cur)
455 anc = dst.ancestor(cur)
456
457 def mergefunc():
445 if anc == cur:
458 if anc == cur:
446 self._repo.ui.debug("updating subrepo %s\n" % subrelpath(self))
459 self._repo.ui.debug("updating subrepo %s\n" % subrelpath(self))
447 hg.update(self._repo, state[1])
460 hg.update(self._repo, state[1])
@@ -451,6 +464,16 b' class hgsubrepo(abstractsubrepo):'
451 self._repo.ui.debug("merging subrepo %s\n" % subrelpath(self))
464 self._repo.ui.debug("merging subrepo %s\n" % subrelpath(self))
452 hg.merge(self._repo, state[1], remind=False)
465 hg.merge(self._repo, state[1], remind=False)
453
466
467 wctx = self._repo[None]
468 if self.dirty():
469 if anc != dst:
470 if _updateprompt(self._repo.ui, self, wctx.dirty(), cur, dst):
471 mergefunc()
472 else:
473 mergefunc()
474 else:
475 mergefunc()
476
454 def push(self, force):
477 def push(self, force):
455 # push subrepos depth-first for coherent ordering
478 # push subrepos depth-first for coherent ordering
456 c = self._repo['']
479 c = self._repo['']
@@ -608,10 +631,12 b' class svnsubrepo(abstractsubrepo):'
608 self._ui.status(status)
631 self._ui.status(status)
609
632
610 def merge(self, state):
633 def merge(self, state):
611 old = int(self._state[1])
634 old = self._state[1]
612 new = int(state[1])
635 new = state[1]
613 if new > old:
636 if new != self._wcrev():
614 self.get(state)
637 dirty = old == self._wcrev() or self._wcchanged()[0]
638 if _updateprompt(self._ui, self, dirty, self._wcrev(), new):
639 self.get(state, False)
615
640
616 def push(self, force):
641 def push(self, force):
617 # push is a no-op for SVN
642 # push is a no-op for SVN
@@ -850,11 +875,22 b' class gitsubrepo(abstractsubrepo):'
850 source, revision, kind = state
875 source, revision, kind = state
851 self._fetch(source, revision)
876 self._fetch(source, revision)
852 base = self._gitcommand(['merge-base', revision, self._state[1]])
877 base = self._gitcommand(['merge-base', revision, self._state[1]])
878 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
879
880 def mergefunc():
853 if base == revision:
881 if base == revision:
854 self.get(state) # fast forward merge
882 self.get(state) # fast forward merge
855 elif base != self._state[1]:
883 elif base != self._state[1]:
856 self._gitcommand(['merge', '--no-commit', revision])
884 self._gitcommand(['merge', '--no-commit', revision])
857
885
886 if self.dirty():
887 if self._gitstate() != revision:
888 dirty = self._gitstate() == self._state[1] or code != 0
889 if _updateprompt(self._ui, self, dirty, self._state[1], revision):
890 mergefunc()
891 else:
892 mergefunc()
893
858 def push(self, force):
894 def push(self, force):
859 # if a branch in origin contains the revision, nothing to do
895 # if a branch in origin contains the revision, nothing to do
860 branch2rev, rev2branch = self._gitbranchmap()
896 branch2rev, rev2branch = self._gitbranchmap()
@@ -329,3 +329,117 b' Check hg update --clean'
329 f1
329 f1
330 f2
330 f2
331 g
331 g
332
333 Sticky subrepositories, no changes
334 $ cd $TESTTMP/ta
335 $ hg id -n
336 7
337 $ cd s
338 $ git rev-parse HEAD
339 32a343883b74769118bb1d3b4b1fbf9156f4dddc
340 $ cd ..
341 $ hg update 1 > /dev/null 2>&1
342 $ hg id -n
343 1
344 $ cd s
345 $ git rev-parse HEAD
346 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
347 $ cd ..
348
349 Sticky subrepositorys, file changes
350 $ touch s/f1
351 $ cd s
352 $ git add f1
353 $ cd ..
354 $ hg id -n
355 1
356 $ cd s
357 $ git rev-parse HEAD
358 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
359 $ cd ..
360 $ hg update 4
361 subrepository sources for s differ
362 use (l)ocal source (da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7) or (r)emote source (aa84837ccfbdfedcdcdeeedc309d73e6eb069edc)?
363 l
364 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
365 $ hg id -n
366 4+
367 $ cd s
368 $ git rev-parse HEAD
369 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
370 $ cd ..
371 $ hg update --clean tip > /dev/null 2>&1
372
373 Sticky subrepository, revision updates
374 $ hg id -n
375 7
376 $ cd s
377 $ git rev-parse HEAD
378 32a343883b74769118bb1d3b4b1fbf9156f4dddc
379 $ cd ..
380 $ cd s
381 $ git checkout aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
382 Previous HEAD position was 32a3438... fff
383 HEAD is now at aa84837... f
384 $ cd ..
385 $ hg update 1
386 subrepository sources for s differ (in checked out version)
387 use (l)ocal source (32a343883b74769118bb1d3b4b1fbf9156f4dddc) or (r)emote source (da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7)?
388 l
389 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
390 $ hg id -n
391 1+
392 $ cd s
393 $ git rev-parse HEAD
394 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
395 $ cd ..
396
397 Sticky subrepository, file changes and revision updates
398 $ touch s/f1
399 $ cd s
400 $ git add f1
401 $ git rev-parse HEAD
402 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
403 $ cd ..
404 $ hg id -n
405 1+
406 $ hg update 7
407 subrepository sources for s differ
408 use (l)ocal source (32a343883b74769118bb1d3b4b1fbf9156f4dddc) or (r)emote source (32a343883b74769118bb1d3b4b1fbf9156f4dddc)?
409 l
410 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 $ hg id -n
412 7
413 $ cd s
414 $ git rev-parse HEAD
415 aa84837ccfbdfedcdcdeeedc309d73e6eb069edc
416 $ cd ..
417
418 Sticky repository, update --clean
419 $ hg update --clean tip
420 Previous HEAD position was aa84837... f
421 HEAD is now at 32a3438... fff
422 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
423 $ hg id -n
424 7
425 $ cd s
426 $ git rev-parse HEAD
427 32a343883b74769118bb1d3b4b1fbf9156f4dddc
428 $ cd ..
429
430 Test subrepo already at intended revision:
431 $ cd s
432 $ git checkout 32a343883b74769118bb1d3b4b1fbf9156f4dddc
433 HEAD is now at 32a3438... fff
434 $ cd ..
435 $ hg update 1
436 Previous HEAD position was 32a3438... fff
437 HEAD is now at da5f5b1... g
438 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
439 $ hg id -n
440 1
441 $ cd s
442 $ git rev-parse HEAD
443 da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
444 $ cd ..
445
@@ -296,3 +296,145 b' Check hg update --clean'
296 ? * f2 (glob)
296 ? * f2 (glob)
297
297
298 Performing status on external item at 'externals'
298 Performing status on external item at 'externals'
299
300 Sticky subrepositories, no changes
301 $ cd $TESTTMP/sub/t
302 $ hg id -n
303 2
304 $ cd s
305 $ svnversion
306 3
307 $ cd ..
308 $ hg update 1
309 U $TESTTMP/sub/t/s/alpha
310
311 Fetching external item into '$TESTTMP/sub/t/s/externals'
312 Checked out external at revision 1.
313
314 Checked out revision 2.
315 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
316 $ hg id -n
317 1
318 $ cd s
319 $ svnversion
320 2
321 $ cd ..
322
323 Sticky subrepositorys, file changes
324 $ touch s/f1
325 $ cd s
326 $ svn add f1
327 A f1
328 $ cd ..
329 $ hg id -n
330 1
331 $ cd s
332 $ svnversion
333 2M
334 $ cd ..
335 $ hg update tip
336 subrepository sources for s differ
337 use (l)ocal source (2) or (r)emote source (3)?
338 l
339 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
340 $ hg id -n
341 2+
342 $ cd s
343 $ svnversion
344 2M
345 $ cd ..
346 $ hg update --clean tip
347 U $TESTTMP/sub/t/s/alpha
348
349 Fetching external item into '$TESTTMP/sub/t/s/externals'
350 Checked out external at revision 1.
351
352 Checked out revision 3.
353 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
354
355 Sticky subrepository, revision updates
356 $ hg id -n
357 2
358 $ cd s
359 $ svnversion
360 3
361 $ cd ..
362 $ cd s
363 $ svn update -r 1
364 U alpha
365 U .
366
367 Fetching external item into 'externals'
368 Updated external to revision 1.
369
370 Updated to revision 1.
371 $ cd ..
372 $ hg update 1
373 subrepository sources for s differ (in checked out version)
374 use (l)ocal source (1) or (r)emote source (2)?
375 l
376 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
377 $ hg id -n
378 1+
379 $ cd s
380 $ svnversion
381 1
382 $ cd ..
383
384 Sticky subrepository, file changes and revision updates
385 $ touch s/f1
386 $ cd s
387 $ svn add f1
388 A f1
389 $ svnversion
390 1M
391 $ cd ..
392 $ hg id -n
393 1+
394 $ hg update tip
395 subrepository sources for s differ
396 use (l)ocal source (1) or (r)emote source (3)?
397 l
398 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
399 $ hg id -n
400 2
401 $ cd s
402 $ svnversion
403 1M
404 $ cd ..
405
406 Sticky repository, update --clean
407 $ hg update --clean tip
408 U $TESTTMP/sub/t/s/alpha
409 U $TESTTMP/sub/t/s
410
411 Fetching external item into '$TESTTMP/sub/t/s/externals'
412 Checked out external at revision 1.
413
414 Checked out revision 3.
415 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
416 $ hg id -n
417 2
418 $ cd s
419 $ svnversion
420 3
421 $ cd ..
422
423 Test subrepo already at intended revision:
424 $ cd s
425 $ svn update -r 2
426 U alpha
427
428 Fetching external item into 'externals'
429 Updated external to revision 1.
430
431 Updated to revision 2.
432 $ cd ..
433 $ hg update 1
434 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
435 $ hg id -n
436 1+
437 $ cd s
438 $ svnversion
439 2
440 $ cd ..
@@ -706,3 +706,125 b' Check hg update --clean'
706 $ hg status -S
706 $ hg status -S
707 ? s/b
707 ? s/b
708 ? s/c
708 ? s/c
709
710 Sticky subrepositories, no changes
711 $ cd $TESTTMP/sub/t
712 $ hg id
713 925c17564ef8 tip
714 $ hg -R s id
715 12a213df6fa9 tip
716 $ hg -R t id
717 52c0adc0515a tip
718 $ hg update 11
719 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
720 $ hg id
721 365661e5936a
722 $ hg -R s id
723 fc627a69481f
724 $ hg -R t id
725 e95bcfa18a35
726
727 Sticky subrepositorys, file changes
728 $ touch s/f1
729 $ touch t/f1
730 $ hg add -S s/f1
731 $ hg add -S t/f1
732 $ hg id
733 365661e5936a
734 $ hg -R s id
735 fc627a69481f+
736 $ hg -R t id
737 e95bcfa18a35+
738 $ hg update tip
739 subrepository sources for s differ
740 use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9)?
741 l
742 subrepository sources for t differ
743 use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a)?
744 l
745 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
746 $ hg id
747 925c17564ef8+ tip
748 $ hg -R s id
749 fc627a69481f+
750 $ hg -R t id
751 e95bcfa18a35+
752 $ hg update --clean tip
753 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
754
755 Sticky subrepository, revision updates
756 $ hg id
757 925c17564ef8 tip
758 $ hg -R s id
759 12a213df6fa9 tip
760 $ hg -R t id
761 52c0adc0515a tip
762 $ cd s
763 $ hg update -r -2
764 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
765 $ cd ../t
766 $ hg update -r 2
767 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
768 $ cd ..
769 $ hg update 10
770 subrepository sources for t differ (in checked out version)
771 use (l)ocal source (7af322bc1198) or (r)emote source (20a0db6fbf6c)?
772 l
773 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
774 $ hg id
775 e45c8b14af55+
776 $ hg -R s id
777 1c833a7a9e3a
778 $ hg -R t id
779 7af322bc1198
780
781 Sticky subrepository, file changes and revision updates
782 $ touch s/f1
783 $ touch t/f1
784 $ hg add -S s/f1
785 $ hg add -S t/f1
786 $ hg id
787 e45c8b14af55+
788 $ hg -R s id
789 1c833a7a9e3a+
790 $ hg -R t id
791 7af322bc1198+
792 $ hg update tip
793 subrepository sources for s differ
794 use (l)ocal source (1c833a7a9e3a) or (r)emote source (12a213df6fa9)?
795 l
796 subrepository sources for t differ
797 use (l)ocal source (7af322bc1198) or (r)emote source (52c0adc0515a)?
798 l
799 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
800 $ hg id
801 925c17564ef8 tip
802 $ hg -R s id
803 1c833a7a9e3a+
804 $ hg -R t id
805 7af322bc1198+
806
807 Sticky repository, update --clean
808 $ hg update --clean tip
809 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
810 $ hg id
811 925c17564ef8 tip
812 $ hg -R s id
813 12a213df6fa9 tip
814 $ hg -R t id
815 52c0adc0515a tip
816
817 Test subrepo already at intended revision:
818 $ cd s
819 $ hg update fc627a69481f
820 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
821 $ cd ..
822 $ hg update 11
823 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
824 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
825 $ hg id -n
826 11+
827 $ hg -R s id
828 fc627a69481f
829 $ hg -R t id
830 e95bcfa18a35
General Comments 0
You need to be logged in to leave comments. Login now