diff options
author | Carl Meyer <carl@dirtcircle.com> | 2009-10-03 23:33:11 -0400 |
---|---|---|
committer | Carl Meyer <carl@dirtcircle.com> | 2009-10-03 23:33:11 -0400 |
commit | 452c8a719d8321e086ca0054586e4d39a75b4ea4 (patch) | |
tree | 418d25a41d61397931050b5c836e24ce9c36f84e | |
parent | afa1c59c81b8229c257399422ca14490a05f4500 (diff) | |
download | pip-452c8a719d8321e086ca0054586e4d39a75b4ea4.tar.gz |
fix #41: allow ignore/wipe/backup choice when attempting to install editable into existing non-repo dir
-rw-r--r-- | docs/news.txt | 3 | ||||
-rw-r--r-- | pip.py | 71 |
2 files changed, 44 insertions, 30 deletions
diff --git a/docs/news.txt b/docs/news.txt index 452f4e534..3c3944b11 100644 --- a/docs/news.txt +++ b/docs/news.txt @@ -47,6 +47,9 @@ tip presence/absence of final slashes or quoted/unquoted special characters don't trigger "ignore/switch/wipe/backup" choice. +* Fixed handling of attempt to checkout editable install to a + non-empty, non-repo directory. + 0.4 --- @@ -2680,6 +2680,8 @@ class FrozenRequirement(object): req = '-e %s' % req return '\n'.join(list(self.comments)+[str(req)])+'\n' +(_CAN_SWITCH, _NO_SWITCH) = (1, 2) + class VersionControl(object): name = '' dirname = '' @@ -2758,38 +2760,47 @@ class VersionControl(object): checkout/clone, False otherwise. """ checkout = True - if os.path.exists(os.path.join(dest, self.dirname)): - existing_url = self.get_url(dest) + prompt = False + if os.path.exists(dest): checkout = False - if self.compare_urls(existing_url, url): - logger.info('%s in %s exists, and has correct URL (%s)' - % (self.repo_name.title(), display_path(dest), url)) - logger.notify('Updating %s %s%s' - % (display_path(dest), self.repo_name, rev_display)) - self.update(dest, rev_options) + if os.path.exists(os.path.join(dest, self.dirname)): + existing_url = self.get_url(dest) + if self.compare_urls(existing_url, url): + logger.info('%s in %s exists, and has correct URL (%s)' + % (self.repo_name.title(), display_path(dest), url)) + logger.notify('Updating %s %s%s' + % (display_path(dest), self.repo_name, rev_display)) + self.update(dest, rev_options) + else: + logger.warn('%s %s in %s exists with URL %s' + % (self.name, self.repo_name, display_path(dest), existing_url)) + prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ', ('s', 'i', 'w', 'b')) else: - logger.warn('%s %s in %s exists with URL %s' - % (self.name, self.repo_name, display_path(dest), existing_url)) - logger.warn('The plan is to install the %s repository %s' - % (self.name, url)) - response = ask('What to do? (s)witch, (i)gnore, (w)ipe, (b)ackup ', ('s', 'i', 'w', 'b')) - if response == 's': - logger.notify('Switching %s %s to %s%s' - % (self.repo_name, display_path(dest), url, rev_display)) - self.switch(dest, url, rev_options) - elif response == 'i': - # do nothing - pass - elif response == 'w': - logger.warn('Deleting %s' % display_path(dest)) - shutil.rmtree(dest) - checkout = True - elif response == 'b': - dest_dir = backup_dir(dest) - logger.warn('Backing up %s to %s' - % (display_path(dest), dest_dir)) - shutil.move(dest, dest_dir) - checkout = True + logger.warn('Directory %s already exists, and is not a %s %s.' + % (dest, self.name, self.repo_name)) + prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b')) + if prompt: + logger.warn('The plan is to install the %s repository %s' + % (self.name, url)) + response = ask('What to do? %s' % prompt[0], prompt[1]) + + if response == 's': + logger.notify('Switching %s %s to %s%s' + % (self.repo_name, display_path(dest), url, rev_display)) + self.switch(dest, url, rev_options) + elif response == 'i': + # do nothing + pass + elif response == 'w': + logger.warn('Deleting %s' % display_path(dest)) + shutil.rmtree(dest) + checkout = True + elif response == 'b': + dest_dir = backup_dir(dest) + logger.warn('Backing up %s to %s' + % (display_path(dest), dest_dir)) + shutil.move(dest, dest_dir) + checkout = True return checkout def unpack(self, location): |