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


Python merge.update函数代码示例

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


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

示例1: makecollapsed

def makecollapsed(ui, repo, parent, revs):
    'Creates the collapsed revision on top of parent'

    last = max(revs)
    ui.debug(_('updating to revision %d\n') % parent)
    merge.update(repo, parent.node(), False, False, False)
    ui.debug(_('reverting to revision %d\n') % last)
    commands.revert(ui, repo, rev=last, all=True, date=None)
    msg = ''

    first = True
    for r in revs:
        if not first:
            msg += '----------------\n'
        first = False
        msg += repo[r].description() + "\n"

    msg += "\nHG: Enter commit message.  Lines beginning with 'HG:' are removed.\n"
    msg += "HG: Remove all lines to abort the collapse operation.\n"

    msg = ui.edit(msg, ui.username())

    if not msg:
        raise util.Abort(_('empty commit message, collapse won\'t proceed'))

    newrev = repo.commit(
        text=msg,
        user=repo[last].user(),
        date=repo[last].date())

    return repo[newrev]
开发者ID:nwp90,项目名称:dotfiles,代码行数:31,代码来源:collapse.py

示例2: abort

def abort(repo, originalwd, target, state):
    'Restore the repository to its original state'
    dstates = [s for s in state.values() if s != nullrev]
    immutable = [d for d in dstates if not repo[d].mutable()]
    if immutable:
        raise util.Abort(_("can't abort rebase due to immutable changesets %s")
                         % ', '.join(str(repo[r]) for r in immutable),
                         hint=_('see hg help phases for details'))

    descendants = set()
    if dstates:
        descendants = set(repo.changelog.descendants(*dstates))
    if descendants - set(dstates):
        repo.ui.warn(_("warning: new changesets detected on target branch, "
                       "can't abort\n"))
        return -1
    else:
        # Strip from the first rebased revision
        merge.update(repo, repo[originalwd].rev(), False, True, False)
        rebased = filter(lambda x: x > -1 and x != target, state.values())
        if rebased:
            strippoint = min(rebased)
            # no backup of rebased cset versions needed
            repair.strip(repo.ui, repo, repo[strippoint].node())
        clearstatus(repo)
        repo.ui.warn(_('rebase aborted\n'))
        return 0
开发者ID:Pelonza,项目名称:Learn2Mine-Main,代码行数:27,代码来源:rebase.py

示例3: checkout_branch

    def checkout_branch(self, branch=None):
        if branch is None:
            branch = self.repository.DEFAULT_BRANCH_NAME
        if branch not in self.repository.branches:
            raise BranchDoesNotExistError

        hg_merge.update(self.repository._repo, branch, False, False, None)
开发者ID:jonashaag,项目名称:vcs,代码行数:7,代码来源:hg.py

示例4: abort

def abort(repo, originalwd, target, state):
    'Restore the repository to its original state'
    dstates = [s for s in state.values() if s > nullrev]
    immutable = [d for d in dstates if not repo[d].mutable()]
    cleanup = True
    if immutable:
        repo.ui.warn(_("warning: can't clean up immutable changesets %s\n")
                     % ', '.join(str(repo[r]) for r in immutable),
                     hint=_('see hg help phases for details'))
        cleanup = False

    descendants = set()
    if dstates:
        descendants = set(repo.changelog.descendants(dstates))
    if descendants - set(dstates):
        repo.ui.warn(_("warning: new changesets detected on target branch, "
                       "can't strip\n"))
        cleanup = False

    if cleanup:
        # Update away from the rebase if necessary
        if inrebase(repo, originalwd, state):
            merge.update(repo, repo[originalwd].rev(), False, True, False)

        # Strip from the first rebased revision
        rebased = filter(lambda x: x > -1 and x != target, state.values())
        if rebased:
            strippoints = [c.node()  for c in repo.set('roots(%ld)', rebased)]
            # no backup of rebased cset versions needed
            repair.strip(repo.ui, repo, strippoints)

    clearstatus(repo)
    repo.ui.warn(_('rebase aborted\n'))
    return 0
