~qbzr-dev/qbzr/0.22

« back to all changes in this revision

Viewing changes to lib/getnew.py

  • Committer: Alexander Belchenko
  • Date: 2012-02-29 07:50:26 UTC
  • Revision ID: bialix@ukr.net-20120229075026-heglo4ps4z0eaw9s
qgetnew: Ask for verification if a checkout should go to a non-empty directory - this may cause unwanted conflicts (André Bachmann, Bug #938835)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import os
25
25
import re
26
 
from PyQt4 import QtCore
 
26
from PyQt4 import QtCore, QtGui
 
27
from bzrlib.plugins.qbzr.lib.i18n import gettext
27
28
from bzrlib.plugins.qbzr.lib.subprocess import SubProcessDialog
28
29
from bzrlib.plugins.qbzr.lib.ui_new_tree import Ui_NewWorkingTreeForm
29
30
from bzrlib.plugins.qbzr.lib.util import (
130
131
 
131
132
        self.process_widget.do_start(None, *args)
132
133
        save_pull_location(None, from_location)
 
134
 
 
135
    def validate(self):
 
136
        # This is a check if the user really wants to checkout to a non-empty directory.
 
137
        # Because this may create conflicts, we want to make sure this is intended.
 
138
        to_location = unicode(self.ui.to_location.text())
 
139
        if os.path.exists(to_location) and os.listdir(to_location):
 
140
            if self.ui.but_checkout.isChecked():
 
141
                msg = gettext("Do you really want to checkout into a non-empty folder?")
 
142
            else:
 
143
                msg = gettext("Do you really want to branch into a non-empty folder?")
 
144
            choice = QtGui.QMessageBox.question(self,
 
145
                self.windowTitle(),
 
146
                msg,
 
147
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
 
148
                QtGui.QMessageBox.No)
 
149
            if choice == QtGui.QMessageBox.No:
 
150
                return False
 
151
 
 
152
        return True