Mercurial > hg4j
comparison test/org/tmatesoft/hg/tools/ChangelogEntryBuilder.java @ 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 | 4b97847d0b2d |
children |
comparison
equal
deleted
inserted
replaced
385:6150555eb41d | 386:73e875154afb |
---|---|
65 modifiedFiles.addAll(files); | 65 modifiedFiles.addAll(files); |
66 return this; | 66 return this; |
67 } | 67 } |
68 | 68 |
69 public ChangelogEntryBuilder branch(String branchName) { | 69 public ChangelogEntryBuilder branch(String branchName) { |
70 if (branchName == null) { | 70 if (branchName == null || "default".equals(branchName)) { |
71 extrasMap.remove("branch"); | 71 extrasMap.remove("branch"); |
72 } else { | 72 } else { |
73 extrasMap.put("branch", branchName); | 73 extrasMap.put("branch", branchName); |
74 } | 74 } |
75 return this; | 75 return this; |
112 if (it.hasNext()) { | 112 if (it.hasNext()) { |
113 extras.append('\00'); | 113 extras.append('\00'); |
114 } | 114 } |
115 } | 115 } |
116 StringBuilder files = new StringBuilder(); | 116 StringBuilder files = new StringBuilder(); |
117 for (Iterator<String> it = modifiedFiles.iterator(); it.hasNext(); ) { | 117 if (modifiedFiles != null) { |
118 files.append(it.next()); | 118 for (Iterator<String> it = modifiedFiles.iterator(); it.hasNext(); ) { |
119 if (it.hasNext()) { | 119 files.append(it.next()); |
120 files.append('\n'); | 120 if (it.hasNext()) { |
121 files.append('\n'); | |
122 } | |
121 } | 123 } |
122 } | 124 } |
123 final long date = csetTime(); | 125 final long date = csetTime(); |
124 final int tz = csetTimezone(date); | 126 final int tz = csetTimezone(date); |
125 return String.format(f, manifestRevision.toString(), user, date, tz, extras, files, comment).getBytes(); | 127 return String.format(f, manifestRevision.toString(), user(), date, tz, extras, files, comment).getBytes(); |
126 } | 128 } |
127 | 129 |
128 private final static CharSequence encodeExtrasPair(String s) { | 130 private final static CharSequence encodeExtrasPair(String s) { |
129 if (s != null) { | 131 if (s != null) { |
130 return s.replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r").replace("\00", "\\0"); | 132 return s.replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r").replace("\00", "\\0"); |