def domergecmd(ui, repo, *revs, **opts):
    node = (list(revs) + opts.get('rev'))[0]
    originalCtx = repo[None].parents()[0]
    originalRev = originalCtx.rev()

    ui.write('Updating to revision %s \n' % node)
    hg.updaterepo(repo, node, True)
    defaultRev = repo['default'].rev()
    
    ui.write('Merging with default revision %s \n' % defaultRev)
    hg.merge(repo, defaultRev)

    #TODO: handle conflict case
    
    ui.write('Committing after merge... \n')
    commitMsg = getMergeDescription(repo[None].parents()[0].description())
    
    ui.write('   Commit message: %s \n' % commitMsg)
    repo.commit(commitMsg)

    if (originalRev != repo[None].parents()[0].parents()[0].rev()): # update to original rev in case branches are different
        ui.write('Updating to original revision %s \n' % originalRev)
        hg.update(repo, originalRev)

    return 0
Esempio n. 2
0
def verlist(ui, repo, *pats, **opts):
    """List the tags in a repo, separated by spaces.

    If one or more rev_ranges are given, limit the tags to the specified ranges.
    By default, all tags are listed.

    The --lastmicro option causes only list the last micro version within a
    minor version family to be listed.  Given a repo with tags 1.0, 1.0.1,
    1.0.2, 1.0.3, and 1.1, 1.1.1, 1.1.2, --lastmicro would list the following
    tags:  1.0, 1.0.3, 1.1, 1.1.2.

    """

    tags = []
    for revspec in pats or [':']:
        tags += _verlist(repo, revspec)
    tags = [x[0] for x in tags] # Just the tag names

    # Skip release candidates, and tip
    tags = filter(lambda t: 'rc' not in t and t != 'tip', tags)

    if opts.get('lastmicro'):
        tags = _lastmicro(tags)
    ui.write(' '.join(tags))
    ui.write('\n')
Esempio n. 3
0
def config(ui, repo, *subtrees, **opts):
    """list or change the subtrees configuration

    One of five operations can be selected:

    --list:  list the configured subtrees; this is the default if no other
      operation is selected.

    --add:  add the specified subtrees to the configuration.

    --del:  delete the specified subtrees from the configuration.
      Use --del --all to delete all subtrees.

    --set:  set the subtree configuration to the specified subtrees.
      Use --set --walk to walk the filesystem rooted at REPO and set the
      subtree configuration to the discovered repos.  Use --depth
      to write the subtree configuration depth-most, so that each
      subtree is defined within the nearest enclosing repository.  Note
      that --walk and --depth may be used together.

    --expand:  list the value of config items from the [trees] section.
      Items in the [trees] section can be defined in terms of other
      items in the [trees] section; tconfig --expand shows the
      recursively expanded value.  It returns 0 if at least one config
      item was found; otherwise it returns 1.

    Note that with the slight exception of --set --depth, this command
    does not recurse into subtrees; it operates only on the current
    repository.  (To recursively list subtrees, use the tlist command.)

    """

    opadd = opts.get('add')
    opdel = opts.get('del')
    opexp = opts.get('expand')
    oplst = opts.get('list')
    opset = opts.get('set')
    cnt = opadd + opdel + opexp + oplst + opset
    if cnt > 1:
        raise util.Abort(
            _('at most one of --add, --del, --list, ' +
              '--set or --expand is allowed'))
    if not opexp and not repo:
        raise util.Abort(_('no repository found'))
    if repo:
        _checklocal(repo)

    if opadd:
        return addconfig(ui, repo, subtrees, opts)
    if opdel:
        return delconfig(ui, repo, subtrees, opts)
    if opexp:
        return expandconfig(ui, repo, subtrees, opts)
    if opset:
        return setconfig(ui, repo, subtrees, opts)

    for subtree in _subtreelist(ui, repo, opts):
        ui.write(subtree + '\n')
    return 0
