author | mpm@selenic.com |
Sat, 21 May 2005 13:14:58 -0800 | |
changeset 128 | d6afb6dbf9f2 |
parent 124 | 0f6c49138f67 |
child 129 | 1db9207def07 |
permissions | -rw-r--r-- |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 |
# |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
3 |
# mercurial - a minimal scalable distributed SCM |
67 | 4 |
# v0.4f "jane dark" |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
5 |
# |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
6 |
# Copyright 2005 Matt Mackall <mpm@selenic.com> |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
# |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
8 |
# This software may be used and distributed according to the terms |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
9 |
# of the GNU General Public License, incorporated herein by reference. |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
10 |
|
46 | 11 |
# the psyco compiler makes commits a bit faster |
12 |
# and makes changegroup merge about 20 times slower! |
|
13 |
# try: |
|
14 |
# import psyco |
|
15 |
# psyco.full() |
|
16 |
# except: |
|
17 |
# pass |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
18 |
|
23 | 19 |
import sys, os, time |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
20 |
from mercurial import hg, mdiff, fancyopts |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
21 |
|
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
22 |
def help(): |
49 | 23 |
print """\ |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
24 |
commands: |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
25 |
|
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
26 |
init create a new repository in this directory |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
27 |
branch <path> create a branch of <path> in this directory |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
28 |
merge <path> merge changes from <path> into local repository |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
29 |
checkout [changeset] checkout the latest or given changeset |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
30 |
status show new, missing, and changed files in working dir |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
31 |
add [files...] add the given files in the next commit |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
32 |
remove [files...] remove the given files in the next commit |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
33 |
addremove add all new files, delete all missing files |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
34 |
commit commit all changes to the repository |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
35 |
history show changeset history |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
36 |
log <file> show revision history of a single file |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
37 |
dump <file> [rev] dump the latest or given revision of a file |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
38 |
dumpmanifest [rev] dump the latest or given revision of the manifest |
22 | 39 |
diff [files...] diff working directory (or selected files) |
67 | 40 |
tags show current changeset tags |
81
17884f79d59d
Add annotate and blame to the command list and README
mpm@selenic.com
parents:
80
diff
changeset
|
41 |
annotate [files...] show changeset number per file line |
17884f79d59d
Add annotate and blame to the command list and README
mpm@selenic.com
parents:
80
diff
changeset
|
42 |
blame [files...] show commit user per file line |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
43 |
""" |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
44 |
|
33 | 45 |
def filterfiles(list, files): |
46 |
l = [ x for x in list if x in files ] |
|
31
642058291e74
diffdir tidy in preparation for arg handling
mpm@selenic.com
parents:
29
diff
changeset
|
47 |
|
33 | 48 |
for f in files: |
49 |
if f[-1] != os.sep: f += os.sep |
|
50 |
l += [ x for x in list if x.startswith(f) ] |
|
51 |
return l |
|
31
642058291e74
diffdir tidy in preparation for arg handling
mpm@selenic.com
parents:
29
diff
changeset
|
52 |
|
34 | 53 |
def diff(files = None, node1 = None, node2 = None): |
64 | 54 |
def date(c): |
55 |
return time.asctime(time.gmtime(float(c[2].split(' ')[0]))) |
|
34 | 56 |
|
57 |
if node2: |
|
58 |
change = repo.changelog.read(node2) |
|
59 |
mmap2 = repo.manifest.read(change[0]) |
|
60 |
(c, a, d) = repo.diffrevs(node1, node2) |
|
61 |
def read(f): return repo.file(f).read(mmap2[f]) |
|
64 | 62 |
date2 = date(change) |
34 | 63 |
else: |
64 | 64 |
date2 = time.asctime() |
34 | 65 |
if not node1: |
66 |
node1 = repo.current |
|
67 |
(c, a, d) = repo.diffdir(repo.root, node1) |
|
64 | 68 |
def read(f): return file(os.path.join(repo.root, f)).read() |
34 | 69 |
|
70 |
change = repo.changelog.read(node1) |
|
71 |
mmap = repo.manifest.read(change[0]) |
|
64 | 72 |
date1 = date(change) |
34 | 73 |
|
74 |
if files: |
|
106 | 75 |
c = filterfiles(c, files) |
76 |
d = filterfiles(d, files) |
|
34 | 77 |
|
78 |
for f in c: |
|
79 |
to = repo.file(f).read(mmap[f]) |
|
80 |
tn = read(f) |
|
64 | 81 |
sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
34 | 82 |
for f in d: |
83 |
to = repo.file(f).read(mmap[f]) |
|
84 |
tn = "" |
|
64 | 85 |
sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
34 | 86 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
87 |
options = {} |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
88 |
opts = [('v', 'verbose', None, 'verbose'), |
83 | 89 |
('d', 'debug', None, 'debug'), |
107 | 90 |
('q', 'quiet', None, 'quiet'), |
91 |
('y', 'noninteractive', None, 'run non-interactively'), |
|
92 |
] |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
93 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
94 |
args = fancyopts.fancyopts(sys.argv[1:], opts, options, |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
95 |
'hg [options] <command> [command options] [files]') |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
96 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
97 |
try: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
98 |
cmd = args[0] |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
99 |
args = args[1:] |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
100 |
except: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
101 |
cmd = "" |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
102 |
|
107 | 103 |
ui = hg.ui(options["verbose"], options["debug"], options["quiet"], |
104 |
not options["noninteractive"]) |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
105 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
106 |
if cmd == "init": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
107 |
repo = hg.repository(ui, ".", create=1) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
108 |
sys.exit(0) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
109 |
elif cmd == "branch" or cmd == "clone": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
110 |
os.system("cp -al %s/.hg .hg" % args[0]) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
111 |
sys.exit(0) |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
112 |
elif cmd == "help": |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
113 |
help() |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
114 |
sys.exit(0) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
115 |
else: |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
116 |
try: |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
117 |
repo = hg.repository(ui=ui) |
74 | 118 |
except IOError: |
83 | 119 |
ui.warn("Unable to open repository\n") |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
120 |
sys.exit(0) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
121 |
|
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
122 |
relpath = None |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
123 |
if os.getcwd() != repo.root: |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
124 |
relpath = os.getcwd()[len(repo.root) + 1: ] |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
125 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
126 |
if cmd == "checkout" or cmd == "co": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
127 |
node = repo.changelog.tip() |
39 | 128 |
if args: |
67 | 129 |
node = repo.lookup(args[0]) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
130 |
repo.checkout(node) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
131 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
132 |
elif cmd == "add": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
133 |
repo.add(args) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
134 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
135 |
elif cmd == "remove" or cmd == "rm" or cmd == "del" or cmd == "delete": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
136 |
repo.remove(args) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
137 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
138 |
elif cmd == "commit" or cmd == "checkin" or cmd == "ci": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
139 |
if 1: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
140 |
if len(args) > 0: |
31
642058291e74
diffdir tidy in preparation for arg handling
mpm@selenic.com
parents:
29
diff
changeset
|
141 |
repo.commit(repo.current, args) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
142 |
else: |
31
642058291e74
diffdir tidy in preparation for arg handling
mpm@selenic.com
parents:
29
diff
changeset
|
143 |
repo.commit(repo.current) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
144 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
145 |
elif cmd == "import" or cmd == "patch": |
69
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
146 |
try: |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
147 |
import psyco |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
148 |
psyco.full() |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
149 |
except: |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
150 |
pass |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
151 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
152 |
ioptions = {} |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
153 |
opts = [('p', 'strip', 1, 'path strip'), |
50 | 154 |
('b', 'base', "", 'base path'), |
155 |
('q', 'quiet', "", 'silence diff') |
|
156 |
] |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
157 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
158 |
args = fancyopts.fancyopts(args, opts, ioptions, |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
159 |
'hg import [options] <patch names>') |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
160 |
d = ioptions["base"] |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
161 |
strip = ioptions["strip"] |
50 | 162 |
quiet = ioptions["quiet"] and "> /dev/null" or "" |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
163 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
164 |
for patch in args: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
165 |
ui.status("applying %s\n" % patch) |
49 | 166 |
pf = os.path.join(d, patch) |
167 |
||
62 | 168 |
text = "" |
169 |
for l in file(pf): |
|
69
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
170 |
if l[:4] == "--- ": break |
62 | 171 |
text += l |
172 |
||
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
173 |
f = os.popen("lsdiff --strip %d %s" % (strip, pf)) |
54 | 174 |
files = filter(None, map(lambda x: x.rstrip(), f.read().splitlines())) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
175 |
f.close() |
69
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
176 |
|
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
177 |
if files: |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
178 |
if os.system("patch -p%d < %s %s" % (strip, pf, quiet)): |
ab03c7a52cf2
Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents:
68
diff
changeset
|
179 |
raise "patch failed!" |
49 | 180 |
repo.commit(repo.current, files, text) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
181 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
182 |
elif cmd == "status": |
33 | 183 |
(c, a, d) = repo.diffdir(repo.root, repo.current) |
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
184 |
if relpath: |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
185 |
(c, a, d) = map(lambda x: filterfiles(x, [ relpath ]), (c, a, d)) |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
186 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
187 |
for f in c: print "C", f |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
188 |
for f in a: print "?", f |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
189 |
for f in d: print "R", f |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
190 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
191 |
elif cmd == "diff": |
34 | 192 |
revs = [] |
31
642058291e74
diffdir tidy in preparation for arg handling
mpm@selenic.com
parents:
29
diff
changeset
|
193 |
|
33 | 194 |
if args: |
38 | 195 |
doptions = {} |
33 | 196 |
opts = [('r', 'revision', [], 'revision')] |
197 |
args = fancyopts.fancyopts(args, opts, doptions, |
|
198 |
'hg diff [options] [files]') |
|
67 | 199 |
revs = map(lambda x: repo.lookup(x), doptions['revision']) |
33 | 200 |
|
201 |
if len(revs) > 2: |
|
83 | 202 |
self.ui.warn("too many revisions to diff\n") |
33 | 203 |
sys.exit(1) |
64 | 204 |
|
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
205 |
if relpath: |
64 | 206 |
if not args: args = [ relpath ] |
207 |
else: args = [ os.path.join(relpath, x) for x in args ] |
|
208 |
||
209 |
diff(args, *revs) |
|
33 | 210 |
|
79 | 211 |
elif cmd == "annotate": |
212 |
aoptions = {} |
|
213 |
opts = [('r', 'revision', '', 'revision')] |
|
214 |
args = fancyopts.fancyopts(args, opts, aoptions, |
|
215 |
'hg annotate [-r id] [files]') |
|
122 | 216 |
|
79 | 217 |
if args: |
122 | 218 |
if relpath: args = [ os.path.join(relpath, x) for x in args ] |
219 |
||
79 | 220 |
node = repo.current |
221 |
if aoptions['revision']: |
|
222 |
node = repo.changelog.lookup(aoptions['revision']) |
|
223 |
change = repo.changelog.read(node) |
|
224 |
mmap = repo.manifest.read(change[0]) |
|
225 |
for f in args: |
|
226 |
for n, l in repo.file(f).annotate(mmap[f]): |
|
80 | 227 |
sys.stdout.write("% 6s:%s"%(n, l)) |
228 |
||
229 |
elif cmd == "blame": |
|
230 |
aoptions = {} |
|
231 |
opts = [('r', 'revision', '', 'revision')] |
|
232 |
args = fancyopts.fancyopts(args, opts, aoptions, |
|
233 |
'hg blame [-r id] [files]') |
|
234 |
if args: |
|
235 |
bcache = {} |
|
236 |
node = repo.current |
|
237 |
if aoptions['revision']: |
|
238 |
node = repo.changelog.lookup(aoptions['revision']) |
|
239 |
change = repo.changelog.read(node) |
|
240 |
mmap = repo.manifest.read(change[0]) |
|
241 |
for f in args: |
|
242 |
for n, l in repo.file(f).annotate(mmap[f]): |
|
243 |
try: |
|
244 |
name = bcache[n] |
|
245 |
except KeyError: |
|
246 |
cl = repo.changelog.read(repo.changelog.node(n)) |
|
247 |
name = cl[1] |
|
248 |
f = name.find('@') |
|
249 |
if f >= 0: |
|
250 |
name = name[:f] |
|
251 |
bcache[n] = name |
|
252 |
sys.stdout.write("% 10s:%s"%(name, l)) |
|
79 | 253 |
|
34 | 254 |
elif cmd == "export": |
67 | 255 |
node = repo.lookup(args[0]) |
68 | 256 |
prev, other = repo.changelog.parents(node) |
257 |
change = repo.changelog.read(node) |
|
258 |
print "# HG changeset patch" |
|
259 |
print "# User %s" % change[1] |
|
260 |
print "# Node ID %s" % hg.hex(node) |
|
261 |
print "# Parent %s" % hg.hex(prev) |
|
262 |
||
263 |
if other != hg.nullid: |
|
264 |
print "# Parent %s" % hg.hex(other) |
|
265 |
print change[4] |
|
266 |
||
34 | 267 |
diff(None, prev, node) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
268 |
|
46 | 269 |
elif cmd == "debugchangegroup": |
67 | 270 |
newer = repo.newer(map(repo.lookup, args)) |
62 | 271 |
for chunk in repo.changegroup(newer): |
272 |
sys.stdout.write(chunk) |
|
46 | 273 |
|
274 |
elif cmd == "debugaddchangegroup": |
|
275 |
data = sys.stdin.read() |
|
276 |
repo.addchangegroup(data) |
|
277 |
||
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
278 |
elif cmd == "addremove": |
29 | 279 |
(c, a, d) = repo.diffdir(repo.root, repo.current) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
280 |
repo.add(a) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
281 |
repo.remove(d) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
282 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
283 |
elif cmd == "history": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
284 |
for i in range(repo.changelog.count()): |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
285 |
n = repo.changelog.node(i) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
286 |
changes = repo.changelog.read(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
287 |
(p1, p2) = repo.changelog.parents(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
288 |
(h, h1, h2) = map(hg.hex, (n, p1, p2)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
289 |
(i1, i2) = map(repo.changelog.rev, (p1, p2)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
290 |
print "rev: %4d:%s" % (i, h) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
291 |
print "parents: %4d:%s" % (i1, h1) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
292 |
if i2: print " %4d:%s" % (i2, h2) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
293 |
print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]), |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
294 |
hg.hex(changes[0])) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
295 |
print "user:", changes[1] |
21 | 296 |
print "date:", time.asctime( |
297 |
time.localtime(float(changes[2].split(' ')[0]))) |
|
123
b93cc016eec9
hg history: don't print file list without -v switch
mpm@selenic.com
parents:
122
diff
changeset
|
298 |
if ui.verbose: print "files:", " ".join(changes[3]) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
299 |
print "description:" |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
300 |
print changes[4] |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
301 |
|
89 | 302 |
elif cmd == "tip": |
303 |
n = repo.changelog.tip() |
|
304 |
t = repo.changelog.rev(n) |
|
305 |
ui.status("%d:%s\n" % (t, hg.hex(n))) |
|
306 |
||
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
307 |
elif cmd == "log": |
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
308 |
|
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
309 |
if len(args) == 1: |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
310 |
if relpath: |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
311 |
args[0] = os.path.join(relpath, args[0]) |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
312 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
313 |
r = repo.file(args[0]) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
314 |
for i in range(r.count()): |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
315 |
n = r.node(i) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
316 |
(p1, p2) = r.parents(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
317 |
(h, h1, h2) = map(hg.hex, (n, p1, p2)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
318 |
(i1, i2) = map(r.rev, (p1, p2)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
319 |
cr = r.linkrev(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
320 |
cn = hg.hex(repo.changelog.node(cr)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
321 |
print "rev: %4d:%s" % (i, h) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
322 |
print "changeset: %4d:%s" % (cr, cn) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
323 |
print "parents: %4d:%s" % (i1, h1) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
324 |
if i2: print " %4d:%s" % (i2, h2) |
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
325 |
changes = repo.changelog.read(repo.changelog.node(cr)) |
105 | 326 |
print "user: %s" % changes[1] |
327 |
print "date: %s" % time.asctime( |
|
106 | 328 |
time.localtime(float(changes[2].split(' ')[0]))) |
103
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
329 |
print "description:" |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
330 |
print changes[4] |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
331 |
|
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
332 |
elif len(args) > 1: |
33500fe7d56c
adding subdir support for log and status commands
jake@edge2.net
parents:
70
diff
changeset
|
333 |
print "too many args" |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
334 |
else: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
335 |
print "missing filename" |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
336 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
337 |
elif cmd == "dump": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
338 |
if args: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
339 |
r = repo.file(args[0]) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
340 |
n = r.tip() |
39 | 341 |
if len(args) > 1: n = r.lookup(args[1]) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
342 |
sys.stdout.write(r.read(n)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
343 |
else: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
344 |
print "missing filename" |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
345 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
346 |
elif cmd == "dumpmanifest": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
347 |
n = repo.manifest.tip() |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
348 |
if len(args) > 0: |
39 | 349 |
n = repo.manifest.lookup(args[0]) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
350 |
m = repo.manifest.read(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
351 |
files = m.keys() |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
352 |
files.sort() |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
353 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
354 |
for f in files: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
355 |
print hg.hex(m[f]), f |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
356 |
|
107 | 357 |
elif cmd == "debugprompt": |
358 |
print ui.prompt(args[0], args[1], args[2]) |
|
359 |
||
24 | 360 |
elif cmd == "debughash": |
361 |
f = repo.file(args[0]) |
|
362 |
print f.encodepath(args[0]) |
|
363 |
||
364 |
elif cmd == "debugindex": |
|
91 | 365 |
if ".hg" not in args[0]: |
366 |
args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i" |
|
367 |
||
24 | 368 |
r = hg.revlog(open, args[0], "") |
70 | 369 |
print " rev offset length base linkrev"+\ |
24 | 370 |
" p1 p2 nodeid" |
371 |
for i in range(r.count()): |
|
372 |
e = r.index[i] |
|
70 | 373 |
print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % ( |
24 | 374 |
i, e[0], e[1], e[2], e[3], |
375 |
hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) |
|
376 |
||
92
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
377 |
elif cmd == "debugindexdot": |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
378 |
if ".hg" not in args[0]: |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
379 |
args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i" |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
380 |
|
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
381 |
r = hg.revlog(open, args[0], "") |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
382 |
print "digraph G {" |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
383 |
for i in range(r.count()): |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
384 |
e = r.index[i] |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
385 |
print "\t%d -> %d" % (r.rev(e[4]), i) |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
386 |
if e[5] != hg.nullid: |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
387 |
print "\t%d -> %d" % (r.rev(e[5]), i) |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
388 |
print "}" |
e6fc7ff52246
Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents:
91
diff
changeset
|
389 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
390 |
elif cmd == "merge": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
391 |
if args: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
392 |
other = hg.repository(ui, args[0]) |
88 | 393 |
ui.status("requesting changegroup\n") |
62 | 394 |
cg = repo.getchangegroup(other) |
395 |
repo.addchangegroup(cg) |
|
396 |
else: |
|
397 |
print "missing source repository" |
|
398 |
||
67 | 399 |
elif cmd == "tags": |
400 |
repo.lookup(0) # prime the cache |
|
401 |
i = repo.tags.items() |
|
402 |
i.sort() |
|
403 |
for k, n in i: |
|
404 |
try: |
|
405 |
r = repo.changelog.rev(n) |
|
406 |
except KeyError: |
|
407 |
r = "?" |
|
408 |
print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) |
|
409 |
||
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
410 |
elif cmd == "verify": |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
411 |
filelinkrevs = {} |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
412 |
filenodes = {} |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
413 |
manifestchangeset = {} |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
414 |
changesets = revisions = files = 0 |
87 | 415 |
errors = 0 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
416 |
|
87 | 417 |
ui.status("checking changesets\n") |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
418 |
for i in range(repo.changelog.count()): |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
419 |
changesets += 1 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
420 |
n = repo.changelog.node(i) |
87 | 421 |
for p in repo.changelog.parents(n): |
422 |
if p not in repo.changelog.nodemap: |
|
423 |
ui.warn("changeset %s has unknown parent %s\n" % |
|
424 |
(hg.short(n), hg.short(p))) |
|
425 |
errors += 1 |
|
426 |
try: |
|
427 |
changes = repo.changelog.read(n) |
|
428 |
except Error, inst: |
|
429 |
ui.warn("unpacking changeset %s: %s\n" % (short(n), inst)) |
|
430 |
errors += 1 |
|
431 |
||
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
432 |
manifestchangeset[changes[0]] = n |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
433 |
for f in changes[3]: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
434 |
revisions += 1 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
435 |
filelinkrevs.setdefault(f, []).append(i) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
436 |
|
87 | 437 |
ui.status("checking manifests\n") |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
438 |
for i in range(repo.manifest.count()): |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
439 |
n = repo.manifest.node(i) |
87 | 440 |
for p in repo.manifest.parents(n): |
441 |
if p not in repo.manifest.nodemap: |
|
442 |
ui.warn("manifest %s has unknown parent %s\n" % |
|
443 |
(hg.short(n), hg.short(p))) |
|
444 |
errors += 1 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
445 |
ca = repo.changelog.node(repo.manifest.linkrev(n)) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
446 |
cc = manifestchangeset[n] |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
447 |
if ca != cc: |
87 | 448 |
ui.warn("manifest %s points to %s, not %s\n" % |
449 |
(hg.hex(n), hg.hex(ca), hg.hex(cc))) |
|
450 |
errors += 1 |
|
451 |
||
452 |
try: |
|
121
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
453 |
delta = mdiff.patchtext(repo.manifest.delta(n)) |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
454 |
except KeyboardInterrupt: |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
455 |
print "aborted" |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
456 |
sys.exit(0) |
93 | 457 |
except Exception, inst: |
87 | 458 |
ui.warn("unpacking manifest %s: %s\n" % (hg.short(n), inst)) |
459 |
errors += 1 |
|
460 |
||
121
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
461 |
ff = [ l.split('\0') for l in delta.splitlines() ] |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
462 |
for f, fn in ff: |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
463 |
filenodes.setdefault(f, {})[hg.bin(fn)] = 1 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
464 |
|
87 | 465 |
ui.status("crosschecking files in changesets and manifests\n") |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
466 |
for f in filenodes: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
467 |
if f not in filelinkrevs: |
87 | 468 |
ui.warn("file %s in manifest but not in changesets\n" % f) |
469 |
errors += 1 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
470 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
471 |
for f in filelinkrevs: |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
472 |
if f not in filenodes: |
121
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
473 |
ui.warn("file %s in changeset but not in manifest\n" % f) |
87 | 474 |
errors += 1 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
475 |
|
87 | 476 |
ui.status("checking files\n") |
121
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
477 |
ff = filenodes.keys() |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
478 |
ff.sort() |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
479 |
for f in ff: |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
480 |
if f == "/dev/null": continue |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
481 |
files += 1 |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
482 |
fl = repo.file(f) |
87 | 483 |
nodes = { hg.nullid: 1 } |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
484 |
for i in range(fl.count()): |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
485 |
n = fl.node(i) |
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
486 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
487 |
if n not in filenodes[f]: |
121
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
488 |
ui.warn("%s: %d:%s not in manifests\n" % (f, i, hg.short(n))) |
66fb61d9d97d
Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents:
107
diff
changeset
|
489 |
print len(filenodes[f].keys()), fl.count(), f |
87 | 490 |
errors += 1 |
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
491 |
else: |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
492 |
del filenodes[f][n] |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
493 |
|
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
494 |
flr = fl.linkrev(n) |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
495 |
if flr not in filelinkrevs[f]: |
87 | 496 |
ui.warn("%s:%s points to unexpected changeset rev %d\n" |
497 |
% (f, hg.short(n), fl.linkrev(n))) |
|
498 |
errors += 1 |
|
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
499 |
else: |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
500 |
filelinkrevs[f].remove(flr) |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
501 |
|
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
502 |
# verify contents |
87 | 503 |
try: |
504 |
t = fl.read(n) |
|
505 |
except Error, inst: |
|
506 |
ui.warn("unpacking file %s %s: %s\n" % (f, short(n), inst)) |
|
507 |
errors += 1 |
|
508 |
||
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
509 |
# verify parents |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
510 |
(p1, p2) = fl.parents(n) |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
511 |
if p1 not in nodes: |
87 | 512 |
ui.warn("file %s:%s unknown parent 1 %s" % |
513 |
(f, hg.short(n), hg.short(p1))) |
|
514 |
errors += 1 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
515 |
if p2 not in nodes: |
87 | 516 |
ui.warn("file %s:%s unknown parent 2 %s" % |
517 |
(f, hg.short(n), hg.short(p1))) |
|
518 |
errors += 1 |
|
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
519 |
nodes[n] = 1 |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
520 |
|
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
521 |
# cross-check |
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
522 |
for flr in filelinkrevs[f]: |
87 | 523 |
ui.warn("changeset rev %d not in %s\n" % (flr, f)) |
524 |
errors += 1 |
|
17
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
525 |
|
ffe6a5ca1a89
Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents:
16
diff
changeset
|
526 |
for node in filenodes[f]: |
87 | 527 |
ui.warn("node %s in manifests not in %s\n" % (hg.hex(n), f)) |
528 |
errors += 1 |
|
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
529 |
|
87 | 530 |
ui.status("%d files, %d changesets, %d total revisions\n" % |
531 |
(files, changesets, revisions)) |
|
532 |
||
533 |
if errors: |
|
93 | 534 |
ui.warn("%d integrity errors encountered!\n" % errors) |
87 | 535 |
sys.exit(1) |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
536 |
|
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
537 |
else: |
18
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
538 |
print "unknown command\n" |
2fd3e1e3783f
Give a friendlier message when repo isn't found
mpm@selenic.com
parents:
17
diff
changeset
|
539 |
help() |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
540 |
sys.exit(1) |