コード例 #1
0
ファイル: kiln.py プロジェクト: szechyjs/dotfiles
def _upgrade(ui, repo):
    ext_dir = os.path.dirname(os.path.abspath(__file__))
    ui.debug(_('kiln: checking for extensions upgrade for %s\n') % ext_dir)

    try:
        r = localrepo.localrepository(hgui.ui(), ext_dir)
    except RepoError:
        commands.init(hgui.ui(), dest=ext_dir)
        r = localrepo.localrepository(hgui.ui(), ext_dir)

    r.ui.setconfig('kiln', 'autoupdate', False)
    r.ui.pushbuffer()
    try:
        source = 'https://developers.kilnhg.com/Repo/Kiln/Group/Kiln-Extensions'
        if commands.incoming(r.ui, r, bundle=None, force=False, source=source) != 0:
            # no incoming changesets, or an error. Don't try to upgrade.
            ui.debug('kiln: no extensions upgrade available\n')
            return
        ui.write(_('updating Kiln Extensions at %s... ') % ext_dir)
        # pull and update return falsy values on success
        if commands.pull(r.ui, r, source=source) or commands.update(r.ui, r, clean=True):
            url = urljoin(repo.url()[:repo.url().lower().index('/repo')], 'Tools')
            ui.write(_('unable to update\nvisit %s to download the newest extensions\n') % url)
        else:
            ui.write(_('complete\n'))
    except Exception, e:
        ui.debug(_('kiln: error updating extensions: %s\n') % e)
        ui.debug(_('kiln: traceback: %s\n') % traceback.format_exc())
コード例 #2
0
ファイル: kiln.py プロジェクト: meereenee/dotfiles
def _upgrade(ui, repo):
    ext_dir = os.path.dirname(os.path.abspath(__file__))
    ui.debug('kiln: checking for extensions upgrade for %s\n' % ext_dir)

    try:
        r = localrepo.localrepository(hgui.ui(), ext_dir)
    except RepoError:
        commands.init(hgui.ui(), dest=ext_dir)
        r = localrepo.localrepository(hgui.ui(), ext_dir)

    r.ui.setconfig('kiln', 'autoupdate', False)
    r.ui.pushbuffer()
    try:
        source = 'https://developers.kilnhg.com/Repo/Kiln/Group/Kiln-Extensions'
        if commands.incoming(r.ui, r, bundle=None, force=False, source=source) != 0:
            # no incoming changesets, or an error. Don't try to upgrade.
            ui.debug('kiln: no extensions upgrade available\n')
            return
        ui.write(_('updating Kiln Extensions at %s... ') % ext_dir)
        # pull and update return falsy values on success
        if commands.pull(r.ui, r, source=source) or commands.update(r.ui, r, clean=True):
            url = urljoin(repo.url()[:repo.url().lower().index('/repo')], 'Tools')
            ui.write(_('unable to update\nvisit %s to download the newest extensions\n') % url)
        else:
            ui.write(_('complete\n'))
    except Exception, e:
        ui.debug(_('kiln: error updating Kiln Extensions: %s\n') % e)
コード例 #3
0
ファイル: hgshelve.py プロジェクト: dpla/zen
 def open_or_create_repo(self, repopath):
     """
     Open existing repo, or create it otherwise
     """
     if os.path.isdir(repopath):
         try:
             r = localrepo.localrepository(self.ui, repopath)
         except repo.RepoError:
             # dir is not an hg repo, we must init it
             r = localrepo.localrepository(self.ui, repopath, create=1)
     else:
         os.makedirs(repopath)
         r = localrepo.localrepository(self.ui, repopath, create=1)
     return r
コード例 #4
0
ファイル: hgcolllog.py プロジェクト: j2a/pyo-sandbox
def get_changes(collection_path, changelog_length=10):
    """
    Return a list of changes for repositories collection
    
    Each item is a tuple ('repo_name', changelog_dict)
    where changelog_dict is a dict with keys: 'author', 'comment',
    'rev', 'changeset', 'timestamp'
    """
    iface = ui.ui(quiet=True, interactive=False)    
    changes = []
    for name in os.listdir(collection_path):
        repo_dir = os.path.join(collection_path, name)
        if os.path.isdir(repo_dir):
            try:
                curr_repo = localrepo.localrepository(
                    iface, 
                    repo_dir)
            except repo.RepoError:
                # dir is not a hg repo
                continue
            # zip(itertools.cycle([name]), seq) -> 
            #    [(name, seq[0]), (name, seq[1]), ...]
            changes += zip(itertools.cycle([name]), 
                            iter_changes_from_single_repo(curr_repo, 
                                                         changelog_length))
    return sorted(
            changes, key=lambda x: x[1]['timestamp'], reverse=True
        )[:changelog_length]
コード例 #5
0
ファイル: hg.py プロジェクト: goodosuser/starcal
def prepareObj(obj):
    obj.repo = localrepository(mercurial.ui.ui(), obj.vcsDir)
    ###
    obj.est = EventSearchTree()
    for rev_id in obj.repo.changelog:
        epoch = obj.repo[rev_id].date()[0]
        obj.est.add(epoch, epoch, rev_id)
コード例 #6
0
ファイル: hg.py プロジェクト: amirkarimi/starcal
def prepareObj(obj):
    obj.repo = localrepository(mercurial.ui.ui(), obj.vcsDir)
    ###
    obj.est = EventSearchTree()
    for rev_id in obj.repo.changelog:
        epoch = obj.repo[rev_id].date()[0]
        obj.est.add(epoch, epoch, rev_id)
コード例 #7
0
ファイル: hg.py プロジェクト: lukaszb/vcs
 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)
