##// 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 help,
36 help,
37 hg,
37 hg,
38 hook,
38 hook,
39 localrepo,
39 profiling,
40 profiling,
40 pycompat,
41 pycompat,
41 rcutil,
42 rcutil,
42 registrar,
43 registrar,
44 requirements as requirementsmod,
43 scmutil,
45 scmutil,
44 ui as uimod,
46 ui as uimod,
45 util,
47 util,
48 vfs,
46 )
49 )
47
50
48 from .utils import (
51 from .utils import (
@@ -939,6 +942,29 b' def runcommand(lui, repo, cmd, fullargs,'
939 return ret
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 def _getlocal(ui, rpath, wd=None):
968 def _getlocal(ui, rpath, wd=None):
943 """Return (path, local ui object) for the given target path.
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 else:
985 else:
960 lui = ui.copy()
986 lui = ui.copy()
961 if rcutil.use_repo_hgrc():
987 if rcutil.use_repo_hgrc():
988 _readsharedsourceconfig(lui, path)
962 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
989 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
963
990
964 if rpath:
991 if rpath:
965 path = lui.expandpath(rpath)
992 path = lui.expandpath(rpath)
966 lui = ui.copy()
993 lui = ui.copy()
967 if rcutil.use_repo_hgrc():
994 if rcutil.use_repo_hgrc():
995 _readsharedsourceconfig(lui, path)
968 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
996 lui.readconfig(os.path.join(path, b".hg", b"hgrc"), path)
969
997
970 return path, lui
998 return path, lui
@@ -102,21 +102,14 b' Test that extensions of source repositor'
102 share
102 share
103 $ hg extdiff -R ../source -p echo
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 is loaded
107 is loaded
107 $ hg debugextensions
108 $ hg debugextensions
108 extdiff
109 extdiff
109 share
110 share
110
111
111 BROKEN: extdiff command should work here
112 $ hg extdiff -p echo
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 However, local .hg/hgrc should override the config set by share source
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