[PATCH 5 of 5 VERSION2] subrepo: removing (and restoring) git subrepo state
Augie Fackler
durin42 at gmail.com
Sun Nov 14 20:57:09 CST 2010
On Nov 14, 2010, at 8:56 PM, Eric Eisner wrote:
>>
>>> + 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.
Ah, that's surprising. I'd like a comment in this code to that effect so that future self knows what's going on.
>
>
> [forgot the reply-all, sorry Augie]
More information about the Mercurial-devel
mailing list