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


Python hg.clean函数代码示例

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


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

示例1: harvest

def harvest(ui, repo, branch, dest="default", **opts):
    """Close and merge a named branch into the destination branch"""
    if branch not in repo.branchtags():
        ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
        return

    if dest not in repo.branchtags():
        ui.warn("Destination branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
        return

    heads = repo.branchheads(branch)
    if len(heads) == 0:
        ui.warn("Cannot harvest branch %s because it is currently closed. \nUse 'hg merge' to merge it manually.\n" % branch)
        return

    if len(heads) > 1:
        ui.warn("Branch %s has multiple heads. \nUse 'hg merge' to merge it manually.\n" % branch)
        return

    rev = repo.branchtip(branch)
    newrev = context.memctx(repo, [rev, None], "Closed branch %s" % branch, [], None, opts.get('user'), opts.get('date'), extra={'close':1, 'branch':branch})
    newrev.commit()

    #don't need to switch if already on destination branch
    curr = repo[None].branch()
    if dest != curr:
        hg.clean(repo, dest, False)
        ui.status("Switched to branch %s before merging\n" % dest)

    failed = hg.merge(repo, branch, remind = False)
    if not failed:
        repo.commit("Merged %s" % branch, opts.get('user'), opts.get('date'), None)
        ui.status("Completed merge of %s into %s\n" % (branch, dest))
开发者ID:jbowtie,项目名称:hg-branching,代码行数:33,代码来源:__init__.py

示例2: strip

def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
    wlock = lock = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()

        if update:
            checklocalchanges(repo, force=force)
            urev, p2 = repo.changelog.parents(revs[0])
            if (util.safehasattr(repo, 'mq') and
                p2 != nullid
                and p2 in [x.node for x in repo.mq.applied]):
                urev = p2
            hg.clean(repo, urev)
            repo.dirstate.write(repo.currenttransaction())

        repair.strip(ui, repo, revs, backup)

        repomarks = repo._bookmarks
        if bookmarks:
            with repo.transaction('strip') as tr:
                if repo._activebookmark in bookmarks:
                    bookmarksmod.deactivate(repo)
                for bookmark in bookmarks:
                    del repomarks[bookmark]
                repomarks.recordchange(tr)
            for bookmark in sorted(bookmarks):
                ui.write(_("bookmark '%s' deleted\n") % bookmark)
    finally:
        release(lock, wlock)
开发者ID:motlin,项目名称:cyg,代码行数:30,代码来源:strip.py

示例3: cleanup

 def cleanup(self):
     try:
         commands.revert(self.repo.ui, self.repo, date=None, rev=None, 
                         all=True, no_backup=True)
         hg.clean(self.repo, self.branch, show_stats=False)
     except Exception, e:
         logger.error(e)
开发者ID:dahool,项目名称:vertaal,代码行数:7,代码来源:hg.py

示例4: test_push_executable_file

 def test_push_executable_file(self):
     self.test_push_to_default(commit=True)
     repo = self.repo
     def file_callback(repo, memctx, path):
         if path == 'gamma':
             return context.memfilectx(path=path,
                                       data='foo',
                                       islink=False,
                                       isexec=True,
                                       copied=False)
         raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
     ctx = context.memctx(repo,
                          (repo['tip'].node(), node.nullid),
                          'message',
                          ['gamma', ],
                          file_callback,
                          'author',
                          '2008-10-29 21:26:00 -0500',
                          {'branch': 'default', })
     new_hash = repo.commitctx(ctx)
     hg.clean(repo, repo['tip'].node())
     self.pushrevisions()
     tip = self.repo['tip']
     self.assertNotEqual(tip.node(), new_hash)
     self.assert_('@' in self.repo['tip'].user())
     self.assertEqual(tip['gamma'].flags(), 'x')
     self.assertEqual(tip['gamma'].data(), 'foo')
     self.assertEqual([x for x in tip.manifest().keys() if 'x' not in
                       tip[x].flags()], ['alpha', 'beta', 'adding_file', ])
开发者ID:bulwinkel,项目名称:dot-files,代码行数:29,代码来源:test_push_command.py

示例5: strip

def strip(ui, repo, revs, update=True, backup=True, force=None, bookmark=None):
    wlock = lock = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()

        if update:
            checklocalchanges(repo, force=force)
            urev, p2 = repo.changelog.parents(revs[0])
            if (util.safehasattr(repo, 'mq') and
                p2 != nullid
                and p2 in [x.node for x in repo.mq.applied]):
                urev = p2
            hg.clean(repo, urev)
            repo.dirstate.write()

        repair.strip(ui, repo, revs, backup)

        marks = repo._bookmarks
        if bookmark:
            if bookmark == repo._bookmarkcurrent:
                bookmarks.unsetcurrent(repo)
            del marks[bookmark]
            marks.write()
            ui.write(_("bookmark '%s' deleted\n") % bookmark)
    finally:
        release(lock, wlock)
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:27,代码来源:strip.py

示例6: switch_branch

def switch_branch(ui, repo, branch, **opts):
    """Switch to the named branch"""
    if branch not in repo.branchtags():
        ui.warn("Branch %s does not exist! (use 'hg branches' to get a list of branches)\n" % branch)
        return
    curr = repo[None].branch()
    if branch == curr:
        ui.status("Already on branch %s\n" % branch)
        return
    hg.clean(repo, branch)
开发者ID:jbowtie,项目名称:hg-branching,代码行数:10,代码来源:__init__.py

示例7: clean

    def clean(self, rev=None):
        '''Bring workspace up to REV (or tip) forcefully (discarding in
        progress changes)'''

        if rev != None:
            rev = self.repo.lookup(rev)
        else:
            rev = self.repo.changelog.tip()

        hg.clean(self.repo, rev, show_stats=False)
开发者ID:apprisi,项目名称:illumos-gate,代码行数:10,代码来源:WorkSpace.py

示例8: cleanup

 def cleanup(self, repo, pats=[], opts={}):
     '''removes all changes from the working copy and makes it so
     there isn't a patch applied'''
     node = repo.dirstate.parents()[0]
     if not pats and not opts.get('include') and not opts.get('exclude'):
         hg.clean(repo, node, False)
     else:
         opts['date'] = None
         opts['all'] = True # Just to trick revert
         opts['rev'] = node
         commands.revert(self.ui, repo, *pats, **opts)
     self.applied = ''
     self.persiststate()
开发者ID:michaelbernstein,项目名称:homedir,代码行数:13,代码来源:attic.py

示例9: commitchanges

    def commitchanges(self, changes, parent='tip', message='automated test'):
        """Commit changes to mercurial directory

        'changes' is a sequence of tuples (source, dest, data). It can look
        like:
        - (source, source, data) to set source content to data
        - (source, dest, None) to set dest content to source one, and mark it as
        copied from source.
        - (source, dest, data) to set dest content to data, and mark it as copied
        from source.
        - (source, None, None) to remove source.
        """
        repo = self.repo
        parentctx = repo[parent]

        changed, removed = [], []
        for source, dest, newdata in changes:
            if dest is None:
                removed.append(source)
            else:
                changed.append(dest)

        def filectxfn(repo, memctx, path):
            if path in removed:
                return compathacks.filectxfn_deleted(memctx, path)
            entry = [e for e in changes if path == e[1]][0]
            source, dest, newdata = entry
            if newdata is None:
                newdata = parentctx[source].data()
            copied = None
            if source != dest:
                copied = source
            return compathacks.makememfilectx(repo,
                                              path=dest,
                                              data=newdata,
                                              islink=False,
                                              isexec=False,
                                              copied=copied)

        ctx = context.memctx(repo,
                             (parentctx.node(), node.nullid),
                             message,
                             changed + removed,
                             filectxfn,
                             'an_author',
                             '2008-10-07 20:59:48 -0500')
        nodeid = repo.commitctx(ctx)
        repo = self.repo
        hg.clean(repo, nodeid)
        return nodeid
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:50,代码来源:test_util.py

示例10: strip

    def strip(self, repo, revs, update=True, backup="all", force=None):
        wlock = lock = None
        try:
            wlock = repo.wlock()
            lock = repo.lock()

            if update:
                self.checklocalchanges(repo, force=force, refresh=False)
                urev = self.qparents(repo, revs[0])
                hg.clean(repo, urev)
                repo.dirstate.write()

            repair.strip(self.ui, repo, revs, backup)
        finally:
            release(lock, wlock)
开发者ID:peiyaoyao,项目名称:intellij-community,代码行数:15,代码来源:mq.py

示例11: process_revision

    def process_revision(revision):
        # change to revision and create metrics
        print 'Processing revision : %s' % revision
        # change repository to revision
        hg.clean(repo, revision)

        # collect files to process
        exclude = re.compile('|'.join([translate(ep) 
            for ep in exclude_pattern]))
        files = [os.path.relpath(os.path.join(dp, name), base) for
            (dp, dn, fn) in os.walk(base)
            for name in fn 
            if not exclude.match(os.path.relpath(os.path.join(dp, name), base))]
        print 'Number of files to process : %d' % len(files)

        return create_metrics(files)
开发者ID:pombredanne,项目名称:visualiser,代码行数:16,代码来源:hg_walker.py

示例12: update

def update(ui, args, repo, clean=False, **opts):
    """update to a specified Subversion revision number
    """

    assert len(args) == 1
    rev = int(args[0])
    meta = repo.svnmeta()

    answers = []
    for k, v in meta.revmap.iteritems():
        if k[0] == rev:
            answers.append((v, k[1]))

    if len(answers) == 1:
        if clean:
            return hg.clean(repo, answers[0][0])
        return hg.update(repo, answers[0][0])
    elif len(answers) == 0:
        ui.status('revision %s did not produce an hg revision\n' % rev)
        return 1
    else:
        ui.status('ambiguous revision!\n')
        revs = ['%s on %s' % (node.hex(a[0]), a[1]) for a in answers] + ['']
        ui.status('\n'.join(revs))
    return 1
开发者ID:chaptastic,项目名称:config_files,代码行数:25,代码来源:svncommands.py

示例13: update

def update(ui, args, repo, clean=False, **opts):
    """update to a specified Subversion revision number
    """

    try:
        rev = int(args[0])
    except IndexError:
        raise error.CommandError('svn',
                                 "no revision number specified for 'update'")
    except ValueError:
        raise error.Abort("'%s' is not a valid Subversion revision number"
                          % args[0])

    meta = repo.svnmeta()

    answers = []
    for k, v in meta.revmap.iteritems():
        if k[0] == rev:
            answers.append((v, k[1]))

    if len(answers) == 1:
        if clean:
            return hg.clean(repo, answers[0][0])
        return hg.update(repo, answers[0][0])
    elif len(answers) == 0:
        ui.status('revision %s did not produce an hg revision\n' % rev)
        return 1
    else:
        ui.status('ambiguous revision!\n')
        revs = ['%s on %s' % (node.hex(a[0]), a[1]) for a in answers] + ['']
        ui.status('\n'.join(revs))
    return 1
开发者ID:fuzzball81,项目名称:dotfiles,代码行数:32,代码来源:svncommands.py

示例14: strip

def strip(ui, repo, revs, update=True, backup="all", force=None):
    wlock = lock = None
    try:
        wlock = repo.wlock()
        lock = repo.lock()

        if update:
            checklocalchanges(repo, force=force)
            urev, p2 = repo.changelog.parents(revs[0])
            if p2 != nullid and p2 in [x.node for x in repo.mq.applied]:
                urev = p2
            hg.clean(repo, urev)
            repo.dirstate.write()

        repair.strip(ui, repo, revs, backup)
    finally:
        release(lock, wlock)
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:17,代码来源:strip.py

示例15: postincoming

 def postincoming(other, modheads):
     if modheads == 0:
         return 0
     if modheads == 1:
         return hg.clean(repo, repo.changelog.tip())
     newheads = repo.heads(parent)
     newchildren = [n for n in repo.heads(parent) if n != parent]
     newparent = parent
     if newchildren:
         newparent = newchildren[0]
         hg.clean(repo, newparent)
     newheads = [n for n in repo.heads() if n != newparent]
     if len(newheads) > 1:
         ui.status(_('not merging with %d other new heads '
                     '(use "hg heads" and "hg merge" to merge them)') %
                   (len(newheads) - 1))
         return
     err = False
     if newheads:
         # By default, we consider the repository we're pulling
         # *from* as authoritative, so we merge our changes into
         # theirs.
         if opts['switch_parent']:
             firstparent, secondparent = newparent, newheads[0]
         else:
             firstparent, secondparent = newheads[0], newparent
             ui.status(_('updating to %d:%s\n') %
                       (repo.changelog.rev(firstparent),
                        short(firstparent)))
         hg.clean(repo, firstparent)
         ui.status(_('merging with %d:%s\n') %
                   (repo.changelog.rev(secondparent), short(secondparent)))
         err = hg.merge(repo, secondparent, remind=False)
     if not err:
         mod, add, rem = repo.status()[:3]
         message = (cmdutil.logmessage(opts) or
                    (_('Automated merge with %s') %
                     util.removeauth(other.url())))
         force_editor = opts.get('force_editor') or opts.get('edit')
         n = repo.commit(mod + add + rem, message,
                         opts['user'], opts['date'], force=True,
                         force_editor=force_editor)
         ui.status(_('new changeset %d:%s merges remote changes '
                     'with local\n') % (repo.changelog.rev(n),
                                        short(n)))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:45,代码来源:fetch.py


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