当前位置: 首页>>代码示例>>Python>>正文


Python commands.clone函数代码示例

本文整理汇总了Python中mercurial.commands.clone函数的典型用法代码示例。如果您正苦于以下问题:Python clone函数的具体用法?Python clone怎么用?Python clone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_repo

 def _get_repo(self, create, src_url=None, update_after_clone=False):
     """
     Function will check for mercurial repository in given path and return
     a localrepo object. If there is no repository in that path it will
     raise an exception unless ``create`` parameter is set to True - in
     that case repository would be created and returned.
     If ``src_url`` is given, would try to clone repository from the
     location at given clone_point. Additionally it'll make update to
     working copy accordingly to ``update_after_clone`` flag
     """
     try:
         if src_url:
             url = str(self._get_url(src_url))
             opts = {}
             if not update_after_clone:
                 opts.update({"noupdate": True})
             try:
                 clone(self.baseui, url, self.path, **opts)
             except urllib2.URLError:
                 raise Abort("Got HTTP 404 error")
             # Don't try to create if we've already cloned repo
             create = False
         return localrepository(self.baseui, self.path, create=create)
     except (Abort, RepoError), err:
         if create:
             msg = "Cannot create repository at %s. Original error was %s" % (self.path, err)
         else:
             msg = "Not valid repository at %s. Original error was %s" % (self.path, err)
         raise RepositoryError(msg)
开发者ID:lukaszb,项目名称:vcs,代码行数:29,代码来源:hg.py

示例2: main

def main(argv):
    # Find destination directory based on current file location
    destdir = os.path.abspath(os.path.join(
            os.path.dirname(__file__), '..', '..'))

    # Read the configuration file for the shared repository to get the pull path
    repo = hg.repository(
        ui.ui(), os.path.join(os.path.dirname(__file__), '..'))
    sharedpath = repo.ui.config('paths', 'default', None)
    if sharedpath is None:
        raise Exception('no default path in the shared directory!')

    unstable = sharedpath.endswith('-unstable')
    path = os.path.dirname(sharedpath)
    print 'using %s as remote repository path' % path

    for module in reduce(lambda x, y: x + y.split(','), argv, []):
        if module.endswith('-unstable'):
            module = module[:-len('-unstable')]

        if not os.path.exists(os.path.join(destdir, module)):
            # Attempt to clone the repository to the destination
            if module == "GUIRipper-Plugin-JFC" or module == "GUIRipper-Core" or module == "GUITARModel-Plugin-JFC" or module == "GUITARModel-Core" or module == "GUIReplayer-Plugin-JFC" or module == "GUIReplayer-Core":
				call("git clone git://github.com/cmsc435sikuli/" + module + ".git " + destdir + "/" +  module, shell=True)
            else:
                url = '%s/%s%s' % (path, module, '-unstable' if unstable else '')
                print 'checking out %s to %s' % (url, destdir)
                commands.clone(ui.ui(), url, os.path.join(destdir, module))
        else:
            # Repository already exists, skip
            print '%s already exists (skipping)' % module
开发者ID:cmsc435sikuli,项目名称:shared,代码行数:31,代码来源:checkout.py

示例3: get_yaml_from_mercurial

def get_yaml_from_mercurial(vcs_address, vcs_subdir):
    from mercurial import ui, commands
    from urllib2 import HTTPError
    import hglib

    vtemp = mkdtemp(prefix='multipkg-vcs-')
    try:
        commands.clone(ui.ui(), str(vcs_address), dest=vtemp)
        client = hglib.open(vtemp)
        # get index.yaml
        path_to_yaml = path_join(vtemp, vcs_subdir, 'index.yaml')
        yaml = yaml_load(file(path_to_yaml).read())
        recent_changes = []
        for entry in client.log('tip:tip^^'):
            num, rev, none, branch, author, msg, date = entry
            date = date.strftime('%Y-%m-%d %H:%M:%S')
            recent_changes.append("commit %s | Author: %s | Date:  %s \n%s\n" %
                                  (rev, author, date, msg))
        yaml['.'] = dict(recent_changes="\n".join(recent_changes))
        return yaml
    except HTTPError:
        raise RemotePackageNotFoundError(vcs_address)
    except IOError as e:
        if e.errno == errno.ENOENT and e.filename.find('.yaml') > -1:
            raise IndexNotFoundError('index.yaml not found in your repository')
        raise
    except:
        raise
    finally:
        if isdir(vtemp):
            rmtree(vtemp)
