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