comparison src/org/tmatesoft/hg/repo/HgBranches.java @ 456:909306e412e2

Refactor LogFacility and SessionContext, better API for both
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 18 Jun 2012 16:54:00 +0200
parents be697c3e951e
children b3c16d1aede0
comparison
equal deleted inserted replaced
454:36fd1fd06492 456:909306e412e2
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.repo; 17 package org.tmatesoft.hg.repo;
18 18
19 import static org.tmatesoft.hg.util.LogFacility.Severity.Error;
20 import static org.tmatesoft.hg.util.LogFacility.Severity.Warn;
21
19 import java.io.BufferedReader; 22 import java.io.BufferedReader;
20 import java.io.BufferedWriter; 23 import java.io.BufferedWriter;
21 import java.io.File; 24 import java.io.File;
22 import java.io.FileReader; 25 import java.io.FileReader;
23 import java.io.FileWriter; 26 import java.io.FileWriter;
96 branches.put(e.getKey(), bi); 99 branches.put(e.getKey(), bi);
97 } 100 }
98 return lastInCache; 101 return lastInCache;
99 } catch (IOException ex) { 102 } catch (IOException ex) {
100 // log error, but otherwise do nothing 103 // log error, but otherwise do nothing
101 repo.getContext().getLog().warn(getClass(), ex, null); 104 repo.getContext().getLog().dump(getClass(), Warn, ex, null);
102 // FALL THROUGH to return -1 indicating no cache information 105 // FALL THROUGH to return -1 indicating no cache information
103 } catch (NumberFormatException ex) { 106 } catch (NumberFormatException ex) {
104 repo.getContext().getLog().warn(getClass(), ex, null); 107 repo.getContext().getLog().dump(getClass(), Warn, ex, null);
105 // FALL THROUGH 108 // FALL THROUGH
106 } catch (HgInvalidControlFileException ex) { 109 } catch (HgInvalidControlFileException ex) {
107 // shall not happen, thus log as error 110 // shall not happen, thus log as error
108 repo.getContext().getLog().error(getClass(), ex, null); 111 repo.getContext().getLog().dump(getClass(), Error, ex, null);
109 // FALL THROUGH 112 // FALL THROUGH
110 } catch (HgInvalidRevisionException ex) { 113 } catch (HgInvalidRevisionException ex) {
111 repo.getContext().getLog().error(getClass(), ex, null); 114 repo.getContext().getLog().dump(getClass(), Error, ex, null);
112 // FALL THROUGH 115 // FALL THROUGH
113 } finally { 116 } finally {
114 if (br != null) { 117 if (br != null) {
115 try { 118 try {
116 br.close(); 119 br.close();
117 } catch (IOException ex) { 120 } catch (IOException ex) {
118 repo.getContext().getLog().info(getClass(), ex, null); // ignore 121 repo.getContext().getLog().dump(getClass(), Warn, ex, null); // ignore
119 } 122 }
120 } 123 }
121 } 124 }
122 return -1; // deliberately not lastInCache, to avoid anything but -1 when 1st line was read and there's error is in lines 2..end 125 return -1; // deliberately not lastInCache, to avoid anything but -1 when 1st line was read and there's error is in lines 2..end
123 } 126 }