Link the tree of the filename in SideBySide2 to gitweb

It is often convenient to be able to see the files in the same
tree as the file being reviewed. Update the gitweb linker to
support linking to a specific revision and file.  Link the base
of the filename to the tree and link the project name to the root
tree.

Change-Id: I11a969e9b1d14ea4180699ae9c02a6a62147d3de
This commit is contained in:
Colby Ranger
2013-12-16 10:52:42 -08:00
parent 7c65557917
commit ac2f30c3e0
3 changed files with 96 additions and 5 deletions

View File

@@ -83,6 +83,18 @@ public class GitwebLink {
return baseUrl + pattern.replace(p);
}
public String toFile(String project, String commit, String file) {
Map<String, String> p = new HashMap<String, String>();
p.put("project", encode(project));
p.put("commit", encode(commit));
p.put("file", encode(file));
ParameterizedString pattern = (file == null || file.isEmpty())
? new ParameterizedString(type.getRootTree())
: new ParameterizedString(type.getFile());
return baseUrl + pattern.replace(p);
}
public String toFileHistory(final Branch.NameKey branch, final String file) {
ParameterizedString pattern = new ParameterizedString(type.getFileHistory());