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