开发者ID:ZanderZhang,项目名称:Andriod-Learning,代码行数:34,代码来源:rebase.py

示例5: fix_hgtags

def fix_hgtags(ui, repo, head_hgtags, tagsmap):
    for tf in iter(tagsmap):
        ui.debug('fix_hgtags: tagsmap %s -> %s\n' % (tf, tagsmap[tf]))
    for old in iter(head_hgtags):
        new = map_recursive(tagsmap, old)
        ui.debug('fix_hgtags: head %s -> %s\n' % (old, new))
        merge.update(repo, repo[new].node(), False, False, False)
        tfile = open('.hgtags', 'wb')
        lines = StringIO.StringIO(head_hgtags[old])
        for line in lines:
            if not line:
                continue
            (nodehex, name) = line.split(" ", 1)
            name = name.strip()
            nhm = map_recursive(tagsmap, nodehex)
            ui.debug('fix_hgtags: hgtags write: %s %s\n' % (nhm, name))
            tfile.write('%s %s\n' % (nhm, name))
        lines.close()    
        tfile.close()
        wctx = repo[None]
        if '.hgtags' not in wctx:
            wctx.add(['.hgtags'])
        nrev = repo.commit(text="collapse tag fix")
        if nrev:
            nctx = repo[nrev]
            ui.debug(_('fix_hgtags: nctx rev %d node %r files %r\n') % 
                     (nctx.rev(), hex(nctx.node()), nctx.files()))
            ui.debug(_('fix_hgtags: nctx parents %r\n') % 
                      ([hex(p.node()) for p in nctx.parents()]))
        else:
            ui.debug(_('fix_hgtags: nctx: None\n'))
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:31,代码来源:collapse.py

示例6: rebasenode

def rebasenode(repo, rev, p1, base, state, collapse, target):
    'Rebase a single revision rev on top of p1 using base as merge ancestor'
    # Merge phase
    # Update to target and merge it with local
    if repo['.'].rev() != p1:
        repo.ui.debug(" update to %d:%s\n" % (p1, repo[p1]))
        merge.update(repo, p1, False, True, False)
    else:
        repo.ui.debug(" already in target\n")
    repo.dirstate.write(repo.currenttransaction())
    repo.ui.debug(" merge against %d:%s\n" % (rev, repo[rev]))
    if base is not None:
        repo.ui.debug("   detach base %d:%s\n" % (base, repo[base]))
    # When collapsing in-place, the parent is the common ancestor, we
    # have to allow merging with it.
    stats = merge.update(repo, rev, True, True, False, base, collapse,
                        labels=['dest', 'source'])
    if collapse:
        copies.duplicatecopies(repo, rev, target)
    else:
        # If we're not using --collapse, we need to
        # duplicate copies between the revision we're
        # rebasing and its first parent, but *not*
        # duplicate any copies that have already been
        # performed in the destination.
        p1rev = repo[rev].p1().rev()
        copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
    return stats
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:28,代码来源:rebase.py

示例7: rebasenode

