コード例 #1
0
    def hgflow_func_feature_finish(self, target_branch, name):
        '''finish this feature.
        1, Check develop branch version and current feature
        1, Close this branch
        2, Merge it into develop
        3, Commit develop branch
        '''

        if not self._findBranch(target_branch, name):
            return

        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui,
                        self.repo,
                        close_branch=True,
                        message='hg flow, close feature %s' % (name, ))

        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        #commands.commit(self.ui, self.repo, message='hg flow, merge feature `%s` to develop branch `%s`' % (target_branch, self.developBranch))
        commands.commit(
            self.ui,
            self.repo,
            message='hg flow, merge release `%s` to develop branch `%s`' %
            (name, self.developBranch))
コード例 #2
0
ファイル: hgflow-0.2.py プロジェクト: itspec-ru/dotfiles
        def _feature_func(action, name, target_branch):
            if 'start' == action:
                self._startBranch(target_branch, 'feature')

            elif 'finish' == action:
                '''finish this feature.
                1, Check develop branch version and current feature
                1, Close this branch
                2, Merge it into develop
                3, Commit develop branch
                '''

                if not self._findBranch(target_branch, name):
                    return

                commands.update(self.ui, self.repo, target_branch)
                commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close feature %s' % (name,))

                commands.update(self.ui, self.repo, self.developBranch)
                commands.merge(self.ui, self.repo, target_branch)
                #commands.commit(self.ui, self.repo, message='hg flow, merge feature `%s` to develop branch `%s`' % (target_branch, self.developBranch))
                commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
                #self.outputln(_('WARNING: No automatic commit after merge from feature `%s`, you should resolve the confict (if any) then commit manually.' % (name,)))

            elif 'change' == action:
                commands.update(self.ui, self.repo, target_branch)
                """
            elif 'fetchdev' == action:
                pass
            """
            else:
                self.outputln(_('Please give a valid action.'))
コード例 #3
0
ファイル: hgflow-0.2.py プロジェクト: yulka/yulka-dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name):
        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui,
                        self.repo,
                        close_branch=True,
                        message='hg flow, close release %s' %
                        (target_branch, ))
        commands.update(self.ui, self.repo, self.publishBranch)

        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(
            self.ui,
            self.repo,
            close_branch=True,
            message='hg flow, merge release `%s` to publish branch `%s`' %
            (name, self.publishBranch))

        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, self.publishBranch)

        commands.commit(
            self.ui,
            self.repo,
            message='hg flow, merge release `%s` to develop branch `%s`' %
            (name, self.developBranch))
コード例 #4
0
    def start(self, rev=None):
        _filemerge = filemerge.filemerge

        def filemerge_(repo, fw, fd, fo, wctx, mctx):
            self.conflicts[fw] = (fd, fo)

        filemerge.filemerge = filemerge_
        commands.merge(self.ui, self.repo, rev=rev)
        filemerge.filemerge = _filemerge

        self.wctx = self.repo.workingctx()
        self.save()
コード例 #5
0
ファイル: my_hgext.py プロジェクト: ikeikeikeike/home
def merge_into(ui, repo, rev, **opts):
    node = repo.changectx(rev)
    curr = repo.changectx(".")
    commands.update(ui, repo, rev=node.rev())
    commands.merge(ui, repo, rev=curr.rev())
    ticket = get_ticket_id(curr)
    message = "refs #%(ticket)s merged %(target)s -> %(branch)s" % {
        "ticket": ticket,
        "target": curr.branch(),
        "branch": node.branch(),
        }
    commands.commit(ui, repo, message=message)
コード例 #6
0
ファイル: hgflow-0.2.py プロジェクト: itspec-ru/dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name):
        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))

        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, self.publishBranch)

        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #7