コード例 #8
0
ファイル: __init__.py プロジェクト: piratenmv/openslides
def _bootstrap():
    conts = realpath(join(dirname(__file__)))
    try:
        ui = hgui.ui()
        repository = localrepository(ui, join(conts, '..'))
        #repository = localrepository(ui, conts)
        ctx = repository['.']
        if ctx.tags() and ctx.tags() != ['tip']:
            revision = ' '.join(ctx.tags())
        else:
            revision = '%(num)s:%(id)s' % {
                'num': ctx.rev(), 'id': shorthex(ctx.node())
            }
    except TypeError:
        revision = 'unknown'
    except RepoError:
        return 0

    # This value defines the timeout for sockets in seconds.  Per default python
    # sockets do never timeout and as such we have blocking workers.
    # Socket timeouts are set globally within the whole application.
    # The value *must* be a floating point value.
    socket.setdefaulttimeout(10.0)

    return revision
コード例 #9
0
    def __init__(self, ui, path, path2):
        localrepo.localrepository.__init__(self, ui, path)
        self.ui.setconfig('phases', 'publish', False)

        self._url = 'union:%s+%s' % (util.expandpath(path),
                                     util.expandpath(path2))
        self.repo2 = localrepo.localrepository(ui, path2)
コード例 #10
0
ファイル: unionrepo.py プロジェクト: jeffjirsa/rhodecode
    def __init__(self, ui, path, path2):
        localrepo.localrepository.__init__(self, ui, path)
        self.ui.setconfig('phases', 'publish', False)

        self._url = 'union:%s+%s' % (util.expandpath(path),
                                     util.expandpath(path2))
        self.repo2 = localrepo.localrepository(ui, path2)
コード例 #11
0
def _checkevolve(ui, cw, hg_version):
    if hg_version < (4, 3, 0):
        ui.warn(EVOLVE_INCOMPATIBLE)
        return

    remote_evolve_path = 'https://www.mercurial-scm.org/repo/evolve/'
    # Install to the same dir as v-c-t, unless the mozbuild directory path is passed (testing)
    evolve_clone_dir = ui.config('mozilla', 'mozbuild_state_path', _vcthome())

    local_evolve_path = '{evolve_clone_dir}/evolve'.format(
        evolve_clone_dir=evolve_clone_dir)
    evolve_config_value = '{evolve_path}/hgext3rd/evolve'.format(
        evolve_path=local_evolve_path)

    # If evolve is not installed, install it
    if not ui.hasconfig('extensions', 'evolve'):
        if uipromptchoice(ui, EVOLVE_INFO_WARNING):
            return

        try:
            # Clone the evolve extension and enable
            hg.clone(ui, {},
                     remote_evolve_path,
                     branch=('stable', ),
                     dest=local_evolve_path)
            _enableext(cw, 'evolve', evolve_config_value)

            ui.write('Evolve was downloaded successfully.\n')

        except error.Abort as hg_err:
            ui.write(str(hg_err))
            ui.write(EVOLVE_CLONE_ERROR)

    # If evolve is installed and managed by this wizard,
    # update it via pull/update
    elif ui.config('extensions', 'evolve') == evolve_config_value:
        if uipromptchoice(
                ui, EVOLVE_UPDATE_PROMPT.format(evolve_dir=local_evolve_path)):
            return

        try:
            local_evolve_repo = localrepo.localrepository(
                ui, local_evolve_path)

            # Pull the latest stable, update to tip
            hgpull(ui,
                   local_evolve_repo,
                   source=remote_evolve_path,
                   branch=('stable', ))
            hgupdate(ui, local_evolve_repo, rev='stable')

            ui.write('Evolve was updated successfully.\n')

        except error.Abort as hg_err:
            ui.write(EVOLVE_CLONE_ERROR)

    # If evolve is not managed by this wizard, do nothing
    else:
        return
コード例 #12
0
ファイル: feedupdate.py プロジェクト: pyconjp/2012.pycon.jp
def load_repository(path):
    u'''
    ローカルディスクにあるリポジトリを開く
    '''

    ui = uimod.ui()

    return localrepo.localrepository(ui, path)
コード例 #13
0
 def __init__(self, url, daemons):
     if not url.endswith("/"):
         url += "/"
     self.url = url + "main/update/"
     self.repo = localrepo.localrepository(ui.ui(), path=".")
     self.tip = "".join("%02x" % ord(c) for c in self.repo.changelog.tip())
     self.branch = self.repo.dirstate.branch()
     self.daemons = daemons
コード例 #14
0
ファイル: tohg.py プロジェクト: corecode/fromcvs
 def __init__(self, ins, outs, hgroot):
     self.ins = ins
     self.outs = outs
     self.ui = ui.ui(interactive = False)
     self.hgrepo = localrepo.localrepository(self.ui, hgroot)
     self.start()
     self.last_date()
     self.branchlist()
コード例 #15
0
def get_bookmark_map(repo):
    project_root = os.path.abspath(os.path.normpath(get_project_root(repo.root)))
    if repo.root == os.path.abspath(os.path.normpath(project_root)):
        project_repo = repo
    else:
        project_repo = localrepo.localrepository(repo.baseui, project_root)
    branch_map = mapped_branches(DEFAULT_BRANCH, list(project_repo._bookmarks))[1]
    if project_repo is repo:
        branch_map = {k: '___'.join((k, v)) for k, v in branch_map.items()}
    bookmark_map = dict(map(reversed, branch_map.items()))
    return branch_map, bookmark_map
