Esempio n. 1
0
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,
           authors={},branchesmap={},tagsmap={},
           sob=False,force=False,hgtags=False,notes=False,encoding='',fn_encoding=''):
  def check_cache(filename, contents):
    if len(contents) == 0:
      sys.stderr.write('Warning: %s does not contain any data, this will probably make an incremental import fail\n' % filename)

  _max=int(m)

  old_marks=load_cache(marksfile,lambda s: int(s)-1)
  mapping_cache=load_cache(mappingfile)
  heads_cache=load_cache(headsfile)
  state_cache=load_cache(tipfile)

  if len(state_cache) != 0:
    for (name, data) in [(marksfile, old_marks),
                         (mappingfile, mapping_cache),
                         (headsfile, state_cache)]:
      check_cache(name, data)

  ui,repo=setup_repo(repourl)

  if not verify_heads(ui,repo,heads_cache,force,branchesmap):
    return 1

  try:
    tip=repo.changelog.count()
  except AttributeError:
    tip=len(repo)

  min=int(state_cache.get('tip',0))
  max=_max
  if _max<0 or max>tip:
    max=tip

  for rev in range(0,max):
  	(revnode,_,_,_,_,_,_,_)=get_changeset(ui,repo,rev,authors)
  	mapping_cache[revnode.encode('hex_codec')] = str(rev)


  c=0
  brmap={}
  for rev in range(min,max):
    c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
                    sob,brmap,hgtags,encoding,fn_encoding)
  if notes:
    for rev in range(min,max):
      c=export_note(ui,repo,rev,c,authors, encoding, rev == min and min != 0)

  state_cache['tip']=max
  state_cache['repo']=repourl
  save_cache(tipfile,state_cache)
  save_cache(mappingfile,mapping_cache)

  c=export_tags(ui,repo,old_marks,mapping_cache,c,authors,tagsmap)

  sys.stderr.write('Issued %d commands\n' % c)

  return 0
Esempio n. 2
0
def hg2git(repourl,
           m,
           marksfile,
           mappingfile,
           headsfile,
           tipfile,
           authors={},
           branchesmap={},
           tagsmap={},
           sob=False,
           force=False,
           hgtags=False,
           notes=False,
           encoding='',
           fn_encoding=''):
    _max = int(m)

    old_marks = load_cache(marksfile, lambda s: int(s) - 1)
    mapping_cache = load_cache(mappingfile)
    heads_cache = load_cache(headsfile)
    state_cache = load_cache(tipfile)

    ui, repo = setup_repo(repourl)

    if not verify_heads(ui, repo, heads_cache, force):
        return 1

    try:
        tip = repo.changelog.count()
    except AttributeError:
        tip = len(repo)

    min = int(state_cache.get('tip', 0))
    max = _max
    if _max < 0 or max > tip:
        max = tip

    for rev in range(0, max):
        (revnode, _, _, _, _, _, _, _) = get_changeset(ui, repo, rev, authors)
        mapping_cache[revnode.encode('hex_codec')] = str(rev)

    c = 0
    brmap = {}
    for rev in range(min, max):
        c = export_commit(ui, repo, rev, old_marks, max, c, authors,
                          branchesmap, sob, brmap, hgtags, notes, encoding,
                          fn_encoding)

    state_cache['tip'] = max
    state_cache['repo'] = repourl
    save_cache(tipfile, state_cache)
    save_cache(mappingfile, mapping_cache)

    c = export_tags(ui, repo, old_marks, mapping_cache, c, authors, tagsmap)

    sys.stderr.write('Issued %d commands\n' % c)

    return 0