def rebasenode(repo, rev, p1, state, collapse):
    'Rebase a single revision'
    # Merge phase
    # Update to target and merge it with local
    if repo['.'].rev() != repo[p1].rev():
        repo.ui.debug(" update to %d:%s\n" % (repo[p1].rev(), repo[p1]))
        merge.update(repo, p1, False, True, False)
    else:
        repo.ui.debug(" already in target\n")
    repo.dirstate.write()
    repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
    if repo[rev].rev() == repo[min(state)].rev():
        # Case (1) initial changeset of a non-detaching rebase.
        # Let the merge mechanism find the base itself.
        base = None
    elif not repo[rev].p2():
        # Case (2) detaching the node with a single parent, use this parent
        base = repo[rev].p1().node()
    else:
        # In case of merge, we need to pick the right parent as merge base.
        #
        # Imagine we have:
        # - M: currently rebase revision in this step
        # - A: one parent of M
        # - B: second parent of M
        # - D: destination of this merge step (p1 var)
        #
        # If we are rebasing on D, D is the successors of A or B. The right
        # merge base is the one D succeed to. We pretend it is B for the rest
        # of this comment
        #
        # If we pick B as the base, the merge involves:
        # - changes from B to M (actual changeset payload)
        # - changes from B to D (induced by rebase) as D is a rebased
        #   version of B)
        # Which exactly represent the rebase operation.
        #
        # If we pick the A as the base, the merge involves
        # - changes from A to M (actual changeset payload)
        # - changes from A to D (with include changes between unrelated A and B
        #   plus changes induced by rebase)
        # Which does not represent anything sensible and creates a lot of
        # conflicts.
        for p in repo[rev].parents():
            if state.get(p.rev()) == repo[p1].rev():
                base = p.node()
                break
        else: # fallback when base not found
            base = None

            # Raise because this function is called wrong (see issue 4106)
            raise AssertionError('no base found to rebase on '
                                 '(rebasenode called wrong)')
    if base is not None:
        repo.ui.debug("   detach base %d:%s\n" % (repo[base].rev(), repo[base]))
    # When collapsing in-place, the parent is the common ancestor, we
    # have to allow merging with it.
    return merge.update(repo, rev, True, True, False, base, collapse,
                        labels=['dest', 'source'])
开发者ID:roopakparikh,项目名称:crane-node-hello,代码行数:59,代码来源:rebase.py

示例8: makecollapsed

def makecollapsed(ui, repo, parent, revs, branch, tagsmap, parent_hgtags, 
                  movelog, opts):
    'Creates the collapsed revision on top of parent'

    last = max(revs)
    ui.debug(_('updating to revision %d\n') % parent)
    merge.update(repo, parent.node(), False, False, False)
    ui.debug(_('reverting to revision %d\n') % last)
    recreaterev(ui, repo, last)
    repo.dirstate.setbranch(branch)
    msg = ''
    nodelist = []
    if opts['message'] != "" :
        msg = opts['message']
    else:
        first = True
        for r in revs:
            nodelist.append(hex(repo[r].node()))
            if repo[r].files() != ['.hgtags']:
                if not first:
                    if opts['changelog']:
                        msg += '\n'
                    else:
                        msg += '----------------\n'
                first = False
                if opts['changelog']:
                    msg += "* " + ' '.join(repo[r].files()) + ":\n"

                msg += repo[r].description() + "\n"

        msg += "\nHG: Enter commit message.  Lines beginning with 'HG:' are removed.\n"
        msg += "HG: Remove all lines to abort the collapse operation.\n"

        if ui.config('ui', 'interactive') != 'off':
            msg = ui.edit(msg, ui.username())

        pattern = re.compile("^HG:.*\n", re.MULTILINE);
        msg  = re.sub(pattern, "", msg).strip();

    if not msg:
        raise util.Abort(_('empty commit message, collapse won\'t proceed'))

    write_hgtags(parent_hgtags)
    newrev = repo.commit(
        text=msg,
        user=repo[last].user(),
        date=repo[last].date())

    ctx = repo[newrev]

    newhex = hex(ctx.node())
    for n in nodelist:
        ui.debug(_('makecollapsed %s -> %s\n' % (n, newhex))) 
        tagsmap[n] = newhex
        if movelog:
            movelog.write('coll %s -> %s\n' % (n, newhex))
        
    return ctx
开发者ID:ellipsis-index,项目名称:zeekay-dot-files,代码行数:58,代码来源:collapse.py

示例9: rebasenode

