Example #1
0
    def __init__(self, ui, repo, dest, opts):
        """Read options and load settings from hgrc"""

        if not repo.local:
            raise util.Abort(_('Repository "%s" is not local') % repo.root)

        self.ui = ui
        self.repo = repo
        self.opts = opts
        self.ctx = repo[dest]
        self.uploaded = None
        self.selected = None

        self.chmod_file = self.opts.get('file') or self.ui.config('ftp', 'chmod_file')
        self.chmod_dir = self.opts.get('dir') or self.ui.config('ftp', 'chmod_dir')

        self.url = self.ui.config('paths', dest) or dest or self.ui.config('paths', 'ftp')
        if not self.url:
            raise util.Abort(_('no ftp destination given'))
        self.url = _url(self.url)

        if self.url.scheme != 'ftp':
            raise util.Abort(_('Only "ftp" scheme is supported'))
        if not self.url.host:
            raise util.Abort(_('No host given'))

        self.useGlobal = self.opts.get('global') or self.ui.configbool('ftp', 'global_tags')

        self.tagname = self.opts.get('tag')
        if not self.tagname:
            prefix = self.ui.config('ftp', 'prefix_tags') or _('uploaded@')
            self.tagname = prefix + self.url.host

        ftp_ignore_file = os.path.join(self.repo.root, '.hgftpignore')
        self._match_ignored_file = ignore.ignore(self.repo.root, [ftp_ignore_file], ui.warn)
Example #2
0
def not_check(repo, cmd):
    '''return a function which returns boolean indicating whether a file
    should be skipped for CMD.'''

    #
    # The ignore routines need a canonical path to the file (relative to the
    # repo root), whereas the check commands get paths relative to the cwd.
    #
    # Wrap our argument such that the path is canonified before it is checked.
    #
    def canonified_check(ignfunc):
        def f(path):
            cpath = util.canonpath(repo.root, repo.getcwd(), path)
            return ignfunc(cpath)
        return f

    ignorefiles = []

    for f in [repo.join('cdm/%s.NOT' % cmd),
               repo.wjoin('exception_lists/%s' % cmd)]:
        if os.path.exists(f):
            ignorefiles.append(f)

    if ignorefiles:
        ign = ignore.ignore(repo.root, ignorefiles, repo.ui.warn)
        return canonified_check(ign)
    else:
        return util.never
Example #3
0
def not_check(repo, cmd):
    '''return a function which returns boolean indicating whether a file
    should be skipped for CMD.'''

    notfile = repo.join('cdm/%s.NOT' % cmd)

    if os.path.exists(notfile):
        return ignore.ignore(repo.root, [notfile], repo.ui.warn)
    else:
        return util.never
Example #4
0
def not_check(root, cmd):
    """Return a function which returns True if a file given as an argument
    should be excluded from the check named by 'cmd'"""

    ignorefiles = filter(os.path.exists,
                         [os.path.join(root, ".git", "%s.NOT" % cmd),
                          os.path.join(root, "exception_lists", cmd)])
    if len(ignorefiles) > 0:
        return ignore.ignore(root, ignorefiles, sys.stderr.write)
    else:
        return lambda x: False
Example #5
0
 def _ignore(self):
     files = [self._join('.hgignore')]
     for name, path in self._ui.configitems("ui"):
         if name == 'ignore' or name.startswith('ignore.'):
               files.append(util.expandpath(path))
     patterns = []
     # Only use .gitignore if there's no .hgignore 
     try:
         fp = open(files[0])
         fp.close()
     except:
         fns = self._finddotgitignores()
         for fn in fns:
             d = os.path.dirname(fn)
             fn = self.pathto(fn)
             fp = open(fn)
             pats, warnings = gignorepats(None,fp,root=d)
             for warning in warnings:
                 self._ui.warn("%s: %s\n" % (fn, warning))
             patterns.extend(pats)
     return ignore.ignore(self._root, files, self._ui.warn, extrapatterns=patterns)
Example #6
0
 def _ignore(self):
     files = [self._join('.hgignore')]
     for name, path in self._ui.configitems("ui"):
         if name == 'ignore' or name.startswith('ignore.'):
             files.append(util.expandpath(path))
     patterns = []
     # Only use .gitignore if there's no .hgignore
     try:
         fp = open(files[0])
         fp.close()
     except:
         fns = self._finddotgitignores()
         for fn in fns:
             d = os.path.dirname(fn)
             fn = self.pathto(fn)
             fp = open(fn)
             pats, warnings = gignorepats(None, fp, root=d)
             for warning in warnings:
                 self._ui.warn("%s: %s\n" % (fn, warning))
             patterns.extend(pats)
     return ignore.ignore(self._root,
                          files,
                          self._ui.warn,
                          extrapatterns=patterns)