mercurial/fileset.py
changeset 14681 0744db5eb51c
parent 14680 49af5fa3809b
child 14682 8785fd757077
equal deleted inserted replaced
14680:49af5fa3809b 14681:0744db5eb51c
   109 
   109 
   110 def listset(mctx, a, b):
   110 def listset(mctx, a, b):
   111     raise error.ParseError(_("can't use a list in this context"))
   111     raise error.ParseError(_("can't use a list in this context"))
   112 
   112 
   113 def modified(mctx, x):
   113 def modified(mctx, x):
       
   114     """``modified()``
       
   115     File that is modified according to status.
       
   116     """
   114     getargs(x, 0, 0, _("modified takes no arguments"))
   117     getargs(x, 0, 0, _("modified takes no arguments"))
   115     s = mctx.status()[0]
   118     s = mctx.status()[0]
   116     return [f for f in mctx.subset if f in s]
   119     return [f for f in mctx.subset if f in s]
   117 
   120 
   118 def added(mctx, x):
   121 def added(mctx, x):
       
   122     """``added()``
       
   123     File that is added according to status.
       
   124     """
   119     getargs(x, 0, 0, _("added takes no arguments"))
   125     getargs(x, 0, 0, _("added takes no arguments"))
   120     s = mctx.status()[1]
   126     s = mctx.status()[1]
   121     return [f for f in mctx.subset if f in s]
   127     return [f for f in mctx.subset if f in s]
   122 
   128 
   123 def removed(mctx, x):
   129 def removed(mctx, x):
       
   130     """``removed()``
       
   131     File that is removed according to status.
       
   132     """
   124     getargs(x, 0, 0, _("removed takes no arguments"))
   133     getargs(x, 0, 0, _("removed takes no arguments"))
   125     s = mctx.status()[2]
   134     s = mctx.status()[2]
   126     return [f for f in mctx.subset if f in s]
   135     return [f for f in mctx.subset if f in s]
   127 
   136 
   128 def deleted(mctx, x):
   137 def deleted(mctx, x):
       
   138     """``deleted()``
       
   139     File that is deleted according to status.
       
   140     """
   129     getargs(x, 0, 0, _("deleted takes no arguments"))
   141     getargs(x, 0, 0, _("deleted takes no arguments"))
   130     s = mctx.status()[3]
   142     s = mctx.status()[3]
   131     return [f for f in mctx.subset if f in s]
   143     return [f for f in mctx.subset if f in s]
   132 
   144 
   133 def unknown(mctx, x):
   145 def unknown(mctx, x):
       
   146     """``unknown()``
       
   147     File that is unknown according to status. These files will only be
       
   148     considered if this predicate is used.
       
   149     """
   134     getargs(x, 0, 0, _("unknown takes no arguments"))
   150     getargs(x, 0, 0, _("unknown takes no arguments"))
   135     s = mctx.status()[4]
   151     s = mctx.status()[4]
   136     return [f for f in mctx.subset if f in s]
   152     return [f for f in mctx.subset if f in s]
   137 
   153 
   138 def ignored(mctx, x):
   154 def ignored(mctx, x):
       
   155     """``ignored()``
       
   156     File that is ignored according to status. These files will only be
       
   157     considered if this predicate is used.
       
   158     """
   139     getargs(x, 0, 0, _("ignored takes no arguments"))
   159     getargs(x, 0, 0, _("ignored takes no arguments"))
   140     s = mctx.status()[5]
   160     s = mctx.status()[5]
   141     return [f for f in mctx.subset if f in s]
   161     return [f for f in mctx.subset if f in s]
   142 
   162 
   143 def clean(mctx, x):
   163 def clean(mctx, x):
       
   164     """``clean()``
       
   165     File that is clean according to status.
       
   166     """
   144     getargs(x, 0, 0, _("clean takes no arguments"))
   167     getargs(x, 0, 0, _("clean takes no arguments"))
   145     s = mctx.status()[6]
   168     s = mctx.status()[6]
   146     return [f for f in mctx.subset if f in s]
   169     return [f for f in mctx.subset if f in s]
   147 
   170 
   148 def func(mctx, a, b):
   171 def func(mctx, a, b):
   162     if len(l) < min or len(l) > max:
   185     if len(l) < min or len(l) > max:
   163         raise error.ParseError(err)
   186         raise error.ParseError(err)
   164     return l
   187     return l
   165 
   188 
   166 def binary(mctx, x):
   189 def binary(mctx, x):
       
   190     """``binary()``
       
   191     File that appears to be binary (contails NUL bytes).
       
   192     """
   167     getargs(x, 0, 0, _("binary takes no arguments"))
   193     getargs(x, 0, 0, _("binary takes no arguments"))
   168     return [f for f in mctx.subset if util.binary(mctx.ctx[f].data())]
   194     return [f for f in mctx.subset if util.binary(mctx.ctx[f].data())]
   169 
   195 
   170 def exec_(mctx, x):
   196 def exec_(mctx, x):
       
   197     """``exec()``
       
   198     File that is marked as executable.
       
   199     """
   171     getargs(x, 0, 0, _("exec takes no arguments"))
   200     getargs(x, 0, 0, _("exec takes no arguments"))
   172     return [f for f in mctx.subset if mctx.ctx.flags(f) == 'x']
   201     return [f for f in mctx.subset if mctx.ctx.flags(f) == 'x']
   173 
   202 
   174 def symlink(mctx, x):
   203 def symlink(mctx, x):
       
   204     """``symlink()``
       
   205     File that is marked as a symlink.
       
   206     """
   175     getargs(x, 0, 0, _("symlink takes no arguments"))
   207     getargs(x, 0, 0, _("symlink takes no arguments"))
   176     return [f for f in mctx.subset if mctx.ctx.flags(f) == 'l']
   208     return [f for f in mctx.subset if mctx.ctx.flags(f) == 'l']
   177 
   209 
   178 def resolved(mctx, x):
   210 def resolved(mctx, x):
       
   211     """``resolved()``
       
   212     File that is marked resolved according to the resolve state.
       
   213     """
   179     getargs(x, 0, 0, _("resolved takes no arguments"))
   214     getargs(x, 0, 0, _("resolved takes no arguments"))
   180     if mctx.ctx.rev() is not None:
   215     if mctx.ctx.rev() is not None:
   181         return []
   216         return []
   182     ms = merge.mergestate(mctx.ctx._repo)
   217     ms = merge.mergestate(mctx.ctx._repo)
   183     return [f for f in mctx.subset if f in ms and ms[f] == 'r']
   218     return [f for f in mctx.subset if f in ms and ms[f] == 'r']
   184 
   219 
   185 def unresolved(mctx, x):
   220 def unresolved(mctx, x):
       
   221     """``unresolved()``
       
   222     File that is marked unresolved according to the resolve state.
       
   223     """
   186     getargs(x, 0, 0, _("unresolved takes no arguments"))
   224     getargs(x, 0, 0, _("unresolved takes no arguments"))
   187     if mctx.ctx.rev() is not None:
   225     if mctx.ctx.rev() is not None:
   188         return []
   226         return []
   189     ms = merge.mergestate(mctx.ctx._repo)
   227     ms = merge.mergestate(mctx.ctx._repo)
   190     return [f for f in mctx.subset if f in ms and ms[f] == 'u']
   228     return [f for f in mctx.subset if f in ms and ms[f] == 'u']
   191 
   229 
   192 def hgignore(mctx, x):
   230 def hgignore(mctx, x):
       
   231     """``resolved()``
       
   232     File that matches the active .hgignore pattern.
       
   233     """
   193     getargs(x, 0, 0, _("hgignore takes no arguments"))
   234     getargs(x, 0, 0, _("hgignore takes no arguments"))
   194     ignore = mctx.ctx._repo.dirstate._ignore
   235     ignore = mctx.ctx._repo.dirstate._ignore
   195     return [f for f in mctx.subset if ignore(f)]
   236     return [f for f in mctx.subset if ignore(f)]
   196 
   237 
   197 symbols = {
   238 symbols = {
   265     else:
   306     else:
   266         status = None
   307         status = None
   267         subset = ctx.walk(ctx.match([]))
   308         subset = ctx.walk(ctx.match([]))
   268 
   309 
   269     return getset(matchctx(ctx, subset, status), tree)
   310     return getset(matchctx(ctx, subset, status), tree)
       
   311 
       
   312 # tell hggettext to extract docstrings from these functions:
       
   313 i18nfunctions = symbols.values()