コード例 #16
0
    def api_update(self, request):
        if not hasattr(self, "repo"):
            self.repo = localrepo.localrepository(ui.ui(), path=".")
            self.tip = "".join("%02x" % ord(c)
                               for c in self.repo.changelog.tip())
            self.branch = self.repo.dirstate.branch()

        return [{
            "name": "noc",
            "repo": "%shg/noc/" % self.get_url(request),
            "branch": self.branch,
            "tip": self.tip
        }]
コード例 #17
0
def get_bookmark_map(repo):
    project_root = os.path.abspath(
        os.path.normpath(get_project_root(repo.root)))
    if repo.root == os.path.abspath(os.path.normpath(project_root)):
        project_repo = repo
    else:
        project_repo = localrepo.localrepository(repo.baseui, project_root)
    branch_map = mapped_branches(DEFAULT_BRANCH,
                                 list(project_repo._bookmarks))[1]
    if project_repo is repo:
        branch_map = {k: '___'.join((k, v)) for k, v in branch_map.items()}
    bookmark_map = dict(map(reversed, branch_map.items()))
    return branch_map, bookmark_map
コード例 #18
0
ファイル: repo.py プロジェクト: PierrePaul/Orgapp
 def __init__(self, path, vcs_type):
     self.ui = hgui.ui()
     self.path = path
     self.vcs_type = vcs_type
     if self.vcs_type == 'git':
         if not os.path.exists(self.path):
             os.makedirs(self.path)
         try:
             self.r = gitrepo.Repo(self.path)
         except:
             self.r = gitrepo.Repo.init(self.path)
     elif self.vcs_type == 'hg':
         if not os.path.exists(self.path):
             os.makedirs(self.path)
         try:
             self.r = hgrepo.localrepository(
                 self.ui,
                 self.path)
         except:
             hg.init(self.ui, self.path)
             self.r = hgrepo.localrepository(
                 self.ui,
                 self.path)
コード例 #19
0
def get_tip():
    global TIP

    if TIP:
        return TIP

    try:
        from mercurial import ui, localrepo, error
    except ImportError:
        return None
    try:
        repo = localrepo.localrepository(ui.ui(), path=".")
    except error.RepoError:
        return None
    TIP = repo.changelog.tip()[:6].encode("hex")
    return TIP
コード例 #20
0
    def __init__(self, path=None, workdir=None, create=False):
        self.path = path
        self.workdir = workdir
        # XXX: path only handling
        if workdir is not None:
            self.repo = workdir.repo
            self.ui = self.repo.ui

        elif path is not None:
            try:
                repo = localrepo.localrepository(ui.ui(),
                                                 str(path),
                                                 create=create)
            except error.RepoError:
                raise NotFoundError('mercurial', path)

            self.ui = repo.ui
            self.repo = repo
コード例 #21
0
ファイル: __init__.py プロジェクト: cgnkev/inyoka-legacy
def _bootstrap():
    """Get the Inyoka version and store it."""
    global INYOKA_REVISION

    # the path to the contents of the Inyoka module
    conts = os.environ.setdefault('INYOKA_MODULE',
                                  realpath(join(dirname(__file__))))
    # the path to the Inyoka instance folder
    os.environ['INYOKA_INSTANCE'] = realpath(join(conts, pardir))
    os.environ['CELERY_LOADER'] = 'inyoka.core.celery_support.CeleryLoader'

    # get the `INYOKA_REVISION` using the mercurial python api
    try:
        ui = hgui.ui()
        repository = localrepository(ui, join(conts, '..'))
        ctx = repository['tip']
        INYOKA_REVISION = ('%(num)s:%(id)s' % {
            'num': ctx.rev(),
            'id': shorthex(ctx.node())
        })
    except TypeError:
        # fail silently
        pass

    # This value defines the timeout for sockets in seconds.  Per default python
    # sockets do never timeout and as such we have blocking workers.
    # Socket timeouts are set globally within the whole application.
    # The value *must* be a floating point value.
    socket.setdefaulttimeout(10.0)

    #: bind the context
    ctx = ApplicationContext()
    ctx.bind()

    # setup components
    ctx.load_packages(ctx.cfg['activated_components'])
    if ctx.cfg['testing']:
        logger.level_name = 'ERROR'

    # makes INYOKA_REVISION visible in the extra dict of every log record
    proc = Processor(lambda x: x.extra.update(INYOKA_REVISION=INYOKA_REVISION))
    proc.push_application()
コード例 #22
0
ファイル: __init__.py プロジェクト: EnTeQuAk/inyoka-legacy
def _bootstrap():
    """Get the Inyoka version and store it."""
    global INYOKA_REVISION

    # the path to the contents of the Inyoka module
    conts = os.environ.setdefault("INYOKA_MODULE", realpath(join(dirname(__file__))))
    # the path to the Inyoka instance folder
    os.environ["INYOKA_INSTANCE"] = realpath(join(conts, pardir))
    os.environ["CELERY_LOADER"] = "inyoka.core.celery_support.CeleryLoader"

    # get the `INYOKA_REVISION` using the mercurial python api
    try:
        ui = hgui.ui()
        repository = localrepository(ui, join(conts, ".."))
        ctx = repository["tip"]
        INYOKA_REVISION = "%(num)s:%(id)s" % {"num": ctx.rev(), "id": shorthex(ctx.node())}
    except TypeError:
        # fail silently
        pass

    # This value defines the timeout for sockets in seconds.  Per default python
    # sockets do never timeout and as such we have blocking workers.
    # Socket timeouts are set globally within the whole application.
    # The value *must* be a floating point value.
    socket.setdefaulttimeout(10.0)

    #: bind the context
    ctx = ApplicationContext()
    ctx.bind()

    # setup components
    ctx.load_packages(ctx.cfg["activated_components"])
    if ctx.cfg["testing"]:
        logger.level_name = "ERROR"

    # makes INYOKA_REVISION visible in the extra dict of every log record
    proc = Processor(lambda x: x.extra.update(INYOKA_REVISION=INYOKA_REVISION))
    proc.push_application()
