Exemplo n.º 1
0
    def __init__(self, ui, repo, hooktype):
        self.ui = ui
        cfg = self.ui.config('notify', 'config')
        if cfg:
            self.ui.readconfig(cfg, sections=['usersubs', 'reposubs'])
        self.repo = repo
        self.stripcount = int(self.ui.config('notify', 'strip', 0))
        self.root = self.strip(self.repo.root)
        self.domain = self.ui.config('notify', 'domain')
        self.mbox = self.ui.config('notify', 'mbox')
        self.test = self.ui.configbool('notify', 'test', True)
        self.charsets = mail._charsets(self.ui)
        self.subs = self.subscribers()
        self.merge = self.ui.configbool('notify', 'merge', True)

        mapfile = self.ui.config('notify', 'style')
        template = (self.ui.config('notify', hooktype) or
                    self.ui.config('notify', 'template'))
        self.t = cmdutil.changeset_templater(self.ui, self.repo,
                                             False, None, mapfile, False)
        if not mapfile and not template:
            template = deftemplates.get(hooktype) or single_template
        if template:
            template = templater.parsestring(template, quoted=False)
            self.t.use_template(template)
Exemplo n.º 2
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo

        self.ciaurl = self.ui.config('cia', 'url', 'http://cia.vc')
        self.user = self.ui.config('cia', 'user')
        self.project = self.ui.config('cia', 'project')
        self.module = self.ui.config('cia', 'module')
        self.diffstat = self.ui.configbool('cia', 'diffstat')
        self.emailfrom = self.ui.config('email', 'from')
        self.dryrun = self.ui.configbool('cia', 'test')
        self.url = self.ui.config('web', 'baseurl')
        # Default to -1 for backward compatibility
        self.stripcount = int(self.ui.config('cia', 'strip', -1))
        self.root = self.strip(self.repo.root)

        style = self.ui.config('cia', 'style')
        template = self.ui.config('cia', 'template')
        if not template:
            template = self.diffstat and self.dstemplate or self.deftemplate
        template = templater.parsestring(template, quoted=False)
        t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
                                        style, False)
        t.use_template(template)
        self.templater = t
Exemplo n.º 3
0
    def update(self, bugid, newstate, ctx):
        '''update bugzilla bug with reference to changeset.'''

        def webroot(root):
            '''strip leading prefix of repo root and turn into
            url-safe path.'''
            count = int(self.ui.config('bugzilla', 'strip', 0))
            root = util.pconvert(root)
            while count > 0:
                c = root.find('/')
                if c == -1:
                    break
                root = root[c + 1:]
                count -= 1
            return root

        mapfile = self.ui.config('bugzilla', 'style')
        tmpl = self.ui.config('bugzilla', 'template')
        t = cmdutil.changeset_templater(self.ui, self.repo,
                                        False, None, mapfile, False)
        if not mapfile and not tmpl:
            tmpl = _('changeset {node|short} in repo {root} refers '
                     'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
        if tmpl:
            tmpl = templater.parsestring(tmpl, quoted=False)
            t.use_template(tmpl)
        self.ui.pushbuffer()
        t.show(ctx, changes=ctx.changeset(),
               bug=str(bugid),
               hgweb=self.ui.config('web', 'baseurl'),
               root=self.repo.root,
               webroot=webroot(self.repo.root))
        data = self.ui.popbuffer()
        self.updatebug(bugid, newstate, data, util.email(ctx.user()))
Exemplo n.º 4
0
def maketemplater(ui, repo, tmpl):
    tmpl = templater.parsestring(tmpl, quoted=False)
    try:
        t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
                                        None, False)
    except SyntaxError, inst:
        raise util.Abort(inst.args[0])
Exemplo n.º 5
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo

        self.ciaurl = self.ui.config('cia', 'url', 'http://cia.vc')
        self.user = self.ui.config('cia', 'user')
        self.project = self.ui.config('cia', 'project')
        self.module = self.ui.config('cia', 'module')
        self.diffstat = self.ui.configbool('cia', 'diffstat')
        self.emailfrom = self.ui.config('email', 'from')
        self.dryrun = self.ui.configbool('cia', 'test')
        self.url = self.ui.config('web', 'baseurl')
        # Default to -1 for backward compatibility
        self.stripcount = int(self.ui.config('cia', 'strip', -1))
        self.root = self.strip(self.repo.root)

        style = self.ui.config('cia', 'style')
        template = self.ui.config('cia', 'template')
        if not template:
            template = self.diffstat and self.dstemplate or self.deftemplate
        template = templater.parsestring(template, quoted=False)
        t = cmdutil.changeset_templater(self.ui, self.repo, False, None, style,
                                        False)
        t.use_template(template)
        self.templater = t
