# HG changeset patch # User jrice@netbeans.org # Date 1204282113 0 # Node ID fe96a8c166f29a785126014acf3e5aeca2036717 # Parent 1e7027a267bbfa6eacd79886514759d9cd5b96bb #127987: sources outside project directory - warn user that the root needs to be at a common ancestor diff -r 1e7027a267bb -r fe96a8c166f2 mercurial/src/org/netbeans/modules/mercurial/ui/create/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/create/Bundle.properties Fri Feb 29 08:49:20 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/create/Bundle.properties Fri Feb 29 10:48:33 2008 +0000 @@ -49,3 +49,11 @@ MSG_CREATE_NOT_SUPPORTED_INVIEW_INFO = I MSG_CREATE_NOT_SUPPORTED_INVIEW_INFO = INFO: Mecurial Project Initialization is not supported in this View MSG_CREATE_NOT_SUPPORTED_INVIEW = Mecurial Project Initialization is not supported in this View. MSG_CREATE_NOT_SUPPORTED_INVIEW_TITLE = Mecurial Project Initialization + +MSG_CREATE_INFO1=There are other source directories outside the project directory:\nProject Directory:\n {0}\nOther Sources:\n +MSG_CREATE_INFO2=\nTo manage all these sources the repository root must be placed at:\nCommon Ancestor:\n {0}\n\n +MSG_CREATE_CONFIRM_QUERY = There are source directories outside the project directory (refer to Output Window).\nTo manage all these sources the repository root must be placed at the common ancestor.\n {0}\n\nCreate the repository with this root? + +MSG_CREATE_CONFIRM_TITLE = Confrim Initialize +MSG_CREATE_CANCELED = INFO: Mercurial Initialize canceled by user + diff -r 1e7027a267bb -r fe96a8c166f2 mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java Fri Feb 29 08:49:20 2008 +0100 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/create/CreateAction.java Fri Feb 29 10:48:33 2008 +0000 @@ -131,7 +131,7 @@ public class CreateAction extends Contex public void performAction(ActionEvent e) { final Mercurial hg = Mercurial.getInstance(); - File [] files = context.getRootFiles().toArray(new File[context.getRootFiles().size()]); + final File [] files = context.getRootFiles().toArray(new File[context.getRootFiles().size()]); if(files == null || files.length == 0) return; // If there is a .hg directory in an ancestor of any of the files in @@ -147,7 +147,7 @@ public class CreateAction extends Contex } final Project proj = HgUtils.getProject(context); - File projFile = HgUtils.getProjectFile(proj); + final File projFile = HgUtils.getProjectFile(proj); if (projFile == null) { OutputLogger logger = OutputLogger.getLogger(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE); @@ -172,6 +172,41 @@ public class CreateAction extends Contex final File rootToManage = root; final String prjName = projName; + + + if (rootToManage.getAbsolutePath().indexOf(projFile.getAbsolutePath()) != 0) { + OutputLogger logger = OutputLogger.getLogger(rootToManage.getAbsolutePath()); + logger.outputInRed( + NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE")); // NOI18N + logger.outputInRed( + NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE_SEP")); // NOI18N + logger.output( + NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_INFO1", projFile.getAbsolutePath())); // NOI18N + for (File f : files) { + if (f.getAbsolutePath().indexOf(projFile.getAbsolutePath()) != 0){ + logger.output(" " + f.getAbsolutePath()); // NOI18N + } + } + logger.output( + NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_INFO2", rootToManage.getAbsolutePath())); // NOI18N + NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_CONFIRM_QUERY", rootToManage.getAbsolutePath())); // NOI18N + + descriptor.setTitle(NbBundle.getMessage(CreateAction.class, "MSG_CREATE_CONFIRM_TITLE")); // NOI18N + descriptor.setMessageType(JOptionPane.INFORMATION_MESSAGE); + descriptor.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); + + Object res = DialogDisplayer.getDefault().notify(descriptor); + if (res == NotifyDescriptor.CANCEL_OPTION) { + logger.outputInRed( + NbBundle.getMessage(CreateAction.class, + "MSG_CREATE_CANCELED", rootToManage.getAbsolutePath())); // NOI18N + logger.output(""); // NOI18N + return; + } + } RequestProcessor rp = hg.getRequestProcessor(rootToManage.getAbsolutePath()); @@ -180,13 +215,12 @@ public class CreateAction extends Contex try { OutputLogger logger = getLogger(); - logger.outputInRed( - NbBundle.getMessage(CreateAction.class, - "MSG_CREATE_TITLE")); // NOI18N - logger.outputInRed( - NbBundle.getMessage(CreateAction.class, - "MSG_CREATE_TITLE_SEP")); // NOI18N - + if (rootToManage.getAbsolutePath().indexOf(projFile.getAbsolutePath()) == 0) { + logger.outputInRed( + NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE")); // NOI18N + logger.outputInRed( + NbBundle.getMessage(CreateAction.class,"MSG_CREATE_TITLE_SEP")); // NOI18N + } logger.output( NbBundle.getMessage(CreateAction.class, "MSG_CREATE_INIT", prjName, rootToManage)); // NOI18N