Mercurial > hg4j
changeset 386:73e875154afb
Do not fail with empty extras string in changeset
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 13 Feb 2012 14:52:21 +0100 |
parents | 6150555eb41d |
children | cdea37239b01 |
files | src/org/tmatesoft/hg/repo/HgChangelog.java test/org/tmatesoft/hg/tools/ChangelogEntryBuilder.java |
diffstat | 2 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/repo/HgChangelog.java Mon Feb 13 14:19:36 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/HgChangelog.java Mon Feb 13 14:52:21 2012 +0100 @@ -284,7 +284,7 @@ String _extras = space2 < _timeString.length() ? _timeString.substring(space2 + 1) : null; Map<String, String> _extrasMap; final String extras_branch_key = "branch"; - if (_extras == null) { + if (_extras == null || _extras.trim().length() == 0) { _extrasMap = Collections.singletonMap(extras_branch_key, HgRepository.DEFAULT_BRANCH_NAME); } else { _extrasMap = new HashMap<String, String>();
--- a/test/org/tmatesoft/hg/tools/ChangelogEntryBuilder.java Mon Feb 13 14:19:36 2012 +0100 +++ b/test/org/tmatesoft/hg/tools/ChangelogEntryBuilder.java Mon Feb 13 14:52:21 2012 +0100 @@ -67,7 +67,7 @@ } public ChangelogEntryBuilder branch(String branchName) { - if (branchName == null) { + if (branchName == null || "default".equals(branchName)) { extrasMap.remove("branch"); } else { extrasMap.put("branch", branchName); @@ -114,15 +114,17 @@ } } StringBuilder files = new StringBuilder(); - for (Iterator<String> it = modifiedFiles.iterator(); it.hasNext(); ) { - files.append(it.next()); - if (it.hasNext()) { - files.append('\n'); + if (modifiedFiles != null) { + for (Iterator<String> it = modifiedFiles.iterator(); it.hasNext(); ) { + files.append(it.next()); + if (it.hasNext()) { + files.append('\n'); + } } } final long date = csetTime(); final int tz = csetTimezone(date); - return String.format(f, manifestRevision.toString(), user, date, tz, extras, files, comment).getBytes(); + return String.format(f, manifestRevision.toString(), user(), date, tz, extras, files, comment).getBytes(); } private final static CharSequence encodeExtrasPair(String s) {