remote-hg: use a shared repository store
This way we don't have to have duplicated Mercurial objects. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
cab3829d2b
commit
6796d49ed0
@ -343,21 +343,29 @@ def get_repo(url, alias):
|
|||||||
|
|
||||||
if hg.islocal(url):
|
if hg.islocal(url):
|
||||||
repo = hg.repository(myui, url)
|
repo = hg.repository(myui, url)
|
||||||
|
if not os.path.exists(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
else:
|
else:
|
||||||
|
shared_path = os.path.join(gitdir, 'hg')
|
||||||
|
if not os.path.exists(shared_path):
|
||||||
|
try:
|
||||||
|
hg.clone(myui, {}, url, shared_path, update=False, pull=True)
|
||||||
|
except:
|
||||||
|
die('Repository error')
|
||||||
|
|
||||||
|
if not os.path.exists(dirname):
|
||||||
|
os.makedirs(dirname)
|
||||||
|
|
||||||
local_path = os.path.join(dirname, 'clone')
|
local_path = os.path.join(dirname, 'clone')
|
||||||
if not os.path.exists(local_path):
|
if not os.path.exists(local_path):
|
||||||
try:
|
hg.share(myui, shared_path, local_path, update=False)
|
||||||
peer, dstpeer = hg.clone(myui, {}, url, local_path, update=True, pull=True)
|
|
||||||
except:
|
repo = hg.repository(myui, local_path)
|
||||||
die('Repository error')
|
try:
|
||||||
repo = dstpeer.local()
|
peer = hg.peer(myui, {}, url)
|
||||||
else:
|
except:
|
||||||
repo = hg.repository(myui, local_path)
|
die('Repository error')
|
||||||
try:
|
repo.pull(peer, heads=None, force=True)
|
||||||
peer = hg.peer(myui, {}, url)
|
|
||||||
except:
|
|
||||||
die('Repository error')
|
|
||||||
repo.pull(peer, heads=None, force=True)
|
|
||||||
|
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
@ -898,7 +906,7 @@ def fix_path(alias, repo, orig_url):
|
|||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
global prefix, dirname, branches, bmarks
|
global prefix, gitdir, dirname, branches, bmarks
|
||||||
global marks, blob_marks, parsed_refs
|
global marks, blob_marks, parsed_refs
|
||||||
global peer, mode, bad_mail, bad_name
|
global peer, mode, bad_mail, bad_name
|
||||||
global track_branches, force_push, is_tmp
|
global track_branches, force_push, is_tmp
|
||||||
@ -944,9 +952,6 @@ def main(args):
|
|||||||
if not is_tmp:
|
if not is_tmp:
|
||||||
fix_path(alias, peer or repo, url)
|
fix_path(alias, peer or repo, url)
|
||||||
|
|
||||||
if not os.path.exists(dirname):
|
|
||||||
os.makedirs(dirname)
|
|
||||||
|
|
||||||
marks_path = os.path.join(dirname, 'marks-hg')
|
marks_path = os.path.join(dirname, 'marks-hg')
|
||||||
marks = Marks(marks_path)
|
marks = Marks(marks_path)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user