Esempio n. 3
0
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,authors={},sob=False,force=False,hgtags=False,notes=False,ignoreSub=False,fixBranch=False,encoding=''):
  _max=int(m)

  old_marks=load_cache(marksfile,lambda s: int(s)-1)
  mapping_cache=load_cache(mappingfile)
  heads_cache=load_cache(headsfile)
  state_cache=load_cache(tipfile)

  ui,repo=setup_repo(repourl)

  if not verify_heads(ui,repo,heads_cache,force):
    return 1

  try:
    tip=repo.changelog.count()
  except AttributeError:
    tip=len(repo)

  min=int(state_cache.get('tip',0))
  max=_max
  if _max<0 or max>tip:
    max=tip

  subRepoWarnings = {}
  for rev in range(0,max):
    if not ignoreSub:
      # check if repository uses unconverted subrepos
      ctx=repo.changectx(str(rev))
      if (ctx.substate):
        subRepoWarnings=verify_subrepo(repourl, ctx, subRepoWarnings)
    (revnode,_,_,_,_,_,_,_)=get_changeset(ui,repo,rev,authors)
    mapping_cache[revnode.encode('hex_codec')] = str(rev)

  if subRepoWarnings:
    sys.stderr.write("\n")
    for key in subRepoWarnings.keys():
      sys.stderr.write(subRepoWarnings[key])
    sys.stderr.write("\n")
    return 1
  c=0
  brmap={}
  for rev in range(min,max):
    c=export_commit(ui,repo,rev,old_marks,max,c,authors,sob,brmap,hgtags,notes,repourl,ignoreSub,fixBranch,encoding)

  state_cache['tip']=max
  state_cache['repo']=repourl
  save_cache(tipfile,state_cache)
  save_cache(mappingfile,mapping_cache)

  c=export_tags(ui,repo,old_marks,mapping_cache,c,authors)

  sys.stderr.write('Issued %d commands\n' % c)

  return 0
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,
           authors={},branchesmap={},tagsmap={},
           sob=False,force=False,hgtags=False,notes=False,encoding='',fn_encoding=''):
  _max=int(m)

  old_marks=load_cache(marksfile,lambda s: int(s)-1)
  mapping_cache=load_cache(mappingfile)
  heads_cache=load_cache(headsfile)
  state_cache=load_cache(tipfile)

  ui,repo=setup_repo(repourl)

  if not verify_heads(ui,repo,heads_cache,force):
    return 1

  try:
    tip=repo.changelog.count()
  except AttributeError:
    tip=len(repo)

  min=int(state_cache.get('tip',0))
  max=_max
  if _max<0 or max>tip:
    max=tip

  for rev in range(0,max):
  	(revnode,_,_,_,_,_,_,_)=get_changeset(ui,repo,rev,authors)
  	mapping_cache[revnode.encode('hex_codec')] = str(rev)


  c=0
  brmap={}
  for rev in range(min,max):
    c=export_commit(ui,repo,rev,old_marks,max,c,authors,branchesmap,
                    sob,brmap,hgtags,encoding,fn_encoding)
  if notes:
    for rev in range(min,max):
      c=export_note(ui,repo,rev,c,authors, encoding, rev == min and min != 0)

  state_cache['tip']=max
  state_cache['repo']=repourl
  save_cache(tipfile,state_cache)
  save_cache(mappingfile,mapping_cache)

  c=export_tags(ui,repo,old_marks,mapping_cache,c,authors,tagsmap)

  sys.stderr.write('Issued %d commands\n' % c)

  return 0