Exemplo n.º 6
0
def maketemplater(ui, repo, tmpl):
    tmpl = templater.parsestring(tmpl, quoted=False)
    try:
        t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None,
                                        False)
    except SyntaxError, inst:
        raise util.Abort(inst.args[0])
Exemplo n.º 7
0
    def update(self, bugid, ctx):
        '''update bugzilla bug with reference to changeset.'''

        def webroot(root):
            '''strip leading prefix of repo root and turn into
            url-safe path.'''
            count = int(self.ui.config('bugzilla', 'strip', 0))
            root = util.pconvert(root)
            while count > 0:
                c = root.find('/')
                if c == -1:
                    break
                root = root[c+1:]
                count -= 1
            return root

        mapfile = self.ui.config('bugzilla', 'style')
        tmpl = self.ui.config('bugzilla', 'template')
        t = cmdutil.changeset_templater(self.ui, self.repo,
                                        False, None, mapfile, False)
        if not mapfile and not tmpl:
            tmpl = _('changeset {node|short} in repo {root} refers '
                     'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
        if tmpl:
            tmpl = templater.parsestring(tmpl, quoted=False)
            t.use_template(tmpl)
        self.ui.pushbuffer()
        t.show(ctx, changes=ctx.changeset(),
               bug=str(bugid),
               hgweb=self.ui.config('web', 'baseurl'),
               root=self.repo.root,
               webroot=webroot(self.repo.root))
        data = self.ui.popbuffer()
        self.add_comment(bugid, data, util.email(ctx.user()))
Exemplo n.º 8
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [], inc, exc)
        self.restrict = kwtools['hgcmd'] in restricted.split()
        self.postcommit = False

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps: # override default templates
            self.templates = dict((k, templater.parsestring(v, False))
                                  for k, v in kwmaps)
        else:
            self.templates = _defaultkwmaps(self.ui)
Exemplo n.º 9
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [], inc, exc)
        self.restrict = kwtools['hgcmd'] in restricted.split()
        self.record = False

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps: # override default templates
            self.templates = dict((k, templater.parsestring(v, False))
                                  for k, v in kwmaps)
        else:
            self.templates = _defaultkwmaps(self.ui)
        templatefilters.filters.update({'utcdate': utcdate,
                                        'svnisodate': svnisodate,
                                        'svnutcdate': svnutcdate})
Exemplo n.º 10
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
        self.restrict = kwtools['hgcmd'] in restricted.split()

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps:  # override default templates
            kwmaps = [(k, templater.parsestring(v, quoted=False))
                      for (k, v) in kwmaps]
            self.templates = dict(kwmaps)
        escaped = map(re.escape, self.templates.keys())
        kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
        self.re_kw = re.compile(kwpat)

        templatefilters.filters['utcdate'] = utcdate
        self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, '',
                                              False)
Exemplo n.º 11
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [], kwtools['inc'],
                                 kwtools['exc'])
        self.restrict = kwtools['hgcmd'] in restricted.split()

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps:  # override default templates
            self.templates = dict(
                (k, templater.parsestring(v, False)) for k, v in kwmaps)
        escaped = map(re.escape, self.templates.keys())
        kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
        self.re_kw = re.compile(kwpat)

        templatefilters.filters['utcdate'] = utcdate
        self.ct = cmdutil.changeset_templater(self.ui, self.repo, False, None,
                                              '', False)
Exemplo n.º 12
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [],
                                 kwtools['inc'], kwtools['exc'])
        self.restrict = kwtools['hgcmd'] in restricted.split()

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps: # override default templates
            self.templates = dict((k, templater.parsestring(v, False))
                                  for k, v in kwmaps)
        escaped = map(re.escape, self.templates.keys())
        kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
        self.re_kw = re.compile(kwpat)

        templatefilters.filters['utcdate'] = utcdate
        self.ct = cmdutil.changeset_templater(self.ui, self.repo,
                                              False, None, '', False)
