annotate src/com/tmate/hgkit/console/Log.java @ 43:1b26247d7367

Calculate result length of the patch operarion, when unknown
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 14 Jan 2011 04:41:05 +0100
parents a78c980749e3
children b01500fe2604
rev   line source
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /**
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2010 Artem Tikhomirov
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 */
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 package com.tmate.hgkit.console;
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
6 import com.tmate.hgkit.fs.RepositoryLookup;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
7 import com.tmate.hgkit.ll.Changeset;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
8 import com.tmate.hgkit.ll.HgDataFile;
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 import com.tmate.hgkit.ll.HgRepository;
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 /**
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 * @author artem
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 */
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 public class Log {
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
15
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 public static void main(String[] args) throws Exception {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
17 RepositoryLookup repoLookup = new RepositoryLookup();
4
aa1912c70b36 Fix offset issue for inline revlogs. Commandline processing.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
18 RepositoryLookup.Options cmdLineOpts = RepositoryLookup.Options.parse(args);
aa1912c70b36 Fix offset issue for inline revlogs. Commandline processing.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 3
diff changeset
19 HgRepository hgRepo = repoLookup.detect(cmdLineOpts);
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20 if (hgRepo.isInvalid()) {
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
21 System.err.printf("Can't find repository in: %s\n", hgRepo.getLocation());
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
22 return;
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 }
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 System.out.println(hgRepo.getLocation());
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
25 final Changeset.Inspector callback = new Changeset.Inspector() {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
26
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
27 public void next(Changeset cset) {
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
28 System.out.println("==>");
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
29 cset.dump();
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
30 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
31 };
6
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
32 if (cmdLineOpts.files.isEmpty()) {
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
33 System.out.println("Complete history of the repo:");
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
34 hgRepo.getChangelog().all(callback);
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
35 } else {
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
36 for (String fname : cmdLineOpts.files) {
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
37 HgDataFile f1 = hgRepo.getFileNode(fname);
8
a78c980749e3 Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
38 System.out.println("History of the file: " + f1.getPath());
6
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
39 f1.history(callback);
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
40 }
5abe5af181bd Ant script to build commands and run sample
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
41 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 1
diff changeset
42 //
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
43 // System.out.println("\n\n=========================");
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
44 // System.out.println("Range 1-3:");
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
45 // f1.history(1,3, callback);
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
46 //
1
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 //new ChangelogWalker().setFile("hello.c").setRevisionRange(1, 4).accept(new Visitor);
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 }
a3576694a4d1 Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 }