Esempio n. 4
0
def config(ui, repo, *subtrees, **opts):
    """list or change the subtrees configuration

    One of five operations can be selected:

    --list:  list the configured subtrees; this is the default if no other
      operation is selected.

    --add:  add the specified subtrees to the configuration.

    --del:  delete the specified subtrees from the configuration.
      Use --del --all to delete all subtrees.

    --set:  set the subtree configuration to the specified subtrees.
      Use --set --walk to walk the filesystem rooted at REPO and set the
      subtree configuration to the discovered repos.  Use --depth
      to write the subtree configuration depth-most, so that each
      subtree is defined within the nearest enclosing repository.  Note
      that --walk and --depth may be used together.

    --expand:  list the value of config items from the [trees] section.
      Items in the [trees] section can be defined in terms of other
      items in the [trees] section; tconfig --expand shows the
      recursively expanded value.  It returns 0 if at least one config
      item was found; otherwise it returns 1.

    Note that with the slight exception of --set --depth, this command
    does not recurse into subtrees; it operates only on the current
    repository.  (To recursively list subtrees, use the tlist command.)

    """

    opadd = opts.get('add')
    opdel = opts.get('del')
    opexp = opts.get('expand')
    oplst = opts.get('list')
    opset = opts.get('set')
    cnt = opadd + opdel + opexp + oplst + opset
    if cnt > 1:
        raise error_Abort(
            _('at most one of --add, --del, --list, ' +
              '--set or --expand is allowed'))
    if not opexp and not repo:
        raise error_Abort(_('no repository found'))
    if repo:
        _checklocal(repo)

    if opadd:
        return addconfig(ui, repo, subtrees, opts)
    if opdel:
        return delconfig(ui, repo, subtrees, opts)
    if opexp:
        return expandconfig(ui, repo, subtrees, opts)
    if opset:
        return setconfig(ui, repo, subtrees, opts)

    for subtree in _subtreelist(ui, repo, opts):
        ui.write(subtree + '\n')
    return 0
Esempio n. 5
0
def runcmd(ui, repo, cmd, empty=""):
    # ui.write('%s: %s\n' % (repo.root, cmd))
    returnValue = os.popen3(cmd)
    returnValue = returnValue[1].read() + returnValue[2].read()  # 输出stdout和stderr
    returnValue = returnValue.strip()
    if returnValue:
        for line in returnValue.split("\n"):
            ui.write("%s: %s\n" % (repo.root, line))
    elif empty:
        ui.write("%s: %s\n" % (repo.root, empty))
Esempio n. 6
0
def debugkeys(ui, src, **opts):
    '''list the tree configuration using mercurial's pushkey mechanism.

    This works for remote repositories as long as the remote hg server has the
    trees extension enabled.'''
    d = hg_repo(ui, src, opts).listkeys(_ns(ui, opts))
    i = 0
    n = len(d)
    while i < n:
        istr = str(i)
        ui.write("%s: %s\n" % (istr, d[istr]))
        i += 1
    return 0
Esempio n. 7
0
def debugkeys(ui, src, **opts):
    '''list the tree configuration using mercurial's pushkey mechanism.

    This works for remote repositories as long as the remote hg server has the
    trees extension enabled.'''
    d = hg_repo(ui, src, opts).listkeys(_ns(ui, opts))
    i = 0
    n = len(d)
    while i < n:
        istr = str(i)
        ui.write("%s: %s\n" % (istr, d[istr]))
        i += 1
    return 0
Esempio n. 8
0
def expandconfig(ui, repo, args, opts):
    """show recursively-expanded trees config items

    Config items in the [trees] section can be defined in terms of other items;
    this command shows the expanded value.

    returns 0 if at least one config item was found; otherwise returns 1.
    """

    rc = 1
    for item in args:
        rhs = ui.configlist('trees', item)
        if rhs:
            rc = 0
            l = _expandsubtrees(ui, rhs)
            ui.write(' '.join(l))
            ui.write('\n')
    return rc
Esempio n. 9
0
def expandconfig(ui, repo, args, opts):
    """show recursively-expanded trees config items

    Config items in the [trees] section can be defined in terms of other items;
    this command shows the expanded value.

    returns 0 if at least one config item was found; otherwise returns 1.
    """

    rc = 1
    for item in args:
        rhs = ui.configlist('trees', item)
        if rhs:
            rc = 0
            l = _expandsubtrees(ui, rhs)
            ui.write(' '.join(l))
            ui.write('\n')
    return rc
Esempio n. 10
0
def dmbranch(ui, repo, **kwargs):
    bookmark_map = get_bookmark_map(repo)[1]
    hexfn = ui.debugflag and hex or short
    parent = repo['.']
    current = repo._activebookmark
    for mark, rev in repo._bookmarks.items():
        if mark == current:
            prefix, label = '*', 'bookmarks.current'
        else:
            prefix, label = ' ', ''
        if mark in bookmark_map:
            mark = '%s (%s)' % (bookmark_map[mark], mark)
        if mark == '@':
            mark = 'master'
        if ui.quiet:
            ui.write("%s %s\n" % mark, label=label)
        else:
            ui.write(" %s %-25s %d:%s\n" %
                     (prefix, mark, repo.changelog.rev(rev), hexfn(rev)),
                     label=label)
