Mercurial > hg4j
annotate test/org/tmatesoft/hg/tools/ChangelogEntryBuilder.java @ 516:0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 18 Dec 2012 18:57:03 +0100 |
parents | 73e875154afb |
children |
rev | line source |
---|---|
384
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012 TMate Software Ltd |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.tools; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 import java.util.ArrayList; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
20 import java.util.Collections; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 import java.util.Iterator; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 import java.util.LinkedHashMap; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 import java.util.List; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 import java.util.Map; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import java.util.TimeZone; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 import java.util.Map.Entry; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import org.tmatesoft.hg.core.Nodeid; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 /** |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 * |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 * @author Artem Tikhomirov |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 * @author TMate Software Ltd. |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 */ |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 public class ChangelogEntryBuilder { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 private String user; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 private List<String> modifiedFiles; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 private final Map<String, String> extrasMap = new LinkedHashMap<String, String>(); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 private Integer tzOffset; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 private Long csetTime; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 public ChangelogEntryBuilder user(String username) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 user = username; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 public String user() { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 if (user == null) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 // for our testing purposes anything but null is ok. no reason to follow Hg username lookup conventions |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 user = System.getProperty("user.name"); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 return user; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 public ChangelogEntryBuilder setModified(List<String> files) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 modifiedFiles = new ArrayList<String>(files == null ? Collections.<String>emptyList() : files); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
61 public ChangelogEntryBuilder addModified(List<String> files) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 if (modifiedFiles == null) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 return setModified(files); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
64 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 modifiedFiles.addAll(files); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
67 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
68 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 public ChangelogEntryBuilder branch(String branchName) { |
386
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
70 if (branchName == null || "default".equals(branchName)) { |
384
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
71 extrasMap.remove("branch"); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 } else { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 extrasMap.put("branch", branchName); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
74 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 public ChangelogEntryBuilder extras(Map<String, String> extras) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
79 extrasMap.clear(); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 extrasMap.putAll(extras); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
82 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 public ChangelogEntryBuilder date(long seconds, int timezoneOffset) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 csetTime = seconds; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 tzOffset = timezoneOffset; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 return this; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 private long csetTime() { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
91 if (csetTime != null) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 return csetTime; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 return System.currentTimeMillis() / 1000; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
95 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
96 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
97 private int csetTimezone(long time) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
98 if (tzOffset != null) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
99 return tzOffset; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
100 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
101 return -(TimeZone.getDefault().getOffset(time) / 1000); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
102 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 public byte[] build(Nodeid manifestRevision, String comment) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 String f = "%s\n%s\n%d %d %s\n%s\n\n%s"; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
106 StringBuilder extras = new StringBuilder(); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 for (Iterator<Entry<String, String>> it = extrasMap.entrySet().iterator(); it.hasNext();) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
108 final Entry<String, String> next = it.next(); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 extras.append(encodeExtrasPair(next.getKey())); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
110 extras.append(':'); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
111 extras.append(encodeExtrasPair(next.getValue())); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
112 if (it.hasNext()) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
113 extras.append('\00'); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 StringBuilder files = new StringBuilder(); |
386
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
117 if (modifiedFiles != null) { |
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
118 for (Iterator<String> it = modifiedFiles.iterator(); it.hasNext(); ) { |
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
119 files.append(it.next()); |
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
120 if (it.hasNext()) { |
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
121 files.append('\n'); |
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
122 } |
384
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 final long date = csetTime(); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 final int tz = csetTimezone(date); |
386
73e875154afb
Do not fail with empty extras string in changeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
384
diff
changeset
|
127 return String.format(f, manifestRevision.toString(), user(), date, tz, extras, files, comment).getBytes(); |
384
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
129 |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
130 private final static CharSequence encodeExtrasPair(String s) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
131 if (s != null) { |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
132 return s.replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r").replace("\00", "\\0"); |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 return s; |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 } |
4b97847d0b2d
Auxilary builders for manifest and changelog to create test repositories
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 } |