コード例 #23
0
def get_version():
    """
    Returns NOC version. Version formats are:
    * X.Y.Z -- releases
    * X.Y.Z-<tip> -- hotfixes
    * X.Y.Zpre<tip> -- pre-releases (release/* branch)
    * X.Y.Zdev<tip> -- develop
    :return:
    """
    global _version
    if _version:
        return _version
    # Get base version
    with open("VERSION") as f:
        v = f.read().split()[0].strip()
    if not os.path.isdir(".hg"):
        return v
    # Get branch
    try:
        from mercurial import ui, localrepo
    except ImportError:
        return v
    repo = localrepo.localrepository(ui.ui(), path=".")
    tip = repo.changelog.rev(repo.changelog.tip())
    branch = repo.dirstate.branch()
    if branch == "default":
        # Release
        _version = v
    elif branch.startswith("hotfix/"):
        # Hotfix
        _version = "%s-%s" % (v, tip)
    elif branch.startswith("release/"):
        # Release candidate
        _version = "%spre%s" % (v, tip)
    else:
        # Develop or feature branch
        _version = "%sdev%s" % (v, tip)
    return _version
コード例 #24
0
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See :hg:`help templates` for information on templates and filters.
    '''
    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in sorted(items):
            ui.write('%s = %s\n' % (k, v))

    fn = 'demo.txt'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repository at %s\n') % tmpdir)
    if repo is None:
        baseui = ui
    else:
        baseui = repo.baseui
    repo = localrepo.localrepository(baseui, tmpdir, True)
    ui.setconfig('keyword', fn, '', 'keyword')
    svn = ui.configbool('keywordset', 'svn')
    # explicitly set keywordset for demo output
    ui.setconfig('keywordset', 'svn', svn, 'keyword')

    uikwmaps = ui.configitems('keywordmaps')
    if args or opts.get(r'rcfile'):
        ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
        if uikwmaps:
            ui.status(_('\textending current template maps\n'))
        if opts.get(r'default') or not uikwmaps:
            if svn:
                ui.status(_('\toverriding default svn keywordset\n'))
            else:
                ui.status(_('\toverriding default cvs keywordset\n'))
        if opts.get(r'rcfile'):
            ui.readconfig(opts.get('rcfile'))
        if args:
            # simulate hgrc parsing
            rcmaps = '[keywordmaps]\n%s\n' % '\n'.join(args)
            repo.vfs.write('hgrc', rcmaps)
            ui.readconfig(repo.vfs.join('hgrc'))
        kwmaps = dict(ui.configitems('keywordmaps'))
    elif opts.get(r'default'):
        if svn:
            ui.status(_('\n\tconfiguration using default svn keywordset\n'))
        else:
            ui.status(_('\n\tconfiguration using default cvs keywordset\n'))
        kwmaps = _defaultkwmaps(ui)
        if uikwmaps:
            ui.status(_('\tdisabling current template maps\n'))
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v, 'keyword')
    else:
        ui.status(_('\n\tconfiguration using current keyword template maps\n'))
        if uikwmaps:
            kwmaps = dict(uikwmaps)
        else:
            kwmaps = _defaultkwmaps(ui)

    uisetup(ui)
    reposetup(ui, repo)
    ui.write(('[extensions]\nkeyword =\n'))
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordset', ui.configitems('keywordset'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
    repo.wvfs.write(fn, keywords)
    repo[None].add([fn])
    ui.note(_('\nkeywords written to %s:\n') % fn)
    ui.note(keywords)
    with repo.wlock():
        repo.dirstate.setbranch('demobranch')
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '', 'keyword')
    msg = _('hg keyword configuration and expansion example')
    ui.note(("hg ci -m '%s'\n" % msg))
    repo.commit(text=msg)
    ui.status(_('\n\tkeywords expanded\n'))
    ui.write(repo.wread(fn))
    repo.wvfs.rmtree(repo.root)
コード例 #25
0
ファイル: keyword.py プロジェクト: leetaizhu/Odoo_ENV_MAC_OS
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See :hg:`help templates` for information on templates and filters.
    '''
    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in sorted(items):
            ui.write('%s = %s\n' % (k, v))

    fn = 'demo.txt'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repository at %s\n') % tmpdir)
    repo = localrepo.localrepository(repo.baseui, tmpdir, True)
    ui.setconfig('keyword', fn, '', 'keyword')
    svn = ui.configbool('keywordset', 'svn')
    # explicitly set keywordset for demo output
    ui.setconfig('keywordset', 'svn', svn, 'keyword')

    uikwmaps = ui.configitems('keywordmaps')
    if args or opts.get('rcfile'):
        ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
        if uikwmaps:
            ui.status(_('\textending current template maps\n'))
        if opts.get('default') or not uikwmaps:
            if svn:
                ui.status(_('\toverriding default svn keywordset\n'))
            else:
                ui.status(_('\toverriding default cvs keywordset\n'))
        if opts.get('rcfile'):
            ui.readconfig(opts.get('rcfile'))
        if args:
            # simulate hgrc parsing
            rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
            fp = repo.opener('hgrc', 'w')
            fp.writelines(rcmaps)
            fp.close()
            ui.readconfig(repo.join('hgrc'))
        kwmaps = dict(ui.configitems('keywordmaps'))
    elif opts.get('default'):
        if svn:
            ui.status(_('\n\tconfiguration using default svn keywordset\n'))
        else:
            ui.status(_('\n\tconfiguration using default cvs keywordset\n'))
        kwmaps = _defaultkwmaps(ui)
        if uikwmaps:
            ui.status(_('\tdisabling current template maps\n'))
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v, 'keyword')
    else:
        ui.status(_('\n\tconfiguration using current keyword template maps\n'))
        if uikwmaps:
            kwmaps = dict(uikwmaps)
        else:
            kwmaps = _defaultkwmaps(ui)

    uisetup(ui)
    reposetup(ui, repo)
    ui.write('[extensions]\nkeyword =\n')
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordset', ui.configitems('keywordset'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
    repo.wopener.write(fn, keywords)
    repo[None].add([fn])
    ui.note(_('\nkeywords written to %s:\n') % fn)
    ui.note(keywords)
    wlock = repo.wlock()
    try:
        repo.dirstate.setbranch('demobranch')
    finally:
        wlock.release()
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '', 'keyword')
    msg = _('hg keyword configuration and expansion example')
    ui.note(("hg ci -m '%s'\n" % msg))
    repo.commit(text=msg)
    ui.status(_('\n\tkeywords expanded\n'))
    ui.write(repo.wread(fn))
    shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #26
