Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Get rid of GIT_REMOTE_HG_TEST_REMOTE and special case for local hg repos
Browse files Browse the repository at this point in the history
For local hg repositories, the repo was not cloned. This special case
made it necessary to have GIT_REMOTE_HG_TEST_REMOTE for use by tests.
It also caused some problems for me, see e.g. issue #26.
  • Loading branch information
fingolfin committed Oct 28, 2014
1 parent 404a54b commit d006a64
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
65 changes: 30 additions & 35 deletions git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -392,46 +392,41 @@ def get_repo(url, alias):

extensions.loadall(myui)

if hg.islocal(url) and not os.environ.get('GIT_REMOTE_HG_TEST_REMOTE'):
repo = hg.repository(myui, url)
if not os.path.exists(dirname):
os.makedirs(dirname)
else:
shared_path = os.path.join(gitdir, 'hg')

# check and upgrade old organization
hg_path = os.path.join(shared_path, '.hg')
if os.path.exists(shared_path) and not os.path.exists(hg_path):
repos = os.listdir(shared_path)
for x in repos:
local_hg = os.path.join(shared_path, x, 'clone', '.hg')
if not os.path.exists(local_hg):
continue
if not os.path.exists(hg_path):
shutil.move(local_hg, hg_path)
shutil.rmtree(os.path.join(shared_path, x, 'clone'))
shared_path = os.path.join(gitdir, 'hg')

# check and upgrade old organization
hg_path = os.path.join(shared_path, '.hg')
if os.path.exists(shared_path) and not os.path.exists(hg_path):
repos = os.listdir(shared_path)
for x in repos:
local_hg = os.path.join(shared_path, x, 'clone', '.hg')
if not os.path.exists(local_hg):
continue
if not os.path.exists(hg_path):
shutil.move(local_hg, hg_path)
shutil.rmtree(os.path.join(shared_path, x, 'clone'))

# setup shared repo (if not there)
try:
hg.peer(myui, {}, shared_path, create=True)
except error.RepoError:
pass
# setup shared repo (if not there)
try:
hg.peer(myui, {}, shared_path, create=True)
except error.RepoError:
pass

if not os.path.exists(dirname):
os.makedirs(dirname)
if not os.path.exists(dirname):
os.makedirs(dirname)

local_path = os.path.join(dirname, 'clone')
if not os.path.exists(local_path):
hg.share(myui, shared_path, local_path, update=False)
else:
# make sure the shared path is always up-to-date
util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path)
local_path = os.path.join(dirname, 'clone')
if not os.path.exists(local_path):
hg.share(myui, shared_path, local_path, update=False)
else:
# make sure the shared path is always up-to-date
util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path)

repo = hg.repository(myui, local_path)
peer = hg.peer(repo.ui, {}, url)
repo.pull(peer, heads=None, force=True)
repo = hg.repository(myui, local_path)
peer = hg.peer(repo.ui, {}, url)
repo.pull(peer, heads=None, force=True)

updatebookmarks(repo, peer)
updatebookmarks(repo, peer)

return repo

Expand Down
3 changes: 0 additions & 3 deletions test/main.t
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ test_expect_success 'remote push from master branch' '
check_branch hgrepo default one
'

GIT_REMOTE_HG_TEST_REMOTE=1
export GIT_REMOTE_HG_TEST_REMOTE

test_expect_success 'remote cloning' '
test_when_finished "rm -rf gitrepo*" &&
Expand Down

0 comments on commit d006a64

Please sign in to comment.