Show More
@@ -15,6 +15,7 b'' | |||||
15 |
|
15 | |||
16 | import os, time |
|
16 | import os, time | |
17 | from mercurial.i18n import _ |
|
17 | from mercurial.i18n import _ | |
|
18 | from mercurial.repo import RepoError | |||
18 | from mercurial.node import bin, hex, nullid |
|
19 | from mercurial.node import bin, hex, nullid | |
19 | from mercurial import hg, revlog, util |
|
20 | from mercurial import hg, revlog, util | |
20 |
|
21 | |||
@@ -32,7 +33,7 b' class mercurial_sink(converter_sink):' | |||||
32 | self.repo = hg.repository(self.ui, path) |
|
33 | self.repo = hg.repository(self.ui, path) | |
33 | if not self.repo.local(): |
|
34 | if not self.repo.local(): | |
34 | raise NoRepo(_('%s is not a local Mercurial repo') % path) |
|
35 | raise NoRepo(_('%s is not a local Mercurial repo') % path) | |
35 |
except |
|
36 | except RepoError, err: | |
36 | ui.print_exc() |
|
37 | ui.print_exc() | |
37 | raise NoRepo(err.args[0]) |
|
38 | raise NoRepo(err.args[0]) | |
38 | else: |
|
39 | else: | |
@@ -42,7 +43,7 b' class mercurial_sink(converter_sink):' | |||||
42 | if not self.repo.local(): |
|
43 | if not self.repo.local(): | |
43 | raise NoRepo(_('%s is not a local Mercurial repo') % path) |
|
44 | raise NoRepo(_('%s is not a local Mercurial repo') % path) | |
44 | self.created.append(path) |
|
45 | self.created.append(path) | |
45 |
except |
|
46 | except RepoError, err: | |
46 | ui.print_exc() |
|
47 | ui.print_exc() | |
47 | raise NoRepo("could not create hg repo %s as sink" % path) |
|
48 | raise NoRepo("could not create hg repo %s as sink" % path) | |
48 | self.lock = None |
|
49 | self.lock = None | |
@@ -155,7 +156,7 b' class mercurial_sink(converter_sink):' | |||||
155 | bin(p1), bin(p2), extra=extra) |
|
156 | bin(p1), bin(p2), extra=extra) | |
156 | self.repo.dirstate.clear() |
|
157 | self.repo.dirstate.clear() | |
157 | text = "(octopus merge fixup)\n" |
|
158 | text = "(octopus merge fixup)\n" | |
158 |
p2 = |
|
159 | p2 = hex(self.repo.changelog.tip()) | |
159 |
|
160 | |||
160 | if self.filemapmode and nparents == 1: |
|
161 | if self.filemapmode and nparents == 1: | |
161 | man = self.repo.manifest |
|
162 | man = self.repo.manifest | |
@@ -194,7 +195,7 b' class mercurial_sink(converter_sink):' | |||||
194 | extra['branch'] = self.tagsbranch |
|
195 | extra['branch'] = self.tagsbranch | |
195 | try: |
|
196 | try: | |
196 | tagparent = self.repo.changectx(self.tagsbranch).node() |
|
197 | tagparent = self.repo.changectx(self.tagsbranch).node() | |
197 |
except |
|
198 | except RepoError, inst: | |
198 | tagparent = nullid |
|
199 | tagparent = nullid | |
199 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
|
200 | self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", | |
200 | date, tagparent, nullid, extra=extra) |
|
201 | date, tagparent, nullid, extra=extra) | |
@@ -212,8 +213,8 b' class mercurial_source(converter_source)' | |||||
212 | # try to provoke an exception if this isn't really a hg |
|
213 | # try to provoke an exception if this isn't really a hg | |
213 | # repo, but some other bogus compatible-looking url |
|
214 | # repo, but some other bogus compatible-looking url | |
214 | if not self.repo.local(): |
|
215 | if not self.repo.local(): | |
215 |
raise |
|
216 | raise RepoError() | |
216 |
except |
|
217 | except RepoError: | |
217 | ui.print_exc() |
|
218 | ui.print_exc() | |
218 | raise NoRepo("%s is not a local Mercurial repo" % path) |
|
219 | raise NoRepo("%s is not a local Mercurial repo" % path) | |
219 | self.lastrev = None |
|
220 | self.lastrev = None |
@@ -46,7 +46,8 b'' | |||||
46 | # vdiff on hovered and selected revisions. |
|
46 | # vdiff on hovered and selected revisions. | |
47 |
|
47 | |||
48 | import os |
|
48 | import os | |
49 |
from mercurial import |
|
49 | from mercurial import commands, util, patch, revlog | |
|
50 | from mercurial.node import nullid, nullrev, short | |||
50 |
|
51 | |||
51 | def difftree(ui, repo, node1=None, node2=None, *files, **opts): |
|
52 | def difftree(ui, repo, node1=None, node2=None, *files, **opts): | |
52 | """diff trees from two commits""" |
|
53 | """diff trees from two commits""" | |
@@ -57,18 +58,18 b' def difftree(ui, repo, node1=None, node2' | |||||
57 | status = repo.status(node1, node2, files=files)[:5] |
|
58 | status = repo.status(node1, node2, files=files)[:5] | |
58 | modified, added, removed, deleted, unknown = status |
|
59 | modified, added, removed, deleted, unknown = status | |
59 |
|
60 | |||
60 |
empty = |
|
61 | empty = short(nullid) | |
61 |
|
62 | |||
62 | for f in modified: |
|
63 | for f in modified: | |
63 | # TODO get file permissions |
|
64 | # TODO get file permissions | |
64 | ui.write(":100664 100664 %s %s M\t%s\t%s\n" % |
|
65 | ui.write(":100664 100664 %s %s M\t%s\t%s\n" % | |
65 |
( |
|
66 | (short(mmap[f]), short(mmap2[f]), f, f)) | |
66 | for f in added: |
|
67 | for f in added: | |
67 | ui.write(":000000 100664 %s %s N\t%s\t%s\n" % |
|
68 | ui.write(":000000 100664 %s %s N\t%s\t%s\n" % | |
68 |
(empty, |
|
69 | (empty, short(mmap2[f]), f, f)) | |
69 | for f in removed: |
|
70 | for f in removed: | |
70 | ui.write(":100664 000000 %s %s D\t%s\t%s\n" % |
|
71 | ui.write(":100664 000000 %s %s D\t%s\t%s\n" % | |
71 |
( |
|
72 | (short(mmap[f]), empty, f, f)) | |
72 | ## |
|
73 | ## | |
73 |
|
74 | |||
74 | while True: |
|
75 | while True: | |
@@ -104,9 +105,9 b' def catcommit(ui, repo, n, prefix, ctx=N' | |||||
104 | if ctx is None: |
|
105 | if ctx is None: | |
105 | ctx = repo.changectx(n) |
|
106 | ctx = repo.changectx(n) | |
106 | (p1, p2) = ctx.parents() |
|
107 | (p1, p2) = ctx.parents() | |
107 |
ui.write("tree %s\n" % |
|
108 | ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ?? | |
108 |
if p1: ui.write("parent %s\n" % |
|
109 | if p1: ui.write("parent %s\n" % short(p1.node())) | |
109 |
if p2: ui.write("parent %s\n" % |
|
110 | if p2: ui.write("parent %s\n" % short(p2.node())) | |
110 | date = ctx.date() |
|
111 | date = ctx.date() | |
111 | description = ctx.description().replace("\0", "") |
|
112 | description = ctx.description().replace("\0", "") | |
112 | lines = description.splitlines() |
|
113 | lines = description.splitlines() | |
@@ -132,7 +133,7 b' def base(ui, repo, node1, node2):' | |||||
132 | node1 = repo.lookup(node1) |
|
133 | node1 = repo.lookup(node1) | |
133 | node2 = repo.lookup(node2) |
|
134 | node2 = repo.lookup(node2) | |
134 | n = repo.changelog.ancestor(node1, node2) |
|
135 | n = repo.changelog.ancestor(node1, node2) | |
135 |
ui.write( |
|
136 | ui.write(short(n) + "\n") | |
136 |
|
137 | |||
137 | def catfile(ui, repo, type=None, r=None, **opts): |
|
138 | def catfile(ui, repo, type=None, r=None, **opts): | |
138 | """cat a specific revision""" |
|
139 | """cat a specific revision""" | |
@@ -252,27 +253,27 b' def revtree(ui, args, repo, full="tree",' | |||||
252 | parentstr = "" |
|
253 | parentstr = "" | |
253 | if parents: |
|
254 | if parents: | |
254 | pp = repo.changelog.parents(n) |
|
255 | pp = repo.changelog.parents(n) | |
255 |
if pp[0] != |
|
256 | if pp[0] != nullid: | |
256 |
parentstr += " " + |
|
257 | parentstr += " " + short(pp[0]) | |
257 |
if pp[1] != |
|
258 | if pp[1] != nullid: | |
258 |
parentstr += " " + |
|
259 | parentstr += " " + short(pp[1]) | |
259 | if not full: |
|
260 | if not full: | |
260 |
ui.write("%s%s\n" % ( |
|
261 | ui.write("%s%s\n" % (short(n), parentstr)) | |
261 | elif full == "commit": |
|
262 | elif full == "commit": | |
262 |
ui.write("%s%s\n" % ( |
|
263 | ui.write("%s%s\n" % (short(n), parentstr)) | |
263 | catcommit(ui, repo, n, ' ', ctx) |
|
264 | catcommit(ui, repo, n, ' ', ctx) | |
264 | else: |
|
265 | else: | |
265 | (p1, p2) = repo.changelog.parents(n) |
|
266 | (p1, p2) = repo.changelog.parents(n) | |
266 |
(h, h1, h2) = map( |
|
267 | (h, h1, h2) = map(short, (n, p1, p2)) | |
267 | (i1, i2) = map(repo.changelog.rev, (p1, p2)) |
|
268 | (i1, i2) = map(repo.changelog.rev, (p1, p2)) | |
268 |
|
269 | |||
269 | date = ctx.date()[0] |
|
270 | date = ctx.date()[0] | |
270 | ui.write("%s %s:%s" % (date, h, mask)) |
|
271 | ui.write("%s %s:%s" % (date, h, mask)) | |
271 | mask = is_reachable(want_sha1, reachable, p1) |
|
272 | mask = is_reachable(want_sha1, reachable, p1) | |
272 |
if i1 != |
|
273 | if i1 != nullrev and mask > 0: | |
273 | ui.write("%s:%s " % (h1, mask)), |
|
274 | ui.write("%s:%s " % (h1, mask)), | |
274 | mask = is_reachable(want_sha1, reachable, p2) |
|
275 | mask = is_reachable(want_sha1, reachable, p2) | |
275 |
if i2 != |
|
276 | if i2 != nullrev and mask > 0: | |
276 | ui.write("%s:%s " % (h2, mask)) |
|
277 | ui.write("%s:%s " % (h2, mask)) | |
277 | ui.write("\n") |
|
278 | ui.write("\n") | |
278 | if maxnr and count >= maxnr: |
|
279 | if maxnr and count >= maxnr: |
@@ -30,6 +30,8 b' refresh contents of top applied patch ' | |||||
30 | ''' |
|
30 | ''' | |
31 |
|
31 | |||
32 | from mercurial.i18n import _ |
|
32 | from mercurial.i18n import _ | |
|
33 | from mercurial.node import bin, hex, short | |||
|
34 | from mercurial.repo import RepoError | |||
33 | from mercurial import commands, cmdutil, hg, patch, revlog, util |
|
35 | from mercurial import commands, cmdutil, hg, patch, revlog, util | |
34 | from mercurial import repair |
|
36 | from mercurial import repair | |
35 | import os, sys, re, errno |
|
37 | import os, sys, re, errno | |
@@ -1254,7 +1256,7 b' class queue:' | |||||
1254 | elif lines[i].startswith('Dirstate:'): |
|
1256 | elif lines[i].startswith('Dirstate:'): | |
1255 | l = lines[i].rstrip() |
|
1257 | l = lines[i].rstrip() | |
1256 | l = l[10:].split(' ') |
|
1258 | l = l[10:].split(' ') | |
1257 |
qpp = [ |
|
1259 | qpp = [ bin(x) for x in l ] | |
1258 | elif datastart != None: |
|
1260 | elif datastart != None: | |
1259 | l = lines[i].rstrip() |
|
1261 | l = lines[i].rstrip() | |
1260 | se = statusentry(l) |
|
1262 | se = statusentry(l) | |
@@ -1277,7 +1279,7 b' class queue:' | |||||
1277 | if rev not in heads: |
|
1279 | if rev not in heads: | |
1278 | self.ui.warn("save entry has children, leaving it alone\n") |
|
1280 | self.ui.warn("save entry has children, leaving it alone\n") | |
1279 | else: |
|
1281 | else: | |
1280 |
self.ui.warn("removing save entry %s\n" % |
|
1282 | self.ui.warn("removing save entry %s\n" % short(rev)) | |
1281 | pp = repo.dirstate.parents() |
|
1283 | pp = repo.dirstate.parents() | |
1282 | if rev in pp: |
|
1284 | if rev in pp: | |
1283 | update = True |
|
1285 | update = True | |
@@ -1286,7 +1288,7 b' class queue:' | |||||
1286 | self.strip(repo, rev, update=update, backup='strip') |
|
1288 | self.strip(repo, rev, update=update, backup='strip') | |
1287 | if qpp: |
|
1289 | if qpp: | |
1288 | self.ui.warn("saved queue repository parents: %s %s\n" % |
|
1290 | self.ui.warn("saved queue repository parents: %s %s\n" % | |
1289 |
( |
|
1291 | (short(qpp[0]), short(qpp[1]))) | |
1290 | if qupdate: |
|
1292 | if qupdate: | |
1291 | self.ui.status(_("queue directory updating\n")) |
|
1293 | self.ui.status(_("queue directory updating\n")) | |
1292 | r = self.qrepo() |
|
1294 | r = self.qrepo() | |
@@ -1311,7 +1313,7 b' class queue:' | |||||
1311 | r = self.qrepo() |
|
1313 | r = self.qrepo() | |
1312 | if r: |
|
1314 | if r: | |
1313 | pp = r.dirstate.parents() |
|
1315 | pp = r.dirstate.parents() | |
1314 |
msg += "\nDirstate: %s %s" % ( |
|
1316 | msg += "\nDirstate: %s %s" % (hex(pp[0]), hex(pp[1])) | |
1315 | msg += "\n\nPatch Data:\n" |
|
1317 | msg += "\n\nPatch Data:\n" | |
1316 | text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and |
|
1318 | text = msg + "\n".join([str(x) for x in self.applied]) + '\n' + (ar and | |
1317 | "\n".join(ar) + '\n' or "") |
|
1319 | "\n".join(ar) + '\n' or "") | |
@@ -1597,7 +1599,7 b' def clone(ui, source, dest=None, **opts)' | |||||
1597 | patchespath = opts['patches'] or patchdir(sr) |
|
1599 | patchespath = opts['patches'] or patchdir(sr) | |
1598 | try: |
|
1600 | try: | |
1599 | pr = hg.repository(ui, patchespath) |
|
1601 | pr = hg.repository(ui, patchespath) | |
1600 |
except |
|
1602 | except RepoError: | |
1601 | raise util.Abort(_('versioned patch repository not found' |
|
1603 | raise util.Abort(_('versioned patch repository not found' | |
1602 | ' (see qinit -c)')) |
|
1604 | ' (see qinit -c)')) | |
1603 | qbase, destrev = None, None |
|
1605 | qbase, destrev = None, None |
@@ -6,6 +6,7 b'' | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from node import hex, nullid, nullrev, short |
|
8 | from node import hex, nullid, nullrev, short | |
|
9 | from repo import RepoError | |||
9 | from i18n import _ |
|
10 | from i18n import _ | |
10 | import os, re, sys, urllib |
|
11 | import os, re, sys, urllib | |
11 | import hg, util, revlog, bundlerepo, extensions |
|
12 | import hg, util, revlog, bundlerepo, extensions | |
@@ -311,7 +312,7 b' def bisect(ui, repo, rev=None, extra=Non' | |||||
311 | try: |
|
312 | try: | |
312 | for kind in state: |
|
313 | for kind in state: | |
313 | for node in state[kind]: |
|
314 | for node in state[kind]: | |
314 |
f.write("%s %s\n" % (kind, |
|
315 | f.write("%s %s\n" % (kind, hex(node))) | |
315 | f.rename() |
|
316 | f.rename() | |
316 | finally: |
|
317 | finally: | |
317 | del wlock |
|
318 | del wlock | |
@@ -333,7 +334,7 b' def bisect(ui, repo, rev=None, extra=Non' | |||||
333 | rev = repo.changelog.rev(node) |
|
334 | rev = repo.changelog.rev(node) | |
334 | ui.write(_("Testing changeset %s:%s " |
|
335 | ui.write(_("Testing changeset %s:%s " | |
335 | "(%s changesets remaining, ~%s tests)\n") |
|
336 | "(%s changesets remaining, ~%s tests)\n") | |
336 |
% (rev, |
|
337 | % (rev, short(node), changesets, tests)) | |
337 | if not noupdate: |
|
338 | if not noupdate: | |
338 | cmdutil.bail_if_changed(repo) |
|
339 | cmdutil.bail_if_changed(repo) | |
339 | return hg.clean(repo, node) |
|
340 | return hg.clean(repo, node) | |
@@ -1522,7 +1523,7 b' def import_(ui, repo, patch1, *patches, ' | |||||
1522 | p2 = repo.lookup(p2) |
|
1523 | p2 = repo.lookup(p2) | |
1523 | if p1 == wp[0].node(): |
|
1524 | if p1 == wp[0].node(): | |
1524 | repo.dirstate.setparents(p1, p2) |
|
1525 | repo.dirstate.setparents(p1, p2) | |
1525 |
except |
|
1526 | except RepoError: | |
1526 | pass |
|
1527 | pass | |
1527 | if opts.get('exact') or opts.get('import_branch'): |
|
1528 | if opts.get('exact') or opts.get('import_branch'): | |
1528 | repo.dirstate.setbranch(branch or 'default') |
|
1529 | repo.dirstate.setbranch(branch or 'default') | |
@@ -2437,7 +2438,7 b' def serve(ui, repo, **opts):' | |||||
2437 |
|
2438 | |||
2438 | if opts["stdio"]: |
|
2439 | if opts["stdio"]: | |
2439 | if repo is None: |
|
2440 | if repo is None: | |
2440 |
raise |
|
2441 | raise RepoError(_("There is no Mercurial repository here" | |
2441 |
|
|
2442 | " (.hg not found)")) | |
2442 | s = sshserver.sshserver(ui, repo) |
|
2443 | s = sshserver.sshserver(ui, repo) | |
2443 | s.serve_forever() |
|
2444 | s.serve_forever() | |
@@ -2452,7 +2453,7 b' def serve(ui, repo, **opts):' | |||||
2452 | repo.ui.setconfig("web", o, str(opts[o])) |
|
2453 | repo.ui.setconfig("web", o, str(opts[o])) | |
2453 |
|
2454 | |||
2454 | if repo is None and not ui.config("web", "webdir_conf"): |
|
2455 | if repo is None and not ui.config("web", "webdir_conf"): | |
2455 |
raise |
|
2456 | raise RepoError(_("There is no Mercurial repository here" | |
2456 |
|
|
2457 | " (.hg not found)")) | |
2457 |
|
2458 | |||
2458 | class service: |
|
2459 | class service: |
@@ -6,6 +6,7 b'' | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | from i18n import _ |
|
8 | from i18n import _ | |
|
9 | from repo import RepoError | |||
9 | import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex, time |
|
10 | import os, sys, atexit, signal, pdb, traceback, socket, errno, shlex, time | |
10 | import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook |
|
11 | import util, commands, hg, lock, fancyopts, revlog, version, extensions, hook | |
11 | import cmdutil |
|
12 | import cmdutil | |
@@ -64,7 +65,7 b' def _runcatch(ui, args):' | |||||
64 | except cmdutil.UnknownCommand, inst: |
|
65 | except cmdutil.UnknownCommand, inst: | |
65 | ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) |
|
66 | ui.warn(_("hg: unknown command '%s'\n") % inst.args[0]) | |
66 | commands.help_(ui, 'shortlist') |
|
67 | commands.help_(ui, 'shortlist') | |
67 |
except |
|
68 | except RepoError, inst: | |
68 | ui.warn(_("abort: %s!\n") % inst) |
|
69 | ui.warn(_("abort: %s!\n") % inst) | |
69 | except lock.LockHeld, inst: |
|
70 | except lock.LockHeld, inst: | |
70 | if inst.errno == errno.ETIMEDOUT: |
|
71 | if inst.errno == errno.ETIMEDOUT: | |
@@ -341,7 +342,7 b' def _dispatch(ui, args):' | |||||
341 | if not repo.local(): |
|
342 | if not repo.local(): | |
342 | raise util.Abort(_("repository '%s' is not local") % path) |
|
343 | raise util.Abort(_("repository '%s' is not local") % path) | |
343 | ui.setconfig("bundle", "mainreporoot", repo.root) |
|
344 | ui.setconfig("bundle", "mainreporoot", repo.root) | |
344 |
except |
|
345 | except RepoError: | |
345 | if cmd not in commands.optionalrepo.split(): |
|
346 | if cmd not in commands.optionalrepo.split(): | |
346 | if args and not path: # try to infer -R from command args |
|
347 | if args and not path: # try to infer -R from command args | |
347 | repos = map(_findrepo, args) |
|
348 | repos = map(_findrepo, args) | |
@@ -349,7 +350,7 b' def _dispatch(ui, args):' | |||||
349 | if guess and repos.count(guess) == len(repos): |
|
350 | if guess and repos.count(guess) == len(repos): | |
350 | return _dispatch(ui, ['--repository', guess] + fullargs) |
|
351 | return _dispatch(ui, ['--repository', guess] + fullargs) | |
351 | if not path: |
|
352 | if not path: | |
352 |
raise |
|
353 | raise RepoError(_("There is no Mercurial repository here" | |
353 |
|
|
354 | " (.hg not found)")) | |
354 | raise |
|
355 | raise | |
355 | d = lambda: func(ui, repo, *args, **cmdoptions) |
|
356 | d = lambda: func(ui, repo, *args, **cmdoptions) |
@@ -8,7 +8,8 b'' | |||||
8 | # of the GNU General Public License, incorporated herein by reference. |
|
8 | # of the GNU General Public License, incorporated herein by reference. | |
9 |
|
9 | |||
10 | from i18n import _ |
|
10 | from i18n import _ | |
11 | import hg, util |
|
11 | from node import short | |
|
12 | import util | |||
12 |
|
13 | |||
13 | def bisect(changelog, state): |
|
14 | def bisect(changelog, state): | |
14 | clparents = changelog.parentrevs |
|
15 | clparents = changelog.parentrevs | |
@@ -41,7 +42,7 b' def bisect(changelog, state):' | |||||
41 | bad = changelog.node(badrev) |
|
42 | bad = changelog.node(badrev) | |
42 | if not ancestors: # now we're confused |
|
43 | if not ancestors: # now we're confused | |
43 | raise util.Abort(_("Inconsistent state, %s:%s is good and bad") |
|
44 | raise util.Abort(_("Inconsistent state, %s:%s is good and bad") | |
44 |
% (badrev, |
|
45 | % (badrev, short(bad))) | |
45 |
|
46 | |||
46 | # build children dict |
|
47 | # build children dict | |
47 | children = {} |
|
48 | children = {} |
@@ -6,8 +6,6 b'' | |||||
6 | # This software may be used and distributed according to the terms |
|
6 | # This software may be used and distributed according to the terms | |
7 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | # of the GNU General Public License, incorporated herein by reference. | |
8 |
|
8 | |||
9 | from node import bin, hex, nullid, nullrev, short |
|
|||
10 | from repo import NoCapability, RepoError |
|
|||
11 | from i18n import _ |
|
9 | from i18n import _ | |
12 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo |
|
10 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo | |
13 | import errno, lock, os, shutil, util, extensions |
|
11 | import errno, lock, os, shutil, util, extensions |
@@ -8,6 +8,7 b'' | |||||
8 |
|
8 | |||
9 | import os, mimetypes, re |
|
9 | import os, mimetypes, re | |
10 | from mercurial.node import hex, nullid, short |
|
10 | from mercurial.node import hex, nullid, short | |
|
11 | from mercurial.repo import RepoError | |||
11 | from mercurial import mdiff, ui, hg, util, archival, patch, hook |
|
12 | from mercurial import mdiff, ui, hg, util, archival, patch, hook | |
12 | from mercurial import revlog, templater, templatefilters, changegroup |
|
13 | from mercurial import revlog, templater, templatefilters, changegroup | |
13 | from common import get_mtime, style_map, paritygen, countgen, get_contact |
|
14 | from common import get_mtime, style_map, paritygen, countgen, get_contact | |
@@ -74,7 +75,7 b' def revnavgen(pos, pagelen, limit, nodef' | |||||
74 | yield {"label": label, "node": node} |
|
75 | yield {"label": label, "node": node} | |
75 |
|
76 | |||
76 | yield {"label": "tip", "node": "tip"} |
|
77 | yield {"label": "tip", "node": "tip"} | |
77 |
except |
|
78 | except RepoError: | |
78 | pass |
|
79 | pass | |
79 |
|
80 | |||
80 | return nav |
|
81 | return nav | |
@@ -248,7 +249,7 b' class hgweb(object):' | |||||
248 | except revlog.LookupError, err: |
|
249 | except revlog.LookupError, err: | |
249 | req.respond(HTTP_NOT_FOUND, ctype) |
|
250 | req.respond(HTTP_NOT_FOUND, ctype) | |
250 | req.write(tmpl('error', error='revision not found: %s' % err.name)) |
|
251 | req.write(tmpl('error', error='revision not found: %s' % err.name)) | |
251 |
except ( |
|
252 | except (RepoError, revlog.RevlogError), inst: | |
252 | req.respond(HTTP_SERVER_ERROR, ctype) |
|
253 | req.respond(HTTP_SERVER_ERROR, ctype) | |
253 | req.write(tmpl('error', error=str(inst))) |
|
254 | req.write(tmpl('error', error=str(inst))) | |
254 | except ErrorResponse, inst: |
|
255 | except ErrorResponse, inst: | |
@@ -915,7 +916,7 b' class hgweb(object):' | |||||
915 |
|
916 | |||
916 | try: |
|
917 | try: | |
917 | ctx = self.repo.changectx(changeid) |
|
918 | ctx = self.repo.changectx(changeid) | |
918 |
except |
|
919 | except RepoError: | |
919 | man = self.repo.manifest |
|
920 | man = self.repo.manifest | |
920 | mn = man.lookup(changeid) |
|
921 | mn = man.lookup(changeid) | |
921 | ctx = self.repo.changectx(man.linkrev(mn)) |
|
922 | ctx = self.repo.changectx(man.linkrev(mn)) | |
@@ -931,7 +932,7 b' class hgweb(object):' | |||||
931 | try: |
|
932 | try: | |
932 | ctx = self.repo.changectx(changeid) |
|
933 | ctx = self.repo.changectx(changeid) | |
933 | fctx = ctx.filectx(path) |
|
934 | fctx = ctx.filectx(path) | |
934 |
except |
|
935 | except RepoError: | |
935 | fctx = self.repo.filectx(path, fileid=changeid) |
|
936 | fctx = self.repo.filectx(path, fileid=changeid) | |
936 |
|
937 | |||
937 | return fctx |
|
938 | return fctx |
@@ -8,6 +8,7 b'' | |||||
8 |
|
8 | |||
9 | import os |
|
9 | import os | |
10 | from mercurial.i18n import gettext as _ |
|
10 | from mercurial.i18n import gettext as _ | |
|
11 | from mercurial.repo import RepoError | |||
11 | from mercurial import ui, hg, util, templater, templatefilters |
|
12 | from mercurial import ui, hg, util, templater, templatefilters | |
12 | from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen,\ |
|
13 | from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen,\ | |
13 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
|
14 | get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | |
@@ -110,7 +111,7 b' class hgwebdir(object):' | |||||
110 | except IOError, inst: |
|
111 | except IOError, inst: | |
111 | msg = inst.strerror |
|
112 | msg = inst.strerror | |
112 | raise ErrorResponse(HTTP_SERVER_ERROR, msg) |
|
113 | raise ErrorResponse(HTTP_SERVER_ERROR, msg) | |
113 |
except |
|
114 | except RepoError, inst: | |
114 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) |
|
115 | raise ErrorResponse(HTTP_SERVER_ERROR, str(inst)) | |
115 |
|
116 | |||
116 | # browse subdirectories |
|
117 | # browse subdirectories |
@@ -8,6 +8,7 b'' | |||||
8 |
|
8 | |||
9 | import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback |
|
9 | import os, sys, errno, urllib, BaseHTTPServer, socket, SocketServer, traceback | |
10 | from mercurial import hg, util |
|
10 | from mercurial import hg, util | |
|
11 | from mercurial.repo import RepoError | |||
11 | from hgweb_mod import hgweb |
|
12 | from hgweb_mod import hgweb | |
12 | from hgwebdir_mod import hgwebdir |
|
13 | from hgwebdir_mod import hgwebdir | |
13 | from mercurial.i18n import gettext as _ |
|
14 | from mercurial.i18n import gettext as _ | |
@@ -247,7 +248,7 b' def create_server(ui, repo):' | |||||
247 | elif repo is not None: |
|
248 | elif repo is not None: | |
248 | hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) |
|
249 | hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |
249 | else: |
|
250 | else: | |
250 |
raise |
|
251 | raise RepoError(_("There is no Mercurial repository here" | |
251 |
|
|
252 | " (.hg not found)")) | |
252 | return hgwebobj |
|
253 | return hgwebobj | |
253 | self.application = make_handler() |
|
254 | self.application = make_handler() | |
@@ -277,7 +278,7 b' def create_server(ui, repo):' | |||||
277 |
|
278 | |||
278 | def __init__(self, *args, **kwargs): |
|
279 | def __init__(self, *args, **kwargs): | |
279 | if self.address_family is None: |
|
280 | if self.address_family is None: | |
280 |
raise |
|
281 | raise RepoError(_('IPv6 not available on this system')) | |
281 | super(IPv6HTTPServer, self).__init__(*args, **kwargs) |
|
282 | super(IPv6HTTPServer, self).__init__(*args, **kwargs) | |
282 |
|
283 | |||
283 | if ssl_cert: |
|
284 | if ssl_cert: |
@@ -6,7 +6,8 b'' | |||||
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | import os, mimetypes |
|
8 | import os, mimetypes | |
9 |
from mercurial import revlog, util |
|
9 | from mercurial import revlog, util | |
|
10 | from mercurial.repo import RepoError | |||
10 | from common import staticfile, ErrorResponse, HTTP_OK, HTTP_NOT_FOUND |
|
11 | from common import staticfile, ErrorResponse, HTTP_OK, HTTP_NOT_FOUND | |
11 |
|
12 | |||
12 | # __all__ is populated with the allowed commands. Be sure to add to it if |
|
13 | # __all__ is populated with the allowed commands. Be sure to add to it if | |
@@ -67,7 +68,7 b' def changelog(web, req, tmpl, shortlog =' | |||||
67 | hi = web.repo.changelog.count() - 1 |
|
68 | hi = web.repo.changelog.count() - 1 | |
68 | try: |
|
69 | try: | |
69 | ctx = web.repo.changectx(hi) |
|
70 | ctx = web.repo.changectx(hi) | |
70 |
except |
|
71 | except RepoError: | |
71 | return web.search(tmpl, hi) # XXX redirect to 404 page? |
|
72 | return web.search(tmpl, hi) # XXX redirect to 404 page? | |
72 |
|
73 | |||
73 | return web.changelog(tmpl, ctx, shortlog = shortlog) |
|
74 | return web.changelog(tmpl, ctx, shortlog = shortlog) |
General Comments 0
You need to be logged in to leave comments.
Login now