Lines 69-74
import org.netbeans.modules.mercurial.Fi
Link Here
|
69 |
import org.netbeans.modules.mercurial.FileStatus; |
69 |
import org.netbeans.modules.mercurial.FileStatus; |
70 |
import org.netbeans.modules.mercurial.HgException; |
70 |
import org.netbeans.modules.mercurial.HgException; |
71 |
import org.netbeans.modules.mercurial.Mercurial; |
71 |
import org.netbeans.modules.mercurial.Mercurial; |
|
|
72 |
import org.netbeans.modules.mercurial.OutputLogger; |
72 |
import org.netbeans.api.queries.SharabilityQuery; |
73 |
import org.netbeans.api.queries.SharabilityQuery; |
73 |
import org.netbeans.modules.mercurial.HgModuleConfig; |
74 |
import org.netbeans.modules.mercurial.HgModuleConfig; |
74 |
import org.netbeans.modules.mercurial.config.HgConfigFiles; |
75 |
import org.netbeans.modules.mercurial.config.HgConfigFiles; |
Lines 348-354
public class HgCommand {
Link Here
|
348 |
* @return hg update output |
349 |
* @return hg update output |
349 |
* @throws org.netbeans.modules.mercurial.HgException |
350 |
* @throws org.netbeans.modules.mercurial.HgException |
350 |
*/ |
351 |
*/ |
351 |
public static List<String> doRollback(File repository) throws HgException { |
352 |
public static List<String> doRollback(File repository, OutputLogger logger) throws HgException { |
352 |
if (repository == null ) return null; |
353 |
if (repository == null ) return null; |
353 |
List<String> command = new ArrayList<String>(); |
354 |
List<String> command = new ArrayList<String>(); |
354 |
|
355 |
|
Lines 359-365
public class HgCommand {
Link Here
|
359 |
|
360 |
|
360 |
List<String> list = exec(command); |
361 |
List<String> list = exec(command); |
361 |
if (list.isEmpty()) |
362 |
if (list.isEmpty()) |
362 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED")); |
363 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED"), logger); |
363 |
|
364 |
|
364 |
return list; |
365 |
return list; |
365 |
} |
366 |
} |
Lines 396-403
public class HgCommand {
Link Here
|
396 |
* @return hg pull output |
397 |
* @return hg pull output |
397 |
* @throws org.netbeans.modules.mercurial.HgException |
398 |
* @throws org.netbeans.modules.mercurial.HgException |
398 |
*/ |
399 |
*/ |
399 |
public static List<String> doPull(File repository) throws HgException { |
400 |
public static List<String> doPull(File repository, OutputLogger logger) throws HgException { |
400 |
return doPull(repository, null); |
401 |
return doPull(repository, null, logger); |
401 |
} |
402 |
} |
402 |
|
403 |
|
403 |
/** |
404 |
/** |
Lines 411-417
public class HgCommand {
Link Here
|
411 |
* @return hg pull output |
412 |
* @return hg pull output |
412 |
* @throws org.netbeans.modules.mercurial.HgException |
413 |
* @throws org.netbeans.modules.mercurial.HgException |
413 |
*/ |
414 |
*/ |
414 |
public static List<String> doPull(File repository, String from) throws HgException { |
415 |
public static List<String> doPull(File repository, String from, OutputLogger logger) throws HgException { |
415 |
if (repository == null ) return null; |
416 |
if (repository == null ) return null; |
416 |
List<String> command = new ArrayList<String>(); |
417 |
List<String> command = new ArrayList<String>(); |
417 |
|
418 |
|
Lines 426-432
public class HgCommand {
Link Here
|
426 |
|
427 |
|
427 |
List<String> list; |
428 |
List<String> list; |
428 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
429 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
429 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true); |
430 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); |
430 |
if(proxy != null){ |
431 |
if(proxy != null){ |
431 |
List<String> env = new ArrayList<String>(); |
432 |
List<String> env = new ArrayList<String>(); |
432 |
env.add(HG_PROXY_ENV + proxy); |
433 |
env.add(HG_PROXY_ENV + proxy); |
Lines 437-443
public class HgCommand {
Link Here
|
437 |
|
438 |
|
438 |
if (!list.isEmpty() && |
439 |
if (!list.isEmpty() && |
439 |
isErrorAbort(list.get(list.size() -1))) { |
440 |
isErrorAbort(list.get(list.size() -1))) { |
440 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
441 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
441 |
} |
442 |
} |
442 |
return list; |
443 |
return list; |
443 |
} |
444 |
} |
Lines 453-459
public class HgCommand {
Link Here
|
453 |
* @return hg unbundle output |
454 |
* @return hg unbundle output |
454 |
* @throws org.netbeans.modules.mercurial.HgException |
455 |
* @throws org.netbeans.modules.mercurial.HgException |
455 |
*/ |
456 |
*/ |
456 |
public static List<String> doUnbundle(File repository, File bundle) throws HgException { |
457 |
public static List<String> doUnbundle(File repository, File bundle, OutputLogger logger) throws HgException { |
457 |
if (repository == null ) return null; |
458 |
if (repository == null ) return null; |
458 |
List<String> command = new ArrayList<String>(); |
459 |
List<String> command = new ArrayList<String>(); |
459 |
|
460 |
|
Lines 469-475
public class HgCommand {
Link Here
|
469 |
List<String> list = exec(command); |
470 |
List<String> list = exec(command); |
470 |
if (!list.isEmpty() && |
471 |
if (!list.isEmpty() && |
471 |
isErrorAbort(list.get(list.size() -1))) { |
472 |
isErrorAbort(list.get(list.size() -1))) { |
472 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
473 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
473 |
} |
474 |
} |
474 |
return list; |
475 |
return list; |
475 |
} |
476 |
} |
Lines 482-489
public class HgCommand {
Link Here
|
482 |
* @return hg incoming output |
483 |
* @return hg incoming output |
483 |
* @throws org.netbeans.modules.mercurial.HgException |
484 |
* @throws org.netbeans.modules.mercurial.HgException |
484 |
*/ |
485 |
*/ |
485 |
public static List<String> doIncoming(File repository) throws HgException { |
486 |
public static List<String> doIncoming(File repository, OutputLogger logger) throws HgException { |
486 |
return doIncoming(repository, null, null); |
487 |
return doIncoming(repository, null, null, logger); |
487 |
} |
488 |
} |
488 |
|
489 |
|
489 |
/** |
490 |
/** |
Lines 496-502
public class HgCommand {
Link Here
|
496 |
* @return hg incoming output |
497 |
* @return hg incoming output |
497 |
* @throws org.netbeans.modules.mercurial.HgException |
498 |
* @throws org.netbeans.modules.mercurial.HgException |
498 |
*/ |
499 |
*/ |
499 |
public static List<String> doIncoming(File repository, String from, File bundle) throws HgException { |
500 |
public static List<String> doIncoming(File repository, String from, File bundle, OutputLogger logger) throws HgException { |
500 |
if (repository == null ) return null; |
501 |
if (repository == null ) return null; |
501 |
List<String> command = new ArrayList<String>(); |
502 |
List<String> command = new ArrayList<String>(); |
502 |
|
503 |
|
Lines 515-521
public class HgCommand {
Link Here
|
515 |
|
516 |
|
516 |
List<String> list; |
517 |
List<String> list; |
517 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
518 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
518 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false); |
519 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); |
519 |
if(proxy != null){ |
520 |
if(proxy != null){ |
520 |
List<String> env = new ArrayList<String>(); |
521 |
List<String> env = new ArrayList<String>(); |
521 |
env.add(HG_PROXY_ENV + proxy); |
522 |
env.add(HG_PROXY_ENV + proxy); |
Lines 526-532
public class HgCommand {
Link Here
|
526 |
|
527 |
|
527 |
if (!list.isEmpty() && |
528 |
if (!list.isEmpty() && |
528 |
isErrorAbort(list.get(list.size() -1))) { |
529 |
isErrorAbort(list.get(list.size() -1))) { |
529 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
530 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
530 |
} |
531 |
} |
531 |
return list; |
532 |
return list; |
532 |
} |
533 |
} |
Lines 540-546
public class HgCommand {
Link Here
|
540 |
* @return hg outgoing output |
541 |
* @return hg outgoing output |
541 |
* @throws org.netbeans.modules.mercurial.HgException |
542 |
* @throws org.netbeans.modules.mercurial.HgException |
542 |
*/ |
543 |
*/ |
543 |
public static List<String> doOutgoing(File repository, String to) throws HgException { |
544 |
public static List<String> doOutgoing(File repository, String to, OutputLogger logger) throws HgException { |
544 |
if (repository == null ) return null; |
545 |
if (repository == null ) return null; |
545 |
List<String> command = new ArrayList<String>(); |
546 |
List<String> command = new ArrayList<String>(); |
546 |
|
547 |
|
Lines 553-559
public class HgCommand {
Link Here
|
553 |
|
554 |
|
554 |
List<String> list; |
555 |
List<String> list; |
555 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
556 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
556 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false); |
557 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); |
557 |
if(proxy != null){ |
558 |
if(proxy != null){ |
558 |
List<String> env = new ArrayList<String>(); |
559 |
List<String> env = new ArrayList<String>(); |
559 |
env.add(HG_PROXY_ENV + proxy); |
560 |
env.add(HG_PROXY_ENV + proxy); |
Lines 563-569
public class HgCommand {
Link Here
|
563 |
} |
564 |
} |
564 |
if (!list.isEmpty() && |
565 |
if (!list.isEmpty() && |
565 |
isErrorAbort(list.get(list.size() -1))) { |
566 |
isErrorAbort(list.get(list.size() -1))) { |
566 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
567 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
567 |
} |
568 |
} |
568 |
return list; |
569 |
return list; |
569 |
} |
570 |
} |
Lines 577-583
public class HgCommand {
Link Here
|
577 |
* @return hg push output |
578 |
* @return hg push output |
578 |
* @throws org.netbeans.modules.mercurial.HgException |
579 |
* @throws org.netbeans.modules.mercurial.HgException |
579 |
*/ |
580 |
*/ |
580 |
public static List<String> doPush(File repository, String to) throws HgException { |
581 |
public static List<String> doPush(File repository, String to, OutputLogger logger) throws HgException { |
581 |
if (repository == null || to == null ) return null; |
582 |
if (repository == null || to == null ) return null; |
582 |
List<String> command = new ArrayList<String>(); |
583 |
List<String> command = new ArrayList<String>(); |
583 |
|
584 |
|
Lines 589-595
public class HgCommand {
Link Here
|
589 |
|
590 |
|
590 |
List<String> list; |
591 |
List<String> list; |
591 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
592 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
592 |
String proxy = getGlobalProxyIfNeeded(defaultPush, true); |
593 |
String proxy = getGlobalProxyIfNeeded(defaultPush, true, logger); |
593 |
if(proxy != null){ |
594 |
if(proxy != null){ |
594 |
List<String> env = new ArrayList<String>(); |
595 |
List<String> env = new ArrayList<String>(); |
595 |
env.add(HG_PROXY_ENV + proxy); |
596 |
env.add(HG_PROXY_ENV + proxy); |
Lines 602-608
public class HgCommand {
Link Here
|
602 |
if (!list.isEmpty() && |
603 |
if (!list.isEmpty() && |
603 |
!isErrorAbortPush(list.get(list.size() -1)) && |
604 |
!isErrorAbortPush(list.get(list.size() -1)) && |
604 |
isErrorAbort(list.get(list.size() -1))) { |
605 |
isErrorAbort(list.get(list.size() -1))) { |
605 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
606 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
606 |
} |
607 |
} |
607 |
return list; |
608 |
return list; |
608 |
} |
609 |
} |
Lines 613-619
public class HgCommand {
Link Here
|
613 |
* @param File repository of the mercurial repository's root directory |
614 |
* @param File repository of the mercurial repository's root directory |
614 |
* @throws org.netbeans.modules.mercurial.HgException |
615 |
* @throws org.netbeans.modules.mercurial.HgException |
615 |
*/ |
616 |
*/ |
616 |
public static List<String> doView(File repository) throws HgException { |
617 |
public static List<String> doView(File repository, OutputLogger logger) throws HgException { |
617 |
if (repository == null) return null; |
618 |
if (repository == null) return null; |
618 |
List<String> command = new ArrayList<String>(); |
619 |
List<String> command = new ArrayList<String>(); |
619 |
List<String> env = new ArrayList<String>(); |
620 |
List<String> env = new ArrayList<String>(); |
Lines 639-651
public class HgCommand {
Link Here
|
639 |
else if (isErrorHgkNotFound(list.get(0))) { |
640 |
else if (isErrorHgkNotFound(list.get(0))) { |
640 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_WARN_HGK_NOT_FOUND_TEXT")); |
641 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_WARN_HGK_NOT_FOUND_TEXT")); |
641 |
} else if (isErrorAbort(list.get(list.size() -1))) { |
642 |
} else if (isErrorAbort(list.get(list.size() -1))) { |
642 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
643 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
643 |
} |
644 |
} |
644 |
} |
645 |
} |
645 |
return list; |
646 |
return list; |
646 |
} |
647 |
} |
647 |
|
648 |
|
648 |
private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails){ |
649 |
private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails, OutputLogger logger){ |
649 |
String proxy = null; |
650 |
String proxy = null; |
650 |
if(defaultPath != null && |
651 |
if(defaultPath != null && |
651 |
(defaultPath.startsWith("http:") || defaultPath.startsWith("https:"))){ // NOI18N |
652 |
(defaultPath.startsWith("http:") || defaultPath.startsWith("https:"))){ // NOI18N |
Lines 670-676
public class HgCommand {
Link Here
|
670 |
} |
671 |
} |
671 |
} |
672 |
} |
672 |
if(proxy != null && bOutputDetails){ |
673 |
if(proxy != null && bOutputDetails){ |
673 |
HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N |
674 |
logger.output(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N |
674 |
} |
675 |
} |
675 |
return proxy; |
676 |
return proxy; |
676 |
} |
677 |
} |
Lines 680-686
public class HgCommand {
Link Here
|
680 |
* @param File repository of the mercurial repository's root directory |
681 |
* @param File repository of the mercurial repository's root directory |
681 |
* @throws org.netbeans.modules.mercurial.HgException |
682 |
* @throws org.netbeans.modules.mercurial.HgException |
682 |
*/ |
683 |
*/ |
683 |
public static List<String> doFetch(File repository) throws HgException { |
684 |
public static List<String> doFetch(File repository, OutputLogger logger) throws HgException { |
684 |
if (repository == null) return null; |
685 |
if (repository == null) return null; |
685 |
List<String> command = new ArrayList<String>(); |
686 |
List<String> command = new ArrayList<String>(); |
686 |
|
687 |
|
Lines 693-699
public class HgCommand {
Link Here
|
693 |
|
694 |
|
694 |
List<String> list; |
695 |
List<String> list; |
695 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
696 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
696 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true); |
697 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); |
697 |
if(proxy != null){ |
698 |
if(proxy != null){ |
698 |
List<String> env = new ArrayList<String>(); |
699 |
List<String> env = new ArrayList<String>(); |
699 |
env.add(HG_PROXY_ENV + proxy); |
700 |
env.add(HG_PROXY_ENV + proxy); |
Lines 704-710
public class HgCommand {
Link Here
|
704 |
|
705 |
|
705 |
if (!list.isEmpty()) { |
706 |
if (!list.isEmpty()) { |
706 |
if (isErrorAbort(list.get(list.size() -1))) { |
707 |
if (isErrorAbort(list.get(list.size() -1))) { |
707 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
708 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
708 |
} |
709 |
} |
709 |
} |
710 |
} |
710 |
return list; |
711 |
return list; |
Lines 754-768
public class HgCommand {
Link Here
|
754 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
755 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
755 |
final File root = new File(rootUrl); |
756 |
final File root = new File(rootUrl); |
756 |
|
757 |
|
|
|
758 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
757 |
try { |
759 |
try { |
758 |
|
760 |
|
759 |
List<String> list = new LinkedList<String>(); |
761 |
List<String> list = new LinkedList<String>(); |
760 |
list = HgCommand.doIncomingForSearch(root); |
762 |
list = HgCommand.doIncomingForSearch(root, logger); |
761 |
processLogMessages(list, messages); |
763 |
processLogMessages(list, messages); |
762 |
|
764 |
|
763 |
} catch (HgException ex) { |
765 |
} catch (HgException ex) { |
764 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
766 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
765 |
DialogDisplayer.getDefault().notifyLater(e); |
767 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
768 |
} finally { |
769 |
logger.closeLog(); |
766 |
} |
770 |
} |
767 |
|
771 |
|
768 |
return messages.toArray(new HgLogMessage[0]); |
772 |
return messages.toArray(new HgLogMessage[0]); |
Lines 772-786
public class HgCommand {
Link Here
|
772 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
776 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
773 |
final File root = new File(rootUrl); |
777 |
final File root = new File(rootUrl); |
774 |
|
778 |
|
|
|
779 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
775 |
try { |
780 |
try { |
776 |
|
781 |
|
777 |
List<String> list = new LinkedList<String>(); |
782 |
List<String> list = new LinkedList<String>(); |
778 |
list = HgCommand.doOut(root); |
783 |
list = HgCommand.doOut(root, logger); |
779 |
processLogMessages(list, messages); |
784 |
processLogMessages(list, messages); |
780 |
|
785 |
|
781 |
} catch (HgException ex) { |
786 |
} catch (HgException ex) { |
782 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
787 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
783 |
DialogDisplayer.getDefault().notifyLater(e); |
788 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
789 |
} finally { |
790 |
logger.closeLog(); |
784 |
} |
791 |
} |
785 |
|
792 |
|
786 |
return messages.toArray(new HgLogMessage[0]); |
793 |
return messages.toArray(new HgLogMessage[0]); |
Lines 790-795
public class HgCommand {
Link Here
|
790 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
797 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
791 |
final File root = new File(rootUrl); |
798 |
final File root = new File(rootUrl); |
792 |
|
799 |
|
|
|
800 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
793 |
try { |
801 |
try { |
794 |
String headRev = HgCommand.getLastRevision(root, null); |
802 |
String headRev = HgCommand.getLastRevision(root, null); |
795 |
if (headRev == null) { |
803 |
if (headRev == null) { |
Lines 799-810
public class HgCommand {
Link Here
|
799 |
List<String> list = new LinkedList<String>(); |
807 |
List<String> list = new LinkedList<String>(); |
800 |
list = HgCommand.doLogForHistory(root, |
808 |
list = HgCommand.doLogForHistory(root, |
801 |
files != null ? new ArrayList<File>(files) : null, |
809 |
files != null ? new ArrayList<File>(files) : null, |
802 |
fromRevision, toRevision, headRev); |
810 |
fromRevision, toRevision, headRev, logger); |
803 |
processLogMessages(list, messages); |
811 |
processLogMessages(list, messages); |
804 |
|
812 |
|
805 |
} catch (HgException ex) { |
813 |
} catch (HgException ex) { |
806 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
814 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
807 |
DialogDisplayer.getDefault().notifyLater(e); |
815 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
816 |
} finally { |
817 |
logger.closeLog(); |
808 |
} |
818 |
} |
809 |
|
819 |
|
810 |
return messages.toArray(new HgLogMessage[0]); |
820 |
return messages.toArray(new HgLogMessage[0]); |
Lines 916-923
public class HgCommand {
Link Here
|
916 |
* @return List<String> list of the log entries for the specified file. |
926 |
* @return List<String> list of the log entries for the specified file. |
917 |
* @throws org.netbeans.modules.mercurial.HgException |
927 |
* @throws org.netbeans.modules.mercurial.HgException |
918 |
*/ |
928 |
*/ |
919 |
public static List<String> doLogShort(File repository, File file) throws HgException { |
929 |
public static List<String> doLogShort(File repository, File file, OutputLogger logger) throws HgException { |
920 |
return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false); |
930 |
return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false, logger); |
921 |
} |
931 |
} |
922 |
|
932 |
|
923 |
/** |
933 |
/** |
Lines 928-935
public class HgCommand {
Link Here
|
928 |
* @return List<String> list of the log entries for the specified file. |
938 |
* @return List<String> list of the log entries for the specified file. |
929 |
* @throws org.netbeans.modules.mercurial.HgException |
939 |
* @throws org.netbeans.modules.mercurial.HgException |
930 |
*/ |
940 |
*/ |
931 |
public static List<String> doLogLong(File repository, File file) throws HgException { |
941 |
public static List<String> doLogLong(File repository, File file, OutputLogger logger) throws HgException { |
932 |
return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false); |
942 |
return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false, logger); |
933 |
} |
943 |
} |
934 |
|
944 |
|
935 |
/** |
945 |
/** |
Lines 942-948
public class HgCommand {
Link Here
|
942 |
* @return List<String> list of the log entries for the specified file. |
952 |
* @return List<String> list of the log entries for the specified file. |
943 |
* @throws org.netbeans.modules.mercurial.HgException |
953 |
* @throws org.netbeans.modules.mercurial.HgException |
944 |
*/ |
954 |
*/ |
945 |
public static List<String> doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug) throws HgException { |
955 |
public static List<String> doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { |
946 |
if (repository == null ) return null; |
956 |
if (repository == null ) return null; |
947 |
|
957 |
|
948 |
List<String> command = new ArrayList<String>(); |
958 |
List<String> command = new ArrayList<String>(); |
Lines 963-971
public class HgCommand {
Link Here
|
963 |
List<String> list = exec(command); |
973 |
List<String> list = exec(command); |
964 |
if (!list.isEmpty()) { |
974 |
if (!list.isEmpty()) { |
965 |
if (isErrorNoRepository(list.get(0))) { |
975 |
if (isErrorNoRepository(list.get(0))) { |
966 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
976 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
967 |
} else if (isErrorAbort(list.get(0))) { |
977 |
} else if (isErrorAbort(list.get(0))) { |
968 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
978 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
969 |
} |
979 |
} |
970 |
} |
980 |
} |
971 |
return list; |
981 |
return list; |
Lines 981-987
public class HgCommand {
Link Here
|
981 |
* @return List<String> list of the log entries for the specified file. |
991 |
* @return List<String> list of the log entries for the specified file. |
982 |
* @throws org.netbeans.modules.mercurial.HgException |
992 |
* @throws org.netbeans.modules.mercurial.HgException |
983 |
*/ |
993 |
*/ |
984 |
public static List<String> doLog(File repository, List<File> files, String LOG_TEMPLATE, boolean bDebug) throws HgException { |
994 |
public static List<String> doLog(File repository, List<File> files, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { |
985 |
if (repository == null ) return null; |
995 |
if (repository == null ) return null; |
986 |
if (files != null && files.isEmpty()) return null; |
996 |
if (files != null && files.isEmpty()) return null; |
987 |
|
997 |
|
Lines 1019-1027
public class HgCommand {
Link Here
|
1019 |
List<String> list = exec(command); |
1029 |
List<String> list = exec(command); |
1020 |
if (!list.isEmpty()) { |
1030 |
if (!list.isEmpty()) { |
1021 |
if (isErrorNoRepository(list.get(0))) { |
1031 |
if (isErrorNoRepository(list.get(0))) { |
1022 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1032 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1023 |
} else if (isErrorAbort(list.get(0))) { |
1033 |
} else if (isErrorAbort(list.get(0))) { |
1024 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1034 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1025 |
} |
1035 |
} |
1026 |
} |
1036 |
} |
1027 |
return list; |
1037 |
return list; |
Lines 1038-1044
public class HgCommand {
Link Here
|
1038 |
* @throws org.netbeans.modules.mercurial.HgException |
1048 |
* @throws org.netbeans.modules.mercurial.HgException |
1039 |
*/ |
1049 |
*/ |
1040 |
public static List<String> doLogForHistory(File repository, List<File> files, |
1050 |
public static List<String> doLogForHistory(File repository, List<File> files, |
1041 |
String from, String to, String headRev) throws HgException { |
1051 |
String from, String to, String headRev, OutputLogger logger) throws HgException { |
1042 |
if (repository == null ) return null; |
1052 |
if (repository == null ) return null; |
1043 |
if (files != null && files.isEmpty()) return null; |
1053 |
if (files != null && files.isEmpty()) return null; |
1044 |
|
1054 |
|
Lines 1083-1091
public class HgCommand {
Link Here
|
1083 |
List<String> list = exec(command); |
1093 |
List<String> list = exec(command); |
1084 |
if (!list.isEmpty()) { |
1094 |
if (!list.isEmpty()) { |
1085 |
if (isErrorNoRepository(list.get(0))) { |
1095 |
if (isErrorNoRepository(list.get(0))) { |
1086 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1096 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1087 |
} else if (isErrorAbort(list.get(0))) { |
1097 |
} else if (isErrorAbort(list.get(0))) { |
1088 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1098 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1089 |
} |
1099 |
} |
1090 |
} |
1100 |
} |
1091 |
return list; |
1101 |
return list; |
Lines 1098-1104
public class HgCommand {
Link Here
|
1098 |
* @return List<String> list of the out entries for the specified repo. |
1108 |
* @return List<String> list of the out entries for the specified repo. |
1099 |
* @throws org.netbeans.modules.mercurial.HgException |
1109 |
* @throws org.netbeans.modules.mercurial.HgException |
1100 |
*/ |
1110 |
*/ |
1101 |
public static List<String> doOut(File repository) throws HgException { |
1111 |
public static List<String> doOut(File repository, OutputLogger logger) throws HgException { |
1102 |
if (repository == null ) return null; |
1112 |
if (repository == null ) return null; |
1103 |
|
1113 |
|
1104 |
List<String> command = new ArrayList<String>(); |
1114 |
List<String> command = new ArrayList<String>(); |
Lines 1113-1119
public class HgCommand {
Link Here
|
1113 |
|
1123 |
|
1114 |
List<String> list; |
1124 |
List<String> list; |
1115 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
1125 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
1116 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false); |
1126 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); |
1117 |
if(proxy != null){ |
1127 |
if(proxy != null){ |
1118 |
List<String> env = new ArrayList<String>(); |
1128 |
List<String> env = new ArrayList<String>(); |
1119 |
env.add(HG_PROXY_ENV + proxy); |
1129 |
env.add(HG_PROXY_ENV + proxy); |
Lines 1125-1133
public class HgCommand {
Link Here
|
1125 |
if(isErrorNoDefaultPush(list.get(0))){ |
1135 |
if(isErrorNoDefaultPush(list.get(0))){ |
1126 |
// Ignore |
1136 |
// Ignore |
1127 |
}else if (isErrorNoRepository(list.get(0))) { |
1137 |
}else if (isErrorNoRepository(list.get(0))) { |
1128 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1138 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1129 |
} else if (isErrorAbort(list.get(0))) { |
1139 |
} else if (isErrorAbort(list.get(0))) { |
1130 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1140 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1131 |
} |
1141 |
} |
1132 |
} |
1142 |
} |
1133 |
return list; |
1143 |
return list; |
Lines 1140-1146
public class HgCommand {
Link Here
|
1140 |
* @return List<String> list of the out entries for the specified repo. |
1150 |
* @return List<String> list of the out entries for the specified repo. |
1141 |
* @throws org.netbeans.modules.mercurial.HgException |
1151 |
* @throws org.netbeans.modules.mercurial.HgException |
1142 |
*/ |
1152 |
*/ |
1143 |
public static List<String> doIncomingForSearch(File repository) throws HgException { |
1153 |
public static List<String> doIncomingForSearch(File repository, OutputLogger logger) throws HgException { |
1144 |
if (repository == null ) return null; |
1154 |
if (repository == null ) return null; |
1145 |
|
1155 |
|
1146 |
List<String> command = new ArrayList<String>(); |
1156 |
List<String> command = new ArrayList<String>(); |
Lines 1154-1160
public class HgCommand {
Link Here
|
1154 |
|
1164 |
|
1155 |
List<String> list = exec(command); |
1165 |
List<String> list = exec(command); |
1156 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
1166 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
1157 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false); |
1167 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); |
1158 |
if(proxy != null){ |
1168 |
if(proxy != null){ |
1159 |
List<String> env = new ArrayList<String>(); |
1169 |
List<String> env = new ArrayList<String>(); |
1160 |
env.add(HG_PROXY_ENV + proxy); |
1170 |
env.add(HG_PROXY_ENV + proxy); |
Lines 1167-1175
public class HgCommand {
Link Here
|
1167 |
if (isErrorNoDefaultPath(list.get(0))) { |
1177 |
if (isErrorNoDefaultPath(list.get(0))) { |
1168 |
// Ignore |
1178 |
// Ignore |
1169 |
} else if (isErrorNoRepository(list.get(0))) { |
1179 |
} else if (isErrorNoRepository(list.get(0))) { |
1170 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1180 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1171 |
} else if (isErrorAbort(list.get(0)) || isErrorAbort(list.get(list.size() - 1))) { |
1181 |
} else if (isErrorAbort(list.get(0)) || isErrorAbort(list.get(list.size() - 1))) { |
1172 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1182 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1173 |
} |
1183 |
} |
1174 |
} |
1184 |
} |
1175 |
return list; |
1185 |
return list; |
Lines 1303-1310
public class HgCommand {
Link Here
|
1303 |
* @param File outFile to contain the contents of the file |
1313 |
* @param File outFile to contain the contents of the file |
1304 |
* @throws org.netbeans.modules.mercurial.HgException |
1314 |
* @throws org.netbeans.modules.mercurial.HgException |
1305 |
*/ |
1315 |
*/ |
1306 |
public static void doCat(File repository, File file, File outFile) throws HgException { |
1316 |
public static void doCat(File repository, File file, File outFile, OutputLogger logger) throws HgException { |
1307 |
doCat(repository, file, outFile, "tip", false); //NOI18N |
1317 |
doCat(repository, file, outFile, "tip", false, logger); //NOI18N |
1308 |
} |
1318 |
} |
1309 |
|
1319 |
|
1310 |
/** |
1320 |
/** |
Lines 1319-1329
public class HgCommand {
Link Here
|
1319 |
* @return List<String> list of all the log entries |
1329 |
* @return List<String> list of all the log entries |
1320 |
* @throws org.netbeans.modules.mercurial.HgException |
1330 |
* @throws org.netbeans.modules.mercurial.HgException |
1321 |
*/ |
1331 |
*/ |
1322 |
public static void doCat(File repository, File file, File outFile, String revision) throws HgException { |
1332 |
public static void doCat(File repository, File file, File outFile, String revision, OutputLogger logger) throws HgException { |
1323 |
doCat(repository, file, outFile, revision, true); //NOI18N |
1333 |
doCat(repository, file, outFile, revision, true, logger); //NOI18N |
1324 |
} |
1334 |
} |
1325 |
|
1335 |
|
1326 |
public static void doCat(File repository, File file, File outFile, String revision, boolean retry) throws HgException { |
1336 |
public static void doCat(File repository, File file, File outFile, String revision, boolean retry, OutputLogger logger) throws HgException { |
1327 |
if (repository == null) return; |
1337 |
if (repository == null) return; |
1328 |
if (file == null) return; |
1338 |
if (file == null) return; |
1329 |
|
1339 |
|
Lines 1345-1353
public class HgCommand {
Link Here
|
1345 |
|
1355 |
|
1346 |
if (!list.isEmpty()) { |
1356 |
if (!list.isEmpty()) { |
1347 |
if (isErrorNoRepository(list.get(0))) { |
1357 |
if (isErrorNoRepository(list.get(0))) { |
1348 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1358 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1349 |
} else if (isErrorAbort(list.get(0))) { |
1359 |
} else if (isErrorAbort(list.get(0))) { |
1350 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1360 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1351 |
} |
1361 |
} |
1352 |
} |
1362 |
} |
1353 |
if (outFile.length() == 0 && retry) { |
1363 |
if (outFile.length() == 0 && retry) { |
Lines 1355-1361
public class HgCommand {
Link Here
|
1355 |
String newRevision = Integer.toString(Integer.parseInt(revision)+1); |
1365 |
String newRevision = Integer.toString(Integer.parseInt(revision)+1); |
1356 |
File prevFile = getPreviousName(repository, file, newRevision); |
1366 |
File prevFile = getPreviousName(repository, file, newRevision); |
1357 |
if (prevFile != null) { |
1367 |
if (prevFile != null) { |
1358 |
doCat(repository, prevFile, outFile, revision, false); //NOI18N |
1368 |
doCat(repository, prevFile, outFile, revision, false, logger); //NOI18N |
1359 |
} |
1369 |
} |
1360 |
} |
1370 |
} |
1361 |
} |
1371 |
} |
Lines 1369-1375
public class HgCommand {
Link Here
|
1369 |
* @return void |
1379 |
* @return void |
1370 |
* @throws org.netbeans.modules.mercurial.HgException |
1380 |
* @throws org.netbeans.modules.mercurial.HgException |
1371 |
*/ |
1381 |
*/ |
1372 |
public static void doCreate(File root) throws HgException { |
1382 |
public static void doCreate(File root, OutputLogger logger) throws HgException { |
1373 |
if (root == null ) return; |
1383 |
if (root == null ) return; |
1374 |
List<String> command = new ArrayList<String>(); |
1384 |
List<String> command = new ArrayList<String>(); |
1375 |
|
1385 |
|
Lines 1379-1385
public class HgCommand {
Link Here
|
1379 |
|
1389 |
|
1380 |
List<String> list = exec(command); |
1390 |
List<String> list = exec(command); |
1381 |
if (!list.isEmpty()) |
1391 |
if (!list.isEmpty()) |
1382 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED")); |
1392 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED"), logger); |
1383 |
} |
1393 |
} |
1384 |
|
1394 |
|
1385 |
/** |
1395 |
/** |
Lines 1390-1398
public class HgCommand {
Link Here
|
1390 |
* @return clone output |
1400 |
* @return clone output |
1391 |
* @throws org.netbeans.modules.mercurial.HgException |
1401 |
* @throws org.netbeans.modules.mercurial.HgException |
1392 |
*/ |
1402 |
*/ |
1393 |
public static List<String> doClone(File repository, String target) throws HgException { |
1403 |
public static List<String> doClone(File repository, String target, OutputLogger logger) throws HgException { |
1394 |
if (repository == null) return null; |
1404 |
if (repository == null) return null; |
1395 |
return doClone(repository.getAbsolutePath(), target); |
1405 |
return doClone(repository.getAbsolutePath(), target, logger); |
1396 |
} |
1406 |
} |
1397 |
|
1407 |
|
1398 |
/** |
1408 |
/** |
Lines 1403-1409
public class HgCommand {
Link Here
|
1403 |
* @return clone output |
1413 |
* @return clone output |
1404 |
* @throws org.netbeans.modules.mercurial.HgException |
1414 |
* @throws org.netbeans.modules.mercurial.HgException |
1405 |
*/ |
1415 |
*/ |
1406 |
public static List<String> doClone(String repository, String target) throws HgException { |
1416 |
public static List<String> doClone(String repository, String target, OutputLogger logger) throws HgException { |
1407 |
if (repository == null || target == null) return null; |
1417 |
if (repository == null || target == null) return null; |
1408 |
|
1418 |
|
1409 |
// Ensure that parent directory of target exists, creating if necessary |
1419 |
// Ensure that parent directory of target exists, creating if necessary |
Lines 1437-1447
public class HgCommand {
Link Here
|
1437 |
List<String> list = exec(command); |
1447 |
List<String> list = exec(command); |
1438 |
if (!list.isEmpty()) { |
1448 |
if (!list.isEmpty()) { |
1439 |
if (isErrorNoRepository(list.get(0))){ |
1449 |
if (isErrorNoRepository(list.get(0))){ |
1440 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1450 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1441 |
}else if (isErrorNoResponse(list.get(list.size() -1))){ |
1451 |
}else if (isErrorNoResponse(list.get(list.size() -1))){ |
1442 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR")); |
1452 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR"), logger); |
1443 |
}else if (isErrorAbort(list.get(list.size() -1))){ |
1453 |
}else if (isErrorAbort(list.get(list.size() -1))){ |
1444 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1454 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1445 |
} |
1455 |
} |
1446 |
} |
1456 |
} |
1447 |
return list; |
1457 |
return list; |
Lines 1456-1462
public class HgCommand {
Link Here
|
1456 |
* @return void |
1466 |
* @return void |
1457 |
* @throws org.netbeans.modules.mercurial.HgException |
1467 |
* @throws org.netbeans.modules.mercurial.HgException |
1458 |
*/ |
1468 |
*/ |
1459 |
public static void doCommit(File repository, List<File> commitFiles, String commitMessage) throws HgException { |
1469 |
public static void doCommit(File repository, List<File> commitFiles, String commitMessage, OutputLogger logger) throws HgException { |
1460 |
List<String> command = new ArrayList<String>(); |
1470 |
List<String> command = new ArrayList<String>(); |
1461 |
|
1471 |
|
1462 |
command.add(getHgCommand()); |
1472 |
command.add(getHgCommand()); |
Lines 1501-1507
public class HgCommand {
Link Here
|
1501 |
|
1511 |
|
1502 |
if (!list.isEmpty() |
1512 |
if (!list.isEmpty() |
1503 |
&& (isErrorNotTracked(list.get(0)) || isErrorCannotReadCommitMsg(list.get(0)))) |
1513 |
&& (isErrorNotTracked(list.get(0)) || isErrorCannotReadCommitMsg(list.get(0)))) |
1504 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED")); |
1514 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED"), logger); |
1505 |
|
1515 |
|
1506 |
}catch (IOException ex){ |
1516 |
}catch (IOException ex){ |
1507 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_FAILED_TO_READ_COMMIT_MESSAGE")); |
1517 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_FAILED_TO_READ_COMMIT_MESSAGE")); |
Lines 1524-1534
public class HgCommand {
Link Here
|
1524 |
* @return void |
1534 |
* @return void |
1525 |
* @throws org.netbeans.modules.mercurial.HgException |
1535 |
* @throws org.netbeans.modules.mercurial.HgException |
1526 |
*/ |
1536 |
*/ |
1527 |
public static void doRename(File repository, File sourceFile, File destFile) throws HgException { |
1537 |
public static void doRename(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { |
1528 |
doRename(repository, sourceFile, destFile, false); |
1538 |
doRename(repository, sourceFile, destFile, false, logger); |
1529 |
} |
1539 |
} |
1530 |
|
1540 |
|
1531 |
private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter) throws HgException { |
1541 |
private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter, OutputLogger logger) throws HgException { |
1532 |
if (repository == null) return; |
1542 |
if (repository == null) return; |
1533 |
|
1543 |
|
1534 |
List<String> command = new ArrayList<String>(); |
1544 |
List<String> command = new ArrayList<String>(); |
Lines 1548-1554
public class HgCommand {
Link Here
|
1548 |
if (!list.isEmpty() && |
1558 |
if (!list.isEmpty() && |
1549 |
isErrorAbort(list.get(list.size() -1))) { |
1559 |
isErrorAbort(list.get(list.size() -1))) { |
1550 |
if (!bAfter || !isErrorAbortNoFilesToCopy(list.get(list.size() -1))) { |
1560 |
if (!bAfter || !isErrorAbortNoFilesToCopy(list.get(list.size() -1))) { |
1551 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED")); |
1561 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED"), logger); |
1552 |
} |
1562 |
} |
1553 |
} |
1563 |
} |
1554 |
} |
1564 |
} |
Lines 1563-1570
public class HgCommand {
Link Here
|
1563 |
* @return void |
1573 |
* @return void |
1564 |
* @throws org.netbeans.modules.mercurial.HgException |
1574 |
* @throws org.netbeans.modules.mercurial.HgException |
1565 |
*/ |
1575 |
*/ |
1566 |
public static void doRenameAfter(File repository, File sourceFile, File destFile) throws HgException { |
1576 |
public static void doRenameAfter(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { |
1567 |
doRename(repository, sourceFile, destFile, true); |
1577 |
doRename(repository, sourceFile, destFile, true, logger); |
1568 |
} |
1578 |
} |
1569 |
|
1579 |
|
1570 |
/** |
1580 |
/** |
Lines 1577-1583
public class HgCommand {
Link Here
|
1577 |
* @return void |
1587 |
* @return void |
1578 |
* @throws org.netbeans.modules.mercurial.HgException |
1588 |
* @throws org.netbeans.modules.mercurial.HgException |
1579 |
*/ |
1589 |
*/ |
1580 |
public static void doAdd(File repository, List<File> addFiles) throws HgException { |
1590 |
public static void doAdd(File repository, List<File> addFiles, OutputLogger logger) throws HgException { |
1581 |
if (repository == null) return; |
1591 |
if (repository == null) return; |
1582 |
if (addFiles.size() == 0) return; |
1592 |
if (addFiles.size() == 0) return; |
1583 |
List<String> command = new ArrayList<String>(); |
1593 |
List<String> command = new ArrayList<String>(); |
Lines 1596-1602
public class HgCommand {
Link Here
|
1596 |
} |
1606 |
} |
1597 |
List<String> list = exec(command); |
1607 |
List<String> list = exec(command); |
1598 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1608 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1599 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
1609 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
1600 |
} |
1610 |
} |
1601 |
|
1611 |
|
1602 |
/** |
1612 |
/** |
Lines 1608-1614
public class HgCommand {
Link Here
|
1608 |
* @return void |
1618 |
* @return void |
1609 |
* @throws org.netbeans.modules.mercurial.HgException |
1619 |
* @throws org.netbeans.modules.mercurial.HgException |
1610 |
*/ |
1620 |
*/ |
1611 |
public static void doRevert(File repository, List<File> revertFiles, String revision) throws HgException { |
1621 |
public static void doRevert(File repository, List<File> revertFiles, String revision, OutputLogger logger) throws HgException { |
1612 |
if (repository == null) return; |
1622 |
if (repository == null) return; |
1613 |
if (revertFiles.size() == 0) return; |
1623 |
if (revertFiles.size() == 0) return; |
1614 |
boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications(); |
1624 |
boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications(); |
Lines 1632-1638
public class HgCommand {
Link Here
|
1632 |
} |
1642 |
} |
1633 |
List<String> list = exec(command); |
1643 |
List<String> list = exec(command); |
1634 |
if (!list.isEmpty() && isErrorNoChangeNeeded(list.get(0))) |
1644 |
if (!list.isEmpty() && isErrorNoChangeNeeded(list.get(0))) |
1635 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED")); |
1645 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED"), logger); |
1636 |
} |
1646 |
} |
1637 |
|
1647 |
|
1638 |
/** |
1648 |
/** |
Lines 1645-1651
public class HgCommand {
Link Here
|
1645 |
* @return void |
1655 |
* @return void |
1646 |
* @throws org.netbeans.modules.mercurial.HgException |
1656 |
* @throws org.netbeans.modules.mercurial.HgException |
1647 |
*/ |
1657 |
*/ |
1648 |
public static void doAdd(File repository, File file) throws HgException { |
1658 |
public static void doAdd(File repository, File file, OutputLogger logger) throws HgException { |
1649 |
if (repository == null) return; |
1659 |
if (repository == null) return; |
1650 |
if (file == null) return; |
1660 |
if (file == null) return; |
1651 |
if (file.isDirectory()) return; |
1661 |
if (file.isDirectory()) return; |
Lines 1662-1668
public class HgCommand {
Link Here
|
1662 |
command.add(file.getAbsolutePath()); |
1672 |
command.add(file.getAbsolutePath()); |
1663 |
List<String> list = exec(command); |
1673 |
List<String> list = exec(command); |
1664 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1674 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1665 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
1675 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
1666 |
} |
1676 |
} |
1667 |
|
1677 |
|
1668 |
/** |
1678 |
/** |
Lines 1674-1680
public class HgCommand {
Link Here
|
1674 |
* @return List<String> list of the annotated lines of the file |
1684 |
* @return List<String> list of the annotated lines of the file |
1675 |
* @throws org.netbeans.modules.mercurial.HgException |
1685 |
* @throws org.netbeans.modules.mercurial.HgException |
1676 |
*/ |
1686 |
*/ |
1677 |
public static List<String> doAnnotate(File repository, File file, String revision) throws HgException { |
1687 |
public static List<String> doAnnotate(File repository, File file, String revision, OutputLogger logger) throws HgException { |
1678 |
if (repository == null) return null; |
1688 |
if (repository == null) return null; |
1679 |
List<String> command = new ArrayList<String>(); |
1689 |
List<String> command = new ArrayList<String>(); |
1680 |
|
1690 |
|
Lines 1694-1707
public class HgCommand {
Link Here
|
1694 |
List<String> list = exec(command); |
1704 |
List<String> list = exec(command); |
1695 |
if (!list.isEmpty()) { |
1705 |
if (!list.isEmpty()) { |
1696 |
if (isErrorNoRepository(list.get(0))) { |
1706 |
if (isErrorNoRepository(list.get(0))) { |
1697 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1707 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1698 |
} else if (isErrorNoSuchFile(list.get(0))) { |
1708 |
} else if (isErrorNoSuchFile(list.get(0))) { |
1699 |
// This can happen if we have multiple heads and the wrong |
1709 |
// This can happen if we have multiple heads and the wrong |
1700 |
// one was picked by default hg annotation |
1710 |
// one was picked by default hg annotation |
1701 |
if (revision == null) { |
1711 |
if (revision == null) { |
1702 |
String rev = getLastRevision(repository, file); |
1712 |
String rev = getLastRevision(repository, file); |
1703 |
if (rev != null) { |
1713 |
if (rev != null) { |
1704 |
list = doAnnotate(repository, file, rev); |
1714 |
list = doAnnotate(repository, file, rev, logger); |
1705 |
} else { |
1715 |
} else { |
1706 |
list = null; |
1716 |
list = null; |
1707 |
} |
1717 |
} |
Lines 1713-1720
public class HgCommand {
Link Here
|
1713 |
return list; |
1723 |
return list; |
1714 |
} |
1724 |
} |
1715 |
|
1725 |
|
1716 |
public static List<String> doAnnotate(File repository, File file) throws HgException { |
1726 |
public static List<String> doAnnotate(File repository, File file, OutputLogger logger) throws HgException { |
1717 |
return doAnnotate(repository, file, null); |
1727 |
return doAnnotate(repository, file, null, logger); |
1718 |
} |
1728 |
} |
1719 |
|
1729 |
|
1720 |
/** |
1730 |
/** |
Lines 2178-2184
public class HgCommand {
Link Here
|
2178 |
* @param f path to be removed from the repository |
2188 |
* @param f path to be removed from the repository |
2179 |
* @throws org.netbeans.modules.mercurial.HgException |
2189 |
* @throws org.netbeans.modules.mercurial.HgException |
2180 |
*/ |
2190 |
*/ |
2181 |
public static void doRemove(File repository, File f) throws HgException { |
2191 |
public static void doRemove(File repository, File f, OutputLogger logger) throws HgException { |
2182 |
List<String> command = new ArrayList<String>(); |
2192 |
List<String> command = new ArrayList<String>(); |
2183 |
|
2193 |
|
2184 |
command.add(getHgCommand()); |
2194 |
command.add(getHgCommand()); |
Lines 2190-2196
public class HgCommand {
Link Here
|
2190 |
|
2200 |
|
2191 |
List<String> list = exec(command); |
2201 |
List<String> list = exec(command); |
2192 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
2202 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
2193 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
2203 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
2194 |
} |
2204 |
} |
2195 |
|
2205 |
|
2196 |
/** |
2206 |
/** |
Lines 2201-2207
public class HgCommand {
Link Here
|
2201 |
* @param outputFileName path of the output file |
2211 |
* @param outputFileName path of the output file |
2202 |
* @throws org.netbeans.modules.mercurial.HgException |
2212 |
* @throws org.netbeans.modules.mercurial.HgException |
2203 |
*/ |
2213 |
*/ |
2204 |
public static List<String> doExport(File repository, String revStr, String outputFileName) throws HgException { |
2214 |
public static List<String> doExport(File repository, String revStr, String outputFileName, OutputLogger logger) throws HgException { |
2205 |
// Ensure that parent directory of target exists, creating if necessary |
2215 |
// Ensure that parent directory of target exists, creating if necessary |
2206 |
File fileTarget = new File (outputFileName); |
2216 |
File fileTarget = new File (outputFileName); |
2207 |
File parentTarget = fileTarget.getParentFile(); |
2217 |
File parentTarget = fileTarget.getParentFile(); |
Lines 2230-2236
public class HgCommand {
Link Here
|
2230 |
List<String> list = exec(command); |
2240 |
List<String> list = exec(command); |
2231 |
if (!list.isEmpty() && |
2241 |
if (!list.isEmpty() && |
2232 |
isErrorAbort(list.get(list.size() -1))) { |
2242 |
isErrorAbort(list.get(list.size() -1))) { |
2233 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED")); |
2243 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED"), logger); |
2234 |
} |
2244 |
} |
2235 |
return list; |
2245 |
return list; |
2236 |
} |
2246 |
} |
Lines 2242-2248
public class HgCommand {
Link Here
|
2242 |
* @param File patchFile of the patch file |
2252 |
* @param File patchFile of the patch file |
2243 |
* @throws org.netbeans.modules.mercurial.HgException |
2253 |
* @throws org.netbeans.modules.mercurial.HgException |
2244 |
*/ |
2254 |
*/ |
2245 |
public static List<String> doImport(File repository, File patchFile) throws HgException { |
2255 |
public static List<String> doImport(File repository, File patchFile, OutputLogger logger) throws HgException { |
2246 |
List<String> command = new ArrayList<String>(); |
2256 |
List<String> command = new ArrayList<String>(); |
2247 |
|
2257 |
|
2248 |
command.add(getHgCommand()); |
2258 |
command.add(getHgCommand()); |
Lines 2257-2264
public class HgCommand {
Link Here
|
2257 |
List<String> list = exec(command); |
2267 |
List<String> list = exec(command); |
2258 |
if (!list.isEmpty() && |
2268 |
if (!list.isEmpty() && |
2259 |
isErrorAbort(list.get(list.size() -1))) { |
2269 |
isErrorAbort(list.get(list.size() -1))) { |
2260 |
HgUtils.outputMercurialTab(list); // need the failure info from import |
2270 |
logger.output(list); // need the failure info from import |
2261 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED")); |
2271 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED"), logger); |
2262 |
} |
2272 |
} |
2263 |
return list; |
2273 |
return list; |
2264 |
} |
2274 |
} |
Lines 2424-2431
public class HgCommand {
Link Here
|
2424 |
} |
2434 |
} |
2425 |
|
2435 |
|
2426 |
List<String> list = exec(command); |
2436 |
List<String> list = exec(command); |
2427 |
if (!list.isEmpty() && isErrorNoRepository(list.get(0))) |
2437 |
if (!list.isEmpty() && isErrorNoRepository(list.get(0))) { |
2428 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
2438 |
OutputLogger logger = OutputLogger.getLogger(repository.getAbsolutePath()); |
|
|
2439 |
try { |
2440 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
2441 |
} finally { |
2442 |
logger.closeLog(); |
2443 |
} |
2444 |
} |
2429 |
return list; |
2445 |
return list; |
2430 |
} |
2446 |
} |
2431 |
/** |
2447 |
/** |
Lines 2564-2575
public class HgCommand {
Link Here
|
2564 |
return defaultPath + File.separatorChar + HG_COMMAND; |
2580 |
return defaultPath + File.separatorChar + HG_COMMAND; |
2565 |
} |
2581 |
} |
2566 |
|
2582 |
|
2567 |
private static void handleError(List<String> command, List<String> list, String message) throws HgException{ |
2583 |
private static void handleError(List<String> command, List<String> list, String message, OutputLogger logger) throws HgException{ |
2568 |
if (command != null && list != null){ |
2584 |
if (command != null && list != null){ |
2569 |
Mercurial.LOG.log(Level.WARNING, "command: " + HgUtils.replaceHttpPassword(command)); // NOI18N |
2585 |
Mercurial.LOG.log(Level.WARNING, "command: " + HgUtils.replaceHttpPassword(command)); // NOI18N |
2570 |
Mercurial.LOG.log(Level.WARNING, "output: " + HgUtils.replaceHttpPassword(list)); // NOI18N |
2586 |
Mercurial.LOG.log(Level.WARNING, "output: " + HgUtils.replaceHttpPassword(list)); // NOI18N |
2571 |
HgUtils.outputMercurialTabInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N |
2587 |
logger.outputInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N |
2572 |
HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", |
2588 |
logger.output(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", |
2573 |
HgUtils.replaceHttpPassword(command), HgUtils.replaceHttpPassword(list))); // NOI18N |
2589 |
HgUtils.replaceHttpPassword(command), HgUtils.replaceHttpPassword(list))); // NOI18N |
2574 |
} |
2590 |
} |
2575 |
|
2591 |
|