From 75cc3533801a012c1fe6676e76148416a70693ca Mon Sep 17 00:00:00 2001 From: Yang Zhenhui Date: Tue, 23 Oct 2012 15:41:54 +0800 Subject: Show user about not initializing repo in current directory If the parent of current directory has an initialized repo, for example, if the current directory is '/home/users/harry/platform/ics', and there is an initialized repo in harry's home directory '/home/users/harry/.repo', when user run 'repo init' command, repo is always initialized to parent directory in '/home/users/harry/.repo', but most of time user intends to initialize repo in the current directory, this patch tells user how to do it. Change-Id: Id7a76fb18ec0af243432c29605140d60f3de85ca --- subcmds/init.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'subcmds/init.py') diff --git a/subcmds/init.py b/subcmds/init.py index b6b98076..e56b9223 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -313,6 +313,21 @@ to update the working directory files. # We store the depth in the main manifest project. self.manifest.manifestProject.config.SetString('repo.depth', depth) + def _DisplayResult(self): + if self.manifest.IsMirror: + init_type = 'mirror ' + else: + init_type = '' + + print '' + print 'repo %shas been initialized in %s' % (init_type, self.manifest.topdir) + + current_dir = os.getcwd() + if current_dir != self.manifest.topdir: + print 'If this is not the directory in which you want to initialize repo, please run:' + print ' rm -r %s/.repo' % self.manifest.topdir + print 'and try again.' + def Execute(self, opt, args): git_require(MIN_GIT_VERSION, fail=True) @@ -329,10 +344,4 @@ to update the working directory files. self._ConfigureDepth(opt) - if self.manifest.IsMirror: - init_type = 'mirror ' - else: - init_type = '' - - print '' - print 'repo %sinitialized in %s' % (init_type, self.manifest.topdir) + self._DisplayResult() -- cgit v1.2.3-54-g00ecf