Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgPhase.java @ 445:d0e5dc3cae6e smartgit3
Support for phases functionality from Mercurial 2.1
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 05 Jun 2012 20:50:06 +0200 |
parents | |
children | 09f2d38ecf26 |
rev | line source |
---|---|
445
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012 TMate Software Ltd |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 /** |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 * Phases for a changeset is a new functionality in Mercurial 2.1 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 * |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 * @author Artem Tikhomirov |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 * @author TMate Software Ltd. |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 */ |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 public enum HgPhase { |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 Public("public"), Draft("draft"), Secret("secret"), Undefined(""); |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 @SuppressWarnings("unused") |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 private final String hgString; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 private HgPhase(String stringRepresentation) { |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 hgString = stringRepresentation; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 } |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 // public String toMercurialString() { |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 // return hgString; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 // } |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 public static HgPhase parse(int value) { |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 switch (value) { |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 case 0 : return Public; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 case 1 : return Draft; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 case 2 : return Secret; |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 } |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 throw new IllegalArgumentException(String.format("Bad phase index: %d", value)); |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 } |
d0e5dc3cae6e
Support for phases functionality from Mercurial 2.1
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 } |