Skip to content

Commit 36ec9e2

Browse files
committed
Merge branch 'fc/remote-helper-fixes'
* 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()
2 parents 97663a1 + 1f7feb7 commit 36ec9e2

File tree

3 files changed

+103
-9
lines changed

3 files changed

+103
-9
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,16 @@ def main(args):
883883
global branches, peers
884884
global transports
885885

886+
marks = None
887+
is_tmp = False
888+
gitdir = os.environ.get('GIT_DIR', None)
889+
890+
if len(args) < 3:
891+
die('Not enough arguments.')
892+
893+
if not gitdir:
894+
die('GIT_DIR not set')
895+
886896
alias = args[1]
887897
url = args[2]
888898

@@ -891,19 +901,15 @@ def main(args):
891901
blob_marks = {}
892902
parsed_refs = {}
893903
files_cache = {}
894-
marks = None
895904
branches = {}
896905
peers = {}
897906
transports = []
898907

899908
if alias[5:] == url:
900909
is_tmp = True
901910
alias = hashlib.sha1(alias).hexdigest()
902-
else:
903-
is_tmp = False
904911

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

909915
if not is_tmp:

contrib/remote-helpers/git-remote-hg

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ def get_repo(url, alias):
415415
local_path = os.path.join(dirname, 'clone')
416416
if not os.path.exists(local_path):
417417
hg.share(myui, shared_path, local_path, update=False)
418+
else:
419+
# make sure the shared path is always up-to-date
420+
util.writefile(os.path.join(local_path, '.hg', 'sharedpath'), hg_path)
418421

419422
repo = hg.repository(myui, local_path)
420423
try:
@@ -537,7 +540,7 @@ def export_ref(repo, name, kind, head):
537540

538541
print "commit %s" % ref
539542
print "mark :%d" % (note_mark)
540-
print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
543+
print "committer remote-hg <> %d %s" % (ptime.time(), gittz(ptime.timezone))
541544
desc = "Notes for %s\n" % (name)
542545
print "data %d" % (len(desc))
543546
print desc
@@ -1164,6 +1167,16 @@ def main(args):
11641167
global dry_run
11651168
global notes, alias
11661169

1170+
marks = None
1171+
is_tmp = False
1172+
gitdir = os.environ.get('GIT_DIR', None)
1173+
1174+
if len(args) < 3:
1175+
die('Not enough arguments.')
1176+
1177+
if not gitdir:
1178+
die('GIT_DIR not set')
1179+
11671180
alias = args[1]
11681181
url = args[2]
11691182
peer = None
@@ -1184,16 +1197,12 @@ def main(args):
11841197
if alias[4:] == url:
11851198
is_tmp = True
11861199
alias = hashlib.sha1(alias).hexdigest()
1187-
else:
1188-
is_tmp = False
11891200

1190-
gitdir = os.environ['GIT_DIR']
11911201
dirname = os.path.join(gitdir, 'hg', alias)
11921202
branches = {}
11931203
bmarks = {}
11941204
blob_marks = {}
11951205
parsed_refs = {}
1196-
marks = None
11971206
parsed_tags = {}
11981207
filenodes = {}
11991208
fake_bmark = None

contrib/remote-helpers/test-hg.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ test_expect_success 'remote cloning' '
337337
check gitrepo HEAD zero
338338
'
339339

340+
test_expect_success 'moving remote clone' '
341+
test_when_finished "rm -rf gitrepo*" &&
342+
343+
(
344+
git clone "hg::hgrepo" gitrepo &&
345+
mv gitrepo gitrepo2 &&
346+
cd gitrepo2 &&
347+
git fetch
348+
)
349+
'
350+
340351
test_expect_success 'remote update bookmark' '
341352
test_when_finished "rm -rf gitrepo*" &&
342353
@@ -444,6 +455,74 @@ test_expect_success 'remote new bookmark multiple branch head' '
444455
# cleanup previous stuff
445456
rm -rf hgrepo
446457

458+
test_expect_success 'fetch special filenames' '
459+
test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
460+
461+
LC_ALL=en_US.UTF-8
462+
export LC_ALL
463+
464+
(
465+
hg init hgrepo &&
466+
cd hgrepo &&
467+
468+
echo test >> "æ rø" &&
469+
hg add "æ rø" &&
470+
echo test >> "ø~?" &&
471+
hg add "ø~?" &&
472+
hg commit -m add-utf-8 &&
473+
echo test >> "æ rø" &&
474+
hg commit -m test-utf-8 &&
475+
hg rm "ø~?" &&
476+
hg mv "æ rø" "ø~?" &&
477+
hg commit -m hg-mv-utf-8
478+
) &&
479+
480+
(
481+
git clone "hg::hgrepo" gitrepo &&
482+
cd gitrepo &&
483+
git -c core.quotepath=false ls-files > ../actual
484+
) &&
485+
echo "ø~?" > expected &&
486+
test_cmp expected actual
487+
'
488+
489+
test_expect_success 'push special filenames' '
490+
test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
491+
492+
mkdir -p tmp && cd tmp &&
493+
494+
LC_ALL=en_US.UTF-8
495+
export LC_ALL
496+
497+
(
498+
hg init hgrepo &&
499+
cd hgrepo &&
500+
501+
echo one >> content &&
502+
hg add content &&
503+
hg commit -m one
504+
) &&
505+
506+
(
507+
git clone "hg::hgrepo" gitrepo &&
508+
cd gitrepo &&
509+
510+
echo test >> "æ rø" &&
511+
git add "æ rø" &&
512+
git commit -m utf-8 &&
513+
514+
git push
515+
) &&
516+
517+
(cd hgrepo &&
518+
hg update &&
519+
hg manifest > ../actual
520+
) &&
521+
522+
printf "content\næ rø\n" > expected &&
523+
test_cmp expected actual
524+
'
525+
447526
setup_big_push () {
448527
(
449528
hg init hgrepo &&

0 commit comments

Comments
 (0)