def verify_heads(ui,repo,cache,force): branches=repo.branchtags() l=[(-repo.changelog.rev(n), n, t) for t, n in branches.items()] l.sort() # get list of hg's branches to verify, don't take all git has for _,_,b in l: b=get_branch(b) sha1=get_git_sha1(b) c=cache.get(b) if sha1!=c: sys.stderr.write('Error: Branch [%s] modified outside hg-fast-export:' '\n%s (repo) != %s (cache)\n' % (b,sha1,c)) if not force: return False # verify that branch has exactly one head t={} for h in repo.heads(): (_,_,_,_,_,_,branch,_)=get_changeset(ui,repo,h) if t.get(branch,False): sys.stderr.write('Error: repository has at least one unnamed head: hg r%s\n' % repo.changelog.rev(h)) if not force: return False t[branch]=True return True
def verify_heads(ui, repo, cache, force, ignore_unnamed_heads, branchesmap): branches = {} for bn, heads in repo.branchmap().iteritems(): branches[bn] = branchtip(repo, heads) l = [(-repo.changelog.rev(n), n, t) for t, n in branches.items()] l.sort() # get list of hg's branches to verify, don't take all git has for _, _, b in l: b = get_branch(b) sanitized_name = sanitize_name(b, "branch", branchesmap) sha1 = get_git_sha1(sanitized_name) c = cache.get(sanitized_name) if sha1 != c: stderr_buffer.write( b'Error: Branch [%s] modified outside hg-fast-export:' b'\n%s (repo) != %s (cache)\n' % (b, b'<None>' if sha1 is None else sha1, c)) if not force: return False # verify that branch has exactly one head t = {} unnamed_heads = False for h in repo.filtered(b'visible').heads(): (_, _, _, _, _, _, branch, _) = get_changeset(ui, repo, h) if t.get(branch, False): stderr_buffer.write( b'Error: repository has an unnamed head: hg r%d\n' % repo.changelog.rev(h)) unnamed_heads = True if not force and not ignore_unnamed_heads: return False t[branch] = True if unnamed_heads and not force and not ignore_unnamed_heads: return False return True
def verify_heads(ui,repo,cache,force,branchesmap, closed_branch_tips={}): branches={} for bn, heads in repo.branchmap().iteritems(): branches[bn] = branchtip(repo, heads) l=[(-repo.changelog.rev(n), n, t) for t, n in branches.items()] l.sort() # get list of hg's branches to verify, don't take all git has for _,_,b in l: b=get_branch(b) sanitized_name=sanitize_name(b,"branch",branchesmap) sha1=get_git_sha1(sanitized_name) c=cache.get(sanitized_name) if sha1!=c: sys.stderr.write('Error: Branch [%s] modified outside hg-fast-export:' '\n%s (repo) != %s (cache)\n' % (b,sha1,c)) if not force: return False # verify that branch has exactly one head t={} for h in repo.heads(): (node,_,_,_,_,desc,branch,_)=get_changeset(ui,repo,h) if t.get(branch,False): sys.stderr.write('Error: repository has at least one unnamed head: hg r%s\n' % repo.changelog.rev(h)) # if not force: return False sys.stderr.write(branch + '; ' + desc + '\n\n') closed_branch_tips[node] = branch + '_closed' t[branch]=True return True
def verify_heads(ui, repo, cache, force, branchesmap): branches = {} for bn, heads in repo.branchmap().iteritems(): branches[bn] = branchtip(repo, heads) l = [(-repo.changelog.rev(n), n, t) for t, n in branches.items()] l.sort() # get list of hg's branches to verify, don't take all git has for _, _, b in l: b = get_branch(b) sanitized_name = sanitize_name(b, "branch", branchesmap) sha1 = get_git_sha1(sanitized_name) c = cache.get(sanitized_name) if sha1 != c: sys.stderr.write( "Error: Branch [%s] modified outside hg-fast-export:" "\n%s (repo) != %s (cache)\n" % (b, sha1, c) ) if not force: return False # verify that branch has exactly one head t = {} for h in repo.heads(): (_, _, _, _, _, _, branch, _) = get_changeset(ui, repo, h) if t.get(branch, False): sys.stderr.write("Error: repository has at least one unnamed head: hg r%s\n" % repo.changelog.rev(h)) if not force: return False t[branch] = True return True
def get_changeset(ui, repo, revision, authors={}): node = repo.lookup(revision) (manifest, user, (time, timezone), files, desc, extra) = repo.changelog.read(node) tz = "%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60)) branch = get_branch(extra.get('branch', 'master')) return (node, manifest, fixup_user(user, authors), (time, tz), files, desc, branch, extra)
def verify_heads(ui,repo,cache,force,branchesmap): branches={} for bn, heads in repo.branchmap().items(): branches[bn] = branchtip(repo, heads) l=[(-repo.changelog.rev(n), n, t) for t, n in branches.items())] l.sort() # get list of hg's branches to verify, don't take all git has for _,_,b in l: b=get_branch(b) sanitized_name=sanitize_name(b,"branch",branchesmap) sha1=get_git_sha1(sanitized_name) c=cache.get(sanitized_name) if sha1!=c: sys.stderr.write('Error: Branch [%s] modified outside hg-fast-export:' '\n%s (repo) != %s (cache)\n' % (b,sha1,c)) if not force: return False
def get_changeset(ui,repo,revision,authors={}): node=repo.lookup(revision) (manifest,user,(time,timezone),files,desc,extra)=repo.changelog.read(node) tz="%+03d%02d" % (-timezone / 3600, ((-timezone % 3600) / 60)) branch=get_branch(extra.get('branch','master')) return (node,manifest,fixup_user(user,authors),(time,tz),files,desc,branch,extra)