Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hg.py @ 46114:59fa3890d40a
node: import symbols explicitly
There is no point in lazy importing mercurial.node, it is used all over
the place anyway. So consistently import the used symbols directly.
Fix one file using symbols indirectly via mercurial.revlog.
Differential Revision: https://phab.mercurial-scm.org/D9480
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 01 Dec 2020 21:54:46 +0100 |
parents | 89a2afe31e82 |
children | 5b9bb4e9a3bf |
comparison
equal
deleted
inserted
replaced
46113:d6afa9c149c3 | 46114:59fa3890d40a |
---|---|
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import stat | 14 import stat |
15 | 15 |
16 from .i18n import _ | 16 from .i18n import _ |
17 from .node import nullid | 17 from .node import ( |
18 hex, | |
19 nullhex, | |
20 nullid, | |
21 short, | |
22 ) | |
18 from .pycompat import getattr | 23 from .pycompat import getattr |
19 | 24 |
20 from . import ( | 25 from . import ( |
21 bookmarks, | 26 bookmarks, |
22 bundlerepo, | 27 bundlerepo, |
33 logcmdutil, | 38 logcmdutil, |
34 logexchange, | 39 logexchange, |
35 merge as mergemod, | 40 merge as mergemod, |
36 mergestate as mergestatemod, | 41 mergestate as mergestatemod, |
37 narrowspec, | 42 narrowspec, |
38 node, | |
39 phases, | 43 phases, |
40 pycompat, | 44 pycompat, |
41 requirements, | 45 requirements, |
42 scmutil, | 46 scmutil, |
43 sshpeer, | 47 sshpeer, |
106 if branch == b'.': | 110 if branch == b'.': |
107 if not lrepo: | 111 if not lrepo: |
108 raise error.Abort(_(b"dirstate branch not accessible")) | 112 raise error.Abort(_(b"dirstate branch not accessible")) |
109 branch = lrepo.dirstate.branch() | 113 branch = lrepo.dirstate.branch() |
110 if branch in branchmap: | 114 if branch in branchmap: |
111 revs.extend(node.hex(r) for r in reversed(branchmap[branch])) | 115 revs.extend(hex(r) for r in reversed(branchmap[branch])) |
112 return True | 116 return True |
113 else: | 117 else: |
114 return False | 118 return False |
115 | 119 |
116 for branch in branches: | 120 for branch in branches: |
760 { | 764 { |
761 b'key': b'0', | 765 b'key': b'0', |
762 }, | 766 }, |
763 ).result() | 767 ).result() |
764 | 768 |
765 if rootnode != node.nullid: | 769 if rootnode != nullid: |
766 sharepath = os.path.join(sharepool, node.hex(rootnode)) | 770 sharepath = os.path.join(sharepool, hex(rootnode)) |
767 else: | 771 else: |
768 ui.status( | 772 ui.status( |
769 _( | 773 _( |
770 b'(not using pooled storage: ' | 774 b'(not using pooled storage: ' |
771 b'remote appears to be empty)\n' | 775 b'remote appears to be empty)\n' |
778 b'unable to resolve identity of remote)\n' | 782 b'unable to resolve identity of remote)\n' |
779 ) | 783 ) |
780 ) | 784 ) |
781 elif sharenamemode == b'remote': | 785 elif sharenamemode == b'remote': |
782 sharepath = os.path.join( | 786 sharepath = os.path.join( |
783 sharepool, node.hex(hashutil.sha1(source).digest()) | 787 sharepool, hex(hashutil.sha1(source).digest()) |
784 ) | 788 ) |
785 else: | 789 else: |
786 raise error.Abort( | 790 raise error.Abort( |
787 _(b'unknown share naming mode: %s') % sharenamemode | 791 _(b'unknown share naming mode: %s') % sharenamemode |
788 ) | 792 ) |
870 _copycache(srcrepo, dstcachedir, cache) | 874 _copycache(srcrepo, dstcachedir, cache) |
871 | 875 |
872 # we need to re-init the repo after manually copying the data | 876 # we need to re-init the repo after manually copying the data |
873 # into it | 877 # into it |
874 destpeer = peer(srcrepo, peeropts, dest) | 878 destpeer = peer(srcrepo, peeropts, dest) |
875 srcrepo.hook( | 879 srcrepo.hook(b'outgoing', source=b'clone', node=nullhex) |
876 b'outgoing', source=b'clone', node=node.hex(node.nullid) | |
877 ) | |
878 else: | 880 else: |
879 try: | 881 try: |
880 # only pass ui when no srcrepo | 882 # only pass ui when no srcrepo |
881 destpeer = peer( | 883 destpeer = peer( |
882 srcrepo or ui, | 884 srcrepo or ui, |
1377 except error.RepoError as e: | 1379 except error.RepoError as e: |
1378 repo.ui.warn(b'%d: %s\n' % (rev, e)) | 1380 repo.ui.warn(b'%d: %s\n' % (rev, e)) |
1379 except Exception: | 1381 except Exception: |
1380 repo.ui.warn( | 1382 repo.ui.warn( |
1381 _(b'.hgsubstate is corrupt in revision %s\n') | 1383 _(b'.hgsubstate is corrupt in revision %s\n') |
1382 % node.short(ctx.node()) | 1384 % short(ctx.node()) |
1383 ) | 1385 ) |
1384 | 1386 |
1385 return ret | 1387 return ret |
1386 | 1388 |
1387 | 1389 |