Esempio n. 5
0
def hg2git(repourl,m,marksfile,mappingfile,headsfile,tipfile,authors={},sob=False,force=False):
  _max=int(m)

  marks_cache=load_cache(marksfile,mangle_mark)
  mapping_cache=load_cache(mappingfile)
  heads_cache=load_cache(headsfile)
  state_cache=load_cache(tipfile)

  ui,repo=setup_repo(repourl)

  if not verify_heads(ui,repo,heads_cache,force):
    return 1

  try:
    tip=repo.changelog.count()
  except AttributeError:
    tip=len(repo)

  min=int(state_cache.get('tip',0))
  max=_max
  if _max<0 or max>tip:
    max=tip

  for rev in range(0,max):
  	(revnode,_,_,_,_,_,_,_)=get_changeset(ui,repo,rev,authors)
  	mapping_cache[revnode.encode('hex_codec')] = str(rev)


  c=0
  last={}
  brmap={}
  for rev in range(min,max):
    c=export_commit(ui,repo,rev,marks_cache,mapping_cache,heads_cache,last,max,c,authors,sob,brmap)

  state_cache['tip']=max
  state_cache['repo']=repourl
  save_cache(tipfile,state_cache)
  save_cache(mappingfile,mapping_cache)

  c=export_tags(ui,repo,marks_cache,mapping_cache,c,authors)

  sys.stderr.write('Issued %d commands\n' % c)

  return 0
Esempio n. 6
0
def hg2git(repourl,
           m,
           marksfile,
           mappingfile,
           headsfile,
           tipfile,
           authors={},
           branchesmap={},
           tagsmap={},
           sob=False,
           force=False,
           ignore_unnamed_heads=False,
           hgtags=False,
           notes=False,
           encoding='',
           fn_encoding='',
           plugins={}):
    def check_cache(filename, contents):
        if len(contents) == 0:
            sys.stderr.write(
                'Warning: %s does not contain any data, this will probably make an incremental import fail\n'
                % filename)

    _max = int(m)

    old_marks = load_cache(marksfile, lambda s: int(s) - 1)
    mapping_cache = load_cache(mappingfile)
    heads_cache = load_cache(headsfile)
    state_cache = load_cache(tipfile)

    if len(state_cache) != 0:
        for (name, data) in [(marksfile, old_marks),
                             (mappingfile, mapping_cache),
                             (headsfile, state_cache)]:
            check_cache(name, data)

    ui, repo = setup_repo(repourl)

    if not verify_heads(ui, repo, heads_cache, force, ignore_unnamed_heads,
                        branchesmap):
        return 1

    try:
        tip = repo.changelog.count()
    except AttributeError:
        tip = len(repo)

    min = int(state_cache.get('tip', 0))
    max = _max
    if _max < 0 or max > tip:
        max = tip

    for rev in range(0, max):
        (revnode, _, _, _, _, _, _, _) = get_changeset(ui, repo, rev, authors)
        if repo[revnode].hidden():
            continue
        mapping_cache[hexlify(revnode)] = b"%d" % rev

    if submodule_mappings:
        # Make sure that all mercurial submodules are registered in the submodule-mappings file
        for rev in range(0, max):
            ctx = revsymbol(repo, b"%d" % rev)
            if ctx.hidden():
                continue
            if ctx.substate:
                for key in ctx.substate:
                    if ctx.substate[key][
                            2] == 'hg' and key not in submodule_mappings:
                        sys.stderr.write(
                            "Error: %s not found in submodule-mappings\n" %
                            (key))
                        return 1

    c = 0
    brmap = {}
    for rev in range(min, max):
        c = export_commit(ui, repo, rev, old_marks, max, c, authors,
                          branchesmap, sob, brmap, hgtags, encoding,
                          fn_encoding, plugins)
    if notes:
        for rev in range(min, max):
            c = export_note(ui, repo, rev, c, authors, encoding, rev == min
                            and min != 0)

    state_cache['tip'] = max
    state_cache['repo'] = repourl
    save_cache(tipfile, state_cache)
    save_cache(mappingfile, mapping_cache)

    c = export_tags(ui, repo, old_marks, mapping_cache, c, authors, tagsmap)

    sys.stderr.write('Issued %d commands\n' % c)

    return 0