Exemplo n.º 13
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [], inc, exc)
        self.restrict = kwtools['hgcmd'] in restricted.split()
        self.record = False

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps:  # override default templates
            self.templates = dict(
                (k, templater.parsestring(v, False)) for k, v in kwmaps)
        else:
            self.templates = _defaultkwmaps(self.ui)
        templatefilters.filters.update({
            'utcdate': utcdate,
            'svnisodate': svnisodate,
            'svnutcdate': svnutcdate
        })
Exemplo n.º 14
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
        self.restrict = kwtools['hgcmd'] in restricted.split()

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps: # override default templates
            kwmaps = [(k, templater.parsestring(v, quoted=False))
                      for (k, v) in kwmaps]
            self.templates = dict(kwmaps)
        escaped = map(re.escape, self.templates.keys())
        kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
        self.re_kw = re.compile(kwpat)

        templatefilters.filters['utcdate'] = utcdate
        self.ct = cmdutil.changeset_templater(self.ui, self.repo,
                                              False, '', False)
Exemplo n.º 15
0
    def __init__(self, ui, repo, inc, exc):
        self.ui = ui
        self.repo = repo
        self.match = match.match(repo.root, '', [], inc, exc)
        self.restrict = kwtools['hgcmd'] in restricted.split()
        self.record = False

        kwmaps = self.ui.configitems('keywordmaps')
        if kwmaps: # override default templates
            self.templates = dict((k, templater.parsestring(v, False))
                                  for k, v in kwmaps)
        else:
            self.templates = _defaultkwmaps(self.ui)
        escaped = '|'.join(map(re.escape, self.templates.keys()))
        self.re_kw = re.compile(r'\$(%s)\$' % escaped)
        self.re_kwexp = re.compile(r'\$(%s): [^$\n\r]*? \$' % escaped)

        templatefilters.filters.update({'utcdate': utcdate,
                                        'svnisodate': svnisodate,
                                        'svnutcdate': svnutcdate})
Exemplo n.º 16
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo

        self.ciaurl = self.ui.config("cia", "url", "http://cia.vc")
        self.user = self.ui.config("cia", "user")
        self.project = self.ui.config("cia", "project")
        self.module = self.ui.config("cia", "module")
        self.diffstat = self.ui.configbool("cia", "diffstat")
        self.emailfrom = self.ui.config("email", "from")
        self.dryrun = self.ui.configbool("cia", "test")
        self.url = self.ui.config("web", "baseurl")

        style = self.ui.config("cia", "style")
        template = self.ui.config("cia", "template")
        if not template:
            template = self.diffstat and self.dstemplate or self.deftemplate
        template = templater.parsestring(template, quoted=False)
        t = cmdutil.changeset_templater(self.ui, self.repo, False, None, style, False)
        t.use_template(template)
        self.templater = t
Exemplo n.º 17
0
    def __init__(self, ui, repo):
        self.ui = ui
        self.repo = repo

        self.ciaurl = self.ui.config("cia", "url", "http://cia.vc")
        self.user = self.ui.config("cia", "user")
        self.project = self.ui.config("cia", "project")
        self.module = self.ui.config("cia", "module")
        self.diffstat = self.ui.configbool("cia", "diffstat")
        self.emailfrom = self.ui.config("email", "from")
        self.dryrun = self.ui.configbool("cia", "test")
        self.url = self.ui.config("web", "baseurl")
        # Default to -1 for backward compatibility
        self.stripcount = int(self.ui.config("cia", "strip", -1))
        self.root = self.strip(self.repo.root)

        style = self.ui.config("cia", "style")
        template = self.ui.config("cia", "template")
        if not template:
            template = self.diffstat and self.dstemplate or self.deftemplate
        template = templater.parsestring(template, quoted=False)
        t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, style, False)
        self.templater = t
