Lines 66-71
import org.netbeans.modules.mercurial.Fi
Link Here
|
66 |
import org.netbeans.modules.mercurial.FileStatus; |
66 |
import org.netbeans.modules.mercurial.FileStatus; |
67 |
import org.netbeans.modules.mercurial.HgException; |
67 |
import org.netbeans.modules.mercurial.HgException; |
68 |
import org.netbeans.modules.mercurial.Mercurial; |
68 |
import org.netbeans.modules.mercurial.Mercurial; |
|
|
69 |
import org.netbeans.modules.mercurial.OutputLogger; |
69 |
import org.netbeans.api.queries.SharabilityQuery; |
70 |
import org.netbeans.api.queries.SharabilityQuery; |
70 |
import org.netbeans.modules.mercurial.HgModuleConfig; |
71 |
import org.netbeans.modules.mercurial.HgModuleConfig; |
71 |
import org.netbeans.modules.mercurial.config.HgConfigFiles; |
72 |
import org.netbeans.modules.mercurial.config.HgConfigFiles; |
Lines 361-367
public class HgCommand {
Link Here
|
361 |
* @return hg update output |
362 |
* @return hg update output |
362 |
* @throws org.netbeans.modules.mercurial.HgException |
363 |
* @throws org.netbeans.modules.mercurial.HgException |
363 |
*/ |
364 |
*/ |
364 |
public static List<String> doRollback(File repository) throws HgException { |
365 |
public static List<String> doRollback(File repository, OutputLogger logger) throws HgException { |
365 |
if (repository == null ) return null; |
366 |
if (repository == null ) return null; |
366 |
List<String> command = new ArrayList<String>(); |
367 |
List<String> command = new ArrayList<String>(); |
367 |
|
368 |
|
Lines 372-383
public class HgCommand {
Link Here
|
372 |
|
373 |
|
373 |
List<String> list = exec(command); |
374 |
List<String> list = exec(command); |
374 |
if (list.isEmpty()) |
375 |
if (list.isEmpty()) |
375 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED")); |
376 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ROLLBACK_FAILED"), logger); |
376 |
|
377 |
|
377 |
return list; |
378 |
return list; |
378 |
} |
379 |
} |
379 |
public static List<String> doBackout(File repository, String revision, |
380 |
public static List<String> doBackout(File repository, String revision, |
380 |
boolean doMerge, String commitMsg) throws HgException { |
381 |
boolean doMerge, String commitMsg, OutputLogger logger) throws HgException { |
381 |
if (repository == null ) return null; |
382 |
if (repository == null ) return null; |
382 |
List<String> env = new ArrayList<String>(); |
383 |
List<String> env = new ArrayList<String>(); |
383 |
List<String> command = new ArrayList<String>(); |
384 |
List<String> command = new ArrayList<String>(); |
Lines 411-423
public class HgCommand {
Link Here
|
411 |
list = exec(command); |
412 |
list = exec(command); |
412 |
} |
413 |
} |
413 |
if (list.isEmpty()) |
414 |
if (list.isEmpty()) |
414 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_FAILED")); |
415 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_FAILED"), logger); |
415 |
|
416 |
|
416 |
return list; |
417 |
return list; |
417 |
} |
418 |
} |
418 |
|
419 |
|
419 |
public static List<String> doStrip(File repository, String revision, |
420 |
public static List<String> doStrip(File repository, String revision, |
420 |
boolean doForceMultiHead, boolean doBackup) throws HgException { |
421 |
boolean doForceMultiHead, boolean doBackup, OutputLogger logger) throws HgException { |
421 |
if (repository == null ) return null; |
422 |
if (repository == null ) return null; |
422 |
List<String> command = new ArrayList<String>(); |
423 |
List<String> command = new ArrayList<String>(); |
423 |
|
424 |
|
Lines 439-445
public class HgCommand {
Link Here
|
439 |
|
440 |
|
440 |
List<String> list = exec(command); |
441 |
List<String> list = exec(command); |
441 |
if (list.isEmpty()) |
442 |
if (list.isEmpty()) |
442 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_STRIP_FAILED")); |
443 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_STRIP_FAILED"), logger); |
443 |
|
444 |
|
444 |
return list; |
445 |
return list; |
445 |
} |
446 |
} |
Lines 476-483
public class HgCommand {
Link Here
|
476 |
* @return hg pull output |
477 |
* @return hg pull output |
477 |
* @throws org.netbeans.modules.mercurial.HgException |
478 |
* @throws org.netbeans.modules.mercurial.HgException |
478 |
*/ |
479 |
*/ |
479 |
public static List<String> doPull(File repository) throws HgException { |
480 |
public static List<String> doPull(File repository, OutputLogger logger) throws HgException { |
480 |
return doPull(repository, null); |
481 |
return doPull(repository, null, logger); |
481 |
} |
482 |
} |
482 |
|
483 |
|
483 |
/** |
484 |
/** |
Lines 491-497
public class HgCommand {
Link Here
|
491 |
* @return hg pull output |
492 |
* @return hg pull output |
492 |
* @throws org.netbeans.modules.mercurial.HgException |
493 |
* @throws org.netbeans.modules.mercurial.HgException |
493 |
*/ |
494 |
*/ |
494 |
public static List<String> doPull(File repository, String from) throws HgException { |
495 |
public static List<String> doPull(File repository, String from, OutputLogger logger) throws HgException { |
495 |
if (repository == null ) return null; |
496 |
if (repository == null ) return null; |
496 |
List<String> command = new ArrayList<String>(); |
497 |
List<String> command = new ArrayList<String>(); |
497 |
|
498 |
|
Lines 506-512
public class HgCommand {
Link Here
|
506 |
|
507 |
|
507 |
List<String> list; |
508 |
List<String> list; |
508 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
509 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
509 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true); |
510 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); |
510 |
if(proxy != null){ |
511 |
if(proxy != null){ |
511 |
List<String> env = new ArrayList<String>(); |
512 |
List<String> env = new ArrayList<String>(); |
512 |
env.add(HG_PROXY_ENV + proxy); |
513 |
env.add(HG_PROXY_ENV + proxy); |
Lines 517-523
public class HgCommand {
Link Here
|
517 |
|
518 |
|
518 |
if (!list.isEmpty() && |
519 |
if (!list.isEmpty() && |
519 |
isErrorAbort(list.get(list.size() -1))) { |
520 |
isErrorAbort(list.get(list.size() -1))) { |
520 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
521 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
521 |
} |
522 |
} |
522 |
return list; |
523 |
return list; |
523 |
} |
524 |
} |
Lines 533-539
public class HgCommand {
Link Here
|
533 |
* @return hg unbundle output |
534 |
* @return hg unbundle output |
534 |
* @throws org.netbeans.modules.mercurial.HgException |
535 |
* @throws org.netbeans.modules.mercurial.HgException |
535 |
*/ |
536 |
*/ |
536 |
public static List<String> doUnbundle(File repository, File bundle) throws HgException { |
537 |
public static List<String> doUnbundle(File repository, File bundle, OutputLogger logger) throws HgException { |
537 |
if (repository == null ) return null; |
538 |
if (repository == null ) return null; |
538 |
List<String> command = new ArrayList<String>(); |
539 |
List<String> command = new ArrayList<String>(); |
539 |
|
540 |
|
Lines 549-555
public class HgCommand {
Link Here
|
549 |
List<String> list = exec(command); |
550 |
List<String> list = exec(command); |
550 |
if (!list.isEmpty() && |
551 |
if (!list.isEmpty() && |
551 |
isErrorAbort(list.get(list.size() -1))) { |
552 |
isErrorAbort(list.get(list.size() -1))) { |
552 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
553 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
553 |
} |
554 |
} |
554 |
return list; |
555 |
return list; |
555 |
} |
556 |
} |
Lines 562-569
public class HgCommand {
Link Here
|
562 |
* @return hg incoming output |
563 |
* @return hg incoming output |
563 |
* @throws org.netbeans.modules.mercurial.HgException |
564 |
* @throws org.netbeans.modules.mercurial.HgException |
564 |
*/ |
565 |
*/ |
565 |
public static List<String> doIncoming(File repository) throws HgException { |
566 |
public static List<String> doIncoming(File repository, OutputLogger logger) throws HgException { |
566 |
return doIncoming(repository, null, null); |
567 |
return doIncoming(repository, null, null, logger); |
567 |
} |
568 |
} |
568 |
|
569 |
|
569 |
/** |
570 |
/** |
Lines 576-582
public class HgCommand {
Link Here
|
576 |
* @return hg incoming output |
577 |
* @return hg incoming output |
577 |
* @throws org.netbeans.modules.mercurial.HgException |
578 |
* @throws org.netbeans.modules.mercurial.HgException |
578 |
*/ |
579 |
*/ |
579 |
public static List<String> doIncoming(File repository, String from, File bundle) throws HgException { |
580 |
public static List<String> doIncoming(File repository, String from, File bundle, OutputLogger logger) throws HgException { |
580 |
if (repository == null ) return null; |
581 |
if (repository == null ) return null; |
581 |
List<String> command = new ArrayList<String>(); |
582 |
List<String> command = new ArrayList<String>(); |
582 |
|
583 |
|
Lines 595-601
public class HgCommand {
Link Here
|
595 |
|
596 |
|
596 |
List<String> list; |
597 |
List<String> list; |
597 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
598 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
598 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false); |
599 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); |
599 |
if(proxy != null){ |
600 |
if(proxy != null){ |
600 |
List<String> env = new ArrayList<String>(); |
601 |
List<String> env = new ArrayList<String>(); |
601 |
env.add(HG_PROXY_ENV + proxy); |
602 |
env.add(HG_PROXY_ENV + proxy); |
Lines 606-612
public class HgCommand {
Link Here
|
606 |
|
607 |
|
607 |
if (!list.isEmpty() && |
608 |
if (!list.isEmpty() && |
608 |
isErrorAbort(list.get(list.size() -1))) { |
609 |
isErrorAbort(list.get(list.size() -1))) { |
609 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
610 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
610 |
} |
611 |
} |
611 |
return list; |
612 |
return list; |
612 |
} |
613 |
} |
Lines 620-626
public class HgCommand {
Link Here
|
620 |
* @return hg outgoing output |
621 |
* @return hg outgoing output |
621 |
* @throws org.netbeans.modules.mercurial.HgException |
622 |
* @throws org.netbeans.modules.mercurial.HgException |
622 |
*/ |
623 |
*/ |
623 |
public static List<String> doOutgoing(File repository, String to) throws HgException { |
624 |
public static List<String> doOutgoing(File repository, String to, OutputLogger logger) throws HgException { |
624 |
if (repository == null ) return null; |
625 |
if (repository == null ) return null; |
625 |
List<String> command = new ArrayList<String>(); |
626 |
List<String> command = new ArrayList<String>(); |
626 |
|
627 |
|
Lines 633-639
public class HgCommand {
Link Here
|
633 |
|
634 |
|
634 |
List<String> list; |
635 |
List<String> list; |
635 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
636 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
636 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false); |
637 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); |
637 |
if(proxy != null){ |
638 |
if(proxy != null){ |
638 |
List<String> env = new ArrayList<String>(); |
639 |
List<String> env = new ArrayList<String>(); |
639 |
env.add(HG_PROXY_ENV + proxy); |
640 |
env.add(HG_PROXY_ENV + proxy); |
Lines 643-649
public class HgCommand {
Link Here
|
643 |
} |
644 |
} |
644 |
if (!list.isEmpty() && |
645 |
if (!list.isEmpty() && |
645 |
isErrorAbort(list.get(list.size() -1))) { |
646 |
isErrorAbort(list.get(list.size() -1))) { |
646 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
647 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
647 |
} |
648 |
} |
648 |
return list; |
649 |
return list; |
649 |
} |
650 |
} |
Lines 657-663
public class HgCommand {
Link Here
|
657 |
* @return hg push output |
658 |
* @return hg push output |
658 |
* @throws org.netbeans.modules.mercurial.HgException |
659 |
* @throws org.netbeans.modules.mercurial.HgException |
659 |
*/ |
660 |
*/ |
660 |
public static List<String> doPush(File repository, String to) throws HgException { |
661 |
public static List<String> doPush(File repository, String to, OutputLogger logger) throws HgException { |
661 |
if (repository == null || to == null ) return null; |
662 |
if (repository == null || to == null ) return null; |
662 |
List<String> command = new ArrayList<String>(); |
663 |
List<String> command = new ArrayList<String>(); |
663 |
|
664 |
|
Lines 669-675
public class HgCommand {
Link Here
|
669 |
|
670 |
|
670 |
List<String> list; |
671 |
List<String> list; |
671 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
672 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
672 |
String proxy = getGlobalProxyIfNeeded(defaultPush, true); |
673 |
String proxy = getGlobalProxyIfNeeded(defaultPush, true, logger); |
673 |
if(proxy != null){ |
674 |
if(proxy != null){ |
674 |
List<String> env = new ArrayList<String>(); |
675 |
List<String> env = new ArrayList<String>(); |
675 |
env.add(HG_PROXY_ENV + proxy); |
676 |
env.add(HG_PROXY_ENV + proxy); |
Lines 682-688
public class HgCommand {
Link Here
|
682 |
if (!list.isEmpty() && |
683 |
if (!list.isEmpty() && |
683 |
!isErrorAbortPush(list.get(list.size() -1)) && |
684 |
!isErrorAbortPush(list.get(list.size() -1)) && |
684 |
isErrorAbort(list.get(list.size() -1))) { |
685 |
isErrorAbort(list.get(list.size() -1))) { |
685 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
686 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
686 |
} |
687 |
} |
687 |
return list; |
688 |
return list; |
688 |
} |
689 |
} |
Lines 693-699
public class HgCommand {
Link Here
|
693 |
* @param File repository of the mercurial repository's root directory |
694 |
* @param File repository of the mercurial repository's root directory |
694 |
* @throws org.netbeans.modules.mercurial.HgException |
695 |
* @throws org.netbeans.modules.mercurial.HgException |
695 |
*/ |
696 |
*/ |
696 |
public static List<String> doView(File repository) throws HgException { |
697 |
public static List<String> doView(File repository, OutputLogger logger) throws HgException { |
697 |
if (repository == null) return null; |
698 |
if (repository == null) return null; |
698 |
List<String> command = new ArrayList<String>(); |
699 |
List<String> command = new ArrayList<String>(); |
699 |
List<String> env = new ArrayList<String>(); |
700 |
List<String> env = new ArrayList<String>(); |
Lines 719-731
public class HgCommand {
Link Here
|
719 |
else if (isErrorHgkNotFound(list.get(0))) { |
720 |
else if (isErrorHgkNotFound(list.get(0))) { |
720 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_WARN_HGK_NOT_FOUND_TEXT")); |
721 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_WARN_HGK_NOT_FOUND_TEXT")); |
721 |
} else if (isErrorAbort(list.get(list.size() -1))) { |
722 |
} else if (isErrorAbort(list.get(list.size() -1))) { |
722 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
723 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
723 |
} |
724 |
} |
724 |
} |
725 |
} |
725 |
return list; |
726 |
return list; |
726 |
} |
727 |
} |
727 |
|
728 |
|
728 |
private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails){ |
729 |
private static String getGlobalProxyIfNeeded(String defaultPath, boolean bOutputDetails, OutputLogger logger){ |
729 |
String proxy = null; |
730 |
String proxy = null; |
730 |
if(defaultPath != null && |
731 |
if(defaultPath != null && |
731 |
(defaultPath.startsWith("http:") || defaultPath.startsWith("https:"))){ // NOI18N |
732 |
(defaultPath.startsWith("http:") || defaultPath.startsWith("https:"))){ // NOI18N |
Lines 750-756
public class HgCommand {
Link Here
|
750 |
} |
751 |
} |
751 |
} |
752 |
} |
752 |
if(proxy != null && bOutputDetails){ |
753 |
if(proxy != null && bOutputDetails){ |
753 |
HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N |
754 |
logger.output(NbBundle.getMessage(HgCommand.class, "MSG_USING_PROXY_INFO", proxy)); // NOI18N |
754 |
} |
755 |
} |
755 |
return proxy; |
756 |
return proxy; |
756 |
} |
757 |
} |
Lines 760-766
public class HgCommand {
Link Here
|
760 |
* @param File repository of the mercurial repository's root directory |
761 |
* @param File repository of the mercurial repository's root directory |
761 |
* @throws org.netbeans.modules.mercurial.HgException |
762 |
* @throws org.netbeans.modules.mercurial.HgException |
762 |
*/ |
763 |
*/ |
763 |
public static List<String> doFetch(File repository) throws HgException { |
764 |
public static List<String> doFetch(File repository, OutputLogger logger) throws HgException { |
764 |
if (repository == null) return null; |
765 |
if (repository == null) return null; |
765 |
List<String> command = new ArrayList<String>(); |
766 |
List<String> command = new ArrayList<String>(); |
766 |
|
767 |
|
Lines 773-779
public class HgCommand {
Link Here
|
773 |
|
774 |
|
774 |
List<String> list; |
775 |
List<String> list; |
775 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
776 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
776 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true); |
777 |
String proxy = getGlobalProxyIfNeeded(defaultPull, true, logger); |
777 |
if(proxy != null){ |
778 |
if(proxy != null){ |
778 |
List<String> env = new ArrayList<String>(); |
779 |
List<String> env = new ArrayList<String>(); |
779 |
env.add(HG_PROXY_ENV + proxy); |
780 |
env.add(HG_PROXY_ENV + proxy); |
Lines 784-790
public class HgCommand {
Link Here
|
784 |
|
785 |
|
785 |
if (!list.isEmpty()) { |
786 |
if (!list.isEmpty()) { |
786 |
if (isErrorAbort(list.get(list.size() -1))) { |
787 |
if (isErrorAbort(list.get(list.size() -1))) { |
787 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
788 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
788 |
} |
789 |
} |
789 |
} |
790 |
} |
790 |
return list; |
791 |
return list; |
Lines 834-848
public class HgCommand {
Link Here
|
834 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
835 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
835 |
final File root = new File(rootUrl); |
836 |
final File root = new File(rootUrl); |
836 |
|
837 |
|
|
|
838 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
837 |
try { |
839 |
try { |
838 |
|
840 |
|
839 |
List<String> list = new LinkedList<String>(); |
841 |
List<String> list = new LinkedList<String>(); |
840 |
list = HgCommand.doIncomingForSearch(root); |
842 |
list = HgCommand.doIncomingForSearch(root, logger); |
841 |
processLogMessages(list, messages); |
843 |
processLogMessages(list, messages); |
842 |
|
844 |
|
843 |
} catch (HgException ex) { |
845 |
} catch (HgException ex) { |
844 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
846 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
845 |
DialogDisplayer.getDefault().notifyLater(e); |
847 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
848 |
} finally { |
849 |
logger.closeLog(); |
846 |
} |
850 |
} |
847 |
|
851 |
|
848 |
return messages.toArray(new HgLogMessage[0]); |
852 |
return messages.toArray(new HgLogMessage[0]); |
Lines 852-866
public class HgCommand {
Link Here
|
852 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
856 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
853 |
final File root = new File(rootUrl); |
857 |
final File root = new File(rootUrl); |
854 |
|
858 |
|
|
|
859 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
855 |
try { |
860 |
try { |
856 |
|
861 |
|
857 |
List<String> list = new LinkedList<String>(); |
862 |
List<String> list = new LinkedList<String>(); |
858 |
list = HgCommand.doOut(root); |
863 |
list = HgCommand.doOut(root, logger); |
859 |
processLogMessages(list, messages); |
864 |
processLogMessages(list, messages); |
860 |
|
865 |
|
861 |
} catch (HgException ex) { |
866 |
} catch (HgException ex) { |
862 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
867 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
863 |
DialogDisplayer.getDefault().notifyLater(e); |
868 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
869 |
} finally { |
870 |
logger.closeLog(); |
864 |
} |
871 |
} |
865 |
|
872 |
|
866 |
return messages.toArray(new HgLogMessage[0]); |
873 |
return messages.toArray(new HgLogMessage[0]); |
Lines 870-875
public class HgCommand {
Link Here
|
870 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
877 |
final List<HgLogMessage> messages = new ArrayList<HgLogMessage>(0); |
871 |
final File root = new File(rootUrl); |
878 |
final File root = new File(rootUrl); |
872 |
|
879 |
|
|
|
880 |
OutputLogger logger = OutputLogger.getLogger(rootUrl); |
873 |
try { |
881 |
try { |
874 |
String headRev = HgCommand.getLastRevision(root, null); |
882 |
String headRev = HgCommand.getLastRevision(root, null); |
875 |
if (headRev == null) { |
883 |
if (headRev == null) { |
Lines 879-890
public class HgCommand {
Link Here
|
879 |
List<String> list = new LinkedList<String>(); |
887 |
List<String> list = new LinkedList<String>(); |
880 |
list = HgCommand.doLogForHistory(root, |
888 |
list = HgCommand.doLogForHistory(root, |
881 |
files != null ? new ArrayList<File>(files) : null, |
889 |
files != null ? new ArrayList<File>(files) : null, |
882 |
fromRevision, toRevision, headRev); |
890 |
fromRevision, toRevision, headRev, logger); |
883 |
processLogMessages(list, messages); |
891 |
processLogMessages(list, messages); |
884 |
|
892 |
|
885 |
} catch (HgException ex) { |
893 |
} catch (HgException ex) { |
886 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
894 |
NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); |
887 |
DialogDisplayer.getDefault().notifyLater(e); |
895 |
DialogDisplayer.getDefault().notifyLater(e); |
|
|
896 |
} finally { |
897 |
logger.closeLog(); |
888 |
} |
898 |
} |
889 |
|
899 |
|
890 |
return messages.toArray(new HgLogMessage[0]); |
900 |
return messages.toArray(new HgLogMessage[0]); |
Lines 996-1003
public class HgCommand {
Link Here
|
996 |
* @return List<String> list of the log entries for the specified file. |
1006 |
* @return List<String> list of the log entries for the specified file. |
997 |
* @throws org.netbeans.modules.mercurial.HgException |
1007 |
* @throws org.netbeans.modules.mercurial.HgException |
998 |
*/ |
1008 |
*/ |
999 |
public static List<String> doLogShort(File repository, File file) throws HgException { |
1009 |
public static List<String> doLogShort(File repository, File file, OutputLogger logger) throws HgException { |
1000 |
return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false); |
1010 |
return doLog(repository, file, HG_LOG_TEMPLATE_SHORT_CMD, false, logger); |
1001 |
} |
1011 |
} |
1002 |
|
1012 |
|
1003 |
/** |
1013 |
/** |
Lines 1008-1015
public class HgCommand {
Link Here
|
1008 |
* @return List<String> list of the log entries for the specified file. |
1018 |
* @return List<String> list of the log entries for the specified file. |
1009 |
* @throws org.netbeans.modules.mercurial.HgException |
1019 |
* @throws org.netbeans.modules.mercurial.HgException |
1010 |
*/ |
1020 |
*/ |
1011 |
public static List<String> doLogLong(File repository, File file) throws HgException { |
1021 |
public static List<String> doLogLong(File repository, File file, OutputLogger logger) throws HgException { |
1012 |
return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false); |
1022 |
return doLog(repository, file, HG_LOG_TEMPLATE_LONG_CMD, false, logger); |
1013 |
} |
1023 |
} |
1014 |
|
1024 |
|
1015 |
/** |
1025 |
/** |
Lines 1022-1028
public class HgCommand {
Link Here
|
1022 |
* @return List<String> list of the log entries for the specified file. |
1032 |
* @return List<String> list of the log entries for the specified file. |
1023 |
* @throws org.netbeans.modules.mercurial.HgException |
1033 |
* @throws org.netbeans.modules.mercurial.HgException |
1024 |
*/ |
1034 |
*/ |
1025 |
public static List<String> doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug) throws HgException { |
1035 |
public static List<String> doLog(File repository, File file, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { |
1026 |
if (repository == null ) return null; |
1036 |
if (repository == null ) return null; |
1027 |
|
1037 |
|
1028 |
List<String> command = new ArrayList<String>(); |
1038 |
List<String> command = new ArrayList<String>(); |
Lines 1043-1051
public class HgCommand {
Link Here
|
1043 |
List<String> list = exec(command); |
1053 |
List<String> list = exec(command); |
1044 |
if (!list.isEmpty()) { |
1054 |
if (!list.isEmpty()) { |
1045 |
if (isErrorNoRepository(list.get(0))) { |
1055 |
if (isErrorNoRepository(list.get(0))) { |
1046 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1056 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1047 |
} else if (isErrorAbort(list.get(0))) { |
1057 |
} else if (isErrorAbort(list.get(0))) { |
1048 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1058 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1049 |
} |
1059 |
} |
1050 |
} |
1060 |
} |
1051 |
return list; |
1061 |
return list; |
Lines 1061-1067
public class HgCommand {
Link Here
|
1061 |
* @return List<String> list of the log entries for the specified file. |
1071 |
* @return List<String> list of the log entries for the specified file. |
1062 |
* @throws org.netbeans.modules.mercurial.HgException |
1072 |
* @throws org.netbeans.modules.mercurial.HgException |
1063 |
*/ |
1073 |
*/ |
1064 |
public static List<String> doLog(File repository, List<File> files, String LOG_TEMPLATE, boolean bDebug) throws HgException { |
1074 |
public static List<String> doLog(File repository, List<File> files, String LOG_TEMPLATE, boolean bDebug, OutputLogger logger) throws HgException { |
1065 |
if (repository == null ) return null; |
1075 |
if (repository == null ) return null; |
1066 |
if (files != null && files.isEmpty()) return null; |
1076 |
if (files != null && files.isEmpty()) return null; |
1067 |
|
1077 |
|
Lines 1099-1107
public class HgCommand {
Link Here
|
1099 |
List<String> list = exec(command); |
1109 |
List<String> list = exec(command); |
1100 |
if (!list.isEmpty()) { |
1110 |
if (!list.isEmpty()) { |
1101 |
if (isErrorNoRepository(list.get(0))) { |
1111 |
if (isErrorNoRepository(list.get(0))) { |
1102 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1112 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1103 |
} else if (isErrorAbort(list.get(0))) { |
1113 |
} else if (isErrorAbort(list.get(0))) { |
1104 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1114 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1105 |
} |
1115 |
} |
1106 |
} |
1116 |
} |
1107 |
return list; |
1117 |
return list; |
Lines 1118-1124
public class HgCommand {
Link Here
|
1118 |
* @throws org.netbeans.modules.mercurial.HgException |
1128 |
* @throws org.netbeans.modules.mercurial.HgException |
1119 |
*/ |
1129 |
*/ |
1120 |
public static List<String> doLogForHistory(File repository, List<File> files, |
1130 |
public static List<String> doLogForHistory(File repository, List<File> files, |
1121 |
String from, String to, String headRev) throws HgException { |
1131 |
String from, String to, String headRev, OutputLogger logger) throws HgException { |
1122 |
if (repository == null ) return null; |
1132 |
if (repository == null ) return null; |
1123 |
if (files != null && files.isEmpty()) return null; |
1133 |
if (files != null && files.isEmpty()) return null; |
1124 |
|
1134 |
|
Lines 1163-1171
public class HgCommand {
Link Here
|
1163 |
List<String> list = exec(command); |
1173 |
List<String> list = exec(command); |
1164 |
if (!list.isEmpty()) { |
1174 |
if (!list.isEmpty()) { |
1165 |
if (isErrorNoRepository(list.get(0))) { |
1175 |
if (isErrorNoRepository(list.get(0))) { |
1166 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1176 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1167 |
} else if (isErrorAbort(list.get(0))) { |
1177 |
} else if (isErrorAbort(list.get(0))) { |
1168 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1178 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1169 |
} |
1179 |
} |
1170 |
} |
1180 |
} |
1171 |
return list; |
1181 |
return list; |
Lines 1178-1184
public class HgCommand {
Link Here
|
1178 |
* @return List<String> list of the out entries for the specified repo. |
1188 |
* @return List<String> list of the out entries for the specified repo. |
1179 |
* @throws org.netbeans.modules.mercurial.HgException |
1189 |
* @throws org.netbeans.modules.mercurial.HgException |
1180 |
*/ |
1190 |
*/ |
1181 |
public static List<String> doOut(File repository) throws HgException { |
1191 |
public static List<String> doOut(File repository, OutputLogger logger) throws HgException { |
1182 |
if (repository == null ) return null; |
1192 |
if (repository == null ) return null; |
1183 |
|
1193 |
|
1184 |
List<String> command = new ArrayList<String>(); |
1194 |
List<String> command = new ArrayList<String>(); |
Lines 1193-1199
public class HgCommand {
Link Here
|
1193 |
|
1203 |
|
1194 |
List<String> list; |
1204 |
List<String> list; |
1195 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
1205 |
String defaultPush = new HgConfigFiles(repository).getDefaultPush(false); |
1196 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false); |
1206 |
String proxy = getGlobalProxyIfNeeded(defaultPush, false, null); |
1197 |
if(proxy != null){ |
1207 |
if(proxy != null){ |
1198 |
List<String> env = new ArrayList<String>(); |
1208 |
List<String> env = new ArrayList<String>(); |
1199 |
env.add(HG_PROXY_ENV + proxy); |
1209 |
env.add(HG_PROXY_ENV + proxy); |
Lines 1205-1213
public class HgCommand {
Link Here
|
1205 |
if(isErrorNoDefaultPush(list.get(0))){ |
1215 |
if(isErrorNoDefaultPush(list.get(0))){ |
1206 |
// Ignore |
1216 |
// Ignore |
1207 |
}else if (isErrorNoRepository(list.get(0))) { |
1217 |
}else if (isErrorNoRepository(list.get(0))) { |
1208 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1218 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1209 |
} else if (isErrorAbort(list.get(0))) { |
1219 |
} else if (isErrorAbort(list.get(0))) { |
1210 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1220 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1211 |
} |
1221 |
} |
1212 |
} |
1222 |
} |
1213 |
return list; |
1223 |
return list; |
Lines 1220-1226
public class HgCommand {
Link Here
|
1220 |
* @return List<String> list of the out entries for the specified repo. |
1230 |
* @return List<String> list of the out entries for the specified repo. |
1221 |
* @throws org.netbeans.modules.mercurial.HgException |
1231 |
* @throws org.netbeans.modules.mercurial.HgException |
1222 |
*/ |
1232 |
*/ |
1223 |
public static List<String> doIncomingForSearch(File repository) throws HgException { |
1233 |
public static List<String> doIncomingForSearch(File repository, OutputLogger logger) throws HgException { |
1224 |
if (repository == null ) return null; |
1234 |
if (repository == null ) return null; |
1225 |
|
1235 |
|
1226 |
List<String> command = new ArrayList<String>(); |
1236 |
List<String> command = new ArrayList<String>(); |
Lines 1234-1240
public class HgCommand {
Link Here
|
1234 |
|
1244 |
|
1235 |
List<String> list = exec(command); |
1245 |
List<String> list = exec(command); |
1236 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
1246 |
String defaultPull = new HgConfigFiles(repository).getDefaultPull(false); |
1237 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false); |
1247 |
String proxy = getGlobalProxyIfNeeded(defaultPull, false, null); |
1238 |
if(proxy != null){ |
1248 |
if(proxy != null){ |
1239 |
List<String> env = new ArrayList<String>(); |
1249 |
List<String> env = new ArrayList<String>(); |
1240 |
env.add(HG_PROXY_ENV + proxy); |
1250 |
env.add(HG_PROXY_ENV + proxy); |
Lines 1247-1255
public class HgCommand {
Link Here
|
1247 |
if (isErrorNoDefaultPath(list.get(0))) { |
1257 |
if (isErrorNoDefaultPath(list.get(0))) { |
1248 |
// Ignore |
1258 |
// Ignore |
1249 |
} else if (isErrorNoRepository(list.get(0))) { |
1259 |
} else if (isErrorNoRepository(list.get(0))) { |
1250 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1260 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1251 |
} else if (isErrorAbort(list.get(0)) || isErrorAbort(list.get(list.size() - 1))) { |
1261 |
} else if (isErrorAbort(list.get(0)) || isErrorAbort(list.get(list.size() - 1))) { |
1252 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1262 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1253 |
} |
1263 |
} |
1254 |
} |
1264 |
} |
1255 |
return list; |
1265 |
return list; |
Lines 1383-1390
public class HgCommand {
Link Here
|
1383 |
* @param File outFile to contain the contents of the file |
1393 |
* @param File outFile to contain the contents of the file |
1384 |
* @throws org.netbeans.modules.mercurial.HgException |
1394 |
* @throws org.netbeans.modules.mercurial.HgException |
1385 |
*/ |
1395 |
*/ |
1386 |
public static void doCat(File repository, File file, File outFile) throws HgException { |
1396 |
public static void doCat(File repository, File file, File outFile, OutputLogger logger) throws HgException { |
1387 |
doCat(repository, file, outFile, "tip", false); //NOI18N |
1397 |
doCat(repository, file, outFile, "tip", false, logger); //NOI18N |
1388 |
} |
1398 |
} |
1389 |
|
1399 |
|
1390 |
/** |
1400 |
/** |
Lines 1399-1409
public class HgCommand {
Link Here
|
1399 |
* @return List<String> list of all the log entries |
1409 |
* @return List<String> list of all the log entries |
1400 |
* @throws org.netbeans.modules.mercurial.HgException |
1410 |
* @throws org.netbeans.modules.mercurial.HgException |
1401 |
*/ |
1411 |
*/ |
1402 |
public static void doCat(File repository, File file, File outFile, String revision) throws HgException { |
1412 |
public static void doCat(File repository, File file, File outFile, String revision, OutputLogger logger) throws HgException { |
1403 |
doCat(repository, file, outFile, revision, true); //NOI18N |
1413 |
doCat(repository, file, outFile, revision, true, logger); //NOI18N |
1404 |
} |
1414 |
} |
1405 |
|
1415 |
|
1406 |
public static void doCat(File repository, File file, File outFile, String revision, boolean retry) throws HgException { |
1416 |
public static void doCat(File repository, File file, File outFile, String revision, boolean retry, OutputLogger logger) throws HgException { |
1407 |
if (repository == null) return; |
1417 |
if (repository == null) return; |
1408 |
if (file == null) return; |
1418 |
if (file == null) return; |
1409 |
|
1419 |
|
Lines 1425-1433
public class HgCommand {
Link Here
|
1425 |
|
1435 |
|
1426 |
if (!list.isEmpty()) { |
1436 |
if (!list.isEmpty()) { |
1427 |
if (isErrorNoRepository(list.get(0))) { |
1437 |
if (isErrorNoRepository(list.get(0))) { |
1428 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1438 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1429 |
} else if (isErrorAbort(list.get(0))) { |
1439 |
} else if (isErrorAbort(list.get(0))) { |
1430 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1440 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1431 |
} |
1441 |
} |
1432 |
} |
1442 |
} |
1433 |
if (outFile.length() == 0 && retry) { |
1443 |
if (outFile.length() == 0 && retry) { |
Lines 1435-1441
public class HgCommand {
Link Here
|
1435 |
String newRevision = Integer.toString(Integer.parseInt(revision)+1); |
1445 |
String newRevision = Integer.toString(Integer.parseInt(revision)+1); |
1436 |
File prevFile = getPreviousName(repository, file, newRevision); |
1446 |
File prevFile = getPreviousName(repository, file, newRevision); |
1437 |
if (prevFile != null) { |
1447 |
if (prevFile != null) { |
1438 |
doCat(repository, prevFile, outFile, revision, false); //NOI18N |
1448 |
doCat(repository, prevFile, outFile, revision, false, logger); //NOI18N |
1439 |
} |
1449 |
} |
1440 |
} |
1450 |
} |
1441 |
} |
1451 |
} |
Lines 1449-1455
public class HgCommand {
Link Here
|
1449 |
* @return void |
1459 |
* @return void |
1450 |
* @throws org.netbeans.modules.mercurial.HgException |
1460 |
* @throws org.netbeans.modules.mercurial.HgException |
1451 |
*/ |
1461 |
*/ |
1452 |
public static void doCreate(File root) throws HgException { |
1462 |
public static void doCreate(File root, OutputLogger logger) throws HgException { |
1453 |
if (root == null ) return; |
1463 |
if (root == null ) return; |
1454 |
List<String> command = new ArrayList<String>(); |
1464 |
List<String> command = new ArrayList<String>(); |
1455 |
|
1465 |
|
Lines 1459-1465
public class HgCommand {
Link Here
|
1459 |
|
1469 |
|
1460 |
List<String> list = exec(command); |
1470 |
List<String> list = exec(command); |
1461 |
if (!list.isEmpty()) |
1471 |
if (!list.isEmpty()) |
1462 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED")); |
1472 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_CREATE_FAILED"), logger); |
1463 |
} |
1473 |
} |
1464 |
|
1474 |
|
1465 |
/** |
1475 |
/** |
Lines 1470-1478
public class HgCommand {
Link Here
|
1470 |
* @return clone output |
1480 |
* @return clone output |
1471 |
* @throws org.netbeans.modules.mercurial.HgException |
1481 |
* @throws org.netbeans.modules.mercurial.HgException |
1472 |
*/ |
1482 |
*/ |
1473 |
public static List<String> doClone(File repository, String target) throws HgException { |
1483 |
public static List<String> doClone(File repository, String target, OutputLogger logger) throws HgException { |
1474 |
if (repository == null) return null; |
1484 |
if (repository == null) return null; |
1475 |
return doClone(repository.getAbsolutePath(), target); |
1485 |
return doClone(repository.getAbsolutePath(), target, logger); |
1476 |
} |
1486 |
} |
1477 |
|
1487 |
|
1478 |
/** |
1488 |
/** |
Lines 1483-1489
public class HgCommand {
Link Here
|
1483 |
* @return clone output |
1493 |
* @return clone output |
1484 |
* @throws org.netbeans.modules.mercurial.HgException |
1494 |
* @throws org.netbeans.modules.mercurial.HgException |
1485 |
*/ |
1495 |
*/ |
1486 |
public static List<String> doClone(String repository, String target) throws HgException { |
1496 |
public static List<String> doClone(String repository, String target, OutputLogger logger) throws HgException { |
1487 |
if (repository == null || target == null) return null; |
1497 |
if (repository == null || target == null) return null; |
1488 |
|
1498 |
|
1489 |
// Ensure that parent directory of target exists, creating if necessary |
1499 |
// Ensure that parent directory of target exists, creating if necessary |
Lines 1517-1527
public class HgCommand {
Link Here
|
1517 |
List<String> list = exec(command); |
1527 |
List<String> list = exec(command); |
1518 |
if (!list.isEmpty()) { |
1528 |
if (!list.isEmpty()) { |
1519 |
if (isErrorNoRepository(list.get(0))){ |
1529 |
if (isErrorNoRepository(list.get(0))){ |
1520 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1530 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1521 |
}else if (isErrorNoResponse(list.get(list.size() -1))){ |
1531 |
}else if (isErrorNoResponse(list.get(list.size() -1))){ |
1522 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR")); |
1532 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_RESPONSE_ERR"), logger); |
1523 |
}else if (isErrorAbort(list.get(list.size() -1))){ |
1533 |
}else if (isErrorAbort(list.get(list.size() -1))){ |
1524 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); |
1534 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED"), logger); |
1525 |
} |
1535 |
} |
1526 |
} |
1536 |
} |
1527 |
return list; |
1537 |
return list; |
Lines 1536-1542
public class HgCommand {
Link Here
|
1536 |
* @return void |
1546 |
* @return void |
1537 |
* @throws org.netbeans.modules.mercurial.HgException |
1547 |
* @throws org.netbeans.modules.mercurial.HgException |
1538 |
*/ |
1548 |
*/ |
1539 |
public static void doCommit(File repository, List<File> commitFiles, String commitMessage) throws HgException { |
1549 |
public static void doCommit(File repository, List<File> commitFiles, String commitMessage, OutputLogger logger) throws HgException { |
1540 |
List<String> command = new ArrayList<String>(); |
1550 |
List<String> command = new ArrayList<String>(); |
1541 |
|
1551 |
|
1542 |
command.add(getHgCommand()); |
1552 |
command.add(getHgCommand()); |
Lines 1581-1587
public class HgCommand {
Link Here
|
1581 |
|
1591 |
|
1582 |
if (!list.isEmpty() |
1592 |
if (!list.isEmpty() |
1583 |
&& (isErrorNotTracked(list.get(0)) || isErrorCannotReadCommitMsg(list.get(0)))) |
1593 |
&& (isErrorNotTracked(list.get(0)) || isErrorCannotReadCommitMsg(list.get(0)))) |
1584 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED")); |
1594 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMIT_FAILED"), logger); |
1585 |
|
1595 |
|
1586 |
}catch (IOException ex){ |
1596 |
}catch (IOException ex){ |
1587 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_FAILED_TO_READ_COMMIT_MESSAGE")); |
1597 |
throw new HgException(NbBundle.getMessage(HgCommand.class, "MSG_FAILED_TO_READ_COMMIT_MESSAGE")); |
Lines 1604-1614
public class HgCommand {
Link Here
|
1604 |
* @return void |
1614 |
* @return void |
1605 |
* @throws org.netbeans.modules.mercurial.HgException |
1615 |
* @throws org.netbeans.modules.mercurial.HgException |
1606 |
*/ |
1616 |
*/ |
1607 |
public static void doRename(File repository, File sourceFile, File destFile) throws HgException { |
1617 |
public static void doRename(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { |
1608 |
doRename(repository, sourceFile, destFile, false); |
1618 |
doRename(repository, sourceFile, destFile, false, logger); |
1609 |
} |
1619 |
} |
1610 |
|
1620 |
|
1611 |
private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter) throws HgException { |
1621 |
private static void doRename(File repository, File sourceFile, File destFile, boolean bAfter, OutputLogger logger) throws HgException { |
1612 |
if (repository == null) return; |
1622 |
if (repository == null) return; |
1613 |
|
1623 |
|
1614 |
List<String> command = new ArrayList<String>(); |
1624 |
List<String> command = new ArrayList<String>(); |
Lines 1628-1634
public class HgCommand {
Link Here
|
1628 |
if (!list.isEmpty() && |
1638 |
if (!list.isEmpty() && |
1629 |
isErrorAbort(list.get(list.size() -1))) { |
1639 |
isErrorAbort(list.get(list.size() -1))) { |
1630 |
if (!bAfter || !isErrorAbortNoFilesToCopy(list.get(list.size() -1))) { |
1640 |
if (!bAfter || !isErrorAbortNoFilesToCopy(list.get(list.size() -1))) { |
1631 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED")); |
1641 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_RENAME_FAILED"), logger); |
1632 |
} |
1642 |
} |
1633 |
} |
1643 |
} |
1634 |
} |
1644 |
} |
Lines 1643-1650
public class HgCommand {
Link Here
|
1643 |
* @return void |
1653 |
* @return void |
1644 |
* @throws org.netbeans.modules.mercurial.HgException |
1654 |
* @throws org.netbeans.modules.mercurial.HgException |
1645 |
*/ |
1655 |
*/ |
1646 |
public static void doRenameAfter(File repository, File sourceFile, File destFile) throws HgException { |
1656 |
public static void doRenameAfter(File repository, File sourceFile, File destFile, OutputLogger logger) throws HgException { |
1647 |
doRename(repository, sourceFile, destFile, true); |
1657 |
doRename(repository, sourceFile, destFile, true, logger); |
1648 |
} |
1658 |
} |
1649 |
|
1659 |
|
1650 |
/** |
1660 |
/** |
Lines 1657-1663
public class HgCommand {
Link Here
|
1657 |
* @return void |
1667 |
* @return void |
1658 |
* @throws org.netbeans.modules.mercurial.HgException |
1668 |
* @throws org.netbeans.modules.mercurial.HgException |
1659 |
*/ |
1669 |
*/ |
1660 |
public static void doAdd(File repository, List<File> addFiles) throws HgException { |
1670 |
public static void doAdd(File repository, List<File> addFiles, OutputLogger logger) throws HgException { |
1661 |
if (repository == null) return; |
1671 |
if (repository == null) return; |
1662 |
if (addFiles.size() == 0) return; |
1672 |
if (addFiles.size() == 0) return; |
1663 |
List<String> command = new ArrayList<String>(); |
1673 |
List<String> command = new ArrayList<String>(); |
Lines 1676-1682
public class HgCommand {
Link Here
|
1676 |
} |
1686 |
} |
1677 |
List<String> list = exec(command); |
1687 |
List<String> list = exec(command); |
1678 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1688 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1679 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
1689 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
1680 |
} |
1690 |
} |
1681 |
|
1691 |
|
1682 |
/** |
1692 |
/** |
Lines 1689-1695
public class HgCommand {
Link Here
|
1689 |
* @throws org.netbeans.modules.mercurial.HgException |
1699 |
* @throws org.netbeans.modules.mercurial.HgException |
1690 |
*/ |
1700 |
*/ |
1691 |
public static void doRevert(File repository, List<File> revertFiles, |
1701 |
public static void doRevert(File repository, List<File> revertFiles, |
1692 |
String revision, boolean doBackup) throws HgException { |
1702 |
String revision, boolean doBackup, OutputLogger logger) throws HgException { |
1693 |
if (repository == null) return; |
1703 |
if (repository == null) return; |
1694 |
if (revertFiles.size() == 0) return; |
1704 |
if (revertFiles.size() == 0) return; |
1695 |
|
1705 |
|
Lines 1712-1718
public class HgCommand {
Link Here
|
1712 |
} |
1722 |
} |
1713 |
List<String> list = exec(command); |
1723 |
List<String> list = exec(command); |
1714 |
if (!list.isEmpty() && isErrorNoChangeNeeded(list.get(0))) |
1724 |
if (!list.isEmpty() && isErrorNoChangeNeeded(list.get(0))) |
1715 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED")); |
1725 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_REVERT_FAILED"), logger); |
1716 |
} |
1726 |
} |
1717 |
|
1727 |
|
1718 |
/** |
1728 |
/** |
Lines 1725-1731
public class HgCommand {
Link Here
|
1725 |
* @return void |
1735 |
* @return void |
1726 |
* @throws org.netbeans.modules.mercurial.HgException |
1736 |
* @throws org.netbeans.modules.mercurial.HgException |
1727 |
*/ |
1737 |
*/ |
1728 |
public static void doAdd(File repository, File file) throws HgException { |
1738 |
public static void doAdd(File repository, File file, OutputLogger logger) throws HgException { |
1729 |
if (repository == null) return; |
1739 |
if (repository == null) return; |
1730 |
if (file == null) return; |
1740 |
if (file == null) return; |
1731 |
if (file.isDirectory()) return; |
1741 |
if (file.isDirectory()) return; |
Lines 1742-1748
public class HgCommand {
Link Here
|
1742 |
command.add(file.getAbsolutePath()); |
1752 |
command.add(file.getAbsolutePath()); |
1743 |
List<String> list = exec(command); |
1753 |
List<String> list = exec(command); |
1744 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1754 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
1745 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
1755 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
1746 |
} |
1756 |
} |
1747 |
|
1757 |
|
1748 |
/** |
1758 |
/** |
Lines 1754-1760
public class HgCommand {
Link Here
|
1754 |
* @return List<String> list of the annotated lines of the file |
1764 |
* @return List<String> list of the annotated lines of the file |
1755 |
* @throws org.netbeans.modules.mercurial.HgException |
1765 |
* @throws org.netbeans.modules.mercurial.HgException |
1756 |
*/ |
1766 |
*/ |
1757 |
public static List<String> doAnnotate(File repository, File file, String revision) throws HgException { |
1767 |
public static List<String> doAnnotate(File repository, File file, String revision, OutputLogger logger) throws HgException { |
1758 |
if (repository == null) return null; |
1768 |
if (repository == null) return null; |
1759 |
List<String> command = new ArrayList<String>(); |
1769 |
List<String> command = new ArrayList<String>(); |
1760 |
|
1770 |
|
Lines 1774-1787
public class HgCommand {
Link Here
|
1774 |
List<String> list = exec(command); |
1784 |
List<String> list = exec(command); |
1775 |
if (!list.isEmpty()) { |
1785 |
if (!list.isEmpty()) { |
1776 |
if (isErrorNoRepository(list.get(0))) { |
1786 |
if (isErrorNoRepository(list.get(0))) { |
1777 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
1787 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
1778 |
} else if (isErrorNoSuchFile(list.get(0))) { |
1788 |
} else if (isErrorNoSuchFile(list.get(0))) { |
1779 |
// This can happen if we have multiple heads and the wrong |
1789 |
// This can happen if we have multiple heads and the wrong |
1780 |
// one was picked by default hg annotation |
1790 |
// one was picked by default hg annotation |
1781 |
if (revision == null) { |
1791 |
if (revision == null) { |
1782 |
String rev = getLastRevision(repository, file); |
1792 |
String rev = getLastRevision(repository, file); |
1783 |
if (rev != null) { |
1793 |
if (rev != null) { |
1784 |
list = doAnnotate(repository, file, rev); |
1794 |
list = doAnnotate(repository, file, rev, logger); |
1785 |
} else { |
1795 |
} else { |
1786 |
list = null; |
1796 |
list = null; |
1787 |
} |
1797 |
} |
Lines 1793-1800
public class HgCommand {
Link Here
|
1793 |
return list; |
1803 |
return list; |
1794 |
} |
1804 |
} |
1795 |
|
1805 |
|
1796 |
public static List<String> doAnnotate(File repository, File file) throws HgException { |
1806 |
public static List<String> doAnnotate(File repository, File file, OutputLogger logger) throws HgException { |
1797 |
return doAnnotate(repository, file, null); |
1807 |
return doAnnotate(repository, file, null, logger); |
1798 |
} |
1808 |
} |
1799 |
|
1809 |
|
1800 |
/** |
1810 |
/** |
Lines 2258-2264
public class HgCommand {
Link Here
|
2258 |
* @param f path to be removed from the repository |
2268 |
* @param f path to be removed from the repository |
2259 |
* @throws org.netbeans.modules.mercurial.HgException |
2269 |
* @throws org.netbeans.modules.mercurial.HgException |
2260 |
*/ |
2270 |
*/ |
2261 |
public static void doRemove(File repository, File f) throws HgException { |
2271 |
public static void doRemove(File repository, File f, OutputLogger logger) throws HgException { |
2262 |
List<String> command = new ArrayList<String>(); |
2272 |
List<String> command = new ArrayList<String>(); |
2263 |
|
2273 |
|
2264 |
command.add(getHgCommand()); |
2274 |
command.add(getHgCommand()); |
Lines 2270-2276
public class HgCommand {
Link Here
|
2270 |
|
2280 |
|
2271 |
List<String> list = exec(command); |
2281 |
List<String> list = exec(command); |
2272 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
2282 |
if (!list.isEmpty() && isErrorAlreadyTracked(list.get(0))) |
2273 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED")); |
2283 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_ALREADY_TRACKED"), logger); |
2274 |
} |
2284 |
} |
2275 |
|
2285 |
|
2276 |
/** |
2286 |
/** |
Lines 2281-2287
public class HgCommand {
Link Here
|
2281 |
* @param outputFileName path of the output file |
2291 |
* @param outputFileName path of the output file |
2282 |
* @throws org.netbeans.modules.mercurial.HgException |
2292 |
* @throws org.netbeans.modules.mercurial.HgException |
2283 |
*/ |
2293 |
*/ |
2284 |
public static List<String> doExport(File repository, String revStr, String outputFileName) throws HgException { |
2294 |
public static List<String> doExport(File repository, String revStr, String outputFileName, OutputLogger logger) throws HgException { |
2285 |
// Ensure that parent directory of target exists, creating if necessary |
2295 |
// Ensure that parent directory of target exists, creating if necessary |
2286 |
File fileTarget = new File (outputFileName); |
2296 |
File fileTarget = new File (outputFileName); |
2287 |
File parentTarget = fileTarget.getParentFile(); |
2297 |
File parentTarget = fileTarget.getParentFile(); |
Lines 2310-2316
public class HgCommand {
Link Here
|
2310 |
List<String> list = exec(command); |
2320 |
List<String> list = exec(command); |
2311 |
if (!list.isEmpty() && |
2321 |
if (!list.isEmpty() && |
2312 |
isErrorAbort(list.get(list.size() -1))) { |
2322 |
isErrorAbort(list.get(list.size() -1))) { |
2313 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED")); |
2323 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_EXPORT_FAILED"), logger); |
2314 |
} |
2324 |
} |
2315 |
return list; |
2325 |
return list; |
2316 |
} |
2326 |
} |
Lines 2322-2328
public class HgCommand {
Link Here
|
2322 |
* @param File patchFile of the patch file |
2332 |
* @param File patchFile of the patch file |
2323 |
* @throws org.netbeans.modules.mercurial.HgException |
2333 |
* @throws org.netbeans.modules.mercurial.HgException |
2324 |
*/ |
2334 |
*/ |
2325 |
public static List<String> doImport(File repository, File patchFile) throws HgException { |
2335 |
public static List<String> doImport(File repository, File patchFile, OutputLogger logger) throws HgException { |
2326 |
List<String> command = new ArrayList<String>(); |
2336 |
List<String> command = new ArrayList<String>(); |
2327 |
|
2337 |
|
2328 |
command.add(getHgCommand()); |
2338 |
command.add(getHgCommand()); |
Lines 2337-2344
public class HgCommand {
Link Here
|
2337 |
List<String> list = exec(command); |
2347 |
List<String> list = exec(command); |
2338 |
if (!list.isEmpty() && |
2348 |
if (!list.isEmpty() && |
2339 |
isErrorAbort(list.get(list.size() -1))) { |
2349 |
isErrorAbort(list.get(list.size() -1))) { |
2340 |
HgUtils.outputMercurialTab(list); // need the failure info from import |
2350 |
logger.output(list); // need the failure info from import |
2341 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED")); |
2351 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_IMPORT_FAILED"), logger); |
2342 |
} |
2352 |
} |
2343 |
return list; |
2353 |
return list; |
2344 |
} |
2354 |
} |
Lines 2504-2511
public class HgCommand {
Link Here
|
2504 |
} |
2514 |
} |
2505 |
|
2515 |
|
2506 |
List<String> list = exec(command); |
2516 |
List<String> list = exec(command); |
2507 |
if (!list.isEmpty() && isErrorNoRepository(list.get(0))) |
2517 |
if (!list.isEmpty() && isErrorNoRepository(list.get(0))) { |
2508 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR")); |
2518 |
OutputLogger logger = OutputLogger.getLogger(repository.getAbsolutePath()); |
|
|
2519 |
try { |
2520 |
handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_NO_REPOSITORY_ERR"), logger); |
2521 |
} finally { |
2522 |
logger.closeLog(); |
2523 |
} |
2524 |
} |
2509 |
return list; |
2525 |
return list; |
2510 |
} |
2526 |
} |
2511 |
/** |
2527 |
/** |
Lines 2644-2655
public class HgCommand {
Link Here
|
2644 |
return defaultPath + File.separatorChar + HG_COMMAND; |
2660 |
return defaultPath + File.separatorChar + HG_COMMAND; |
2645 |
} |
2661 |
} |
2646 |
|
2662 |
|
2647 |
private static void handleError(List<String> command, List<String> list, String message) throws HgException{ |
2663 |
private static void handleError(List<String> command, List<String> list, String message, OutputLogger logger) throws HgException{ |
2648 |
if (command != null && list != null){ |
2664 |
if (command != null && list != null){ |
2649 |
Mercurial.LOG.log(Level.WARNING, "command: " + HgUtils.replaceHttpPassword(command)); // NOI18N |
2665 |
Mercurial.LOG.log(Level.WARNING, "command: " + HgUtils.replaceHttpPassword(command)); // NOI18N |
2650 |
Mercurial.LOG.log(Level.WARNING, "output: " + HgUtils.replaceHttpPassword(list)); // NOI18N |
2666 |
Mercurial.LOG.log(Level.WARNING, "output: " + HgUtils.replaceHttpPassword(list)); // NOI18N |
2651 |
HgUtils.outputMercurialTabInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N |
2667 |
logger.outputInRed(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ERR")); // NOI18N |
2652 |
HgUtils.outputMercurialTab(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", |
2668 |
logger.output(NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_INFO_ERR", |
2653 |
HgUtils.replaceHttpPassword(command), HgUtils.replaceHttpPassword(list))); // NOI18N |
2669 |
HgUtils.replaceHttpPassword(command), HgUtils.replaceHttpPassword(list))); // NOI18N |
2654 |
} |
2670 |
} |
2655 |
|
2671 |
|