开发者ID:jianingy,项目名称:multipkgadmin,代码行数:31,代码来源:utils.py

示例4: test_branchmap_rebuildmeta

    def test_branchmap_rebuildmeta(self):
        '''test rebuildmeta on a branchmapped clone'''
        repo_path = self.load_svndump('branchmap.svndump')
        branchmap = open(self.branchmap, 'w')
        branchmap.write("badname = dit\n")
        branchmap.write("feature = dah\n")
        branchmap.close()
        ui = self.ui()
        ui.setconfig('hgsubversion', 'branchmap', self.branchmap)
        commands.clone(ui, test_util.fileurl(repo_path),
                       self.wc_path, branchmap=self.branchmap)
        originfo = self.repo.svnmeta().branches

        # clone & rebuild
        ui = self.ui()
        src, dest = test_util.hgclone(ui, self.wc_path, self.wc_path + '_clone',
                                      update=False)
        src = test_util.getlocalpeer(src)
        dest = test_util.getlocalpeer(dest)
        svncommands.rebuildmeta(ui, dest,
                                args=[test_util.fileurl(repo_path)])

        # just check the keys; assume the contents are unaffected by the branch
        # map and thus properly tested by other tests
        self.assertEquals(sorted(src.svnmeta().branches),
                          sorted(dest.svnmeta().branches))
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:26,代码来源:test_fetch_mappings.py

示例5: nclone

def nclone(ui, source, dest=None, **opts):
    '''make a copy of an existing repository and all nested repositories

    Create a copy of an existing repository in a new directory.

    Look at the help of clone command for more informations.'''
    origsource = ui.expandpath(source)
    remotesource, remotebranch = hg.parseurl(origsource, opts.get('branch'))
    if hasattr(hg, 'peer'):
        remoterepo = hg.peer(ui, opts, remotesource)
        localrepo = remoterepo.local()
        if localrepo:
            remoterepo = localrepo
    else:
        remoterepo = hg.repository(hg.remoteui(ui, opts), remotesource)
    if dest is None:
        dest = hg.defaultdest(source)
        ui.status(_("destination directory: %s\n") % dest)
    for npath in remoterepo.nested:
        if npath == '.':
            npath = ''
        u = util.url(source)
        if u.scheme:
            nsource = '%s/%s' % (source, npath)
        else:
            nsource = os.path.join(source, npath)
        ndest = os.path.join(dest, npath)
        ui.status('[%s]\n' % os.path.normpath(
            os.path.join(os.path.basename(dest),
                ndest[len(dest) + 1:])))
        commands.clone(ui, nsource, dest=ndest, **opts)
        ui.status('\n')
开发者ID:tygerlord,项目名称:hgnested,代码行数:32,代码来源:__init__.py

示例6: test_updatemetahook

    def test_updatemetahook(self):
        repo, repo_path = self._loadupdate('single_rev.svndump')
        state = repo.parents()
        self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
        commands.pull(self.repo.ui, self.repo)

        # Clone to a new repository and add a hook
        new_wc_path = "%s-2" % self.wc_path
        commands.clone(self.repo.ui, self.wc_path, new_wc_path)
        newrepo = hg.repository(test_util.testui(), new_wc_path)
        newrepo.ui.setconfig('hooks', 'changegroup.meta',
                'python:hgsubversion.hooks.updatemeta.hook')

        # Commit a rev that should trigger svn meta update
        self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed Again'})
        commands.pull(self.repo.ui, self.repo)

        self.called = False
        import hgsubversion.svncommands
        oldupdatemeta = hgsubversion.svncommands.updatemeta
        def _updatemeta(ui, repo, args=[]):
            self.called = True
        hgsubversion.svncommands.updatemeta = _updatemeta

        # Pull and make sure our updatemeta function gets called
        commands.pull(newrepo.ui, newrepo)
        hgsubversion.svncommands.updatemeta = oldupdatemeta
        self.assertTrue(self.called)
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:28,代码来源:test_hooks.py

