Skip to content

Commit

Permalink
Merge branch 'fc/remote-helper-fixes'
Browse files Browse the repository at this point in the history
* fc/remote-helper-fixes:
  remote-hg: test 'shared_path' in a moved clone
  remote-hg: add tests for special filenames
  remote-hg: fix 'shared path' path
  remote-helpers: add extra safety checks
  remote-hg: avoid buggy strftime()
  • Loading branch information
Junio C Hamano committed Dec 27, 2013
2 parents 97663a1 + 1f7feb7 commit 36ec9e2
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 9 deletions.
14 changes: 10 additions & 4 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,16 @@ def main(args):
global branches, peers
global transports

marks = None
is_tmp = False
gitdir = os.environ.get('GIT_DIR', None)

if len(args) < 3:
die('Not enough arguments.')

if not gitdir:
die('GIT_DIR not set')

alias = args[1]
url = args[2]

Expand All @@ -891,19 +901,15 @@ def main(args):
blob_marks = {}
parsed_refs = {}
files_cache = {}
marks = None
branches = {}
peers = {}
transports = []

if alias[5:] == url:
is_tmp = True
alias = hashlib.sha1(alias).hexdigest()
else:
is_tmp = False

prefix = 'refs/bzr/%s' % alias
gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'bzr', alias)

if not is_tmp:
Expand Down
19 changes: 14 additions & 5 deletions contrib/remote-helpers/git-remote-hg
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ def get_repo(url, alias):
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)
try:
Expand Down Expand Up @@ -537,7 +540,7 @@ def export_ref(repo, name, kind, head):

print "commit %s" % ref
print "mark :%d" % (note_mark)
print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
print "committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone))
desc = "Notes for %s\n" % (name)
print "data %d" % (len(desc))
print desc
Expand Down Expand Up @@ -1164,6 +1167,16 @@ def main(args):
global dry_run
global notes, alias

marks = None
is_tmp = False
gitdir = os.environ.get('GIT_DIR', None)

if len(args) < 3:
die('Not enough arguments.')

if not gitdir:
die('GIT_DIR not set')

alias = args[1]
url = args[2]
peer = None
Expand All @@ -1184,16 +1197,12 @@ def main(args):
if alias[4:] == url:
is_tmp = True
alias = hashlib.sha1(alias).hexdigest()
else:
is_tmp = False

gitdir = os.environ['GIT_DIR']
dirname = os.path.join(gitdir, 'hg', alias)
branches = {}
bmarks = {}
blob_marks = {}
parsed_refs = {}
marks = None
parsed_tags = {}
filenodes = {}
fake_bmark = None
Expand Down
79 changes: 79 additions & 0 deletions contrib/remote-helpers/test-hg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,17 @@ test_expect_success 'remote cloning' '
check gitrepo HEAD zero
'

test_expect_success 'moving remote clone' '
test_when_finished "rm -rf gitrepo*" &&
(
git clone "hg::hgrepo" gitrepo &&
mv gitrepo gitrepo2 &&
cd gitrepo2 &&
git fetch
)
'

test_expect_success 'remote update bookmark' '
test_when_finished "rm -rf gitrepo*" &&
Expand Down Expand Up @@ -444,6 +455,74 @@ test_expect_success 'remote new bookmark multiple branch head' '
# cleanup previous stuff
rm -rf hgrepo

test_expect_success 'fetch special filenames' '
test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
LC_ALL=en_US.UTF-8
export LC_ALL
(
hg init hgrepo &&
cd hgrepo &&
echo test >> "æ rø" &&
hg add "æ rø" &&
echo test >> "ø~?" &&
hg add "ø~?" &&
hg commit -m add-utf-8 &&
echo test >> "æ rø" &&
hg commit -m test-utf-8 &&
hg rm "ø~?" &&
hg mv "æ rø" "ø~?" &&
hg commit -m hg-mv-utf-8
) &&
(
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
git -c core.quotepath=false ls-files > ../actual
) &&
echo "ø~?" > expected &&
test_cmp expected actual
'

test_expect_success 'push special filenames' '
test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
mkdir -p tmp && cd tmp &&
LC_ALL=en_US.UTF-8
export LC_ALL
(
hg init hgrepo &&
cd hgrepo &&
echo one >> content &&
hg add content &&
hg commit -m one
) &&
(
git clone "hg::hgrepo" gitrepo &&
cd gitrepo &&
echo test >> "æ rø" &&
git add "æ rø" &&
git commit -m utf-8 &&
git push
) &&
(cd hgrepo &&
hg update &&
hg manifest > ../actual
) &&
printf "content\næ rø\n" > expected &&
test_cmp expected actual
'

setup_big_push () {
(
hg init hgrepo &&
Expand Down

0 comments on commit 36ec9e2

Please sign in to comment.