##// END OF EJS Templates
dispatch: load shared source repository config in share-safe mode...
Pulkit Goyal -
r46367:fd1de908 default
parent child Browse files
Show More
@@ -36,13 +36,16 b' from . import ('
36 36 help,
37 37 hg,
38 38 hook,
39 localrepo,
39 40 profiling,
40 41 pycompat,
41 42 rcutil,
42 43 registrar,
44 requirements as requirementsmod,
43 45 scmutil,
44 46 ui as uimod,
45 47 util,
48 vfs,
46 49 )
47 50
48 51 from .utils import (
@@ -939,6 +942,29 b' def runcommand(lui, repo, cmd, fullargs,'
939 942 return ret
940 943
941 944
945 def _readsharedsourceconfig(ui, path):
946 """if the current repository is shared one, this tries to read
947 .hg/hgrc of shared source if we are in share-safe mode
948
949 Config read is loaded into the ui object passed
950
951 This should be called before reading .hg/hgrc or the main repo
952 as that overrides config set in shared source"""
953 try:
954 with open(os.path.join(path, b".hg", b"requires"), "rb") as fp:
955 requirements = set(fp.read().splitlines())
956 if not (
957 requirementsmod.SHARESAFE_REQUIREMENT in requirements
958 and requirementsmod.SHARED_REQUIREMENT in requirements
959 ):
960 return
961 hgvfs = vfs.vfs(os.path.join(path, b".hg"))
962 sharedvfs = localrepo._getsharedvfs(hgvfs, requirements)
963 ui.readconfig(sharedvfs.join(b"hgrc"), path)
964 except IOError:
965 pass
966
967
942 968 def _getlocal(ui, rpath, wd=None):
943 969 """Return (path, local ui object) for the given target path.
944 970
@@ -959,12 +985,14 b' def _getlocal(ui, rpath, wd=None):'
959 985 else:
960 986 lui = ui.copy()
961 987 if rcutil.use_repo_hgrc():
988 _readsharedsourceconfig(lui, path)
962 989 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
963 990
964 991 if rpath:
965 992 path = lui.expandpath(rpath)
966 993 lui = ui.copy()
967 994 if rcutil.use_repo_hgrc():
995 _readsharedsourceconfig(lui, path)
968 996 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
969 997
970 998 return path, lui
@@ -102,21 +102,14 b' Test that extensions of source repositor'
102 102 share
103 103 $ hg extdiff -R ../source -p echo
104 104
105 BROKEN: the command below does not work but debugextensions says that extension
105 BROKEN: the command below will not work if config of shared source is not loaded
106 on dispatch but debugextensions says that extension
106 107 is loaded
107 108 $ hg debugextensions
108 109 extdiff
109 110 share
110 111
111 BROKEN: extdiff command should work here
112 112 $ hg extdiff -p echo
113 hg: unknown command 'extdiff'
114 'extdiff' is provided by the following extension:
115
116 extdiff command to allow external programs to compare revisions
117
118 (use 'hg help extensions' for information on enabling extensions)
119 [255]
120 113
121 114 However, local .hg/hgrc should override the config set by share source
122 115
General Comments 0
You need to be logged in to leave comments. Login now