示例7: pull

    def pull(self, source=None, target=None):
        from mercurial import commands, hg, ui, error
        log.debug("Clone or update HG repository.")

        source = source or self.source
        target = target or self.target

        # Folders need to be manually created
        if not os.path.exists(target):
            os.makedirs(target)

        # Doesn't work with unicode type
        url = str(source)
        path = str(target)

        try:
            repo = hg.repository(ui.ui(), path)
            commands.pull(ui.ui(), repo, source=url)
            commands.update(ui.ui(), repo)
            log.debug("Mercurial: repository at " + url + " updated.")
        except error.RepoError, e:
            log.debug("Mercurial: " + str(e))
            try:
                commands.clone(ui.ui(), url, path)
                log.debug("Mercurial: repository at " + url + " cloned.")
            except Exception, e:
                log.debug("Mercurial: " + str(e))
                raise PullFromRepositoryException(unicode(e))
开发者ID:diasks2,项目名称:pontoon,代码行数:28,代码来源:vcs.py

示例8: clone_repo

def clone_repo(ui, clone_url, target_dir, fullName):
    """
    Clones the specified repository. Returns True if successful. If
    the clone fails, prints an error message and returns False,
    without aborting the entire process.
    """
    # If the filesystem does not use Unicode (from Python’s perspective),
    # convert target_dir to plain ASCII.
    if not sys.getfilesystemencoding().upper().startswith('UTF'):
        target_dir = target_dir.encode('ascii', 'xmlcharrefreplace')
    # Mercurial API throws an exception if target_dir is passed (below)
    # as unicode object, so it's required to be converted to string.
    else:
        target_dir = str(target_dir)
    
    # If directory already exists...
    if os.path.isdir(target_dir):
        # ... and is not empty...
        if os.listdir(target_dir):
            # ... just skip it, without aborting the entire process.
            ui.warn(encode_stderr(('Warning: directory %s already exists ' +
                'and is not empty, it will be skipped.\n') % target_dir))
            return False
    # Otherwise create required catalogs tree.
    else:
        os.makedirs(target_dir)
    
    ui.status(encode_stdout('\nCloning "%s" repository\n' % fullName))
    commands.clone(ui, clone_url, dest=target_dir)
    return True
开发者ID:pombredanne,项目名称:kiln-clone,代码行数:30,代码来源:kilnclone.py

