]> source.dussan.org Git - jgit.git/commitdiff
Don't use deprecated constructors of CmdLineException 16/64316/2
authorDavid Pursehouse <david.pursehouse@sonymobile.com>
Thu, 14 Jan 2016 06:25:28 +0000 (15:25 +0900)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 19 Jan 2016 16:27:44 +0000 (17:27 +0100)
Change-Id: If01fa896537209821d6a7a262ee978572195a397
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/RevParse.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/AbstractTreeIteratorHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/ObjectIdHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevCommitHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/RevTreeHandler.java
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/opt/SubcommandHandler.java

index e02fffd650cbbe9431314134c1e5df3f6a072f55..e32fc9cab404823bc2f61dba01666e76b66de735 100644 (file)
@@ -57,6 +57,7 @@ import org.kohsuke.args4j.Option;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.pgm.internal.CLIText;
+import org.eclipse.jgit.pgm.opt.CmdLineParser;
 
 @Command(usage = "usage_RevParse")
 class RevParse extends TextBuiltin {
@@ -78,7 +79,8 @@ class RevParse extends TextBuiltin {
                        }
                } else {
                        if (verify && commits.size() > 1) {
-                               throw new CmdLineException(CLIText.get().needSingleRevision);
+                               final CmdLineParser clp = new CmdLineParser(this);
+                               throw new CmdLineException(clp, CLIText.get().needSingleRevision);
                        }
 
                        for (final ObjectId o : commits) {
index 229fb67b0cf41781a16908b1b7e7dbfc68445114..6b8a61d4d1d235a0b18f60aac94cc54daeb83e2e 100644 (file)
@@ -109,7 +109,7 @@ public class AbstractTreeIteratorHandler extends
                        try {
                                dirc = DirCache.read(new File(name), FS.DETECTED);
                        } catch (IOException e) {
-                               throw new CmdLineException(MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
+                               throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnIndexFile, name), e);
                        }
                        setter.addValue(new DirCacheIterator(dirc));
                        return 1;
@@ -119,20 +119,20 @@ public class AbstractTreeIteratorHandler extends
                try {
                        id = clp.getRepository().resolve(name);
                } catch (IOException e) {
-                       throw new CmdLineException(e.getMessage());
+                       throw new CmdLineException(clp, e.getMessage());
                }
                if (id == null)
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
 
                final CanonicalTreeParser p = new CanonicalTreeParser();
                try (ObjectReader curs = clp.getRepository().newObjectReader()) {
                        p.reset(curs, clp.getRevWalk().parseTree(id));
                } catch (MissingObjectException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
                } catch (IncorrectObjectTypeException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
                } catch (IOException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
                }
 
                setter.addValue(p);
index fa24d4b02ffce907f18e98dd30059c2a09a27872..364809d835c5676c30dc1783ab2ba26b5fd3d051 100644 (file)
@@ -86,14 +86,14 @@ public class ObjectIdHandler extends OptionHandler<ObjectId> {
                try {
                        id = clp.getRepository().resolve(name);
                } catch (IOException e) {
-                       throw new CmdLineException(e.getMessage());
+                       throw new CmdLineException(clp, e.getMessage());
                }
                if (id != null) {
                        setter.addValue(id);
                        return 1;
                }
 
-               throw new CmdLineException(MessageFormat.format(CLIText.get().notAnObject, name));
+               throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notAnObject, name));
        }
 
        @Override
index b1be128db1037bf1d3c12bf3857a476c297a3fbe..9ae56e4eafd4d5261f3eaa67933ab508d12eebed 100644 (file)
@@ -96,8 +96,10 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
                final int dot2 = name.indexOf(".."); //$NON-NLS-1$
                if (dot2 != -1) {
                        if (!option.isMultiValued())
-                               throw new CmdLineException(MessageFormat.format(CLIText.get().onlyOneMetaVarExpectedIn
-                                       , option.metaVar(), name));
+                               throw new CmdLineException(clp,
+                                               MessageFormat.format(
+                                                               CLIText.get().onlyOneMetaVarExpectedIn,
+                                                               option.metaVar(), name));
 
                        final String left = name.substring(0, dot2);
                        final String right = name.substring(dot2 + 2);
@@ -116,20 +118,20 @@ public class RevCommitHandler extends OptionHandler<RevCommit> {
                try {
                        id = clp.getRepository().resolve(name);
                } catch (IOException e) {
-                       throw new CmdLineException(e.getMessage());
+                       throw new CmdLineException(clp, e.getMessage());
                }
                if (id == null)
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name));
 
                final RevCommit c;
                try {
                        c = clp.getRevWalk().parseCommit(id);
                } catch (MissingObjectException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name));
                } catch (IncorrectObjectTypeException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notACommit, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notACommit, name));
                } catch (IOException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
                }
 
                if (interesting)
index eb155af9f4b963b878ddf4b8f53b745b33d8e167..e2879e076a6228556a8e0b7bcf0693a32617c923 100644 (file)
@@ -89,20 +89,20 @@ public class RevTreeHandler extends OptionHandler<RevTree> {
                try {
                        id = clp.getRepository().resolve(name);
                } catch (IOException e) {
-                       throw new CmdLineException(e.getMessage());
+                       throw new CmdLineException(clp, e.getMessage());
                }
                if (id == null)
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
 
                final RevTree c;
                try {
                        c = clp.getRevWalk().parseTree(id);
                } catch (MissingObjectException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
                } catch (IncorrectObjectTypeException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().notATree, name));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().notATree, name));
                } catch (IOException e) {
-                       throw new CmdLineException(MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
+                       throw new CmdLineException(clp, MessageFormat.format(CLIText.get().cannotReadBecause, name, e.getMessage()));
                }
                setter.addValue(c);
                return 1;
index c62ef0d2b8f2355a68a5b8957fcd493fef44eee4..96f3ed0afaf80abf8cd9d051d13e710764427eb3 100644 (file)
@@ -63,6 +63,8 @@ import org.eclipse.jgit.pgm.internal.CLIText;
  * we can execute at runtime with the remaining arguments of the parser.
  */
 public class SubcommandHandler extends OptionHandler<TextBuiltin> {
+       private final org.eclipse.jgit.pgm.opt.CmdLineParser clp;
+
        /**
         * Create a new handler for the command name.
         * <p>
@@ -75,6 +77,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> {
        public SubcommandHandler(final CmdLineParser parser,
                        final OptionDef option, final Setter<? super TextBuiltin> setter) {
                super(parser, option, setter);
+               clp = (org.eclipse.jgit.pgm.opt.CmdLineParser) parser;
        }
 
        @Override
@@ -82,7 +85,7 @@ public class SubcommandHandler extends OptionHandler<TextBuiltin> {
                final String name = params.getParameter(0);
                final CommandRef cr = CommandCatalog.get(name);
                if (cr == null)
-                       throw new CmdLineException(MessageFormat.format(
+                       throw new CmdLineException(clp, MessageFormat.format(
                                        CLIText.get().notAJgitCommand, name));
 
                // Force option parsing to stop. Everything after us should