diff src/org/tmatesoft/hg/util/Path.java @ 292:a415fe296a50

Refactor PathRewrite to accept any char sequence, not only string
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 14 Sep 2011 02:16:19 +0200
parents 1ec6b327a6ac
children 863356c2847e
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/Path.java	Wed Sep 14 02:12:47 2011 +0200
+++ b/src/org/tmatesoft/hg/util/Path.java	Wed Sep 14 02:16:19 2011 +0200
@@ -101,14 +101,19 @@
 		return CompareResult.Unrelated;
 	}
 
-	public static Path create(String path) {
+	public static Path create(CharSequence path) {
 		if (path == null) {
 			throw new IllegalArgumentException();
 		}
-		if (path.indexOf('\\') != -1) {
+		if (path instanceof Path) {
+			Path o = (Path) path;
+			return o;
+		}
+		String p = path.toString();
+		if (p.indexOf('\\') != -1) {
 			throw new IllegalArgumentException();
 		}
-		Path rv = new Path(path);
+		Path rv = new Path(p);
 		return rv;
 	}