示例9: internal_push_over_svnserve

    def internal_push_over_svnserve(self, subdir='', commit=True):
        test_util.load_svndump_fixture(self.repo_path, 'simple_branch.svndump')
        open(os.path.join(self.repo_path, 'conf', 'svnserve.conf'),
             'w').write('[general]\nanon-access=write\n[sasl]\n')
        self.port = random.randint(socket.IPPORT_USERRESERVED, 65535)
        self.host = 'localhost'
        args = ['svnserve', '--daemon', '--foreground',
                '--listen-port=%d' % self.port,
                '--listen-host=%s' % self.host,
                '--root=%s' % self.repo_path]

        svnserve = subprocess.Popen(args, stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
        self.svnserve_pid = svnserve.pid
        try:
            time.sleep(2)
            import shutil
            shutil.rmtree(self.wc_path)
            commands.clone(self.ui(),
                           'svn://%s:%d/%s' % (self.host, self.port, subdir),
                           self.wc_path, noupdate=True)

            repo = self.repo
            old_tip = repo['tip'].node()
            expected_parent = repo['default'].node()
            def file_callback(repo, memctx, path):
                if path == 'adding_file':
                    return context.memfilectx(path=path,
                                              data='foo',
                                              islink=False,
                                              isexec=False,
                                              copied=False)
                raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
            ctx = context.memctx(repo,
                                 parents=(repo['default'].node(), node.nullid),
                                 text='automated test',
                                 files=['adding_file'],
                                 filectxfn=file_callback,
                                 user='an_author',
                                 date='2008-10-07 20:59:48 -0500',
                                 extra={'branch': 'default',})
            new_hash = repo.commitctx(ctx)
            if not commit:
                return # some tests use this test as an extended setup.
            hg.update(repo, repo['tip'].node())
            oldauthor = repo['tip'].user()
            commands.push(repo.ui, repo)
            tip = self.repo['tip']
            self.assertNotEqual(oldauthor, tip.user())
            self.assertNotEqual(tip.node(), old_tip)
            self.assertEqual(tip.parents()[0].node(), expected_parent)
            self.assertEqual(tip['adding_file'].data(), 'foo')
            self.assertEqual(tip.branch(), 'default')
            # unintended behaviour:
            self.assertNotEqual('an_author', tip.user())
            self.assertEqual('(no author)', tip.user().rsplit('@', 1)[0])
        finally:
            # TODO: use svnserve.kill() in Python >2.5
            test_util.kill_process(svnserve)
开发者ID:bulwinkel,项目名称:dot-files,代码行数:59,代码来源:test_push_command.py

示例10: upload

 def upload( self, trans, **kwd ):
     message = escape( kwd.get( 'message', '' ) )
     status = kwd.get( 'status', 'done' )
     commit_message = escape( kwd.get( 'commit_message', 'Uploaded'  ) )
     category_ids = util.listify( kwd.get( 'category_id', '' ) )
     categories = suc.get_categories( trans.app )
     repository_id = kwd.get( 'repository_id', '' )
     repository = suc.get_repository_in_tool_shed( trans.app, repository_id )
     repo_dir = repository.repo_path( trans.app )
     repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False )
     uncompress_file = util.string_as_bool( kwd.get( 'uncompress_file', 'true' ) )
     remove_repo_files_not_in_tar = util.string_as_bool( kwd.get( 'remove_repo_files_not_in_tar', 'true' ) )
     uploaded_file = None
     upload_point = commit_util.get_upload_point( repository, **kwd )
     tip = repository.tip( trans.app )
     file_data = kwd.get( 'file_data', '' )
     url = kwd.get( 'url', '' )
     # Part of the upload process is sending email notification to those that have registered to
     # receive them.  One scenario occurs when the first change set is produced for the repository.
     # See the suc.handle_email_alerts() method for the definition of the scenarios.
     new_repo_alert = repository.is_new( trans.app )
     uploaded_directory = None
     if kwd.get( 'upload_button', False ):
         if file_data == '' and url == '':
             message = 'No files were entered on the upload form.'
             status = 'error'
             uploaded_file = None
         elif url and url.startswith( 'hg' ):
             # Use mercurial clone to fetch repository, contents will then be copied over.
             uploaded_directory = tempfile.mkdtemp()
             repo_url = 'http%s' % url[ len( 'hg' ): ]
             repo_url = repo_url.encode( 'ascii', 'replace' )
             try:
                 commands.clone( hg_util.get_configured_ui(), repo_url, uploaded_directory )
             except Exception, e:
                 message = 'Error uploading via mercurial clone: %s' % basic_util.to_html_string( str( e ) )
                 status = 'error'
                 basic_util.remove_dir( uploaded_directory )
                 uploaded_directory = None
         elif url:
             valid_url = True
             try:
                 stream = urllib.urlopen( url )
             except Exception, e:
                 valid_url = False
                 message = 'Error uploading file via http: %s' % str( e )
                 status = 'error'
                 uploaded_file = None
             if valid_url:
                 fd, uploaded_file_name = tempfile.mkstemp()
                 uploaded_file = open( uploaded_file_name, 'wb' )
                 while 1:
                     chunk = stream.read( util.CHUNK_SIZE )
                     if not chunk:
                         break
                     uploaded_file.write( chunk )
                 uploaded_file.flush()
                 uploaded_file_filename = url.split( '/' )[ -1 ]
                 isempty = os.path.getsize( os.path.abspath( uploaded_file_name ) ) == 0
开发者ID:BinglanLi,项目名称:galaxy,代码行数:59,代码来源:upload.py

示例11: load_fixture_and_fetch

def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='',
                           noupdate=True, layout='auto'):
    load_svndump_fixture(repo_path, fixture_name)
    if subdir:
        repo_path += '/' + subdir
    _ui = testui(stupid=stupid, layout=layout)
    commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate)
    return hg.repository(testui(), wc_path)
