##// END OF EJS Templates
subrepo: cloning and updating of git subrepos...
Eric Eisner -
r12993:a9133438 default
parent child Browse files
Show More
@@ -581,6 +581,7 b' class gitsubrepo(object):'
581 # TODO add git version check.
581 # TODO add git version check.
582 self._state = state
582 self._state = state
583 self._ctx = ctx
583 self._ctx = ctx
584 self._relpath = path
584 self._path = ctx._repo.wjoin(path)
585 self._path = ctx._repo.wjoin(path)
585 self._ui = ctx._repo.ui
586 self._ui = ctx._repo.ui
586
587
@@ -633,6 +634,18 b' class gitsubrepo(object):'
633 out, code = self._gitdir(['cat-file', '-e', revision])
634 out, code = self._gitdir(['cat-file', '-e', revision])
634 return code == 0
635 return code == 0
635
636
637 def _fetch(self, source, revision):
638 if not os.path.exists('%s/.git' % self._path):
639 self._ui.status(_('cloning subrepo %s\n') % self._relpath)
640 self._gitnodir(['clone', source, self._path])
641 if self._githavelocally(revision):
642 return
643 self._ui.status(_('pulling subrepo %s\n') % self._relpath)
644 self._gitcommand(['fetch', '--all', '-q'])
645 if not self._githavelocally(revision):
646 raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
647 (revision, self._path))
648
636 def dirty(self):
649 def dirty(self):
637 if self._state[1] != self._gitstate(): # version checked out changed?
650 if self._state[1] != self._gitstate(): # version checked out changed?
638 return True
651 return True
@@ -642,6 +655,16 b' class gitsubrepo(object):'
642 '--untracked-files=no'])
655 '--untracked-files=no'])
643 return bool(changed.strip())
656 return bool(changed.strip())
644
657
658 def get(self, state):
659 source, revision, kind = state
660 self._fetch(source, revision)
661 if self._gitstate() != revision:
662 self._ui.warn(_('checking out detached HEAD in subrepo %s\n') %
663 self._relpath)
664 self._ui.warn(_('check out a git branch if you intend '
665 'to make changes\n'))
666 self._gitcommand(['checkout', '-q', revision])
667
645 def commit(self, text, user, date):
668 def commit(self, text, user, date):
646 cmd = ['commit', '-a', '-m', text]
669 cmd = ['commit', '-a', '-m', text]
647 if user:
670 if user:
@@ -56,3 +56,28 b' record a new commit from upstream'
56 path s
56 path s
57 source ../gitroot
57 source ../gitroot
58 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
58 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
59
60 clone root
61
62 $ hg clone . ../tc
63 updating to branch default
64 cloning subrepo s
65 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
66 $ cd ../tc
67 $ hg debugsub
68 path s
69 source ../gitroot
70 revision 126f2a14290cd5ce061fdedc430170e8d39e1c5a
71
72 update to previous substate
73
74 $ hg update 1
75 checking out detached HEAD in subrepo s
76 check out a git branch if you intend to make changes
77 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
78 $ cat s/g
79 g
80 $ hg debugsub
81 path s
82 source ../gitroot
83 revision da5f5b1d8ffcf62fb8327bcd3c89a4367a6018e7
General Comments 0
You need to be logged in to leave comments. Login now