Esempio n. 11
0
def dmbranch(ui, repo, **kwargs):
    bookmark_map = get_bookmark_map(repo)[1]
    hexfn = ui.debugflag and hex or short
    parent = repo['.']
    current = repo._activebookmark
    for mark, rev in repo._bookmarks.items():
        if mark == current:
            prefix, label = '*', 'bookmarks.current'
        else:
            prefix, label = ' ', ''
        if mark in bookmark_map:
            mark = '%s (%s)' % (bookmark_map[mark], mark)
        if mark == '@':
            mark = 'master'
        if ui.quiet:
            ui.write("%s %s\n" % mark, label=label)
        else:
            ui.write(" %s %-25s %d:%s\n" % (
                prefix, mark, repo.changelog.rev(rev), hexfn(rev)),
                label=label)
Esempio n. 12
0
def list(ui, repo, **opts):
    """list the repo and configured subtrees, recursively

    The initial list of subtrees is obtained from the command line (if present)
    or from the repo configuration.

    If the --walk option is specified, search the filesystem instead of using
    the command line or repo configuration.

    If the --short option is specified, the listed paths are relative to
    the top-level repo."""

    _checklocal(repo)
    if opts.get('walk'):
        l = _walk(ui, repo, opts)
    else:
        l = _list(ui, repo, opts)
    if opts.get('short'):
        l = _shortpaths(repo.root, l)
    for subtree in l:
        ui.write(subtree + '\n')
    return 0
Esempio n. 13
0
def list_cmd(ui, repo, **opts):
    """list the repo and configured subtrees, recursively

    The initial list of subtrees is obtained from the command line (if present)
    or from the repo configuration.

    If the --walk option is specified, search the filesystem instead of using
    the command line or repo configuration.

    If the --short option is specified, the listed paths are relative to
    the top-level repo."""

    _checklocal(repo)
    if opts.get('walk'):
        l = _walk(ui, repo, opts)
    else:
        l = _list(ui, repo, opts)
    if opts.get('short'):
        l = _shortpaths(repo.root, l)
    for subtree in l:
        ui.write(subtree + '\n')
    return 0
Esempio n. 14
0
def publish(ui, repo, source="", node="default", **opts):

    # 只对静态编译框架维护的库进行操作
    if not opm.StaticPackage.is_root(repo.root) or source == "pull":
        return

    publish_branch = ui.config("opm", "publish-branch", "default")  # 默认作为发布源的分支名称
    node = repo[node]
    node_branch = node.branch()

    # 不是需要被编译的分支
    # 不判断分支,因为通过changegroup hook触发编译时,获取到的分支信息有可能不是default,导致不编译
    # if node_branch != publish_branch:
    # ui.warn('%s: ignore branch %s\n' % (repo.root, node_branch))
    # return

    # update到需要编译的分支
    mergemod.update(repo, publish_branch, False, False, None)

    # 生成commitlog
    commitlog_path = os.path.realpath(os.path.join(repo.root, "./commitlog.txt"))
    parent = node.parents()[0].rev()
    rev = node.rev()
    ui.write("%s: update version from %s to %s\n" % (repo.root, parent, rev))
    os.chdir(repo.root)
    os.system("hg log -b %s -r %s:%s > %s" % (node_branch, parent, rev, commitlog_path))

    # 编译自己
    _publish(ui, repo, commitlog_path, rebuild=True)

    # 编译依赖自己的库
    package = opm.StaticPackage(repo.root)
    for repo_path in package.get_reverse_libs(all=True):
        sub_repo = hg.repository(ui, repo_path)
        _publish(sub_repo.ui, sub_repo, commitlog_path, rebuild=False)

    # 删除commitlog
    os.remove(commitlog_path)
Esempio n. 15
0
def bjadd(ui, repo):
    # we need to do whatever it is bananjour add does. i suspect
    # it's just a git init. if so, do the same, and print a message
    if hg_bananajour_curr_repo:
        bj_repo_dir = os.path.expanduser('~/.bananajour/repositories/')
        repo_dir = bj_repo_dir + hg_bananajour_reponame + '.git'
        if os.path.isdir(repo_dir):
            ui.write ("This repository already exists!")
            ui.write ("If you want to push to this repository, try hg push bananajour")
            ui.write ("Otherwise, delete it before re-creating")
            exit()
        else:
            os.makedirs(repo_dir)
            Repo.init_bare(repo_dir)
            ui.write ("Repository added to bananajour")
            ui.write ("Run hg push bananajour to add your commits, and to update!")
    else:
        ui.write("You need to run this command from within a repository")
        exit()