Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 4
0
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
Esempio n. 5
0
def get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,max):
  h=heads(ui,repo,max=max)
  stale=dict.fromkeys(heads_cache)
  changed=[]
  unchanged=[]
  for node,rev in h:
    _,_,user,(_,_),_,desc,branch,_=get_changeset(ui,repo,rev)
    del stale[branch]
    git_sha1=get_git_sha1(branch)
    cache_sha1=marks_cache.get(str(int(rev)+1))
    if git_sha1!=None and git_sha1==cache_sha1:
      unchanged.append([branch,cache_sha1,rev,desc.split('\n')[0],user])
    else:
      changed.append([branch,cache_sha1,rev,desc.split('\n')[0],user])
  changed.sort()
  unchanged.sort()
  return stale,changed,unchanged
Esempio n. 6
0
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
Esempio n. 7
0
def get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,max):
  h=heads(ui,repo,max=max)
  stale=dict.fromkeys(heads_cache)
  changed=[]
  unchanged=[]
  for node,rev in h:
    _,_,user,(_,_),_,desc,branch,_=get_changeset(ui,repo,rev)
    del stale[branch]
    git_sha1=get_git_sha1(branch)
    cache_sha1=marks_cache.get(str(int(rev)+1))
    if git_sha1!=None and git_sha1==cache_sha1:
      unchanged.append([branch,cache_sha1,rev,desc.split('\n')[0],user])
    else:
      changed.append([branch,cache_sha1,rev,desc.split('\n')[0],user])
  changed.sort()
  unchanged.sort()
  return stale,changed,unchanged