##// END OF EJS Templates
subrepo: removing (and restoring) git subrepo state
Eric Eisner -
r12996:3a42651b default
parent child Browse files
Show More
@@ -678,7 +678,14 b' class gitsubrepo(object):'
678 def get(self, state):
678 def get(self, state):
679 source, revision, kind = state
679 source, revision, kind = state
680 self._fetch(source, revision)
680 self._fetch(source, revision)
681 if self._gitstate() == revision:
681 # if the repo was set to be bare, unbare it
682 if self._gitcommand(['config', '--get', 'core.bare']
683 ).strip() == 'true':
684 self._gitcommand(['config', 'core.bare', 'false'])
685 if self._gitstate() == revision:
686 self._gitcommand(['reset', '--hard', 'HEAD'])
687 return
688 elif self._gitstate() == revision:
682 return
689 return
683 current, bm = self._gitbranchmap()
690 current, bm = self._gitbranchmap()
684 if revision not in bm:
691 if revision not in bm:
@@ -742,6 +749,24 b' class gitsubrepo(object):'
742 'nothing to push') % self._relpath)
749 'nothing to push') % self._relpath)
743 return False
750 return False
744
751
752 def remove(self):
753 if self.dirty():
754 self._ui.warn(_('not removing repo %s because '
755 'it has changes.\n') % self._path)
756 return
757 # we can't fully delete the repository as it may contain
758 # local-only history
759 self._ui.note(_('removing subrepo %s\n') % self._path)
760 self._gitcommand(['config', 'core.bare', 'true'])
761 for f in os.listdir(self._path):
762 if f == '.git':
763 continue
764 path = os.path.join(self._path, f)
765 if os.path.isdir(path) and not os.path.islink(path):
766 shutil.rmtree(path)
767 else:
768 os.remove(path)
769
745 types = {
770 types = {
746 'hg': hgsubrepo,
771 'hg': hgsubrepo,
747 'svn': svnsubrepo,
772 'svn': svnsubrepo,
@@ -175,3 +175,21 b' user a pulls, merges, commits'
175 adding manifests
175 adding manifests
176 adding file changes
176 adding file changes
177 added 2 changesets with 2 changes to 1 files
177 added 2 changesets with 2 changes to 1 files
178
179 update to a revision without the subrepo, keeping the local git repository
180
181 $ cd ../t
182 $ hg up 0
183 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
184 $ ls s -a
185 .
186 ..
187 .git
188
189 $ hg up 2
190 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
191 $ ls s -a
192 .
193 ..
194 .git
195 g
General Comments 0
You need to be logged in to leave comments. Login now