0
ファイル: hgflow.py プロジェクト: djm/dotfiles
    def hgflow_func_feature_finish(self, target_branch, name):
        '''finish this feature.
        1, Check develop branch version and current feature
        1, Close this branch
        2, Merge it into develop
        3, Commit develop branch
        '''

        if not self._findBranch(target_branch, name):
            return
        
        commands.update(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close feature %s' % (name,))

        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        #commands.commit(self.ui, self.repo, message='hg flow, merge feature `%s` to develop branch `%s`' % (target_branch, self.developBranch))
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #8
0
ファイル: hgflow.py プロジェクト: djm/dotfiles
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('Close branch `%s`' % (target_branch))

        #TODO: source_tag_name should in source_branch
        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
            self.outputln('Merge TAG `%s` into PRODCTION branch.' % (source_tag_name, ))
        else:
            commands.merge(self.ui, self.repo, target_branch)
            self.outputln('Merge BRANCH `%s` into PRODCTION branch.' % (target_branch, ))
            
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        
        self.outputln('Merge BRANCH `%s` into DEVELOP branch.' % (target_branch, ))

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #9
0
ファイル: hgflow.py プロジェクト: peixinchen/my-conf
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('Close branch `%s`' % (target_branch))

        #TODO: source_tag_name should in source_branch
        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
            self.outputln('Merge TAG `%s` into PRODCTION branch.' % (source_tag_name, ))
        else:
            commands.merge(self.ui, self.repo, target_branch)
            self.outputln('Merge BRANCH `%s` into PRODCTION branch.' % (target_branch, ))
            
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        commands.tag(self.ui, self.repo, tag_name)
        
        self.outputln('Merge BRANCH `%s` into DEVELOP branch.' % (target_branch, ))

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #10
0
ファイル: hgflow.py プロジェクト: d3m3vilurr/settings
    def _mergeIntoPublishBranch(self, target_branch, name, source_tag_name = None):
        commands.update(self.ui, self.repo, target_branch)

        #tag for publish
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        if source_tag_name:
            commands.tag(self.ui, self.repo, tag_name, rev=source_tag_name)
        else:
            commands.tag(self.ui, self.repo, tag_name)
        
        commands.commit(self.ui, self.repo, close_branch=True, message='hg flow, close release %s' % (target_branch,))
        commands.update(self.ui, self.repo, self.publishBranch)

        self.outputln('close target_branch')


        if source_tag_name:
            commands.merge(self.ui, self.repo, source_tag_name)
        else:
            commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to publish branch `%s`' % (name, self.publishBranch))
        self.outputln('merge source_tag_name into publish branch')
        
        '''
        tag_name = '%s%s' % (self.versionTagPrefix, name)
        commands.tag(self.ui, self.repo, tag_name)
        '''
        self.outputln('merge target_branch into develop branch')

        #merge it into develop branch, there should be many confilct code
        commands.update(self.ui, self.repo, self.developBranch)
        commands.merge(self.ui, self.repo, target_branch)
        commands.commit(self.ui, self.repo, message='hg flow, merge release `%s` to develop branch `%s`' % (name, self.developBranch))
コード例 #11
0
ファイル: hgflow-0.2.py プロジェクト: yulka/yulka-dotfiles
        def _feature_func(action, name, target_branch):
            if 'start' == action:
                self._startBranch(target_branch, 'feature')

            elif 'finish' == action:
                '''finish this feature.
                1, Check develop branch version and current feature
                1, Close this branch
                2, Merge it into develop
                3, Commit develop branch
                '''

                if not self._findBranch(target_branch, name):
                    return

                commands.update(self.ui, self.repo, target_branch)
                commands.commit(self.ui,
                                self.repo,
                                close_branch=True,
                                message='hg flow, close feature %s' % (name, ))

                commands.update(self.ui, self.repo, self.developBranch)
                commands.merge(self.ui, self.repo, target_branch)
                #commands.commit(self.ui, self.repo, message='hg flow, merge feature `%s` to develop branch `%s`' % (target_branch, self.developBranch))
                commands.commit(
                    self.ui,
                    self.repo,
                    message='hg flow, merge release `%s` to develop branch `%s`'
                    % (name, self.developBranch))
                #self.outputln(_('WARNING: No automatic commit after merge from feature `%s`, you should resolve the confict (if any) then commit manually.' % (name,)))

            elif 'change' == action:
                commands.update(self.ui, self.repo, target_branch)
                """
            elif 'fetchdev' == action:
                pass
            """
            else:
                self.outputln(_('Please give a valid action.'))
コード例 #12
0
    def merge_heads(self, branch, heads, requestid):
        if len(heads) == 1:
            return  # nothing to merge

        if len(heads) > 2:
            self.ui.status(
                _("Review request bundle import resulted in more than two heads on branch %s"
                  ) % branch)
            raise util.Abort(
                _("Review request bundle import resulted in more than two heads on branch %s"
                  ) % branch)

        self.ui.status(_("Merging heads for branch %s\n") % branch)
        self.ui.pushbuffer()
        try:
            commands.update(self.ui, self.repo, heads[0].rev())
            commands.merge(self.ui, self.repo, tool="internal:fail")

            message = _(
                "Automatic merge after review request %s fetch") % requestid
            commands.commit(self.ui, self.repo, message=message)
        finally:
            self.ui.popbuffer()
コード例 #13
0
ファイル: hg.py プロジェクト: mausvt/rhodecode-vcsserver
 def merge(self, wire, revision):
     repo = self._factory.repo(wire)
     baseui = self._factory._create_config(wire['config'])
     repo.ui.setconfig('ui', 'merge', 'internal:dump')
     commands.merge(baseui, repo, rev=revision)
コード例 #14
0
def hg_merge(rev):
    opts = { 'rev': str(rev) }
    commands.merge(_ui, get_sandbox_repo(), **opts)
コード例 #15
0
    def pfinish(self, patch_name):
        """
        [pbranch] Execute 'pfinish' command.
        
        The workdir must be clean.
        The patch branch dependencies must be merged.
        
        :param patch_name: A patch branch (not an internal branch)
        """
        # Check preconditions for pfinish

        assert self.is_patch(patch_name)

        pmerge_status = self.pstatus(patch_name)
        if pmerge_status != []:
            dialog.error_dialog(self.parent_window,
            _('Pending Pmerge'),
            _('You cannot finish this patch branch unless you pmerge it first.\n'
              'pmerge will solve the following issues with %(patch)s:\n'
              '* %(issuelist)s') %
            {'patch': patch_name,
             'issuelist': '* '.join(pmerge_status)}
            )
            return

        if not self.workdir_is_clean():
            dialog.error_dialog(self.parent_window,
            _('Uncommitted Local Changes'),
            _('pfinish uses your working directory for temporary work.\n'
              'Please commit your local changes before issuing pfinish.')
            )
            return

        if hasattr(self.repo, 'mq') and len(self.repo.mq.applied) > 0:
            dialog.error_dialog(self.parent_window,
            _('Applied MQ patch'),
            _('pfinish must be able to commit, but this is not allowed\n'
              'as long as you have MQ patches applied.')
            )
            return

        # Set up environment for mercurial commands
        class CmdWidgetUi(mercurial.ui.ui):
            def __init__(self, cmdLogWidget):
                src = None
                super(CmdWidgetUi, self).__init__(src)
                self.cmdLogWidget = cmdLogWidget
            def write(self, *args, **opts):
                for a in args:
                    self.cmdLogWidget.append(str(a))
            def write_err(self, *args, **opts):
                for a in args:
                    self.cmdLogWidget.append(str(a), error=True)
            def flush(self):
                pass
            def prompt(self, msg, choices=None, default="y"):
                raise util.Abort("Internal Error: prompt not available")
            def promptchoice(self, msg, choices, default=0):
                raise util.Abort("Internal Error: promptchoice not available")
            def getpass(self, prompt=None, default=None):
                raise util.Abort("Internal Error: getpass not available")
        repo = self.repo
        ui = CmdWidgetUi(self.cmd.log)
        old_ui = repo.ui
        repo.ui = ui

        # Commit patch to dependency
        fd, patch_file_name = tempfile.mkstemp(prefix='thg-patch-')
        patch_file = os.fdopen(fd, 'w')
        patch_file.writelines(self.pdiff(patch_name))
        patch_file.close()    
        upstream_branch = self.pgraph().deps(patch_name)[0]
        hg.update(ui, repo, rev=upstream_branch)
        hg.import_(ui, repo, patch_file_name, base='', strip=1)
        os.unlink(patch_file_name)
        
        # Close patch branch
        hg.update(ui, repo, rev=patch_name)
        hg.merge(ui, repo, upstream_branch)
        msg = _('Patch branch finished')
        hg.commit(ui, repo, close_branch=True, message=msg)
        
        # Update GUI
        repo.ui = old_ui
        self.emit('repo-invalidated')
コード例 #16
0
def tclose(ui, repo, *args, **opts):
  """ close the current topic branch and push to the central repository """

  mustBeTopicRepo(repo)

  # Sanity check
  if not isClean(ui, repo):
    return 1

  if args:
    branches = args
  else:
    if not onTopicBranch(ui, repo):
      return 1
    branches = [repo.dirstate.branch()]

  if 'tmenu' in opts:
    if ui.prompt("Branch '%s': close it?" % branches[0]).upper() != 'Y':
      return 1
    opts = { 'nopull':False, 'nopush':False }

  pulled = False # only pull once

  for branch in branches:

    # Pull new changes from the central repo to avoid multiple-heads problem
    if not opts['nopull'] and not pulled:
      if tryCommand(ui, "pull", lambda:commands.pull(ui, repo, **opts) >= 2):
        return 1
      pulled = True

    # Can't close already closed branches, nor any of the special branches
    if not repo.branchheads(branch) or branch in repo.topicSpecialBranches:
      ui.warn("Error: %s is not an open topic branch\n" % branch)
      return 1

    # Now update to the head of the branch being closed
    if repo.dirstate.parents()[0] not in repo.branchheads(branch):
      if tryCommand(ui, "update %s" % quoteBranch(branch), lambda:commands.update(ui, repo, node=branch)):
        return 1

    # Unlike a normal hg commit, if no text is specified we supply a reasonable default.
    branch = repo.dirstate.branch()
    text = opts.get('message')
    if text is None:
      text = "Closing %s" % branch

    # Close it
    if tryCommand(ui, "commit --close-branch", lambda:repo.commit(text, extra = {'close':'True'}) is None):
      return 1

    # Aditionally, for this to not be considered a "head" it has to have a
    # child commit. So we have to merge into prod. First, update.
    #
    if tryCommand(ui, "update %s" % repo.topicProdBranch, lambda:commands.update(ui, repo, node=repo.topicProdBranch)):
      return 1

    # Now merge, ignoring all conflicts.
    mergeOpts = copy.deepcopy(opts)
    mergeOpts['tool'] = "internal:fail"
    mergeOpts['noninteractive'] = True
    # Ignore return value... ok if merge fails
    tryCommand(ui, "merge -r %s" % quoteBranch(branch), 
               lambda:commands.merge(ui, repo, node=branch, **mergeOpts),
               repo = repo)

    # Revert all files to prod (regardless of what happened on the branch)
    revertOpts = copy.deepcopy(opts)
    revertOpts['all'] = True
    revertOpts['rev'] = "."
    if tryCommand(ui, "revert -a -r .", lambda:commands.revert(ui, repo, **revertOpts), repo = repo):
      return 1

    # Were there any merge conflicts?
    resolveOpts = copy.deepcopy(opts)
    resolveOpts['list'] = True
    if tryCommand(ui, "resolve -l", lambda:commands.resolve(ui, repo, **resolveOpts), repo = repo):
      return 1

    # Anything that had a merge conflict, mark it resolved (by the revert)
    if ui.lastTryCommandOutput != '':
      resolveOpts = copy.deepcopy(opts)
      resolveOpts['all'] = True
      resolveOpts['mark'] = True
      if tryCommand(ui, "resolve -a -m", lambda:commands.resolve(ui, repo, **resolveOpts), repo = repo):
        return 1

    # Commit the merge
    if tryCommand(ui, "commit", lambda:repo.commit(text) is None):
      return 1

  # And push.
  if not opts['nopush']:
    pushOpts = copy.deepcopy(opts)
    if 'message' in pushOpts:
      del pushOpts['message']
    pushOpts['force'] = True
    nameSet = set()
    for name, path in ui.configitems("paths"):
      nameSet.add(name)
    if tryCommand(ui, "push -f -b %s -b %s default" % (quoteBranch(branch), repo.topicProdBranch), 
                  lambda:commands.push(ui, repo, branch=(branch,repo.topicProdBranch), **pushOpts), 
                  repo=repo) > 1:
      return 1
    if "dev" in nameSet:
      if tryCommand(ui, "push -f -b %s -b %s dev" % (quoteBranch(branch), repo.topicProdBranch), 
                    lambda:commands.push(ui, repo, branch=(branch,repo.topicProdBranch), dest="dev", **pushOpts), 
                    repo=repo) > 1:
        return 1
    if "stage" in nameSet:
      if tryCommand(ui, "push -f -b %s -b %s stage" % (quoteBranch(branch), repo.topicProdBranch), 
                    lambda:commands.push(ui, repo, branch=(branch,repo.topicProdBranch), dest="stage", **pushOpts), 
                    repo=repo) > 1:
        return 1
    if "prod" in nameSet:
      if tryCommand(ui, "push -f -b %s -b %s prod" % (quoteBranch(branch), repo.topicProdBranch), 
                    lambda:commands.push(ui, repo, branch=(branch,repo.topicProdBranch), dest="prod", **pushOpts), 
                    repo=repo) > 1:
        return 1

  ui.status("Done.\n")
コード例 #17
0
ファイル: repo_fixtures.py プロジェクト: flodolo/elmo
 def merge(cls, repo, rev1, rev2):
     hgcommands.update(repo.ui, repo, rev=rev1, clean=True)
     hgcommands.merge(repo.ui, repo, rev=rev2)
コード例 #18
0
 def merge(cls, repo, rev1, rev2):
     hgcommands.update(repo.ui, repo, rev=rev1, clean=True)
     hgcommands.merge(repo.ui, repo, rev=rev2)
コード例 #19
0
ファイル: subtree.py プロジェクト: mrzv/hg-subtree
def subpull(ui, repo, name='', **opts):
    """Pull subtree(s)"""

    # change to root directory
    if repo.getcwd() != '':
        ui.warn(
            "Working directory is not repository root. At best, this directory won't exist when subpull is done.\n"
        )
        repo.dirstate._cwd = repo.root
        os.chdir(repo.root)

    # if there are uncommitted change, abort --- we will be modifying the working copy quite drammatically
    modified, added, removed, deleted, _unknown, _ignored, _clean = repo.status(
    )
    if modified or added or removed or deleted:
        raise error.Abort(
            "Uncommitted changes in the working copy. Subtree extension needs to modify the working copy, so it cannot proceed."
        )

    # parse .hgsubtree
    hgsubtree = ui.config('subtree', 'hgsubtree', default=default_hgsubtree)
    subtrees = _parse_hgsubtree(os.path.join(repo.root, hgsubtree))

    # if names not in .hgsubtree, abort
    # if names is empty, go through all repos in .hgsubtree
    if name:
        if name not in subtrees:
            raise error.Abort("Cannot find %s in %s." % (name, hgsubtree))
        names = [name]
    else:
        if opts['source']:
            raise error.Abort(
                "Cannot use --source without specifying a repository")
        names = subtrees.keys()

    null = repo['null']
    origin = str(repo[None])
    commit_opts = {'edit': opts['edit']}
    bookmark_prefix = ui.config('subtree',
                                'bookmark',
                                default=default_bookmark_prefix)
    nocache = ui.config('subtree', 'nocache', default='')

    for name in names:
        subtree = subtrees[name]
        if 'destination' not in subtree:
            raise error.Abort('No destination found for %s' % name)

        collapse = 'collapse' in subtree and subtree['collapse']

        # figure out the revision to pull
        pull_opts = {}
        if 'rev' in subtree:
            pull_opts['rev'] = [subtree['rev']]
        if opts['rev']:
            pull_opts['rev'] = opts['rev']

        # clone or pull into cache
        source = subtree['source'] if not opts['source'] else opts['source']
        if not nocache:
            source = _clone_or_pull(ui, repo, name, source, pull_opts)

        # pull
        tip = repo['tip']
        commands.pull(ui, repo, source=source, force=True, **pull_opts)
        if tip == repo['tip']:
            ui.status("no changes: nothing for subtree to do\n")
            continue

        # collapse or update -C
        if collapse:
            # find a matching bookmark
            bookmark_name = bookmark_prefix + name
            if bookmark_name in repo._bookmarks:
                commands.update(ui, repo, bookmark_name, clean=True)
            else:
                commands.update(ui, repo, 'null', clean=True)

            # set up the correct file state and commit as a new changeset
            pulled_tip = repo['tip']
            commands.revert(ui, repo, rev='tip', all=True)
            hgsubrepo_meta = [
                os.path.join(repo.root, '.hgsubstate'),
                os.path.join(repo.root, '.hgsub')
            ]
            for fn in hgsubrepo_meta:
                if os.path.exists(fn):
                    ui.debug("removing %s\n" % fn)
                    commands.remove(ui, repo, fn, force=True)
                    os.remove(fn)
            changed = commands.commit(ui,
                                      repo,
                                      message=ui.config(
                                          'subtree', 'collapse',
                                          default_collapse_comment).format(
                                              name=name,
                                              rev=str(pulled_tip)[:12]),
                                      **commit_opts)
            commands.bookmark(ui, repo, bookmark_name, inactive=True)

            if not opts['no_strip']:
                # delete bookmarks on the changesets that will be stripped; not
                # the most efficient procedure to find them, but will do for now
                remove_bookmarks = []
                for k in repo._bookmarks.keys():
                    ctx = repo[k]
                    if pulled_tip.ancestor(ctx) != null:
                        remove_bookmarks.append(k)

                for bookmark in remove_bookmarks:
                    commands.bookmark(ui, repo, bookmark, delete=True)

                strip.stripcmd(ui,
                               repo,
                               rev=['ancestors(%s)' % str(pulled_tip)],
                               bookmark=[])

            if changed == 1:  # nothing changed
                ui.status("no changes: nothing for subtree to do\n")
                commands.update(ui, repo, origin[:12])
                continue
        else:
            commands.update(ui, repo, 'tip', clean=True)

        # move or delete
        destinations = _destinations(subtree['destination'])

        # process destinations
        keep_list = []
        for dest in destinations:
            if dest[0] == 'mkdir':
                if not os.path.exists(dest[1]):
                    os.makedirs(dest[1])
            elif dest[0] == 'mv':
                commands.rename(ui, repo, *dest[1:], force=False)
            elif dest[0] == 'cp':
                commands.copy(ui, repo, *dest[1:], force=False)
            elif dest[0] == 'rm':
                commands.remove(ui, repo, *dest[1:], force=False)
            elif dest[0] == 'keep':
                keep_list.append(' '.join(dest[1:]))

        # remove all untouched files, unless instructed to keep them
        if 'keep' not in subtree or not subtree['keep']:
            _modified, _added, _removed, _deleted, _unknown, _ignored, clean = repo.status(
                clean=True)
            for fn in clean:
                for keep_pattern in keep_list:
                    if fnmatch(fn, keep_pattern):
                        break
                else:
                    commands.remove(ui, repo, fn)

        commands.commit(
            ui,
            repo,
            message=ui.config('subtree', 'move',
                              default_move_comment).format(name=name),
            **commit_opts)
        merge_commit = str(repo[None])

        # update to original and merge with the new
        commands.update(ui, repo, origin[:12])
        commands.merge(ui, repo, merge_commit[:12])
        commands.commit(
            ui,
            repo,
            message=ui.config('subtree', 'merge',
                              default_merge_comment).format(name=name),
            **commit_opts)
        origin = str(repo[None])
コード例 #20
0
def do_merge(repo):
    try:
        return commands.merge(repo.ui, repo)
    except NoMergeDestAbort as e:
        traceback.print_exc(e)
        return False