0

def print(*args, **kwargs):
    """print() wrapper that flushes stdout buffers to avoid py3 buffer issues

    We could also just write directly to sys.stdout.buffer the way the
    ui object will, but this was easier for porting the test.
    """
    print_(*args, **kwargs)
    sys.stdout.flush()


u = uimod.ui.load()

print('% creating repo')
repo = localrepo.localrepository(u, b'.', create=True)

f = open('test.py', 'w')
try:
    f.write('foo\n')
finally:
    f.close

print('% add and commit')
commands.add(u, repo, b'test.py')
commands.commit(u, repo, message=b'*')
commands.status(u, repo, clean=True)

print('% change')
f = open('test.py', 'w')
try:
コード例 #27
0
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See "hg help templates" for information on templates and filters.
    '''
    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in sorted(items):
            ui.write('%s = %s\n' % (k, v))

    msg = 'hg keyword config and expansion example'
    fn = 'demo.txt'
    branchname = 'demobranch'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repository at %s\n') % tmpdir)
    repo = localrepo.localrepository(ui, tmpdir, True)
    ui.setconfig('keyword', fn, '')

    uikwmaps = ui.configitems('keywordmaps')
    if args or opts.get('rcfile'):
        ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
        if uikwmaps:
            ui.status(_('\textending current template maps\n'))
        if opts.get('default') or not uikwmaps:
            ui.status(_('\toverriding default template maps\n'))
        if opts.get('rcfile'):
            ui.readconfig(opts.get('rcfile'))
        if args:
            # simulate hgrc parsing
            rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
            fp = repo.opener('hgrc', 'w')
            fp.writelines(rcmaps)
            fp.close()
            ui.readconfig(repo.join('hgrc'))
        kwmaps = dict(ui.configitems('keywordmaps'))
    elif opts.get('default'):
        ui.status(_('\n\tconfiguration using default keyword template maps\n'))
        kwmaps = kwtemplater.templates
        if uikwmaps:
            ui.status(_('\tdisabling current template maps\n'))
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v)
    else:
        ui.status(_('\n\tconfiguration using current keyword template maps\n'))
        kwmaps = dict(uikwmaps) or kwtemplater.templates

    uisetup(ui)
    reposetup(ui, repo)
    for k, v in ui.configitems('extensions'):
        if k.endswith('keyword'):
            extension = '%s = %s' % (k, v)
            break
    ui.write('[extensions]\n%s\n' % extension)
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
    repo.wopener(fn, 'w').write(keywords)
    repo.add([fn])
    path = repo.wjoin(fn)
    ui.note(_('\nkeywords written to %s:\n') % path)
    ui.note(keywords)
    ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
    # silence branch command if not verbose
    quiet = ui.quiet
    ui.quiet = not ui.verbose
    commands.branch(ui, repo, branchname)
    ui.quiet = quiet
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '')
    ui.note(_('unhooked all commit hooks\n'))
    ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
    repo.commit(text=msg)
    ui.status(_('\n\tkeywords expanded\n'))
    ui.write(repo.wread(fn))
    ui.debug('\nremoving temporary repository %s\n' % tmpdir)
    shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #28
0
def main():
    ui = uimod.ui()
    # Needed so we can open a local repo with obsstore without a warning.
    ui.setconfig('experimental', 'evolution.createmarkers', True)

    checkzobject(badpeer())

    ziverify.verifyClass(repository.ipeerbase, httppeer.httppeer)
    checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None,
                                   None))

    ziverify.verifyClass(repository.ipeerconnection, httppeer.httpv2peer)
    ziverify.verifyClass(repository.ipeercapabilities, httppeer.httpv2peer)
    checkzobject(httppeer.httpv2peer(None, b'', b'', None, None, None))

    ziverify.verifyClass(repository.ipeerbase, localrepo.localpeer)
    checkzobject(localrepo.localpeer(dummyrepo()))

    ziverify.verifyClass(repository.ipeercommandexecutor,
                         localrepo.localcommandexecutor)
    checkzobject(localrepo.localcommandexecutor(None))

    ziverify.verifyClass(repository.ipeercommandexecutor,
                         wireprotov1peer.peerexecutor)
    checkzobject(wireprotov1peer.peerexecutor(None))

    ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv1peer)
    checkzobject(
        sshpeer.sshv1peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
                          dummypipe(), None, None))

    ziverify.verifyClass(repository.ipeerbase, sshpeer.sshv2peer)
    checkzobject(
        sshpeer.sshv2peer(ui, b'ssh://localhost/foo', b'', dummypipe(),
                          dummypipe(), None, None))

    ziverify.verifyClass(repository.ipeerbase, bundlerepo.bundlepeer)
    checkzobject(bundlerepo.bundlepeer(dummyrepo()))

    ziverify.verifyClass(repository.ipeerbase, statichttprepo.statichttppeer)
    checkzobject(statichttprepo.statichttppeer(dummyrepo()))

    ziverify.verifyClass(repository.ipeerbase, unionrepo.unionpeer)
    checkzobject(unionrepo.unionpeer(dummyrepo()))

    ziverify.verifyClass(repository.completelocalrepository,
                         localrepo.localrepository)
    repo = localrepo.localrepository(ui, rootdir)
    checkzobject(repo)

    ziverify.verifyClass(wireprototypes.baseprotocolhandler,
                         wireprotoserver.sshv1protocolhandler)
    ziverify.verifyClass(wireprototypes.baseprotocolhandler,
                         wireprotoserver.sshv2protocolhandler)
    ziverify.verifyClass(wireprototypes.baseprotocolhandler,
                         wireprotoserver.httpv1protocolhandler)
    ziverify.verifyClass(wireprototypes.baseprotocolhandler,
                         wireprotov2server.httpv2protocolhandler)

    sshv1 = wireprotoserver.sshv1protocolhandler(None, None, None)
    checkzobject(sshv1)
    sshv2 = wireprotoserver.sshv2protocolhandler(None, None, None)
    checkzobject(sshv2)

    httpv1 = wireprotoserver.httpv1protocolhandler(None, None, None)
    checkzobject(httpv1)
    httpv2 = wireprotov2server.httpv2protocolhandler(None, None)
    checkzobject(httpv2)

    ziverify.verifyClass(repository.ifilestorage, filelog.filelog)

    vfs = vfsmod.vfs(b'.')
    fl = filelog.filelog(vfs, b'dummy.i')
    checkzobject(fl, allowextra=True)
コード例 #29
0
ファイル: keyword.py プロジェクト: saminigod/cygwin
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps
    and their expansion.

    Extend current configuration by specifying maps as arguments
    and optionally by reading from an additional hgrc file.

    Override current keyword template maps with "default" option.
    '''
    def demostatus(stat):
        ui.status(_('\n\t%s\n') % stat)

    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in items:
            ui.write('%s = %s\n' % (k, v))

    msg = 'hg keyword config and expansion example'
    kwstatus = 'current'
    fn = 'demo.txt'
    branchname = 'demobranch'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repo at %s\n') % tmpdir)
    repo = localrepo.localrepository(ui, path=tmpdir, create=True)
    ui.setconfig('keyword', fn, '')
    if args or opts.get('rcfile'):
        kwstatus = 'custom'
    if opts.get('rcfile'):
        ui.readconfig(opts.get('rcfile'))
    if opts.get('default'):
        kwstatus = 'default'
        kwmaps = kwtemplater.templates
        if ui.configitems('keywordmaps'):
            # override maps from optional rcfile
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v)
    elif args:
        # simulate hgrc parsing
        rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
        fp = repo.opener('hgrc', 'w')
        fp.writelines(rcmaps)
        fp.close()
        ui.readconfig(repo.join('hgrc'))
    if not opts.get('default'):
        kwmaps = dict(ui.configitems('keywordmaps')) or kwtemplater.templates
    reposetup(ui, repo)
    for k, v in ui.configitems('extensions'):
        if k.endswith('keyword'):
            extension = '%s = %s' % (k, v)
            break
    demostatus('config using %s keyword template maps' % kwstatus)
    ui.write('[extensions]\n%s\n' % extension)
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
    repo.wopener(fn, 'w').write(keywords)
    repo.add([fn])
    path = repo.wjoin(fn)
    ui.note(_('\n%s keywords written to %s:\n') % (kwstatus, path))
    ui.note(keywords)
    ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
    # silence branch command if not verbose
    quiet = ui.quiet
    ui.quiet = not ui.verbose
    commands.branch(ui, repo, branchname)
    ui.quiet = quiet
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '')
    ui.note(_('unhooked all commit hooks\n'))
    ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
    repo.commit(text=msg)
    format = ui.verbose and ' in %s' % path or ''
    demostatus('%s keywords expanded%s' % (kwstatus, format))
    ui.write(repo.wread(fn))
    ui.debug(_('\nremoving temporary repo %s\n') % tmpdir)
    shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #30
