Ejemplo n.º 1
0
 def do_one(arg):
     data = GitHgHelper.git2hg(arg.encode('ascii'))
     if data:
         assert data.startswith(b'changeset ')
         bytes_stdout.write(data[10:10 + args.abbrev])
     else:
         bytes_stdout.write(NULL_NODE_ID[:args.abbrev])
     bytes_stdout.write(b'\n')
Ejemplo n.º 2
0
def git2hg(args):
    '''convert git sha1 to corresponding mercurial sha1'''

    for arg in args.sha1:
        data = GitHgHelper.git2hg(arg)
        if data:
            assert data.startswith('changeset ')
            print(data[10:10 + args.abbrev])
        else:
            print(NULL_NODE_ID[:args.abbrev])
Ejemplo n.º 3
0
def git2hg(args):
    '''convert git sha1 to corresponding mercurial sha1'''

    for arg in args.sha1:
        data = GitHgHelper.git2hg(arg.encode('ascii'))
        if data:
            assert data.startswith(b'changeset ')
            bytes_stdout.write(data[10:10 + args.abbrev])
        else:
            bytes_stdout.write(NULL_NODE_ID[:args.abbrev])
        bytes_stdout.write(b'\n')
Ejemplo n.º 4
0
def git2hg(args):
    '''convert git sha1 to corresponding mercurial sha1'''

    for sha1, ref in Git.for_each_ref('refs/cinnabar/replace'):
        Git._replace[ref[22:]] = sha1
    for arg in args.sha1:
        data = GitHgHelper.git2hg(arg)
        if data:
            assert data.startswith('changeset ')
            print data[10:50]
        else:
            print NULL_NODE_ID
Ejemplo n.º 5
0
def git2hg(args):
    '''convert git sha1 to corresponding mercurial sha1'''

    for sha1, ref in Git.for_each_ref('refs/cinnabar/replace'):
        Git._replace[ref[22:]] = sha1
    for arg in args.sha1:
        data = GitHgHelper.git2hg(arg)
        if data:
            assert data.startswith('changeset ')
            print data[10:10 + args.abbrev]
        else:
            print NULL_NODE_ID[:args.abbrev]
Ejemplo n.º 6
0
def main(args):
    cmd = args.pop(0)
    if cmd == 'data':
        store = GitHgStore()
        if args[0] == '-c':
            sys.stdout.write(store.changeset(args[1]).data)
        elif args[0] == '-m':
            sys.stdout.write(store.manifest(args[1]).data)
        store.close()
    elif cmd == 'fsck':
        return fsck(args)
    elif cmd == 'reclone':
        for ref in Git.for_each_ref('refs/cinnabar',
                                    'refs/remote-hg',
                                    'refs/notes/cinnabar',
                                    'refs/notes/remote-hg/git2hg',
                                    format='%(refname)'):
            Git.delete_ref(ref)
        Git.close()

        for line in Git.iter('config', '--get-regexp', 'remote\..*\.url'):
            config, url = line.split()
            name = config[len('remote.'):-len('.url')]
            skip_pref = 'remote.%s.skipDefaultUpdate' % name
            if (url.startswith('hg::')
                    and Git.config(skip_pref, 'bool') != 'true'):
                Git.run('remote', 'update', '--prune', name)

        print 'Please note that reclone left your local branches untouched.'
        print 'They may be based on entirely different commits.'
    elif cmd == 'hg2git':
        for arg in args:
            print GitHgHelper.hg2git(arg)
    elif cmd == 'git2hg':
        for arg in args:
            data = GitHgHelper.git2hg(arg)
            if data:
                data = ChangesetData.parse(data)
                print data.get('changeset', NULL_NODE_ID)
            else:
                print NULL_NODE_ID
    else:
        print >> sys.stderr, 'Unknown command:', cmd
        return 1
Ejemplo n.º 7
0
def main(args):
    cmd = args.pop(0)
    if cmd == 'data':
        store = GitHgStore()
        if args[0] == '-c':
            sys.stdout.write(store.changeset(args[1]).data)
        elif args[0] == '-m':
            sys.stdout.write(store.manifest(args[1]).data)
        store.close()
    elif cmd == 'fsck':
        return fsck(args)
    elif cmd == 'reclone':
        for ref in Git.for_each_ref('refs/cinnabar', 'refs/remote-hg',
                                    'refs/notes/cinnabar',
                                    'refs/notes/remote-hg/git2hg',
                                    format='%(refname)'):
            Git.delete_ref(ref)
        Git.close()

        for line in Git.iter('config', '--get-regexp', 'remote\..*\.url'):
            config, url = line.split()
            name = config[len('remote.'):-len('.url')]
            skip_pref = 'remote.%s.skipDefaultUpdate' % name
            if (url.startswith('hg::') and
                    Git.config(skip_pref, 'bool') != 'true'):
                Git.run('remote', 'update', '--prune', name)

        print 'Please note that reclone left your local branches untouched.'
        print 'They may be based on entirely different commits.'
    elif cmd == 'hg2git':
        for arg in args:
            print GitHgHelper.hg2git(arg)
    elif cmd == 'git2hg':
        for arg in args:
            data = GitHgHelper.git2hg(arg)
            if data:
                data = ChangesetData.parse(data)
                print data.get('changeset', NULL_NODE_ID)
            else:
                print NULL_NODE_ID
    else:
        print >>sys.stderr, 'Unknown command:', cmd
        return 1