diff --git a/git-remote-hg b/git-remote-hg index 13b80d1..8267a9f 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -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 diff --git a/test/main.t b/test/main.t index e785a3a..712c017 100755 --- a/test/main.t +++ b/test/main.t @@ -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*" &&