diff src/org/tmatesoft/hg/internal/EncodingHelper.java @ 526:2f9ed6bcefa2

Initial support for Revert command with accompanying minor refactoring
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 15 Jan 2013 17:07:19 +0100
parents 0be5be8d57e9
children 47b7bedf0569
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/EncodingHelper.java	Fri Jan 11 18:12:39 2013 +0100
+++ b/src/org/tmatesoft/hg/internal/EncodingHelper.java	Tue Jan 15 17:07:19 2013 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 TMate Software Ltd
+ * Copyright (c) 2011-2013 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -60,7 +60,7 @@
 	/**
 	 * @return byte representation of the string directly comparable to bytes in manifest
 	 */
-	public byte[] toManifest(String s) {
+	public byte[] toManifest(CharSequence s) {
 		if (s == null) {
 			// perhaps, can return byte[0] in this case?
 			throw new IllegalArgumentException();
@@ -75,7 +75,7 @@
 		return decodeWithSystemDefaultFallback(data, start, length);
 	}
 	
-	public byte[] toDirstate(String fname) {
+	public byte[] toDirstate(CharSequence fname) {
 		if (fname == null) {
 			throw new IllegalArgumentException();
 		}
@@ -92,7 +92,7 @@
 		}
 	}
 	
-	private byte[] encodeWithSystemDefaultFallback(String s) {
+	private byte[] encodeWithSystemDefaultFallback(CharSequence s) {
 		try {
 			// synchronized(encoder) {
 			ByteBuffer bb = encoder.encode(CharBuffer.wrap(s));
@@ -103,7 +103,7 @@
 		} catch (CharacterCodingException ex) {
 			sessionContext.getLog().dump(getClass(), Error, ex, String.format("Use of charset %s failed, resort to system default", charset().name()));
 			// resort to system-default
-			return s.getBytes();
+			return s.toString().getBytes();
 		}
 	}