##// END OF EJS Templates
subrepo: make "_sanitize()" work...
FUJIWARA Katsunori -
r21564:2e91d496 stable
parent child Browse files
Show More
@@ -315,16 +315,14 b' def _abssource(repo, push=False, abort=T'
315 raise util.Abort(_("default path for subrepository not found"))
315 raise util.Abort(_("default path for subrepository not found"))
316
316
317 def _sanitize(ui, path):
317 def _sanitize(ui, path):
318 def v(arg, dirname, names):
318 for dirname, dirs, names in os.walk(path):
319 if os.path.basename(dirname).lower() != '.hg':
319 if os.path.basename(dirname).lower() != '.hg':
320 return
320 continue
321 for f in names:
321 for f in names:
322 if f.lower() == 'hgrc':
322 if f.lower() == 'hgrc':
323 ui.warn(
323 ui.warn(_("warning: removing potentially hostile 'hgrc' "
324 _("warning: removing potentially hostile .hg/hgrc in '%s'")
324 "in '%s'\n") % dirname)
325 % path)
326 os.unlink(os.path.join(dirname, f))
325 os.unlink(os.path.join(dirname, f))
327 os.walk(path, v, None)
328
326
329 def subrepo(ctx, path):
327 def subrepo(ctx, path):
330 """return instance of the right subrepo class for subrepo in path"""
328 """return instance of the right subrepo class for subrepo in path"""
@@ -566,3 +566,45 b' traceback'
566 #endif
566 #endif
567
567
568 $ cd ..
568 $ cd ..
569
570 Test sanitizing ".hg/hgrc" in subrepo
571
572 $ cd t
573 $ hg tip -q
574 7:af6d2edbb0d3
575 $ hg update -q -C af6d2edbb0d3
576 $ cd s
577 $ git checkout -q -b sanitize-test
578 $ mkdir .hg
579 $ echo '.hg/hgrc in git repo' > .hg/hgrc
580 $ mkdir -p sub/.hg
581 $ echo 'sub/.hg/hgrc in git repo' > sub/.hg/hgrc
582 $ git add .hg sub
583 $ git commit -qm 'add .hg/hgrc to be sanitized at hg update'
584 $ git push -q origin sanitize-test
585 $ cd ..
586 $ grep ' s$' .hgsubstate
587 32a343883b74769118bb1d3b4b1fbf9156f4dddc s
588 $ hg commit -qm 'commit with git revision including .hg/hgrc'
589 $ hg parents -q
590 8:3473d20bddcf
591 $ grep ' s$' .hgsubstate
592 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
593 $ cd ..
594
595 $ cd tc
596 $ hg pull -q
597 $ hg update -q -C 3473d20bddcf 2>&1 | sort
598 warning: removing potentially hostile 'hgrc' in 's/.hg' (glob)
599 warning: removing potentially hostile 'hgrc' in 's/sub/.hg' (glob)
600 $ hg parents -q
601 8:3473d20bddcf
602 $ grep ' s$' .hgsubstate
603 c4069473b459cf27fd4d7c2f50c4346b4e936599 s
604 $ cat s/.hg/hgrc
605 cat: s/.hg/hgrc: No such file or directory
606 [1]
607 $ cat s/sub/.hg/hgrc
608 cat: s/sub/.hg/hgrc: No such file or directory
609 [1]
610 $ cd ..
@@ -632,3 +632,48 b' well.'
632 Checked out revision 15.
632 Checked out revision 15.
633 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
633 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
634 $ cd ..
634 $ cd ..
635
636 Test sanitizing ".hg/hgrc" in subrepo
637
638 $ cd sub/t
639 $ hg update -q -C tip
640 $ cd s
641 $ mkdir .hg
642 $ echo '.hg/hgrc in svn repo' > .hg/hgrc
643 $ mkdir -p sub/.hg
644 $ echo 'sub/.hg/hgrc in svn repo' > sub/.hg/hgrc
645 $ svn add .hg sub
646 A .hg
647 A .hg/hgrc (glob)
648 A sub
649 A sub/.hg (glob)
650 A sub/.hg/hgrc (glob)
651 $ svn ci -m 'add .hg/hgrc to be sanitized at hg update'
652 Adding .hg
653 Adding .hg/hgrc (glob)
654 Adding sub
655 Adding sub/.hg (glob)
656 Adding sub/.hg/hgrc (glob)
657 Transmitting file data ..
658 Committed revision 16.
659 $ svn up -q
660 $ cd ..
661 $ hg commit -S -m 'commit with svn revision including .hg/hgrc'
662 $ grep ' s$' .hgsubstate
663 16 s
664 $ cd ..
665
666 $ cd tc
667 $ hg pull -u -q 2>&1 | sort
668 warning: removing potentially hostile 'hgrc' in 's/.hg' (glob)
669 warning: removing potentially hostile 'hgrc' in 's/sub/.hg' (glob)
670 $ grep ' s$' .hgsubstate
671 16 s
672 $ cat s/.hg/hgrc
673 cat: s/.hg/hgrc: No such file or directory
674 [1]
675 $ cat s/sub/.hg/hgrc
676 cat: s/sub/.hg/hgrc: No such file or directory
677 [1]
678
679 $ cd ../..
General Comments 0
You need to be logged in to leave comments. Login now