mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2026-05-07 00:16:59 +02:00
Tips metadata is now obsolete on fetch as well as push
... so discard it altogether when reading marks. All this also removes fetch-first error which is either no error at all or is either really a non-fast-forward error.
This commit is contained in:
@@ -153,7 +153,7 @@ class Marks:
|
||||
|
||||
tmp = json.load(open(self.path))
|
||||
|
||||
self.tips = tmp['tips']
|
||||
self.tips = []
|
||||
self.marks = tmp['marks']
|
||||
self.last_mark = tmp['last-mark']
|
||||
self.version = tmp.get('version', 1)
|
||||
@@ -204,11 +204,6 @@ class Marks:
|
||||
def is_marked(self, rev):
|
||||
return rev in self.marks
|
||||
|
||||
def get_tip(self, branch):
|
||||
return str(self.tips[branch])
|
||||
|
||||
def set_tip(self, branch, tip):
|
||||
self.tips[branch] = tip
|
||||
|
||||
class ParserContext:
|
||||
|
||||
@@ -525,16 +520,8 @@ def revwalk(repo, name, b):
|
||||
|
||||
def export_ref(repo, name, kind, head):
|
||||
ename = '%s/%s' % (kind, name)
|
||||
try:
|
||||
tip = marks.get_tip(ename)
|
||||
tip = repo[tip]
|
||||
except:
|
||||
tip = repo[-1]
|
||||
|
||||
revs = revwalk(repo, ename, head)
|
||||
|
||||
total = len(revs)
|
||||
tip = tip.rev()
|
||||
|
||||
for progress, rev in enumerate(revs):
|
||||
|
||||
@@ -653,8 +640,6 @@ def export_ref(repo, name, kind, head):
|
||||
|
||||
marks.last_note = note_mark
|
||||
|
||||
marks.set_tip(ename, head.hex())
|
||||
|
||||
def export_tag(repo, tag):
|
||||
export_ref(repo, tag, 'tags', repo[hgref(tag)])
|
||||
|
||||
@@ -1255,15 +1240,6 @@ def push(repo, remote, p_revs, force):
|
||||
|
||||
return ret
|
||||
|
||||
def check_tip(ref, kind, name, heads):
|
||||
try:
|
||||
ename = '%s/%s' % (kind, name)
|
||||
tip = marks.get_tip(ename)
|
||||
except KeyError:
|
||||
return True
|
||||
else:
|
||||
return tip in heads
|
||||
|
||||
def do_export(parser):
|
||||
do_push_hg(parser)
|
||||
print
|
||||
@@ -1308,8 +1284,6 @@ def do_push_hg(parser):
|
||||
else:
|
||||
die('unhandled export command: %s' % line)
|
||||
|
||||
need_fetch = False
|
||||
|
||||
for ref, node in parsed_refs.iteritems():
|
||||
bnode = hgbin(node) if node else None
|
||||
if ref.startswith('refs/heads/branches'):
|
||||
@@ -1319,15 +1293,6 @@ def do_push_hg(parser):
|
||||
print "ok %s up to date" % ref
|
||||
continue
|
||||
|
||||
if peer:
|
||||
remotemap = peer.branchmap()
|
||||
if remotemap and branch in remotemap:
|
||||
heads = [hghex(e) for e in remotemap[branch]]
|
||||
if not check_tip(ref, 'branches', branch, heads):
|
||||
print "error %s fetch first" % ref
|
||||
need_fetch = True
|
||||
continue
|
||||
|
||||
p_revs[bnode] = ref
|
||||
print "ok %s" % ref
|
||||
elif ref.startswith('refs/heads/'):
|
||||
@@ -1344,14 +1309,6 @@ def do_push_hg(parser):
|
||||
not (bmark == 'master' and bmark not in parser.repo._bookmarks):
|
||||
p_bmarks.append((ref, bmark, old, new))
|
||||
|
||||
if peer:
|
||||
remote_old = peer.listkeys('bookmarks').get(bmark)
|
||||
if remote_old:
|
||||
if not check_tip(ref, 'bookmarks', bmark, remote_old):
|
||||
print "error %s fetch first" % ref
|
||||
need_fetch = True
|
||||
continue
|
||||
|
||||
p_revs[bnode] = ref
|
||||
elif ref.startswith('refs/tags/'):
|
||||
if dry_run:
|
||||
@@ -1375,9 +1332,6 @@ def do_push_hg(parser):
|
||||
# transport-helper/fast-export bugs
|
||||
continue
|
||||
|
||||
if need_fetch:
|
||||
return
|
||||
|
||||
if dry_run:
|
||||
if peer and not force_push:
|
||||
checkheads(parser.repo, peer, p_revs, force_push)
|
||||
|
||||
11
test/main.t
11
test/main.t
@@ -89,9 +89,6 @@ check_push () {
|
||||
'non-fast-forward')
|
||||
grep "^ ! \[rejected\] *${branch} -> ${branch} (non-fast-forward)$" error || ref_ret=1
|
||||
;;
|
||||
'fetch-first')
|
||||
grep "^ ! \[rejected\] *${branch} -> ${branch} (fetch first)$" error || ref_ret=1
|
||||
;;
|
||||
'forced-update')
|
||||
grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *${branch} -> ${branch} (forced update)$" error || ref_ret=1
|
||||
;;
|
||||
@@ -450,7 +447,7 @@ test_expect_success 'remote update bookmark diverge' '
|
||||
echo diverge > content &&
|
||||
git commit -a -m diverge &&
|
||||
check_push 1 <<-\EOF
|
||||
diverge:fetch-first
|
||||
diverge:non-fast-forward
|
||||
EOF
|
||||
) &&
|
||||
|
||||
@@ -691,7 +688,7 @@ test_expect_success 'remote big push' '
|
||||
fi
|
||||
'
|
||||
|
||||
test_expect_success 'remote big push fetch first' '
|
||||
test_expect_success 'remote big push non fast forward' '
|
||||
test_when_finished "rm -rf hgrepo gitrepo*" &&
|
||||
|
||||
(
|
||||
@@ -740,8 +737,8 @@ test_expect_success 'remote big push fetch first' '
|
||||
check_push 1 --all <<-\EOF &&
|
||||
master
|
||||
good_bmark
|
||||
bad_bmark:fetch-first
|
||||
branches/bad_branch:festch-first
|
||||
bad_bmark:non-fast-forward
|
||||
branches/bad_branch:non-fast-forward
|
||||
EOF
|
||||
|
||||
git fetch &&
|
||||
|
||||
Reference in New Issue
Block a user