Show More
@@ -1,4 +1,4 b'' | |||
|
1 | import os, re, traceback, sys, signal | |
|
1 | import os, re, traceback, sys, signal, time | |
|
2 | 2 | from mercurial import fancyopts, ui, hg |
|
3 | 3 | |
|
4 | 4 | class UnknownCommand(Exception): pass |
@@ -122,6 +122,26 b' def annotate(u, repo, *args, **ops):' | |||
|
122 | 122 | for p,l in zip(zip(*pieces), lines): |
|
123 | 123 | u.write(" ".join(p) + ": " + l[1]) |
|
124 | 124 | |
|
125 | def heads(ui, repo): | |
|
126 | '''show current repository heads''' | |
|
127 | for n in repo.changelog.heads(): | |
|
128 | i = repo.changelog.rev(n) | |
|
129 | changes = repo.changelog.read(n) | |
|
130 | (p1, p2) = repo.changelog.parents(n) | |
|
131 | (h, h1, h2) = map(hg.hex, (n, p1, p2)) | |
|
132 | (i1, i2) = map(repo.changelog.rev, (p1, p2)) | |
|
133 | print "rev: %4d:%s" % (i, h) | |
|
134 | print "parents: %4d:%s" % (i1, h1) | |
|
135 | if i2: print " %4d:%s" % (i2, h2) | |
|
136 | print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]), | |
|
137 | hg.hex(changes[0])) | |
|
138 | print "user:", changes[1] | |
|
139 | print "date:", time.asctime( | |
|
140 | time.localtime(float(changes[2].split(' ')[0]))) | |
|
141 | if ui.verbose: print "files:", " ".join(changes[3]) | |
|
142 | print "description:" | |
|
143 | print changes[4] | |
|
144 | ||
|
125 | 145 | def status(ui, repo): |
|
126 | 146 | '''show changed files in the working directory |
|
127 | 147 | |
@@ -143,6 +163,7 b' def undo(ui, repo):' | |||
|
143 | 163 | table = { |
|
144 | 164 | "init": (init, [], 'hg init'), |
|
145 | 165 | "branch|clone": (branch, [], 'hg branch [path]'), |
|
166 | "heads": (heads, [], 'hg heads'), | |
|
146 | 167 | "help": (help, [], 'hg help [command]'), |
|
147 | 168 | "checkout|co": (checkout, [], 'hg checkout [changeset]'), |
|
148 | 169 | "ann|annotate": (annotate, |
@@ -156,6 +156,17 b' class revlog:' | |||
|
156 | 156 | def end(self, rev): return self.start(rev) + self.length(rev) |
|
157 | 157 | def base(self, rev): return self.index[rev][2] |
|
158 | 158 | |
|
159 | def heads(self): | |
|
160 | p = {} | |
|
161 | h = [] | |
|
162 | for r in range(self.count() - 1, 0, -1): | |
|
163 | n = self.node(r) | |
|
164 | if n not in p: | |
|
165 | h.append(n) | |
|
166 | for pn in self.parents(n): | |
|
167 | p[pn] = 1 | |
|
168 | return h | |
|
169 | ||
|
159 | 170 | def lookup(self, id): |
|
160 | 171 | try: |
|
161 | 172 | rev = int(id) |
General Comments 0
You need to be logged in to leave comments.
Login now