Esempio n. 7
0
    if options.statusfile == None: bail(parser, '--status option')
    if options.repourl == None: bail(parser, '--repo option')
    if options.revision == None: bail(parser, '-R/--revision')

    heads_cache = load_cache(options.headsfile)
    marks_cache = load_cache(options.marksfile, mangle_mark)
    state_cache = load_cache(options.statusfile)
    mapping_cache = load_cache(options.mappingfile)

    l = int(state_cache.get('tip', options.revision))
    if options.revision + 1 > l:
        sys.stderr.write('Revision is beyond last revision imported: %d>%d\n' %
                         (options.revision, l))
        sys.exit(1)

    ui, repo = setup_repo(options.repourl)

    stale, changed, unchanged = get_branches(ui, repo, heads_cache,
                                             marks_cache, mapping_cache,
                                             options.revision + 1)
    good, bad = get_tags(ui, repo, marks_cache, mapping_cache,
                         options.revision + 1)

    print "Possibly stale branches:"
    map(lambda b: sys.stdout.write('\t%s\n' % b), stale.keys())

    print "Possibly stale tags:"
    map(lambda b: sys.stdout.write('\t%s on %s (r%s)\n' % (b[0], b[1], b[3])),
        bad)

    print "Unchanged branches:"
Esempio n. 8
0
def hg2git(repourl,
           m,
           marksfile,
           mappingfile,
           headsfile,
           tipfile,
           authors={},
           sob=False,
           force=False,
           hgtags=False,
           notes=False,
           ignoreSub=False,
           fixBranch=False,
           encoding=''):
    _max = int(m)

    old_marks = load_cache(marksfile, lambda s: int(s) - 1)
    mapping_cache = load_cache(mappingfile)
    heads_cache = load_cache(headsfile)
    state_cache = load_cache(tipfile)

    ui, repo = setup_repo(repourl)

    if not verify_heads(ui, repo, heads_cache, force):
        return 1

    try:
        tip = repo.changelog.count()
    except AttributeError:
        tip = len(repo)

    min = int(state_cache.get('tip', 0))
    max = _max
    if _max < 0 or max > tip:
        max = tip

    subRepoWarnings = {}
    for rev in range(0, max):
        if not ignoreSub:
            # check if repository uses unconverted subrepos
            ctx = repo.changectx(str(rev))
            if (ctx.substate):
                subRepoWarnings = verify_subrepo(repourl, ctx, subRepoWarnings)
        (revnode, _, _, _, _, _, _, _) = get_changeset(ui, repo, rev, authors)
        mapping_cache[revnode.encode('hex_codec')] = str(rev)

    if subRepoWarnings:
        sys.stderr.write("\n")
        for key in subRepoWarnings.keys():
            sys.stderr.write(subRepoWarnings[key])
        sys.stderr.write("\n")
        return 1
    c = 0
    brmap = {}
    for rev in range(min, max):
        c = export_commit(ui, repo, rev, old_marks, max, c, authors, sob,
                          brmap, hgtags, notes, repourl, ignoreSub, fixBranch,
                          encoding)

    state_cache['tip'] = max
    state_cache['repo'] = repourl
    save_cache(tipfile, state_cache)
    save_cache(mappingfile, mapping_cache)

    c = export_tags(ui, repo, old_marks, mapping_cache, c, authors)

    sys.stderr.write('Issued %d commands\n' % c)

    return 0