def rebasenode(repo, rev, target, state, skipped, targetancestors, collapse,
               extrafn):
    'Rebase a single revision'
    repo.ui.debug(_("rebasing %d:%s\n") % (rev, repo[rev]))

    p1, p2 = defineparents(repo, rev, target, state, targetancestors)

    repo.ui.debug(_(" future parents are %d and %d\n") % (repo[p1].rev(),
                                                            repo[p2].rev()))

    # Merge phase
    if len(repo.parents()) != 2:
        # Update to target and merge it with local
        if repo['.'].rev() != repo[p1].rev():
            repo.ui.debug(_(" update to %d:%s\n") % (repo[p1].rev(), repo[p1]))
            merge.update(repo, p1, False, True, False)
        else:
            repo.ui.debug(_(" already in target\n"))
        repo.dirstate.write()
        repo.ui.debug(_(" merge against %d:%s\n") % (repo[rev].rev(), repo[rev]))
        first = repo[rev].rev() == repo[min(state)].rev()
        stats = rebasemerge(repo, rev, first)

        if stats[3] > 0:
            raise util.Abort(_('fix unresolved conflicts with hg resolve then '
                                                'run hg rebase --continue'))
    else: # we have an interrupted rebase
        repo.ui.debug(_('resuming interrupted rebase\n'))

    # Keep track of renamed files in the revision that is going to be rebased
    # Here we simulate the copies and renames in the source changeset
    cop, diver = copies.copies(repo, repo[rev], repo[target], repo[p2], True)
    m1 = repo[rev].manifest()
    m2 = repo[target].manifest()
    for k, v in cop.iteritems():
        if k in m1:
            if v in m1 or v in m2:
                repo.dirstate.copy(v, k)
                if v in m2 and v not in m1:
                    repo.dirstate.remove(v)

    newrev = concludenode(repo, rev, p1, p2, state, collapse,
                          extrafn=extrafn)

    # Update the state
    if newrev is not None:
        state[rev] = repo[newrev].rev()
    else:
        if not collapse:
            repo.ui.note(_('no changes, revision %d skipped\n') % rev)
            repo.ui.debug(_('next revision set to %s\n') % p1)
            skipped.add(rev)
        state[rev] = p1
开发者ID:wangbiaouestc,项目名称:WindowsMingWMC,代码行数:53,代码来源:rebase.py

示例10: abort

def abort(repo, originalwd, target, state):
    'Restore the repository to its original state'
    if set(repo.changelog.descendants(target)) - set(state.values()):
        repo.ui.warn(_("warning: new changesets detected on target branch, "
                                                    "not stripping\n"))
    else:
        # Strip from the first rebased revision
        merge.update(repo, repo[originalwd].rev(), False, True, False)
        rebased = filter(lambda x: x > -1, state.values())
        if rebased:
            strippoint = min(rebased)
            repair.strip(repo.ui, repo, repo[strippoint].node(), "strip")
        clearstatus(repo)
        repo.ui.status(_('rebase aborted\n'))
开发者ID:Frostman,项目名称:intellij-community,代码行数:14,代码来源:rebase.py

示例11: rebasenode

def rebasenode(repo, rev, p1, p2, state):
    'Rebase a single revision'
    # Merge phase
    # Update to target and merge it with local
    if repo['.'].rev() != repo[p1].rev():
        repo.ui.debug(" update to %d:%s\n" % (repo[p1].rev(), repo[p1]))
        merge.update(repo, p1, False, True, False)
    else:
        repo.ui.debug(" already in target\n")
    repo.dirstate.write()
    repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
    first = repo[rev].rev() == repo[min(state)].rev()
    stats = rebasemerge(repo, rev, first)
    return stats
开发者ID:ThissDJ,项目名称:designhub,代码行数:14,代码来源:rebase.py

示例12: override_rollback

def override_rollback(orig, ui, repo, **opts):
    result = orig(ui, repo, **opts)
    merge.update(repo, node=None, branchmerge=False, force=True,
        partial=lfutil.isstandin)
    lfdirstate = lfutil.openlfdirstate(ui, repo)
    lfiles = lfutil.listlfiles(repo)
    oldlfiles = lfutil.listlfiles(repo, repo[None].parents()[0].rev())
    for file in lfiles:
        if file in oldlfiles:
            lfdirstate.normallookup(file)
        else:
            lfdirstate.add(file)
    lfdirstate.write()
    return result
开发者ID:mortonfox,项目名称:cr48,代码行数:14,代码来源:overrides.py

示例13: abort