Exemplo n.º 18
0
def list_files(ui, repo, *args, **opts):
    """list files and related information

    For each name given that is a file of a type other than a directory,
    displays its name as well as any requested, associated information.
    For each name given that is a directory, displays the names of files
    within that directory, as well as any requested, associated information.

    If no names are given, the contents of the working directory are
    displayed.

    N.B. the :hg:`list` command *only displays items that are checked in
    to the repository*.  It specifically *does not* display items that are
    merely present in the working directory, even if you have used :hg:`add`
    on them.

    Use the -s/--sort option to change the sort order for the files; the
    argument is a comma-separated list of any of the following items:

      :name:     the name of the file
      :rev:      the last revision at which the file was changed
      :date:     the date of the last revision at which the file was changed
      :author:   the name of the user who last changed the file
      :user:     the short name of the user who last changed the file
      :size:     the size of the file
      :subrepo:  the name of the subrepository
      :linkurl:  the URL for a subrepository link
      :linkrev:  the revision for a subrepository link (for hg, a node value)
      :linktype: the type of a subrepository link

    Each item may optionally be preceded by a '+' or a '-' character to
    control sort direction.

    If the -l/--long option is given, the following information is displayed
    for each file:

      - file flags
      - short user (pass -v to change to full username)
      - size of the file (pass -H to view in human-readable form)
      - revision of last change (in rev:node format)
      - date of last change
      - file name

    Additionally, if you use the -S option to recurse into subrepositories,
    a column will be inserted before the revision column naming the
    subrepository.  Subrepository recursion only works for Mercurial
    subrepositories; foreign subrepositories are not supported.

    When you are using the -S option, the subrepository roots will be listed
    as if they were directories.  If you want to see the subrepositories as
    links instead, specify --links.  The --links option and the -S option
    are mutually exclusive; also note that -S is fragile and cannot support
    non-Mercurial subrepositories, whereas --links is robust and will work
    with any kind of subrepository supported by Mercurial.

    If the -F/--flags option is specified, an '@', '*', or '/' character
    will be appended to the name to indicate symbolic links, executable files,
    subrepositories and directories respectively.  If --links is specified,
    subrepositories will be listed with an '&' character appended.

    You can also customise the output using the --template argument; this
    uses the same template system as :hg:`log`; the following keywords are
    defined:

      :name:     the name of the file
      :mode:     the UNIX mode of the file
      :size:     the size of the file, in bytes
      :kind:     an '@', '*', '&' or '/' character depending on the type of
                 the file
      :subrepo:  if this file is in a subrepository, the path within the outer
                 repository
      :rev:      the last revision at which the file was changed
      :node:     the changeset ID for that revision
      :date:     the date of the last revision at which the file was changed
      :author:   the name of the user who last changed the file
      :branch:   the branch of the last revision at which the file was changed
      :desc:     the description of that revision
      :linkurl:  the URL for a subrepository link
      :linkrev:  the revision for a subrepository link
      :linktype: the type of a subrepository link

    If you pass the --columns switch as well as the --template switch,
    you can obtain column-aligned output.  The --columns switch takes a
    string, each character of which corresponds to a column in the output.
    An 'l' character left-justifies within the column, while an 'r'
    right-justifies and a 'c' character will center within the column.
    Any other character will cause right-justification.

    If you are using the --columns switch, your template should use '\0'
    characters (i.e. NULs) to separate the columns.  If you have more
    columns than the number of alignment specifications, the extra
    columns will be left-justified by default.  A trailing left-aligned
    column will not be padded."""

    rev = opts['rev']
    ctx = repo[rev]
    all = opts['all']
    flags = opts['flags']
    sort = [s.lower().strip() for s in opts['sort'].split(',')]
    template = opts['template']
    style = opts['style']
    should_format = ui.formatted()
    long_format = opts['long']
    human = opts['human']
    subrepos = opts['subrepos']
    links = opts['links']
    recursive = opts['recursive']
    dumb = opts['dumb']
    align_columns = opts['columns']
    file_buffer = []

    # Work out where to get our template from
    if not (style or template):
        template = ui.config('ui', 'listtemplate')
        if template:
            try:
                template = templater.parsestring(template)
            except SyntaxError:
                template = templater.parsestring(template, quoted=False)
        else:
            style = util.expandpath(ui.config('ui', 'style', ''))
    elif template:
        try:
            template = templater.parsestring(template, quoted=False)
        except SyntaxError, e:
            raise util.Abort('bad template: %s' % e.args[0])