Mercurial > hg4j
diff src/org/tmatesoft/hg/repo/HgPhase.java @ 474:09f2d38ecf26
Tests for phases support
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 12 Jul 2012 15:36:21 +0200 |
parents | d0e5dc3cae6e |
children | 5afc7eedb3dd |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgPhase.java Wed Jul 11 22:45:29 2012 +0200 +++ b/src/org/tmatesoft/hg/repo/HgPhase.java Thu Jul 12 15:36:21 2012 +0200 @@ -26,7 +26,6 @@ Public("public"), Draft("draft"), Secret("secret"), Undefined(""); - @SuppressWarnings("unused") private final String hgString; private HgPhase(String stringRepresentation) { @@ -45,4 +44,17 @@ } throw new IllegalArgumentException(String.format("Bad phase index: %d", value)); } + + public static HgPhase parse(String value) { + if (Public.hgString.equals(value)) { + return Public; + } + if (Draft.hgString.equals(value)) { + return Draft; + } + if (Secret.hgString.equals(value)) { + return Secret; + } + throw new IllegalArgumentException(String.format("Bad phase name: %d", value)); + } }