def abort(repo, originalwd, target, state, activebookmark=None):
    '''Restore the repository to its original state.  Additional args:

    activebookmark: the name of the bookmark that should be active after the
        restore'''

    try:
        # If the first commits in the rebased set get skipped during the rebase,
        # their values within the state mapping will be the target rev id. The
        # dstates list must must not contain the target rev (issue4896)
        dstates = [s for s in state.values() if s >= 0 and s != target]
        immutable = [d for d in dstates if not repo[d].mutable()]
        cleanup = True
        if immutable:
            repo.ui.warn(_("warning: can't clean up public changesets %s\n")
                        % ', '.join(str(repo[r]) for r in immutable),
                        hint=_('see "hg help phases" for details'))
            cleanup = False

        descendants = set()
        if dstates:
            descendants = set(repo.changelog.descendants(dstates))
        if descendants - set(dstates):
            repo.ui.warn(_("warning: new changesets detected on target branch, "
                        "can't strip\n"))
            cleanup = False

        if cleanup:
            # Update away from the rebase if necessary
            if needupdate(repo, state):
                merge.update(repo, originalwd, False, True, False)

            # Strip from the first rebased revision
            rebased = filter(lambda x: x >= 0 and x != target, state.values())
            if rebased:
                strippoints = [
                        c.node()  for c in repo.set('roots(%ld)', rebased)]
                # no backup of rebased cset versions needed
                repair.strip(repo.ui, repo, strippoints)

        if activebookmark and activebookmark in repo._bookmarks:
            bookmarks.activate(repo, activebookmark)

    finally:
        clearstatus(repo)
        repo.ui.warn(_('rebase aborted\n'))
    return 0
开发者ID:CSCI-362-02-2015,项目名称:RedTeam,代码行数:47,代码来源:rebase.py

示例14: rebasenode

def rebasenode(repo, rev, p1, state, collapse):
    'Rebase a single revision'
    # Merge phase
    # Update to target and merge it with local
    if repo['.'].rev() != repo[p1].rev():
        repo.ui.debug(" update to %d:%s\n" % (repo[p1].rev(), repo[p1]))
        merge.update(repo, p1, False, True, False)
    else:
        repo.ui.debug(" already in target\n")
    repo.dirstate.write()
    repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
    base = None
    if repo[rev].rev() != repo[min(state)].rev():
        base = repo[rev].p1().node()
    # When collapsing in-place, the parent is the common ancestor, we
    # have to allow merging with it.
    return merge.update(repo, rev, True, True, False, base, collapse)
开发者ID:jordigh,项目名称:mercurial-crew,代码行数:17,代码来源:rebase.py

示例15: _moveto

def _moveto(repo, bookmark, ctx, clean=False):
    """Moves the given bookmark and the working copy to the given revision.
    By default it does not overwrite the working copy contents unless clean is
    True.

    Assumes the wlock is already taken.
    """
    # Move working copy over
    if clean:
        merge.update(repo, ctx.node(),
                     False, # not a branchmerge
                     True, # force overwriting files
                     None) # not a partial update
    else:
        # Mark any files that are different between the two as normal-lookup
        # so they show up correctly in hg status afterwards.
        wctx = repo[None]
        m1 = wctx.manifest()
        m2 = ctx.manifest()
        diff = m1.diff(m2)

        changedfiles = []
        changedfiles.extend(diff.iterkeys())

        dirstate = repo.dirstate
        dirchanges = [f for f in dirstate if dirstate[f] != 'n']
        changedfiles.extend(dirchanges)

        if changedfiles or ctx.node() != repo['.'].node():
            with dirstate.parentchange():
                dirstate.rebuild(ctx.node(), m2, changedfiles)

    # Move bookmark over
    if bookmark:
        lock = tr = None
        try:
            lock = repo.lock()
            tr = repo.transaction('reset')
            changes = [(bookmark, ctx.node())]
            repo._bookmarks.applychanges(repo, tr, changes)
            tr.close()
        finally:
            lockmod.release(lock, tr)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:43,代码来源:reset.py


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