コード例 #1
0
ファイル: gitdirstate.py プロジェクト: schacon/hg-git
def gignore(root, files, warn, extrapatterns=None):
    allpats = []
    pats = []
    if ignoremod:
        pats = ignore.readpats(root, files, warn)
        for f, patlist in pats:
            allpats.extend(patlist)
    else:
        allpats.extend(['include:%s' % f for f in files])

    if extrapatterns:
        allpats.extend(extrapatterns)
    if not allpats:
        return util.never
    try:
        ignorefunc = matchmod.match(root, '', [], allpats)
    except util.Abort:
        for f, patlist in pats:
            try:
                matchmod.match(root, '', [], patlist)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % (f, inst[0]))
        if extrapatterns:
            try:
                matchmod.match(root, '', [], extrapatterns)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % ('extra patterns', inst[0]))
コード例 #2
0
ファイル: hg-isignored.py プロジェクト: pcdude2143/dotfiles
def isignored(ui, repo, path, **opts):
    """Find ignore rule for file or directory, specified in PATH parameter
    """
    if not os.path.exists(path):
        raise util.Abort("Specified path does not exist")

    if not os.path.exists("{0}/.hgignore".format(repo.root)):
        raise util.Abort(".hgignore file not found")

    pats = ignore.readpats(repo.root, ['.hgignore'], 0)

    allpats = []
    for f, patlist in pats:
        allpats.extend(patlist)
    if not allpats:
        return util.never

    for p in patlist:
        matcher = match.match(repo.root, '', [], [p])
        if matcher(path):
            print("Path '{0}' is ignored by:".format(path))
            print(p)
            return

    print("Path '{0}' is not ignored".format(path))
コード例 #3
0
ファイル: gitdirstate.py プロジェクト: dioceccon/hg-git
def gignore(root, files, warn, extrapatterns=None):
    allpats = []
    pats = []
    if ignoremod:
        pats = ignore.readpats(root, files, warn)
        for f, patlist in pats:
            allpats.extend(patlist)
    else:
        allpats.extend(['include:%s' % f for f in files])

    if extrapatterns:
        allpats.extend(extrapatterns)
    if not allpats:
        return util.never
    try:
        ignorefunc = matchmod.match(root, '', [], allpats)
    except util.Abort:
        for f, patlist in pats:
            try:
                matchmod.match(root, '', [], patlist)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % (f, inst[0]))
        if extrapatterns:
            try:
                matchmod.match(root, '', [], extrapatterns)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % ('extra patterns', inst[0]))
コード例 #4
0
ファイル: gitdirstate.py プロジェクト: dlax/hg-git
def gignore(root, files, warn, extrapatterns=None):
    allpats = []
    pats = []
    if ignoremod:
        pats = ignore.readpats(root, files, warn)
    else:
        pats = [(f, ['include:%s' % f]) for f in files]
    for f, patlist in pats:
        allpats.extend(patlist)

    if extrapatterns:
        allpats.extend(extrapatterns)
    if not allpats:
        return util.never
    try:
        ignorefunc = matchmod.match(root, '', [], allpats)
    except util.Abort:
        for f, patlist in pats:
            try:
                matchmod.match(root, '', [], patlist)
            except util.Abort, inst:
                if not ignoremod:
                    # in this case, patlist is ['include: FILE'], and
                    # inst[0] should already include FILE
                    raise
                raise util.Abort('%s: %s' % (f, inst[0]))
        if extrapatterns:
            try:
                matchmod.match(root, '', [], extrapatterns)
            except util.Abort, inst:
                raise util.Abort('%s: %s' % ('extra patterns', inst[0]))