[PATCH 5 of 5 VERSION2] subrepo: removing (and restoring) git subrepo state
Eric Eisner
ede at mit.edu
Sun Nov 14 20:56:07 CST 2010
>
> > + def remove(self):
> > + if self.dirty():
> > + self._ui.warn(_('not removing repo %s because '
> > + 'it has changes.\n') % self._path)
> > + return
> > + # we can't fully delete the repository as it may contain
> > + # local-only history
> > + self._ui.note(_('removing subrepo %s\n') % self._path)
> > + self._gitcommand(['config', 'core.bare', 'true'])
>
> Why mark a repo as bare? I suppose that emulates hg co null, but that seems
> like a strange thing to do. I'm not sure if we can do better though, so I
> guess it's just something we have to live with.
>
Git has no direct equivalent to checking out null, but marking the repo bare
prevents any operations that affect the working dir.
>
> > + for f in os.listdir(self._path):
> > + if f == '.git':
> > + continue
> > + path = os.path.join(self._path, f)
> > + if os.path.isdir(path) and not os.path.islink(path):
> > + shutil.rmtree(path)
> > + else:
> > + os.remove(path)
>
> What's this code doing? Just trying to understand.
Simply marking the repo bare doesn't actually touch the working dir, so I
explicitly remove all files that are not the .git directory.
[forgot the reply-all, sorry Augie]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20101114/929ceedb/attachment.htm>
More information about the Mercurial-devel
mailing list