开发者ID:chaptastic,项目名称:config_files,代码行数:8,代码来源:test_util.py

示例12: clone

 def clone(self):
     """If we don't have a copy of the open-ihm repository on disk
     clone one now.
     """
     try:
         self.chmod()
         commands.clone(self.ui, self.url, dest=REPO_DIR, insecure=True)
     except Exception:
         self.fail()
     return
开发者ID:r4vi,项目名称:open-ihm,代码行数:10,代码来源:frmupdateopenihm.py

示例13: test_diff_base_against_clone

    def test_diff_base_against_clone(self):
        """Test that the right error is raised on trying to do a diff across
        a different divergant clone"""
        ui = mock_ui()
        orig = os.path.join(settings.REPOSITORY_BASE, "orig")
        clone = os.path.join(settings.REPOSITORY_BASE, "clone")
        hgcommands.init(ui, orig)
        hgorig = repository(ui, orig)
        (
            open(hgorig.pathto("file.dtd"), "w").write(
                """
          <!ENTITY old "content we will delete">
          <!ENTITY mod "this has stuff to keep and delete">
        """
            )
        )
        hgcommands.addremove(ui, hgorig)
        hgcommands.commit(ui, hgorig, user="Jane Doe <[email protected]", message="initial commit")
        assert len(hgorig) == 1  # 1 commit

        # set up a second repo called 'clone'
        hgcommands.clone(ui, orig, clone)
        hgclone = repository(ui, clone)

        # new commit on base
        (
            open(hgorig.pathto("file.dtd"), "w").write(
                """
         <!ENTITY mod "this has stuff to keep and add">
         <!ENTITY new "this has stuff that is new">
         """
            )
        )
        hgcommands.commit(ui, hgorig, user="Jane Doe <[email protected]", message="second commit on base")
        assert len(hgorig) == 2  # 2 commits
        rev_from = hgorig[1].hex()

        # different commit on clone
        (
            open(hgclone.pathto("file.dtd"), "w").write(
                """
         <!ENTITY mod "this has stuff to keep and change">
         <!ENTITY new_in_clone "this has stuff that is different from base">
         """
            )
        )
        hgcommands.commit(ui, hgclone, user="John Doe <[email protected]", message="a different commit on clone")
        rev_to = hgclone[1].hex()

        Repository.objects.create(name="orig", url="http://localhost:8001/orig/")
        Repository.objects.create(name="clone", url="http://localhost:8001/clone/")

        url = reverse("pushes.views.diff")
        # right now, we can't diff between repos, this might change!
        self.assertRaises(RepoError, self.client.get, url, {"repo": "clone", "from": rev_from[:12], "to": rev_to[:12]})
开发者ID:gerv,项目名称:elmo,代码行数:55,代码来源:tests.py

示例14: test_file_map

 def test_file_map(self, stupid=False):
     test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
     filemap = open(self.filemap, 'w')
     filemap.write("include alpha\n")
     filemap.close()
     ui = self.ui(stupid)
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     commands.clone(ui, test_util.fileurl(self.repo_path),
                    self.wc_path, filemap=self.filemap)
     self.assertEqual(node.hex(self.repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
     self.assertEqual(node.hex(self.repo['default'].node()), 'e524296152246b3837fe9503c83b727075835155')
开发者ID:chaptastic,项目名称:config_files,代码行数:11,代码来源:test_fetch_mappings.py

示例15: test_file_map_exclude

 def test_file_map_exclude(self, stupid=False):
     test_util.load_svndump_fixture(self.repo_path, 'replace_trunk_with_branch.svndump')
     filemap = open(self.filemap, 'w')
     filemap.write("exclude alpha\n")
     filemap.close()
     ui = self.ui(stupid)
     ui.setconfig('hgsubversion', 'filemap', self.filemap)
     commands.clone(ui, test_util.fileurl(self.repo_path),
                    self.wc_path, filemap=self.filemap)
     self.assertEqual(node.hex(self.repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
     self.assertEqual(node.hex(self.repo['default'].node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
开发者ID:chaptastic,项目名称:config_files,代码行数:11,代码来源:test_fetch_mappings.py


注:本文中的mercurial.commands.clone函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。