comparison src/org/tmatesoft/hg/core/HgUpdateConfigCommand.java @ 427:31a89587eb04

FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 17:14:35 +0200
parents 9c9c442b5f2e
children e31e85cf4d4c
comparison
equal deleted inserted replaced
426:063b0663495a 427:31a89587eb04
25 25
26 import org.tmatesoft.hg.internal.ConfigFile; 26 import org.tmatesoft.hg.internal.ConfigFile;
27 import org.tmatesoft.hg.internal.Experimental; 27 import org.tmatesoft.hg.internal.Experimental;
28 import org.tmatesoft.hg.internal.Internals; 28 import org.tmatesoft.hg.internal.Internals;
29 import org.tmatesoft.hg.repo.HgInternals; 29 import org.tmatesoft.hg.repo.HgInternals;
30 import org.tmatesoft.hg.repo.HgInvalidFileException;
31 import org.tmatesoft.hg.repo.HgRepository; 30 import org.tmatesoft.hg.repo.HgRepository;
32 31
33 /** 32 /**
34 * WORK IN PROGRESS, DO NOT USE 33 * WORK IN PROGRESS, DO NOT USE
35 * 34 *
110 */ 109 */
111 public HgUpdateConfigCommand add(String section, String key, String value) { 110 public HgUpdateConfigCommand add(String section, String key, String value) {
112 throw new UnsupportedOperationException(); 111 throw new UnsupportedOperationException();
113 } 112 }
114 113
114 /**
115 * Perform config file update
116 *
117 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state
118 */
115 public void execute() throws HgException { 119 public void execute() throws HgException {
116 try { 120 try {
117 ConfigFile cfg = new ConfigFile(); 121 ConfigFile cfg = new ConfigFile();
118 cfg.addLocation(configFile); 122 cfg.addLocation(configFile);
119 if (toRemove != null) { 123 if (toRemove != null) {
130 } 134 }
131 } 135 }
132 } 136 }
133 cfg.writeTo(configFile); 137 cfg.writeTo(configFile);
134 } catch (IOException ex) { 138 } catch (IOException ex) {
135 throw new HgInvalidFileException("Failed to update configuration file", ex, configFile); 139 String m = String.format("Failed to update configuration file %s", configFile);
140 throw new HgBadArgumentException(m, ex); // TODO [post-1.0] better exception, it's not bad argument case
136 } 141 }
137 } 142 }
138 143
139 144
140 public static void main(String[] args) throws Exception { 145 public static void main(String[] args) throws Exception {