Пример #1
0
def reposetup(ui, repo):
    if repo.local():
        repo.journal = journalstorage(repo)
        repo._wlockfreeprefix.add(b'namejournal')

        dirstate, cached = localrepo.isfilecached(repo, b'dirstate')
        if cached:
            # already instantiated dirstate isn't yet marked as
            # "journal"-ing, even though repo.dirstate() was already
            # wrapped by own wrapdirstate()
            _setupdirstate(repo, dirstate)
Пример #2
0
def reposetup(ui, repo):
    # We don't work with largefiles or inotify
    exts = extensions.enabled()
    for ext in _blacklist:
        if ext in exts:
            ui.warn(
                _('The fsmonitor extension is incompatible with the %s '
                  'extension and has been disabled.\n') % ext)
            return

    if repo.local():
        # We don't work with subrepos either.
        #
        # if repo[None].substate can cause a dirstate parse, which is too
        # slow. Instead, look for a file called hgsubstate,
        if repo.wvfs.exists('.hgsubstate') or repo.wvfs.exists('.hgsub'):
            return

        fsmonitorstate = state.state(repo)
        if fsmonitorstate.mode == 'off':
            return

        try:
            client = watchmanclient.client(repo)
        except Exception as ex:
            _handleunavailable(ui, fsmonitorstate, ex)
            return

        repo._fsmonitorstate = fsmonitorstate
        repo._watchmanclient = client

        dirstate, cached = localrepo.isfilecached(repo, 'dirstate')
        if cached:
            # at this point since fsmonitorstate wasn't present,
            # repo.dirstate is not a fsmonitordirstate
            makedirstate(repo, dirstate)

        class fsmonitorrepo(repo.__class__):
            def status(self, *args, **kwargs):
                orig = super(fsmonitorrepo, self).status
                return overridestatus(orig, self, *args, **kwargs)

        repo.__class__ = fsmonitorrepo
Пример #3
0
def reposetup(ui, repo):
    # We don't work with largefiles or inotify
    exts = extensions.enabled()
    for ext in _blacklist:
        if ext in exts:
            ui.warn(
                _(b'The fsmonitor extension is incompatible with the %s '
                  b'extension and has been disabled.\n') % ext)
            return

    if repo.local():
        # We don't work with subrepos either.
        #
        # if repo[None].substate can cause a dirstate parse, which is too
        # slow. Instead, look for a file called hgsubstate,
        if repo.wvfs.exists(b'.hgsubstate') or repo.wvfs.exists(b'.hgsub'):
            return

        if repo_has_depth_one_nested_repo(repo):
            return

        fsmonitorstate = state.state(repo)
        if fsmonitorstate.mode == b'off':
            return

        try:
            client = watchmanclient.client(repo.ui, repo.root)
        except Exception as ex:
            _handleunavailable(ui, fsmonitorstate, ex)
            return

        repo._fsmonitorstate = fsmonitorstate
        repo._watchmanclient = client

        dirstate, cached = localrepo.isfilecached(repo, b'dirstate')
        if cached:
            # at this point since fsmonitorstate wasn't present,
            # repo.dirstate is not a fsmonitordirstate
            makedirstate(repo, dirstate)

        class fsmonitorrepo(repo.__class__):
            def status(self, *args, **kwargs):
                orig = super(fsmonitorrepo, self).status
                return overridestatus(orig, self, *args, **kwargs)

            def wlocknostateupdate(self, *args, **kwargs):
                return super(fsmonitorrepo, self).wlock(*args, **kwargs)

            def wlock(self, *args, **kwargs):
                l = super(fsmonitorrepo, self).wlock(*args, **kwargs)
                if not ui.configbool(b"experimental",
                                     b"fsmonitor.transaction_notify"):
                    return l
                if l.held != 1:
                    return l
                origrelease = l.releasefn

                def staterelease():
                    if origrelease:
                        origrelease()
                    if l.stateupdate:
                        l.stateupdate.exit()
                        l.stateupdate = None

                try:
                    l.stateupdate = None
                    l.stateupdate = state_update(self, name=b"hg.transaction")
                    l.stateupdate.enter()
                    l.releasefn = staterelease
                except Exception as e:
                    # Swallow any errors; fire and forget
                    self.ui.log(b'watchman', b'Exception in state update %s\n',
                                e)
                return l

        repo.__class__ = fsmonitorrepo