mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
stop hg svn rebuildmeta/updatemeta from talking to svn server
Summary: # RFC, not sure if I know what I am doing but I know my goal as follow In case of the entire `.hg/svn` missing, in order to get the subdir and uuid information, hgsubversion needs to talk to svn server. In our cases, it's polluting our logging and it's hard to know who is really using svn server. In this diff I want to disable this by writing these 2 information directly in config and hgsubversion will just read from there. Reviewed By: mitrandir77 Differential Revision: D15989449 fbshipit-source-id: fd9cead094245b3c0baf6e7e1099cc302899668f
This commit is contained in:
parent
97cff8167d
commit
f4a2f2875f
@ -415,6 +415,10 @@ configitem("hgsubversion", "startrev", default=configitem.dynamicdefault)
|
||||
configitem("hgsubversion", "sqlitepragmas", default=list)
|
||||
# real default is False
|
||||
configitem("hgsubversion", "failonmissing", default=configitem.dynamicdefault)
|
||||
# for stopping hg svn rebuildmeta from resolving this info from svn server
|
||||
configitem("hgsubversion", "reposubdir", default=configitem.dynamicdefault)
|
||||
# for stopping hg svn rebuildmeta from getting this info from svn server
|
||||
configitem("hgsubversion", "repouuid", default=configitem.dynamicdefault)
|
||||
|
||||
|
||||
@templatekeyword("svnrev")
|
||||
|
@ -97,10 +97,11 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
|
||||
|
||||
meta = svnmeta.SVNMeta(repo, skiperrorcheck=True)
|
||||
|
||||
svn = None
|
||||
if meta.subdir is None:
|
||||
svn = svnrepo.svnremoterepo(ui, url).svn
|
||||
meta.subdir = svn.subdir
|
||||
subdir = ui.config(
|
||||
"hgsubversion", "reposubdir", svnrepo.svnremoterepo(ui, url).svn.subdir
|
||||
)
|
||||
meta.subdir = subdir
|
||||
|
||||
youngest = 0
|
||||
startrev = 0
|
||||
@ -231,9 +232,12 @@ def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
|
||||
validateuuid = False
|
||||
uuid = convinfo[4:40]
|
||||
if not skipuuid:
|
||||
if svn is None:
|
||||
svn = svnrepo.svnremoterepo(ui, url).svn
|
||||
if uuid != svn.uuid:
|
||||
uuidfromconforserver = ui.config(
|
||||
"hgsubversion",
|
||||
"repouuid",
|
||||
svnrepo.svnremoterepo(ui, url).svn.uuid,
|
||||
)
|
||||
if uuid != uuidfromconforserver:
|
||||
raise hgutil.Abort(
|
||||
"remote svn repository identifier " "does not match"
|
||||
)
|
||||
|
@ -7,7 +7,14 @@ import re
|
||||
|
||||
import test_hgsubversion_util
|
||||
from edenscm.hgext import rebase
|
||||
from edenscm.hgext.hgsubversion import compathacks, svncommands, util, verify, wrappers
|
||||
from edenscm.hgext.hgsubversion import (
|
||||
compathacks,
|
||||
svncommands,
|
||||
svnmeta,
|
||||
util,
|
||||
verify,
|
||||
wrappers,
|
||||
)
|
||||
from edenscm.mercurial import commands, context, hg, node, revlog, util as hgutil
|
||||
|
||||
|
||||
@ -224,9 +231,12 @@ missing file: binary3
|
||||
def test_svnrebuildmeta(self):
|
||||
otherpath = self.load_svndump("binaryfiles-broken.svndump")
|
||||
otherurl = test_hgsubversion_util.fileurl(otherpath)
|
||||
self.load_and_fetch("replace_trunk_with_branch.svndump")
|
||||
_, repopath = self.load_and_fetch("replace_trunk_with_branch.svndump")
|
||||
repourl = test_hgsubversion_util.fileurl(repopath)
|
||||
# rebuildmeta with original repo
|
||||
svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[])
|
||||
# rebuildmeta with original repo explicitly
|
||||
svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[repourl])
|
||||
# rebuildmeta with unrelated repo
|
||||
self.assertRaises(
|
||||
hgutil.Abort,
|
||||
@ -267,6 +277,67 @@ missing file: binary3
|
||||
list(repo.revs("svnrev(%s)" % orig_tip_svn_rev)), [new_tip_rev]
|
||||
)
|
||||
|
||||
def test_svn_reposubdir_config(self):
|
||||
otherpath = self.load_svndump("binaryfiles-broken.svndump")
|
||||
otherurl = test_hgsubversion_util.fileurl(otherpath)
|
||||
_, repopath = self.load_and_fetch(
|
||||
"subdir_is_file_prefix.svndump", subdir="flaf"
|
||||
)
|
||||
repourl = test_hgsubversion_util.fileurl(repopath)
|
||||
ui = self.ui()
|
||||
|
||||
# rebuildmeta with original repo
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[repourl])
|
||||
old_subdir = svnmeta.SVNMeta(self.repo).subdir
|
||||
# remove metadata, rebuild with a wrong subdir config
|
||||
# this should raise
|
||||
test_hgsubversion_util.rmtree(self.repo.sharedvfs.join("svn"))
|
||||
ui.setconfig("hgsubversion", "reposubdir", "new_wrong_subdir")
|
||||
self.assertRaises(
|
||||
AssertionError,
|
||||
svncommands.rebuildmeta,
|
||||
ui=ui,
|
||||
repo=self.repo,
|
||||
args=[repourl],
|
||||
)
|
||||
# remove metadata, rebuild with the correct subdir config
|
||||
test_hgsubversion_util.rmtree(self.repo.sharedvfs.join("svn"))
|
||||
ui.setconfig("hgsubversion", "reposubdir", old_subdir)
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[repourl])
|
||||
new_subdir = svnmeta.SVNMeta(self.repo).subdir
|
||||
self.assertEqual(old_subdir, new_subdir)
|
||||
# remove metadata, rebuild with the correct subdir config, with a unrealted url
|
||||
test_hgsubversion_util.rmtree(self.repo.sharedvfs.join("svn"))
|
||||
ui.setconfig("hgsubversion", "reposubdir", old_subdir)
|
||||
ui.setconfig("hgsubversion", "repouuid", "924a052a-5e5a-4a8e-a677-da5565bec340")
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[otherurl])
|
||||
another_subdir = svnmeta.SVNMeta(self.repo).subdir
|
||||
self.assertEqual(old_subdir, another_subdir)
|
||||
|
||||
def test_svn_repouuid_config(self):
|
||||
otherpath = self.load_svndump("binaryfiles-broken.svndump")
|
||||
otherurl = test_hgsubversion_util.fileurl(otherpath)
|
||||
_, repopath = self.load_and_fetch("replace_trunk_with_branch.svndump")
|
||||
repourl = test_hgsubversion_util.fileurl(repopath)
|
||||
# rebuildmeta with original repo
|
||||
svncommands.rebuildmeta(self.ui(), repo=self.repo, args=[])
|
||||
# updatemeta with the wrong, pre-configured uuid
|
||||
ui = self.ui()
|
||||
ui.setconfig("hgsubversion", "repouuid", "a wrong uuid")
|
||||
self.assertRaises(
|
||||
hgutil.Abort, svncommands.updatemeta, ui=ui, repo=self.repo, args=[repourl]
|
||||
)
|
||||
# updatemeta with the right, pre-configured uuid
|
||||
ui.setconfig("hgsubversion", "repouuid", "5b65bade-98f3-4993-a01f-b7a6710da339")
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[repourl])
|
||||
# updatemeta with the right, pre-configured uuid, and unrelated repo
|
||||
ui.setconfig("hgsubversion", "repouuid", "5b65bade-98f3-4993-a01f-b7a6710da339")
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[otherurl])
|
||||
# updatemeta with empty meta
|
||||
test_hgsubversion_util.rmtree(self.repo.sharedvfs.join("svn"))
|
||||
ui.setconfig("hgsubversion", "repouuid", "5b65bade-98f3-4993-a01f-b7a6710da339")
|
||||
svncommands.rebuildmeta(ui, repo=self.repo, args=[otherurl])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import silenttestrunner
|
||||
|
Loading…
Reference in New Issue
Block a user