Esempio n. 9
0
def hg2git(
    repourl,
    m,
    marksfile,
    mappingfile,
    headsfile,
    tipfile,
    authors={},
    branchesmap={},
    tagsmap={},
    sob=False,
    force=False,
    hgtags=False,
    notes=False,
    encoding="",
    fn_encoding="",
):
    def check_cache(filename, contents):
        if len(contents) == 0:
            sys.stderr.write(
                "Warning: %s does not contain any data, this will probably make an incremental import fail\n" % filename
            )

    _max = int(m)

    old_marks = load_cache(marksfile, lambda s: int(s) - 1)
    mapping_cache = load_cache(mappingfile)
    heads_cache = load_cache(headsfile)
    state_cache = load_cache(tipfile)

    if len(state_cache) != 0:
        for (name, data) in [(marksfile, old_marks), (mappingfile, mapping_cache), (headsfile, state_cache)]:
            check_cache(name, data)

    ui, repo = setup_repo(repourl)

    if not verify_heads(ui, repo, heads_cache, force, branchesmap):
        return 1

    try:
        tip = repo.changelog.count()
    except AttributeError:
        tip = len(repo)

    min = int(state_cache.get("tip", 0))
    max = _max
    if _max < 0 or max > tip:
        max = tip

    for rev in range(0, max):
        (revnode, _, _, _, _, _, _, _) = get_changeset(ui, repo, rev, authors)
        mapping_cache[revnode.encode("hex_codec")] = str(rev)

    c = 0
    brmap = {}
    for rev in range(min, max):
        c = export_commit(
            ui, repo, rev, old_marks, max, c, authors, branchesmap, sob, brmap, hgtags, encoding, fn_encoding
        )
    if notes:
        for rev in range(min, max):
            c = export_note(ui, repo, rev, c, authors, encoding, rev == min and min != 0)

    state_cache["tip"] = max
    state_cache["repo"] = repourl
    save_cache(tipfile, state_cache)
    save_cache(mappingfile, mapping_cache)

    c = export_tags(ui, repo, old_marks, mapping_cache, c, authors, tagsmap)

    sys.stderr.write("Issued %d commands\n" % c)

    return 0
Esempio n. 10
0
  if options.marksfile==None: bail(parser,'--marks option')
  if options.headsfile==None: bail(parser,'--heads option')
  if options.statusfile==None: bail(parser,'--status option')
  if options.repourl==None: bail(parser,'--repo option')
  if options.revision==None: bail(parser,'-R/--revision')

  heads_cache=load_cache(options.headsfile)
  marks_cache=load_cache(options.marksfile,mangle_mark)
  state_cache=load_cache(options.statusfile)

  l=int(state_cache.get('tip',options.revision))
  if options.revision+1>l:
    sys.stderr.write('Revision is beyond last revision imported: %d>%d\n' % (options.revision,l))
    sys.exit(1)

  ui,repo=setup_repo(options.repourl)

  stale,changed,unchanged=get_branches(ui,repo,heads_cache,marks_cache,mapping_cache,options.revision+1)
  good,bad=get_tags(ui,repo,marks_cache,mapping_cache,options.revision+1)

  print "Possibly stale branches:"
  map(lambda b: sys.stdout.write('\t%s\n' % b),stale.keys())

  print "Possibly stale tags:"
  map(lambda b: sys.stdout.write('\t%s on %s (r%s)\n' % (b[0],b[1],b[3])),bad)

  print "Unchanged branches:"
  map(lambda b: sys.stdout.write('\t%s (r%s)\n' % (b[0],b[2])),unchanged)

  print "Unchanged tags:"
  map(lambda b: sys.stdout.write('\t%s on %s (r%s)\n' % (b[0],b[1],b[3])),good)
Esempio n. 11
0
      sys.stderr.write('Warning: %s does not contain any data, this will probably make an incremental import fail\n' % filename)

  _max=int(m)

  old_marks=load_cache(marksfile,lambda s: int(s)-1)
  mapping_cache=load_cache(mappingfile)
  heads_cache=load_cache(headsfile)
  state_cache=load_cache(tipfile)

  if len(state_cache) != 0:
    for (name, data) in [(marksfile, old_marks),
                         (mappingfile, mapping_cache),
                         (headsfile, state_cache)]:
      check_cache(name, data)

  ui,repo=setup_repo(repourl)

  if not verify_heads(ui,repo,heads_cache,force,branchesmap):
    return 1

  try:
    tip=repo.changelog.count()
  except AttributeError:
    tip=len(repo)

  min=int(state_cache.get('tip',0))
  max=_max
  if _max<0 or max>tip:
    max=tip

  for rev in range(0,max):