0
#!/usr/bin/env python
from __future__ import absolute_import, print_function

from mercurial import (
    commands,
    localrepo,
    ui as uimod,
)

u = uimod.ui()

print('% creating repo')
repo = localrepo.localrepository(u, '.', create=True)

f = open('test.py', 'w')
try:
    f.write('foo\n')
finally:
    f.close

print('% add and commit')
commands.add(u, repo, 'test.py')
commands.commit(u, repo, message='*')
commands.status(u, repo, clean=True)


print('% change')
f = open('test.py', 'w')
try:
    f.write('bar\n')
finally:
コード例 #31
0
ファイル: repo.py プロジェクト: oshepherd/eforge
 def __init__(self, path):
     self.ui   = ui()
     self.repo = localrepository(self.ui, path)
     self.path = path
コード例 #32
0
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend current configuration by specifying maps as arguments and
    optionally by reading from an additional hgrc file.

    Override current keyword template maps with "default" option.
    '''
    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in items:
            ui.write('%s = %s\n' % (k, v))

    msg = 'hg keyword config and expansion example'
    kwstatus = 'current'
    fn = 'demo.txt'
    branchname = 'demobranch'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repository at %s\n') % tmpdir)
    repo = localrepo.localrepository(ui, tmpdir, True)
    ui.setconfig('keyword', fn, '')
    if args or opts.get('rcfile'):
        kwstatus = 'custom'
    if opts.get('rcfile'):
        ui.readconfig(opts.get('rcfile'))
    if opts.get('default'):
        kwstatus = 'default'
        kwmaps = kwtemplater.templates
        if ui.configitems('keywordmaps'):
            # override maps from optional rcfile
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v)
    elif args:
        # simulate hgrc parsing
        rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
        fp = repo.opener('hgrc', 'w')
        fp.writelines(rcmaps)
        fp.close()
        ui.readconfig(repo.join('hgrc'))
    if not opts.get('default'):
        kwmaps = dict(ui.configitems('keywordmaps')) or kwtemplater.templates
    uisetup(ui)
    reposetup(ui, repo)
    for k, v in ui.configitems('extensions'):
        if k.endswith('keyword'):
            extension = '%s = %s' % (k, v)
            break
    ui.status(_('\n\tconfig using %s keyword template maps\n') % kwstatus)
    ui.write('[extensions]\n%s\n' % extension)
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(kwmaps.keys()) + '$\n'
    repo.wopener(fn, 'w').write(keywords)
    repo.add([fn])
    path = repo.wjoin(fn)
    ui.note(_('\n%s keywords written to %s:\n') % (kwstatus, path))
    ui.note(keywords)
    ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
    # silence branch command if not verbose
    quiet = ui.quiet
    ui.quiet = not ui.verbose
    commands.branch(ui, repo, branchname)
    ui.quiet = quiet
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '')
    ui.note(_('unhooked all commit hooks\n'))
    ui.note('hg -R "%s" ci -m "%s"\n' % (tmpdir, msg))
    repo.commit(text=msg)
    fmt = ui.verbose and ' in %s' % path or ''
    ui.status(_('\n\t%s keywords expanded%s\n') % (kwstatus, fmt))
    ui.write(repo.wread(fn))
    ui.debug(_('\nremoving temporary repository %s\n') % tmpdir)
    shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #33
0
ファイル: hg.py プロジェクト: ErfanBagheri/starcal
def prepareObj(obj):
    obj.repo = localrepository(mercurial.ui.ui(), obj.vcsDir)
コード例 #34
0
ファイル: keyword.py プロジェクト: yangdy-buji/idea-community
def demo(ui, repo, *args, **opts):
    '''print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See "hg help templates" for information on templates and filters.
    '''
    def demoitems(section, items):
        ui.write('[%s]\n' % section)
        for k, v in sorted(items):
            ui.write('%s = %s\n' % (k, v))

    fn = 'demo.txt'
    branchname = 'demobranch'
    tmpdir = tempfile.mkdtemp('', 'kwdemo.')
    ui.note(_('creating temporary repository at %s\n') % tmpdir)
    repo = localrepo.localrepository(ui, tmpdir, True)
    ui.setconfig('keyword', fn, '')

    uikwmaps = ui.configitems('keywordmaps')
    if args or opts.get('rcfile'):
        ui.status(_('\n\tconfiguration using custom keyword template maps\n'))
        if uikwmaps:
            ui.status(_('\textending current template maps\n'))
        if opts.get('default') or not uikwmaps:
            ui.status(_('\toverriding default template maps\n'))
        if opts.get('rcfile'):
            ui.readconfig(opts.get('rcfile'))
        if args:
            # simulate hgrc parsing
            rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
            fp = repo.opener('hgrc', 'w')
            fp.writelines(rcmaps)
            fp.close()
            ui.readconfig(repo.join('hgrc'))
        kwmaps = dict(ui.configitems('keywordmaps'))
    elif opts.get('default'):
        ui.status(_('\n\tconfiguration using default keyword template maps\n'))
        kwmaps = kwtemplater.templates
        if uikwmaps:
            ui.status(_('\tdisabling current template maps\n'))
            for k, v in kwmaps.iteritems():
                ui.setconfig('keywordmaps', k, v)
    else:
        ui.status(_('\n\tconfiguration using current keyword template maps\n'))
        kwmaps = dict(uikwmaps) or kwtemplater.templates

    uisetup(ui)
    reposetup(ui, repo)
    for k, v in ui.configitems('extensions'):
        if k.endswith('keyword'):
            extension = '%s = %s' % (k, v)
            break
    ui.write('[extensions]\n%s\n' % extension)
    demoitems('keyword', ui.configitems('keyword'))
    demoitems('keywordmaps', kwmaps.iteritems())
    keywords = '$' + '$\n$'.join(sorted(kwmaps.keys())) + '$\n'
    repo.wopener(fn, 'w').write(keywords)
    repo.add([fn])
    path = repo.wjoin(fn)
    ui.note(_('\nkeywords written to %s:\n') % path)
    ui.note(keywords)
    ui.note('\nhg -R "%s" branch "%s"\n' % (tmpdir, branchname))
    # silence branch command if not verbose
    quiet = ui.quiet
    ui.quiet = not ui.verbose
    commands.branch(ui, repo, branchname)
    ui.quiet = quiet
    for name, cmd in ui.configitems('hooks'):
        if name.split('.', 1)[0].find('commit') > -1:
            repo.ui.setconfig('hooks', name, '')
    ui.note(_('unhooked all commit hooks\n'))
    msg = _('hg keyword configuration and expansion example')
    ui.note("hg -R '%s' ci -m '%s'\n" % (tmpdir, msg))
    repo.commit(text=msg)
    ui.status(_('\n\tkeywords expanded\n'))
    ui.write(repo.wread(fn))
    ui.debug('\nremoving temporary repository %s\n' % tmpdir)
    shutil.rmtree(tmpdir, ignore_errors=True)
コード例 #35
0
#!/usr/bin/python
from mercurial.ui import ui
from mercurial.localrepo import localrepository
from mercurial.commands import add, commit, status

u = ui()

print "% creating repo"
repo = localrepository(u, ".", create=True)

f = open("test.py", "w")
try:
    f.write("foo\n")
finally:
    f.close

print "% add and commit"
add(u, repo, "test.py")
commit(u, repo, message="*")
status(u, repo, clean=True)


print "% change"
f = open("test.py", "w")
try:
    f.write("bar\n")
finally:
    f.close()

# this would return clean instead of changed before the fix
status(u, repo, clean=True, modified=True)
コード例 #36
0
import subprocess
import xmlrpclib
from mercurial.localrepo import localrepository
from mercurial.ui import ui

REPOPATH = os.path.join(os.environ['REPOSITORY'], 'filemq')
STAGEPATH = os.path.join(os.environ['STAGING'])
SERVER = 'stage_file_pipeline'

# Change to repository
os.chdir(REPOPATH)

# Update repository
subprocess.check_call(['hg', 'up'])

# Install the fileprocess
subprocess.check_call([STAGEPATH+'/bin/python', 'setup.py', 'install'])

# Restart the fileprocess
proxy = xmlrpclib.ServerProxy('http://localhost:9001')
if proxy.supervisor.getProcessInfo(SERVER)['statename'] == 'RUNNING':
    proxy.supervisor.stopProcess(SERVER)

proxy.supervisor.startProcess(SERVER)

# Record the current version.
repo = localrepository(ui(), os.environ['REPOSITORY'])
fd = open(os.path.join(os.environ['STAGING'], 'pipeline-changeset'), 'w')
fd.write(str(repo.changectx()))
fd.close()
コード例 #37
0
ファイル: keyword.py プロジェクト: pierfort123/mercurial
def demo(ui, repo, *args, **opts):
    """print [keywordmaps] configuration and an expansion example

    Show current, custom, or default keyword template maps and their
    expansions.

    Extend the current configuration by specifying maps as arguments
    and using -f/--rcfile to source an external hgrc file.

    Use -d/--default to disable current configuration.

    See :hg:`help templates` for information on templates and filters.
    """

    def demoitems(section, items):
        ui.write("[%s]\n" % section)
        for k, v in sorted(items):
            ui.write("%s = %s\n" % (k, v))

    fn = "demo.txt"
    tmpdir = tempfile.mkdtemp("", "kwdemo.")
    ui.note(_("creating temporary repository at %s\n") % tmpdir)
    repo = localrepo.localrepository(repo.baseui, tmpdir, True)
    ui.setconfig("keyword", fn, "", "keyword")
    svn = ui.configbool("keywordset", "svn")
    # explicitly set keywordset for demo output
    ui.setconfig("keywordset", "svn", svn, "keyword")

    uikwmaps = ui.configitems("keywordmaps")
    if args or opts.get("rcfile"):
        ui.status(_("\n\tconfiguration using custom keyword template maps\n"))
        if uikwmaps:
            ui.status(_("\textending current template maps\n"))
        if opts.get("default") or not uikwmaps:
            if svn:
                ui.status(_("\toverriding default svn keywordset\n"))
            else:
                ui.status(_("\toverriding default cvs keywordset\n"))
        if opts.get("rcfile"):
            ui.readconfig(opts.get("rcfile"))
        if args:
            # simulate hgrc parsing
            rcmaps = ["[keywordmaps]\n"] + [a + "\n" for a in args]
            fp = repo.vfs("hgrc", "w")
            fp.writelines(rcmaps)
            fp.close()
            ui.readconfig(repo.join("hgrc"))
        kwmaps = dict(ui.configitems("keywordmaps"))
    elif opts.get("default"):
        if svn:
            ui.status(_("\n\tconfiguration using default svn keywordset\n"))
        else:
            ui.status(_("\n\tconfiguration using default cvs keywordset\n"))
        kwmaps = _defaultkwmaps(ui)
        if uikwmaps:
            ui.status(_("\tdisabling current template maps\n"))
            for k, v in kwmaps.iteritems():
                ui.setconfig("keywordmaps", k, v, "keyword")
    else:
        ui.status(_("\n\tconfiguration using current keyword template maps\n"))
        if uikwmaps:
            kwmaps = dict(uikwmaps)
        else:
            kwmaps = _defaultkwmaps(ui)

    uisetup(ui)
    reposetup(ui, repo)
    ui.write("[extensions]\nkeyword =\n")
    demoitems("keyword", ui.configitems("keyword"))
    demoitems("keywordset", ui.configitems("keywordset"))
    demoitems("keywordmaps", kwmaps.iteritems())
    keywords = "$" + "$\n$".join(sorted(kwmaps.keys())) + "$\n"
    repo.wvfs.write(fn, keywords)
    repo[None].add([fn])
    ui.note(_("\nkeywords written to %s:\n") % fn)
    ui.note(keywords)
    wlock = repo.wlock()
    try:
        repo.dirstate.setbranch("demobranch")
    finally:
        wlock.release()
    for name, cmd in ui.configitems("hooks"):
        if name.split(".", 1)[0].find("commit") > -1:
            repo.ui.setconfig("hooks", name, "", "keyword")
    msg = _("hg keyword configuration and expansion example")
    ui.note(("hg ci -m '%s'\n" % msg))
    repo.commit(text=msg)
    ui.status(_("\n\tkeywords expanded\n"))
    ui.write(repo.wread(fn))
    repo.wvfs.rmtree(repo.root)