Merge branch 'fc/contrib-bzr-hg-fixes'
* fc/contrib-bzr-hg-fixes: contrib/remote-helpers: quote variable references in redirection targets contrib/remote-helpers: style updates for test scripts remote-hg: use notes to keep track of Hg revisions remote-helpers: cleanup more global variables remote-helpers: trivial style fixes remote-hg: improve basic test remote-hg: add missing &&s in the test remote-hg: fix test remote-bzr: make bzr branches configurable per-repo remote-bzr: fix export of utf-8 authorsmaint
commit
751e2b3718
|
@ -13,8 +13,11 @@
|
|||
# or
|
||||
# % git clone bzr::lp:myrepo
|
||||
#
|
||||
# If you want to specify which branches you want track (per repo):
|
||||
# git config remote-bzr.branches 'trunk, devel, test'
|
||||
# If you want to specify which branches you want to track (per repo):
|
||||
# % git config remote.origin.bzr-branches 'trunk, devel, test'
|
||||
#
|
||||
# Where 'origin' is the name of the repository you want to specify the
|
||||
# branches.
|
||||
#
|
||||
|
||||
import sys
|
||||
|
@ -168,17 +171,16 @@ class Parser:
|
|||
if not m:
|
||||
return None
|
||||
_, name, email, date, tz = m.groups()
|
||||
name = name.decode('utf-8')
|
||||
committer = '%s <%s>' % (name, email)
|
||||
tz = int(tz)
|
||||
tz = ((tz / 100) * 3600) + ((tz % 100) * 60)
|
||||
return (committer, int(date), tz)
|
||||
|
||||
def rev_to_mark(rev):
|
||||
global marks
|
||||
return marks.from_rev(rev)
|
||||
|
||||
def mark_to_rev(mark):
|
||||
global marks
|
||||
return marks.to_rev(mark)
|
||||
|
||||
def fixup_user(user):
|
||||
|
@ -233,8 +235,6 @@ def get_filechanges(cur, prev):
|
|||
return modified, removed
|
||||
|
||||
def export_files(tree, files):
|
||||
global marks, filenodes
|
||||
|
||||
final = []
|
||||
for path, fid in files.iteritems():
|
||||
kind = tree.kind(fid)
|
||||
|
@ -276,8 +276,6 @@ def export_files(tree, files):
|
|||
return final
|
||||
|
||||
def export_branch(repo, name):
|
||||
global prefix
|
||||
|
||||
ref = '%s/heads/%s' % (prefix, name)
|
||||
tip = marks.get_tip(name)
|
||||
|
||||
|
@ -378,16 +376,12 @@ def export_branch(repo, name):
|
|||
marks.set_tip(name, revid)
|
||||
|
||||
def export_tag(repo, name):
|
||||
global tags, prefix
|
||||
|
||||
ref = '%s/tags/%s' % (prefix, name)
|
||||
print "reset %s" % ref
|
||||
print "from :%u" % rev_to_mark(tags[name])
|
||||
print
|
||||
|
||||
def do_import(parser):
|
||||
global dirname
|
||||
|
||||
repo = parser.repo
|
||||
path = os.path.join(dirname, 'marks-git')
|
||||
|
||||
|
@ -413,8 +407,6 @@ def do_import(parser):
|
|||
sys.stdout.flush()
|
||||
|
||||
def parse_blob(parser):
|
||||
global blob_marks
|
||||
|
||||
parser.next()
|
||||
mark = parser.get_mark()
|
||||
parser.next()
|
||||
|
@ -425,8 +417,6 @@ def parse_blob(parser):
|
|||
class CustomTree():
|
||||
|
||||
def __init__(self, branch, revid, parents, files):
|
||||
global files_cache
|
||||
|
||||
self.updates = {}
|
||||
self.branch = branch
|
||||
|
||||
|
@ -583,9 +573,6 @@ def c_style_unescape(string):
|
|||
return string
|
||||
|
||||
def parse_commit(parser):
|
||||
global marks, blob_marks, parsed_refs
|
||||
global mode
|
||||
|
||||
parents = []
|
||||
|
||||
ref = parser[1]
|
||||
|
@ -657,8 +644,6 @@ def parse_commit(parser):
|
|||
marks.new_mark(revid, commit_mark)
|
||||
|
||||
def parse_reset(parser):
|
||||
global parsed_refs
|
||||
|
||||
ref = parser[1]
|
||||
parser.next()
|
||||
|
||||
|
@ -674,8 +659,6 @@ def parse_reset(parser):
|
|||
parsed_refs[ref] = mark_to_rev(from_mark)
|
||||
|
||||
def do_export(parser):
|
||||
global parsed_refs, dirname, transports
|
||||
|
||||
parser.next()
|
||||
|
||||
for line in parser.each_block('done'):
|
||||
|
@ -725,8 +708,6 @@ def do_export(parser):
|
|||
print
|
||||
|
||||
def do_capabilities(parser):
|
||||
global dirname
|
||||
|
||||
print "import"
|
||||
print "export"
|
||||
print "refspec refs/heads/*:%s/heads/*" % prefix
|
||||
|
@ -744,8 +725,6 @@ def ref_is_valid(name):
|
|||
return not True in [c in name for c in '~^: \\']
|
||||
|
||||
def do_list(parser):
|
||||
global tags
|
||||
|
||||
master_branch = None
|
||||
|
||||
for name in branches:
|
||||
|
@ -770,7 +749,6 @@ def do_list(parser):
|
|||
print
|
||||
|
||||
def clone(path, remote_branch):
|
||||
global transports
|
||||
try:
|
||||
bdir = bzrlib.bzrdir.BzrDir.create(path, possible_transports=transports)
|
||||
except bzrlib.errors.AlreadyControlDirError:
|
||||
|
@ -780,8 +758,6 @@ def clone(path, remote_branch):
|
|||
return remote_branch.sprout(bdir, repository=repo)
|
||||
|
||||
def get_remote_branch(name):
|
||||
global dirname, branches, transports
|
||||
|
||||
remote_branch = bzrlib.branch.Branch.open(branches[name],
|
||||
possible_transports=transports)
|
||||
if isinstance(remote_branch.user_transport, bzrlib.transport.local.LocalTransport):
|
||||
|
@ -825,8 +801,6 @@ def find_branches(repo):
|
|||
yield name, branch.base
|
||||
|
||||
def get_repo(url, alias):
|
||||
global dirname, peer, branches, transports
|
||||
|
||||
normal_url = bzrlib.urlutils.normalize_url(url)
|
||||
origin = bzrlib.bzrdir.BzrDir.open(url, possible_transports=transports)
|
||||
is_local = isinstance(origin.transport, bzrlib.transport.local.LocalTransport)
|
||||
|
@ -858,6 +832,10 @@ def get_repo(url, alias):
|
|||
except bzrlib.errors.NoRepositoryPresent:
|
||||
pass
|
||||
|
||||
wanted = get_config('remote.%s.bzr-branches' % alias).rstrip().split(', ')
|
||||
# stupid python
|
||||
wanted = [e for e in wanted if e]
|
||||
if not wanted:
|
||||
wanted = get_config('remote-bzr.branches').rstrip().split(', ')
|
||||
# stupid python
|
||||
wanted = [e for e in wanted if e]
|
||||
|
|
|
@ -23,7 +23,11 @@ import subprocess
|
|||
import urllib
|
||||
import atexit
|
||||
import urlparse, hashlib
|
||||
import time as ptime
|
||||
|
||||
#
|
||||
# If you want to see Mercurial revisions as Git commit notes:
|
||||
# git config core.notesRef refs/notes/hg
|
||||
#
|
||||
# If you are not in hg-git-compat mode and want to disable the tracking of
|
||||
# named branches:
|
||||
|
@ -126,6 +130,7 @@ class Marks:
|
|||
self.rev_marks = {}
|
||||
self.last_mark = 0
|
||||
self.version = 0
|
||||
self.last_note = 0
|
||||
|
||||
def load(self):
|
||||
if not os.path.exists(self.path):
|
||||
|
@ -137,6 +142,7 @@ class Marks:
|
|||
self.marks = tmp['marks']
|
||||
self.last_mark = tmp['last-mark']
|
||||
self.version = tmp.get('version', 1)
|
||||
self.last_note = tmp.get('last-note', 0)
|
||||
|
||||
for rev, mark in self.marks.iteritems():
|
||||
self.rev_marks[mark] = rev
|
||||
|
@ -150,7 +156,7 @@ class Marks:
|
|||
self.version = 2
|
||||
|
||||
def dict(self):
|
||||
return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version }
|
||||
return { 'tips': self.tips, 'marks': self.marks, 'last-mark' : self.last_mark, 'version' : self.version, 'last-note' : self.last_note }
|
||||
|
||||
def store(self):
|
||||
json.dump(self.dict(), open(self.path, 'w'))
|
||||
|
@ -227,8 +233,6 @@ class Parser:
|
|||
return sys.stdin.read(size)
|
||||
|
||||
def get_author(self):
|
||||
global bad_mail
|
||||
|
||||
ex = None
|
||||
m = RAW_AUTHOR_RE.match(self.line)
|
||||
if not m:
|
||||
|
@ -261,8 +265,6 @@ def fix_file_path(path):
|
|||
return os.path.relpath(path, '/')
|
||||
|
||||
def export_files(files):
|
||||
global marks, filenodes
|
||||
|
||||
final = []
|
||||
for f in files:
|
||||
fid = node.hex(f.filenode())
|
||||
|
@ -344,8 +346,6 @@ def fixup_user_hg(user):
|
|||
return (name, mail)
|
||||
|
||||
def fixup_user(user):
|
||||
global mode, bad_mail
|
||||
|
||||
if mode == 'git':
|
||||
name, mail = fixup_user_git(user)
|
||||
else:
|
||||
|
@ -374,7 +374,7 @@ def updatebookmarks(repo, peer):
|
|||
bookmarks.write(repo)
|
||||
|
||||
def get_repo(url, alias):
|
||||
global dirname, peer
|
||||
global peer
|
||||
|
||||
myui = ui.ui()
|
||||
myui.setconfig('ui', 'interactive', 'off')
|
||||
|
@ -429,16 +429,12 @@ def get_repo(url, alias):
|
|||
return repo
|
||||
|
||||
def rev_to_mark(rev):
|
||||
global marks
|
||||
return marks.from_rev(rev.hex())
|
||||
|
||||
def mark_to_rev(mark):
|
||||
global marks
|
||||
return marks.to_rev(mark)
|
||||
|
||||
def export_ref(repo, name, kind, head):
|
||||
global prefix, marks, mode
|
||||
|
||||
ename = '%s/%s' % (kind, name)
|
||||
try:
|
||||
tip = marks.get_tip(ename)
|
||||
|
@ -535,6 +531,31 @@ def export_ref(repo, name, kind, head):
|
|||
print "from :%u" % rev_to_mark(head)
|
||||
print
|
||||
|
||||
pending_revs = set(revs) - notes
|
||||
if pending_revs:
|
||||
note_mark = marks.next_mark()
|
||||
ref = "refs/notes/hg"
|
||||
|
||||
print "commit %s" % ref
|
||||
print "mark :%d" % (note_mark)
|
||||
print "committer remote-hg <> %s" % (ptime.strftime('%s %z'))
|
||||
desc = "Notes for %s\n" % (name)
|
||||
print "data %d" % (len(desc))
|
||||
print desc
|
||||
if marks.last_note:
|
||||
print "from :%u" % marks.last_note
|
||||
|
||||
for rev in pending_revs:
|
||||
notes.add(rev)
|
||||
c = repo[rev]
|
||||
print "N inline :%u" % rev_to_mark(c)
|
||||
msg = c.hex()
|
||||
print "data %d" % (len(msg))
|
||||
print msg
|
||||
print
|
||||
|
||||
marks.last_note = note_mark
|
||||
|
||||
marks.set_tip(ename, head.hex())
|
||||
|
||||
def export_tag(repo, tag):
|
||||
|
@ -550,12 +571,9 @@ def export_branch(repo, branch):
|
|||
export_ref(repo, branch, 'branches', head)
|
||||
|
||||
def export_head(repo):
|
||||
global g_head
|
||||
export_ref(repo, g_head[0], 'bookmarks', g_head[1])
|
||||
|
||||
def do_capabilities(parser):
|
||||
global prefix, dirname
|
||||
|
||||
print "import"
|
||||
print "export"
|
||||
print "refspec refs/heads/branches/*:%s/branches/*" % prefix
|
||||
|
@ -575,8 +593,6 @@ def branch_tip(branch):
|
|||
return branches[branch][-1]
|
||||
|
||||
def get_branch_tip(repo, branch):
|
||||
global branches
|
||||
|
||||
heads = branches.get(hgref(branch), None)
|
||||
if not heads:
|
||||
return None
|
||||
|
@ -589,7 +605,7 @@ def get_branch_tip(repo, branch):
|
|||
return heads[0]
|
||||
|
||||
def list_head(repo, cur):
|
||||
global g_head, bmarks, fake_bmark
|
||||
global g_head, fake_bmark
|
||||
|
||||
if 'default' not in branches:
|
||||
# empty repo
|
||||
|
@ -605,8 +621,6 @@ def list_head(repo, cur):
|
|||
g_head = (head, node)
|
||||
|
||||
def do_list(parser):
|
||||
global branches, bmarks, track_branches
|
||||
|
||||
repo = parser.repo
|
||||
for bmark, node in bookmarks.listbookmarks(repo).iteritems():
|
||||
bmarks[bmark] = repo[node]
|
||||
|
@ -674,8 +688,6 @@ def do_import(parser):
|
|||
print 'done'
|
||||
|
||||
def parse_blob(parser):
|
||||
global blob_marks
|
||||
|
||||
parser.next()
|
||||
mark = parser.get_mark()
|
||||
parser.next()
|
||||
|
@ -692,9 +704,6 @@ def get_merge_files(repo, p1, p2, files):
|
|||
files[e] = f
|
||||
|
||||
def parse_commit(parser):
|
||||
global marks, blob_marks, parsed_refs
|
||||
global mode
|
||||
|
||||
from_mark = merge_mark = None
|
||||
|
||||
ref = parser[1]
|
||||
|
@ -812,8 +821,6 @@ def parse_commit(parser):
|
|||
marks.new_mark(node, commit_mark)
|
||||
|
||||
def parse_reset(parser):
|
||||
global parsed_refs
|
||||
|
||||
ref = parser[1]
|
||||
parser.next()
|
||||
# ugh
|
||||
|
@ -1006,8 +1013,6 @@ def check_tip(ref, kind, name, heads):
|
|||
return tip in heads
|
||||
|
||||
def do_export(parser):
|
||||
global parsed_refs, bmarks, peer
|
||||
|
||||
p_bmarks = []
|
||||
p_revs = {}
|
||||
|
||||
|
@ -1079,7 +1084,7 @@ def do_export(parser):
|
|||
author, msg = parsed_tags.get(tag, (None, None))
|
||||
if mode == 'git':
|
||||
if not msg:
|
||||
msg = 'Added tag %s for changeset %s' % (tag, node[:12]);
|
||||
msg = 'Added tag %s for changeset %s' % (tag, node[:12])
|
||||
tagnode, branch = write_tag(parser.repo, tag, node, msg, author)
|
||||
p_revs[tagnode] = 'refs/heads/branches/' + gitref(branch)
|
||||
else:
|
||||
|
@ -1152,6 +1157,7 @@ def main(args):
|
|||
global filenodes
|
||||
global fake_bmark, hg_version
|
||||
global dry_run
|
||||
global notes, alias
|
||||
|
||||
alias = args[1]
|
||||
url = args[2]
|
||||
|
@ -1191,6 +1197,7 @@ def main(args):
|
|||
except:
|
||||
hg_version = None
|
||||
dry_run = False
|
||||
notes = set()
|
||||
|
||||
repo = get_repo(url, alias)
|
||||
prefix = 'refs/hg/%s' % alias
|
||||
|
|
|
@ -7,12 +7,14 @@ test_description='Test remote-bzr'
|
|||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq PYTHON; then
|
||||
if ! test_have_prereq PYTHON
|
||||
then
|
||||
skip_all='skipping remote-bzr tests; python not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! python -c 'import bzrlib'; then
|
||||
if ! python -c 'import bzrlib'
|
||||
then
|
||||
skip_all='skipping remote-bzr tests; bzr not available'
|
||||
test_done
|
||||
fi
|
||||
|
@ -98,7 +100,7 @@ test_expect_success 'roundtrip' '
|
|||
test_cmp expected actual
|
||||
'
|
||||
|
||||
cat > expected <<EOF
|
||||
cat >expected <<\EOF
|
||||
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
|
||||
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
|
||||
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
|
||||
|
@ -136,7 +138,7 @@ test_expect_success 'special modes' '
|
|||
test_cmp expected actual
|
||||
'
|
||||
|
||||
cat > expected <<EOF
|
||||
cat >expected <<\EOF
|
||||
100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
|
||||
100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
|
||||
120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
|
||||
|
@ -285,7 +287,7 @@ test_expect_success 'pushing a merge' '
|
|||
test_cmp expected actual
|
||||
'
|
||||
|
||||
cat > expected <<EOF
|
||||
cat >expected <<\EOF
|
||||
origin/HEAD
|
||||
origin/branch
|
||||
origin/trunk
|
||||
|
@ -358,4 +360,34 @@ test_expect_success 'strip' '
|
|||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'export utf-8 authors' '
|
||||
test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C && unset GIT_COMMITTER_NAME" &&
|
||||
|
||||
LC_ALL=en_US.UTF-8
|
||||
export LC_ALL
|
||||
|
||||
GIT_COMMITTER_NAME="Grégoire"
|
||||
export GIT_COMMITTER_NAME
|
||||
|
||||
bzr init bzrrepo &&
|
||||
|
||||
(
|
||||
git init gitrepo &&
|
||||
cd gitrepo &&
|
||||
echo greg >>content &&
|
||||
git add content &&
|
||||
git commit -m one &&
|
||||
git remote add bzr "bzr::../bzrrepo" &&
|
||||
git push bzr
|
||||
) &&
|
||||
|
||||
(
|
||||
cd bzrrepo &&
|
||||
bzr log | grep "^committer: " >../actual
|
||||
) &&
|
||||
|
||||
echo "committer: Grégoire <committer@example.com>" >expected &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
|
@ -10,12 +10,14 @@ test_description='Test bidirectionality of remote-hg'
|
|||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq PYTHON; then
|
||||
if ! test_have_prereq PYTHON
|
||||
then
|
||||
skip_all='skipping remote-hg tests; python not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! python -c 'import mercurial'; then
|
||||
if ! python -c 'import mercurial'
|
||||
then
|
||||
skip_all='skipping remote-hg tests; mercurial not available'
|
||||
test_done
|
||||
fi
|
||||
|
|
|
@ -10,17 +10,20 @@ test_description='Test remote-hg output compared to hg-git'
|
|||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq PYTHON; then
|
||||
if ! test_have_prereq PYTHON
|
||||
then
|
||||
skip_all='skipping remote-hg tests; python not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! python -c 'import mercurial'; then
|
||||
if ! python -c 'import mercurial'
|
||||
then
|
||||
skip_all='skipping remote-hg tests; mercurial not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! python -c 'import hggit'; then
|
||||
if ! python -c 'import hggit'
|
||||
then
|
||||
skip_all='skipping remote-hg tests; hg-git not available'
|
||||
test_done
|
||||
fi
|
||||
|
@ -133,17 +136,18 @@ test_expect_success 'executable bit' '
|
|||
git commit -m "clear executable bit"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
hg_clone_$x gitrepo hgrepo-$x &&
|
||||
cd hgrepo-$x &&
|
||||
hg_log . &&
|
||||
hg manifest -r 1 -v &&
|
||||
hg manifest -v
|
||||
) > output-$x &&
|
||||
) >"output-$x" &&
|
||||
|
||||
git_clone_$x hgrepo-$x gitrepo2-$x &&
|
||||
git_log gitrepo2-$x > log-$x
|
||||
git_log gitrepo2-$x >"log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp output-hg output-git &&
|
||||
|
@ -164,16 +168,17 @@ test_expect_success 'symlink' '
|
|||
git commit -m "add beta"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
hg_clone_$x gitrepo hgrepo-$x &&
|
||||
cd hgrepo-$x &&
|
||||
hg_log . &&
|
||||
hg manifest -v
|
||||
) > output-$x &&
|
||||
) >"output-$x" &&
|
||||
|
||||
git_clone_$x hgrepo-$x gitrepo2-$x &&
|
||||
git_log gitrepo2-$x > log-$x
|
||||
git_log gitrepo2-$x >"log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp output-hg output-git &&
|
||||
|
@ -203,11 +208,12 @@ test_expect_success 'merge conflict 1' '
|
|||
hg ci -m "merge to C"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
git_clone_$x hgrepo1 gitrepo-$x &&
|
||||
hg_clone_$x gitrepo-$x hgrepo2-$x &&
|
||||
hg_log hgrepo2-$x > hg-log-$x &&
|
||||
git_log gitrepo-$x > git-log-$x
|
||||
hg_log hgrepo2-$x >"hg-log-$x" &&
|
||||
git_log gitrepo-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -237,11 +243,12 @@ test_expect_success 'merge conflict 2' '
|
|||
hg ci -m "merge to B"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
git_clone_$x hgrepo1 gitrepo-$x &&
|
||||
hg_clone_$x gitrepo-$x hgrepo2-$x &&
|
||||
hg_log hgrepo2-$x > hg-log-$x &&
|
||||
git_log gitrepo-$x > git-log-$x
|
||||
hg_log hgrepo2-$x >"hg-log-$x" &&
|
||||
git_log gitrepo-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -272,11 +279,12 @@ test_expect_success 'converged merge' '
|
|||
hg ci -m "merge"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
git_clone_$x hgrepo1 gitrepo-$x &&
|
||||
hg_clone_$x gitrepo-$x hgrepo2-$x &&
|
||||
hg_log hgrepo2-$x > hg-log-$x &&
|
||||
git_log gitrepo-$x > git-log-$x
|
||||
hg_log hgrepo2-$x >"hg-log-$x" &&
|
||||
git_log gitrepo-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -310,12 +318,13 @@ test_expect_success 'encoding' '
|
|||
git commit -m "add déltà"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
hg_clone_$x gitrepo hgrepo-$x &&
|
||||
git_clone_$x hgrepo-$x gitrepo2-$x &&
|
||||
|
||||
HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
|
||||
git_log gitrepo2-$x > git-log-$x
|
||||
HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
|
||||
git_log gitrepo2-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -344,17 +353,18 @@ test_expect_success 'file removal' '
|
|||
git commit -m "remove foo/bar"
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
hg_clone_$x gitrepo hgrepo-$x &&
|
||||
cd hgrepo-$x &&
|
||||
hg_log . &&
|
||||
hg manifest -r 3 &&
|
||||
hg manifest
|
||||
) > output-$x &&
|
||||
) >"output-$x" &&
|
||||
|
||||
git_clone_$x hgrepo-$x gitrepo2-$x &&
|
||||
git_log gitrepo2-$x > log-$x
|
||||
git_log gitrepo2-$x >"log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp output-hg output-git &&
|
||||
|
@ -379,9 +389,10 @@ test_expect_success 'git tags' '
|
|||
git tag -a -m "added tag beta" beta
|
||||
) &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
hg_clone_$x gitrepo hgrepo-$x &&
|
||||
hg_log hgrepo-$x > log-$x
|
||||
hg_log hgrepo-$x >"log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp log-hg log-git
|
||||
|
@ -390,7 +401,8 @@ test_expect_success 'git tags' '
|
|||
test_expect_success 'hg author' '
|
||||
test_when_finished "rm -rf gitrepo* hgrepo*" &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
git init -q gitrepo-$x &&
|
||||
cd gitrepo-$x &&
|
||||
|
@ -445,8 +457,8 @@ test_expect_success 'hg author' '
|
|||
hg_push_$x hgrepo-$x gitrepo-$x &&
|
||||
hg_clone_$x gitrepo-$x hgrepo2-$x &&
|
||||
|
||||
hg_log hgrepo2-$x > hg-log-$x &&
|
||||
git_log gitrepo-$x > git-log-$x
|
||||
hg_log hgrepo2-$x >"hg-log-$x" &&
|
||||
git_log gitrepo-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -456,7 +468,8 @@ test_expect_success 'hg author' '
|
|||
test_expect_success 'hg branch' '
|
||||
test_when_finished "rm -rf gitrepo* hgrepo*" &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
git init -q gitrepo-$x &&
|
||||
cd gitrepo-$x &&
|
||||
|
@ -481,8 +494,8 @@ test_expect_success 'hg branch' '
|
|||
hg_push_$x hgrepo-$x gitrepo-$x &&
|
||||
hg_clone_$x gitrepo-$x hgrepo2-$x &&
|
||||
|
||||
hg_log hgrepo2-$x > hg-log-$x &&
|
||||
git_log gitrepo-$x > git-log-$x
|
||||
hg_log hgrepo2-$x >"hg-log-$x" &&
|
||||
git_log gitrepo-$x >"git-log-$x"
|
||||
done &&
|
||||
|
||||
test_cmp hg-log-hg hg-log-git &&
|
||||
|
@ -492,7 +505,8 @@ test_expect_success 'hg branch' '
|
|||
test_expect_success 'hg tags' '
|
||||
test_when_finished "rm -rf gitrepo* hgrepo*" &&
|
||||
|
||||
for x in hg git; do
|
||||
for x in hg git
|
||||
do
|
||||
(
|
||||
git init -q gitrepo-$x &&
|
||||
cd gitrepo-$x &&
|
||||
|
@ -518,7 +532,7 @@ test_expect_success 'hg tags' '
|
|||
git --git-dir=gitrepo-$x/.git tag -l &&
|
||||
hg_log hgrepo2-$x &&
|
||||
cat hgrepo2-$x/.hgtags
|
||||
) > output-$x
|
||||
) >"output-$x"
|
||||
done &&
|
||||
|
||||
test_cmp output-hg output-git
|
||||
|
|
|
@ -10,12 +10,14 @@ test_description='Test remote-hg'
|
|||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq PYTHON; then
|
||||
if ! test_have_prereq PYTHON
|
||||
then
|
||||
skip_all='skipping remote-hg tests; python not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
if ! python -c 'import mercurial'; then
|
||||
if ! python -c 'import mercurial'
|
||||
then
|
||||
skip_all='skipping remote-hg tests; mercurial not available'
|
||||
test_done
|
||||
fi
|
||||
|
@ -27,7 +29,8 @@ check () {
|
|||
}
|
||||
|
||||
check_branch () {
|
||||
if [ -n "$3" ]; then
|
||||
if test -n "$3"
|
||||
then
|
||||
echo $3 >expected &&
|
||||
hg -R $1 log -r $2 --template '{desc}\n' >actual &&
|
||||
test_cmp expected actual
|
||||
|
@ -38,7 +41,8 @@ check_branch () {
|
|||
}
|
||||
|
||||
check_bookmark () {
|
||||
if [ -n "$3" ]; then
|
||||
if test -n "$3"
|
||||
then
|
||||
echo $3 >expected &&
|
||||
hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
|
||||
test_cmp expected actual
|
||||
|
@ -75,10 +79,10 @@ check_push () {
|
|||
grep "^ [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
|
||||
;;
|
||||
esac
|
||||
let 'ref_ret' && echo "match for '$branch' failed" && break
|
||||
test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
|
||||
done
|
||||
|
||||
if let 'expected_ret != ret || ref_ret'
|
||||
if test $expected_ret -ne $ret -o $ref_ret -ne 0
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
@ -282,7 +286,7 @@ test_expect_success 'remote push with master bookmark' '
|
|||
check_branch hgrepo default two
|
||||
'
|
||||
|
||||
cat > expected <<EOF
|
||||
cat >expected <<\EOF
|
||||
changeset: 0:6e2126489d3d
|
||||
tag: tip
|
||||
user: A U Thor <author@example.com>
|
||||
|
@ -382,7 +386,7 @@ test_expect_success 'remote push diverged' '
|
|||
cd gitrepo &&
|
||||
echo diverge >content &&
|
||||
git commit -a -m diverged &&
|
||||
check_push 1 <<-EOF
|
||||
check_push 1 <<-\EOF
|
||||
master:non-fast-forward
|
||||
EOF
|
||||
) &&
|
||||
|
@ -412,7 +416,7 @@ test_expect_success 'remote update bookmark diverge' '
|
|||
git checkout --quiet diverge &&
|
||||
echo diverge >content &&
|
||||
git commit -a -m diverge &&
|
||||
check_push 1 <<-EOF
|
||||
check_push 1 <<-\EOF
|
||||
diverge:fetch-first
|
||||
EOF
|
||||
) &&
|
||||
|
@ -509,7 +513,7 @@ test_expect_success 'remote big push' '
|
|||
(
|
||||
cd gitrepo &&
|
||||
|
||||
check_push 1 --all <<-EOF
|
||||
check_push 1 --all <<-\EOF
|
||||
master
|
||||
good_bmark
|
||||
branches/good_branch
|
||||
|
@ -577,18 +581,16 @@ test_expect_success 'remote big push fetch first' '
|
|||
echo five >content &&
|
||||
git commit -q -a -m five &&
|
||||
|
||||
check_push 1 --all <<-EOF
|
||||
check_push 1 --all <<-\EOF &&
|
||||
master
|
||||
good_bmark
|
||||
new_bmark:new
|
||||
new_branch:new
|
||||
bad_bmark:fetch-first
|
||||
branches/bad_branch:festch-first
|
||||
EOF
|
||||
|
||||
git fetch &&
|
||||
|
||||
check_push 1 --all <<-EOF
|
||||
check_push 1 --all <<-\EOF
|
||||
master
|
||||
good_bmark
|
||||
bad_bmark:non-fast-forward
|
||||
|
@ -605,7 +607,7 @@ test_expect_failure 'remote big push force' '
|
|||
(
|
||||
cd gitrepo &&
|
||||
|
||||
check_push 0 --force --all <<-EOF
|
||||
check_push 0 --force --all <<-\EOF
|
||||
master
|
||||
good_bmark
|
||||
branches/good_branch
|
||||
|
@ -635,7 +637,7 @@ test_expect_failure 'remote big push dry-run' '
|
|||
(
|
||||
cd gitrepo &&
|
||||
|
||||
check_push 0 --dry-run --all <<-EOF
|
||||
check_push 1 --dry-run --all <<-\EOF &&
|
||||
master
|
||||
good_bmark
|
||||
branches/good_branch
|
||||
|
@ -646,7 +648,7 @@ test_expect_failure 'remote big push dry-run' '
|
|||
branches/bad_branch:non-fast-forward
|
||||
EOF
|
||||
|
||||
check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
|
||||
check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
|
||||
master
|
||||
good_bmark
|
||||
branches/good_branch
|
||||
|
|
Loading…
Reference in New Issue