Пример #1
0
def serve(ui, *pats, **opts):
    """web server"""
    from tortoisehg.hgtk.serve import run
    if paths.find_root() == None and not (opts['web_conf'] or opts['webdir_conf']):
        raise error.RepoError(_("There is no Mercurial repository here"
                    " (.hg not found)"))
    gtkrun(run, ui, *pats, **opts)
Пример #2
0
    def dropEvent(self, event):
        data = event.mimeData()
        index, group, row = self.dropLocation(event)

        if index:
            if event.source() is self:
                # Event is an internal move, so pass it to the model
                col = 0
                drop = self.model().dropMimeData(data, event.dropAction(), row,
                                                 col, group)
                if drop:
                    event.accept()
                    self.dropAccepted.emit()
            else:
                # Event is a drop of an external repo
                accept = False
                for u in data.urls():
                    root = paths.find_root(hglib.fromunicode(u.toLocalFile()))
                    if root and not self.model().getRepoItem(root):
                        self.model().addRepo(group, root, row)
                        accept = True
                if accept:
                    event.setDropAction(Qt.LinkAction)
                    event.accept()
                    self.dropAccepted.emit()
        self.setAutoScroll(False)
        self.setState(QAbstractItemView.NoState)
        self.viewport().update()
        self.setAutoScroll(True)
Пример #3
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    from tortoisehg.hgqt import thgrepo
    repo = thgrepo.repository(ui, path=paths.find_root())
    pats = hglib.canonpaths(pats)
    os.chdir(repo.root)
    return StatusDialog(repo, pats, opts)
Пример #4
0
    def move_clicked(self, toolbutton, data=None):
        move_list = self.relevant_checked_files('C')
        if move_list:
            # get destination directory to files into
            dlg = gtklib.NativeFolderSelectDialog(
                    title=_('Move files to directory...'),
                    initial=self.repo.root)
            destdir = dlg.run()
            if not destdir:
                return True

            # verify directory
            destroot = paths.find_root(destdir)
            if destroot != self.repo.root:
                gdialog.Prompt(_('Nothing Moved'),
                       _('Cannot move outside repo!'), self).run()
                return True

            # move the files to dest directory
            move_list.append(hglib.fromutf(destdir))
            self.act.hg_move(move_list)
        else:
            gdialog.Prompt(_('Nothing Moved'), _('No movable files selected\n\n'
                    'Note: only clean files can be moved.'), self).run()
        return True
Пример #5
0
    def dropEvent(self, event):
        data = event.mimeData()
        index, group, row = self.dropLocation(event)

        if index:
            if event.source() is self:
                # Event is an internal move, so pass it to the model
                col = 0
                drop = self.model().dropMimeData(data, event.dropAction(), row,
                                                 col, group)
                if drop:
                    event.accept()
                    self.dropAccepted.emit()
            else:
                # Event is a drop of an external repo
                accept = False
                for u in data.urls():
                    root = paths.find_root(hglib.fromunicode(u.toLocalFile()))
                    if root and not self.model().getRepoItem(root):
                        self.model().addRepo(group, root, row)
                        accept = True
                if accept:
                    event.setDropAction(Qt.LinkAction)
                    event.accept()
                    self.dropAccepted.emit()
        self.setAutoScroll(False)
        self.setState(QAbstractItemView.NoState)
        self.viewport().update()
        self.setAutoScroll(True)
Пример #6
0
def run(_ui, *pats, **opts):
    from tortoisehg.util import paths
    from tortoisehg.hgqt import thgrepo
    repo = thgrepo.repository(_ui, path=paths.find_root())
    if pats and pats[0].endswith('.hgignore'):
        pats = []
    return HgignoreDialog(repo, None, *pats)
Пример #7
0
    def dropEvent(self, event):
        data = event.mimeData()
        index, group, row = self.dropLocation(event)

        if index:
            m = self.model()
            if event.source() is self:
                # Event is an internal move, so pass it to the model
                col = 0
                if m.dropMimeData(data, event.dropAction(), row, col, group):
                    event.accept()
                    self.dropAccepted.emit()
            else:
                # Event is a drop of an external repo
                accept = False
                for u in data.urls():
                    uroot = paths.find_root(unicode(u.toLocalFile()))
                    if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
                        repoindex = m.addRepo(uroot, row, group)
                        m.loadSubrepos(repoindex)
                        accept = True
                if accept:
                    event.setDropAction(Qt.LinkAction)
                    event.accept()
                    self.dropAccepted.emit()
        self.setAutoScroll(False)
        self.setState(QAbstractItemView.NoState)
        self.viewport().update()
        self.setAutoScroll(True)
Пример #8
0
 def init_data(self, ui, pats):
     """calculate initial values for widgets"""
     fname = ''
     target = ''
     cwd = os.getcwd()
     try:
         self.root = paths.find_root()
         self.repo = thgrepo.repository(ui, path=self.root)
     except (error.RepoError):
         qtlib.ErrorMsgBox(_('Error'),
                 _('Could not find or initialize the repository '
                   'from folder<p>%s</p>' % cwd))
         return ('', '')
     try:
         fname = hglib.canonpath(self.root, cwd, pats[0])
         target = hglib.canonpath(self.root, cwd, pats[1])
     except:
         pass
     os.chdir(self.root)
     fname = hglib.tounicode(util.normpath(fname))
     if target:
         target = hglib.tounicode(util.normpath(target))
     else:
         target = fname
     return (fname, target)
Пример #9
0
def run(ui, *pats, **opts):
    repo = thgrepo.repository(None, paths.find_root())
    if hasattr(repo, 'mq'):
        return QQueueDialog(repo)
    else:
        qtlib.ErrorMsgBox(_('TortoiseHg Error'),
            _('Please enable the MQ extension first.'))
Пример #10
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    from tortoisehg.hgqt import thgrepo
    repo = thgrepo.repository(ui, path=paths.find_root())
    pats = hglib.canonpaths(pats)
    os.chdir(repo.root)
    return StatusDialog(repo, pats, opts)
Пример #11
0
    def addRepo(self, group, root, row=-1):
        grp = group
        if grp == None:
            grp = self.allreposIndex()
        rgi = grp.internalPointer()
        if row < 0:
            row = rgi.childCount()

        # make sure all paths are properly normalized
        root = os.path.normpath(root)

        # Check whether the repo that we are adding is a subrepo
        # This check could be expensive, particularly for network repositories
        # Thus, only perform this check on network repos if the showNetworkSubrepos
        # flag is set
        itemIsSubrepo = False
        if self.showNetworkSubrepos \
                or not paths.netdrive_status(root):
            outerrepopath = paths.find_root(os.path.dirname(root))
            if outerrepopath:
                # Check whether repo we are adding is a subrepo of
                # its containing (outer) repo
                # This check is currently quite imperfect, since it
                # only checks the current repo revision
                outerrepo = hg.repository(ui.ui(), path=outerrepopath)
                relroot = util.normpath(root[len(outerrepopath) + 1:])
                if relroot in outerrepo['.'].substate:
                    itemIsSubrepo = True

        self.beginInsertRows(grp, row, row)
        if itemIsSubrepo:
            ri = SubrepoItem(root)
        else:
            ri = RepoItem(root)
        rgi.insertChild(row, ri)

        if not self.showSubrepos \
                or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
            self.endInsertRows()
            return

        invalidRepoList = ri.appendSubrepos()

        self.endInsertRows()

        if invalidRepoList:
            if invalidRepoList[0] == root:
                qtlib.WarningMsgBox(
                    _('Could not get subrepository list'),
                    _('It was not possible to get the subrepository list for '
                      'the repository in:<br><br><i>%s</i>') % root)
            else:
                qtlib.WarningMsgBox(
                    _('Could not open some subrepositories'),
                    _('It was not possible to fully load the subrepository '
                      'list for the repository in:<br><br><i>%s</i><br><br>'
                      'The following subrepositories may be missing, broken or '
                      'on an inconsistent state and cannot be accessed:'
                      '<br><br><i>%s</i>') %
                    (root, "<br>".join(invalidRepoList)))
Пример #12
0
def _workbench(ui, *pats, **opts):
    root = opts.get('root') or paths.find_root()

    # TODO: unclear that _workbench() is called inside qtrun(). maybe this
    # function should receive factory object instead of using global qtrun.
    w = qtrun.createWorkbench()
    if root:
        root = hglib.tounicode(root)
        bundle = opts.get('bundle')
        if bundle:
            w.openRepo(root, False, bundle=hglib.tounicode(bundle))
        else:
            w.showRepo(root)

        if pats:
            q = []
            for f in pats:
                pat = hglib.canonpaths([f])[0]
                if os.path.isdir(f):
                    q.append('file("%s/**")' % pat)
                elif os.path.isfile(f):
                    q.append('file("%s")' % pat)
            w.setRevsetFilter(root, ' or '.join(q))
    if w.repoTabsWidget.count() <= 0:
        w.reporegistry.setVisible(True)
    return w
Пример #13
0
def run(ui, *pats, **opts):
    root = opts.get('root') or paths.find_root()
    if root and pats:
        repo = thgrepo.repository(ui, root)
        pats = hglib.canonpaths(pats)
        if len(pats) == 1 and os.path.isfile(repo.wjoin(pats[0])):
            from tortoisehg.hgqt.filedialogs import FileLogDialog
            fname = pats[0]
            ufname = hglib.tounicode(fname)
            dlg = FileLogDialog(repo, fname, None)
            dlg.setWindowTitle(_('Hg file log viewer [%s] - %s') % (
                repo.displayname, ufname))
            return dlg
    w = Workbench()
    if root:
        root = hglib.tounicode(root)
        w.showRepo(root)
        if pats:
            q = []
            for pat in pats:
                f = repo.wjoin(pat)
                if os.path.isdir(f):
                    q.append('file("%s/**")' % pat)
                elif os.path.isfile(f):
                    q.append('file("%s")' % pat)
            w.setRevsetFilter(root, ' or '.join(q))
    if w.repoTabsWidget.count() <= 0:
        w.reporegistry.setVisible(True)
    return w
Пример #14
0
    def __init__(self, resizable=False, norepo=False):
        gtk.Dialog.__init__(self)
        gtklib.set_tortoise_icon(self, self.get_icon())
        gtklib.set_tortoise_keys(self)
        self.set_resizable(resizable)
        self.set_has_separator(False)
        self.earlyout = False

        self.ui = ui.ui()
        if norepo:
            repo = None
        else:
            try:
                repo = hg.repository(self.ui, path=paths.find_root())
            except error.RepoError:
                gtklib.idle_add_single_call(self.destroy)
                return
        self.repo = repo
        self.after_done = True

        # persistent settings
        name = self.get_setting_name()
        if name:
            self.settings = settings.Settings(name)

        # signal handler
        self.connect('realize', self.realized)

        # disable entire dialog
        self.set_sensitive(False)
Пример #15
0
def run(ui, *pats, **opts):
    repo = thgrepo.repository(None, paths.find_root())
    if hasattr(repo, 'mq'):
        return QReorderDialog(repo)
    else:
        qtlib.ErrorMsgBox(_('TortoiseHg Error'),
                          _('Please enable the MQ extension first.'))
Пример #16
0
def log(ui, *pats, **opts):
    """workbench application"""
    root = opts.get('root') or paths.find_root()
    if root and len(pats) == 1 and os.path.isfile(pats[0]):
        # TODO: do not instantiate repo here
        repo = thgrepo.repository(ui, root)
        repoagent = repo._pyqtobj
        return _filelog(ui, repoagent, *pats, **opts)

    # Before starting the workbench, we must check if we must try to reuse an
    # existing workbench window (we don't by default)
    # Note that if the "single workbench mode" is enabled, and there is no
    # existing workbench window, we must tell the Workbench object to create
    # the workbench server
    singleworkbenchmode = ui.configbool('tortoisehg', 'workbench.single', True)
    mustcreateserver = False
    if singleworkbenchmode:
        newworkbench = opts.get('newworkbench')
        if root and not newworkbench:
            if qtapp.connectToExistingWorkbench(root):
                # The were able to connect to an existing workbench server, and
                # it confirmed that it has opened the selected repo for us
                sys.exit(0)
            # there is no pre-existing workbench server
            serverexists = False
        else:
            serverexists = qtapp.connectToExistingWorkbench('[echo]')
        # When in " single workbench mode", we must create a server if there
        # is not one already
        mustcreateserver = not serverexists

    w = _workbench(ui, *pats, **opts)
    if mustcreateserver:
        qtrun.createWorkbenchServer()
    return w
Пример #17
0
 def init_data(self, ui, pats):
     """calculate initial values for widgets"""
     fname = ''
     target = ''
     cwd = os.getcwd()
     try:
         self.root = paths.find_root()
         self.repo = thgrepo.repository(ui, path=self.root)
     except (error.RepoError):
         qtlib.ErrorMsgBox(_('Error'),
                 _('Could not find or initialize the repository '
                   'from folder<p>%s</p>' % cwd))
         return ('', '')
     try:
         fname = scmutil.canonpath(self.root, cwd, pats[0])
         target = scmutil.canonpath(self.root, cwd, pats[1])
     except:
         pass
     os.chdir(self.root)
     fname = hglib.tounicode(util.normpath(fname))
     if target:
         target = hglib.tounicode(util.normpath(target))
     else:
         target = fname
     return (fname, target)
Пример #18
0
def _workbench(ui, *pats, **opts):
    root = opts.get('root') or paths.find_root()

    # TODO: unclear that _workbench() is called inside qtrun(). maybe this
    # function should receive factory object instead of using global qtrun.
    w = qtrun.createWorkbench()
    if root:
        root = hglib.tounicode(root)
        bundle = opts.get('bundle')
        if bundle:
            w.openRepo(root, False, bundle=hglib.tounicode(bundle))
        else:
            w.showRepo(root)

        if pats:
            q = []
            for f in pats:
                pat = hglib.canonpaths([f])[0]
                if os.path.isdir(f):
                    q.append('file("%s/**")' % pat)
                elif os.path.isfile(f):
                    q.append('file("%s")' % pat)
            w.setRevsetFilter(root, ' or '.join(q))
    if w.repoTabsWidget.count() <= 0:
        w.reporegistry.setVisible(True)
    return w
Пример #19
0
def log(ui, *pats, **opts):
    """workbench application"""
    root = opts.get('root') or paths.find_root()
    if root and len(pats) == 1 and os.path.isfile(pats[0]):
        # TODO: do not instantiate repo here
        repo = thgrepo.repository(ui, root)
        repoagent = repo._pyqtobj
        return _filelog(ui, repoagent, *pats, **opts)

    # Before starting the workbench, we must check if we must try to reuse an
    # existing workbench window (we don't by default)
    # Note that if the "single workbench mode" is enabled, and there is no
    # existing workbench window, we must tell the Workbench object to create
    # the workbench server
    singleworkbenchmode = ui.configbool('tortoisehg', 'workbench.single', True)
    mustcreateserver = False
    if singleworkbenchmode:
        newworkbench = opts.get('newworkbench')
        if root and not newworkbench:
            if qtapp.connectToExistingWorkbench(root):
                # The were able to connect to an existing workbench server, and
                # it confirmed that it has opened the selected repo for us
                sys.exit(0)
            # there is no pre-existing workbench server
            serverexists = False
        else:
            serverexists = qtapp.connectToExistingWorkbench('[echo]')
        # When in " single workbench mode", we must create a server if there
        # is not one already
        mustcreateserver = not serverexists

    w = _workbench(ui, *pats, **opts)
    if mustcreateserver:
        qtrun.createWorkbenchServer()
    return w
Пример #20
0
def runcommand(ui, args):
    cmd, func, args, options, cmdoptions, alias = _parse(ui, args)
    cmdoptions['alias'] = alias
    ui.setconfig("ui", "verbose", str(bool(options["verbose"])))
    i18n.setlanguage(ui.config('tortoisehg', 'ui.language'))

    if options['help']:
        return help_(ui, cmd)

    if options['newworkbench']:
        cmdoptions['newworkbench'] = True

    path = options['repository']
    if path:
        if path.startswith('bundle:'):
            s = path[7:].split('+', 1)
            if len(s) == 1:
                path, bundle = os.getcwd(), s[0]
            else:
                path, bundle = s
            cmdoptions['bundle'] = os.path.abspath(bundle)
        path = ui.expandpath(path)
        # TODO: replace by abspath() if chdir() isn't necessary
        try:
            os.chdir(path)
            path = os.getcwd()
        except OSError:
            pass
    if options['profile']:
        options['nofork'] = True
    path = paths.find_root(path)
    if path:
        try:
            lui = ui.copy()
            lui.readconfig(os.path.join(path, ".hg", "hgrc"))
        except IOError:
            pass
    else:
        lui = ui

    hglib.wrapextensionsloader()  # enable blacklist of extensions
    extensions.loadall(lui)

    args += get_files_from_listfile()

    if options['quiet']:
        ui.quiet = True

    # repository existence will be tested in qtrun()
    if cmd not in nonrepo_commands.split():
        cmdoptions['repository'] = path or options['repository'] or '.'

    cmdoptions['mainapp'] = True
    checkedfunc = util.checksignature(func)
    if cmd in console_commands.split():
        d = lambda: checkedfunc(ui, *args, **cmdoptions)
    else:
        portable_fork(ui, options)
        d = lambda: qtrun(checkedfunc, ui, *args, **cmdoptions)
    return _runcommand(lui, options, cmd, d)
Пример #21
0
    def dropEvent(self, event):
        data = event.mimeData()
        index, group, row = self.dropLocation(event)

        if index:
            m = self.model()
            if event.source() is self:
                # Event is an internal move, so pass it to the model
                col = 0
                if m.dropMimeData(data, event.dropAction(), row, col, group):
                    event.accept()
                    self.dropAccepted.emit()
            else:
                # Event is a drop of an external repo
                accept = False
                for u in data.urls():
                    uroot = paths.find_root(unicode(u.toLocalFile()))
                    if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
                        repoindex = m.addRepo(uroot, row, group)
                        m.loadSubrepos(repoindex)
                        accept = True
                if accept:
                    event.setDropAction(Qt.LinkAction)
                    event.accept()
                    self.dropAccepted.emit()
        self.setAutoScroll(False)
        self.setState(QAbstractItemView.NoState)
        self.viewport().update()
        self.setAutoScroll(True)
Пример #22
0
def run(_ui, *pats, **opts):
    from tortoisehg.util import paths
    from tortoisehg.hgqt import thgrepo
    repo = thgrepo.repository(_ui, path=paths.find_root())
    if pats and pats[0].endswith('.hgignore'):
        pats = []
    return HgignoreDialog(repo, None, *pats)
Пример #23
0
def runcommand(ui, args):
    cmd, func, args, options, cmdoptions, alias = _parse(ui, args)
    cmdoptions['alias'] = alias
    ui.setconfig("ui", "verbose", str(bool(options["verbose"])))
    i18n.setlanguage(ui.config('tortoisehg', 'ui.language'))

    if options['help']:
        return help_(ui, cmd)

    if options['newworkbench']:
        cmdoptions['newworkbench'] = True

    path = options['repository']
    if path:
        if path.startswith('bundle:'):
            s = path[7:].split('+', 1)
            if len(s) == 1:
                path, bundle = os.getcwd(), s[0]
            else:
                path, bundle = s
            cmdoptions['bundle'] = os.path.abspath(bundle)
        path = ui.expandpath(path)
        # TODO: replace by abspath() if chdir() isn't necessary
        try:
            os.chdir(path)
            path = os.getcwd()
        except OSError:
            pass
    if options['profile']:
        options['nofork'] = True
    path = paths.find_root(path)
    if path:
        try:
            lui = ui.copy()
            lui.readconfig(os.path.join(path, ".hg", "hgrc"))
        except IOError:
            pass
    else:
        lui = ui

    hglib.wrapextensionsloader()  # enable blacklist of extensions
    extensions.loadall(lui)

    args += get_files_from_listfile()

    if options['quiet']:
        ui.quiet = True

    # repository existence will be tested in qtrun()
    if cmd not in nonrepo_commands.split():
        cmdoptions['repository'] = path or options['repository'] or '.'

    cmdoptions['mainapp'] = True
    checkedfunc = util.checksignature(func)
    if cmd in console_commands.split():
        d = lambda: checkedfunc(ui, *args, **cmdoptions)
    else:
        portable_fork(ui, options)
        d = lambda: qtrun(checkedfunc, ui, *args, **cmdoptions)
    return _runcommand(lui, options, cmd, d)
Пример #24
0
def run(_ui, *pats, **opts):

    if opts.get('all'):
        roots = []
        base = os.getcwd()
        for f in os.listdir(base):
            r = paths.find_root(os.path.join(base, f))
            if r is not None:
                roots.append(r)
        for r in roots:
            _ui.note("%s\n" % r) 
            shlib.update_thgstatus(_ui, r, wait=False)
            shlib.shell_notify([r])
        return

    root = paths.find_root()
    if opts.get('repository'):
        root = opts.get('repository')
    if root is None:
        _ui.status("no repository\n")
        return

    repo = hg.repository(_ui, root)

    if opts.get('remove'):
        try:
            os.remove(cachefilepath(repo))
        except OSError:
            pass
        return

    if opts.get('show'):
        try:
            f = open(cachefilepath(repo), 'rb')
            for e in f:
                _ui.status("%s %s\n" % (e[0], e[1:-1]))
            f.close()
        except IOError:
            _ui.status("*no status*\n")
        return

    wait = opts.get('delay') is not None
    shlib.update_thgstatus(_ui, root, wait=wait)

    if opts.get('notify'):
        shlib.shell_notify(opts.get('notify'))
    _ui.note("thgstatus updated\n") 
Пример #25
0
def run(_ui, *pats, **opts):

    if opts.get('all'):
        roots = []
        base = os.getcwd()
        for f in os.listdir(base):
            r = paths.find_root(os.path.join(base, f))
            if r is not None:
                roots.append(r)
        for r in roots:
            _ui.note("%s\n" % r)
            shlib.update_thgstatus(_ui, r, wait=False)
            shlib.shell_notify([r])
        return

    root = paths.find_root()
    if opts.get('repository'):
        root = opts.get('repository')
    if root is None:
        _ui.status("no repository\n")
        return

    repo = hg.repository(_ui, root)

    if opts.get('remove'):
        try:
            os.remove(cachefilepath(repo))
        except OSError:
            pass
        return

    if opts.get('show'):
        try:
            f = open(cachefilepath(repo), 'rb')
            for e in f:
                _ui.status("%s %s\n" % (e[0], e[1:-1]))
            f.close()
        except IOError:
            _ui.status("*no status*\n")
        return

    wait = opts.get('delay') is not None
    shlib.update_thgstatus(_ui, root, wait=wait)

    if opts.get('notify'):
        shlib.shell_notify(opts.get('notify'))
    _ui.note("thgstatus updated\n")
Пример #26
0
def run(ui, *pats, **opts):
    if 'repo' in opts:
        repo = opts['repo']
    else:
        from tortoisehg.util import paths
        from tortoisehg.hgqt import thgrepo
        repo = thgrepo.repository(ui, path=paths.find_root())
    return ShelveDialog(repo, None)
Пример #27
0
 def _set_path(self, uri):
     if not uri.startswith('file://'):
         return
     path = urllib.unquote(uri[7:])
     if paths.find_root(path) == path:
         self.pathtext.set_text(hglib.toutf(path))
     elif not os.path.isdir(path) and path.endswith('.hg'):
         self.pathtext.set_text(hglib.toutf(path))
Пример #28
0
def run(ui, *pats, **opts):
    repo = thgrepo.repository(ui, path=paths.find_root())
    rev = None
    if opts.get('rev'):
        rev = opts.get('rev')
    elif len(pats) == 1:
        rev = pats[0]
    return rUpdateDialog(repo, rev, None, opts)
Пример #29
0
def run(ui, *pats, **opts):
    repo = thgrepo.repository(ui, path=paths.find_root())
    rev = None
    if opts.get('rev'):
        rev = opts.get('rev')
    elif len(pats) == 1:
        rev = pats[0]
    return UpdateDialog(repo, rev, None, opts)
Пример #30
0
 def dragEnterEvent(self, event):
     d = event.mimeData()
     for u in d.urls():
         root = paths.find_root(unicode(u.toLocalFile()))
         if root:
             event.setDropAction(Qt.LinkAction)
             event.accept()
             break
Пример #31
0
def run(ui, *pats, **opts):
    if 'repo' in opts:
        repo = opts['repo']
    else:
        from tortoisehg.util import paths
        from tortoisehg.hgqt import thgrepo
        repo = thgrepo.repository(ui, path=paths.find_root())
    return ShelveDialog(repo, None)
Пример #32
0
def run(ui, *pats, **opts):
    repo = opts.get("repo") or thgrepo.repository(ui, paths.find_root())
    try:
        # ManifestWidget expects integer revision
        rev = repo[opts.get("rev")].rev()
    except error.RepoLookupError, e:
        qtlib.ErrorMsgBox(_("Failed to open Manifest dialog"), hglib.tounicode(e.message))
        return
Пример #33
0
    def addRepo(self, group, root, row=-1):
        grp = group
        if grp == None:
            grp = self.allreposIndex()
        rgi = grp.internalPointer()
        if row < 0:
            row = rgi.childCount()

        # make sure all paths are properly normalized
        root = os.path.normpath(root)

        # Check whether the repo that we are adding is a subrepo
        # This check could be expensive, particularly for network repositories
        # Thus, only perform this check on network repos if the showNetworkSubrepos
        # flag is set
        itemIsSubrepo = False
        if self.showNetworkSubrepos \
                or not paths.netdrive_status(root):
            outerrepopath = paths.find_root(os.path.dirname(root))
            if outerrepopath:
                # Check whether repo we are adding is a subrepo of
                # its containing (outer) repo
                # This check is currently quite imperfect, since it
                # only checks the current repo revision
                outerrepo = hg.repository(ui.ui(), path=outerrepopath)
                relroot = util.normpath(root[len(outerrepopath)+1:])
                if relroot in outerrepo['.'].substate:
                    itemIsSubrepo = True

        self.beginInsertRows(grp, row, row)
        if itemIsSubrepo:
            ri = SubrepoItem(root)
        else:
            ri = RepoItem(root)
        rgi.insertChild(row, ri)

        if not self.showSubrepos \
                or (not self.showNetworkSubrepos and paths.netdrive_status(root)):
            self.endInsertRows()
            return

        invalidRepoList = ri.appendSubrepos()

        self.endInsertRows()

        if invalidRepoList:
            if invalidRepoList[0] == root:
                qtlib.WarningMsgBox(_('Could not get subrepository list'),
                    _('It was not possible to get the subrepository list for '
                    'the repository in:<br><br><i>%s</i>') % root)
            else:
                qtlib.WarningMsgBox(_('Could not open some subrepositories'),
                    _('It was not possible to fully load the subrepository '
                    'list for the repository in:<br><br><i>%s</i><br><br>'
                    'The following subrepositories may be missing, broken or '
                    'on an inconsistent state and cannot be accessed:'
                    '<br><br><i>%s</i>')  %
                    (root, "<br>".join(invalidRepoList)))
Пример #34
0
def runcommand(ui, args):
    cmd, func, args, options, cmdoptions, alias = _parse(ui, args)
    cmdoptions['alias'] = alias
    ui.setconfig("ui", "verbose", str(bool(options["verbose"])))
    i18n.setlanguage(ui.config('tortoisehg', 'ui.language'))

    if options['help']:
        return help_(ui, cmd)

    if options['newworkbench']:
        cmdoptions['newworkbench'] = True

    path = options['repository']
    if path:
        if path.startswith('bundle:'):
            s = path[7:].split('+', 1)
            if len(s) == 1:
                path, bundle = os.getcwd(), s[0]
            else:
                path, bundle = s
            cmdoptions['bundle'] = os.path.abspath(bundle)
        path = ui.expandpath(path)
        if not os.path.exists(path) or not os.path.isdir(path + '/.hg'):
            print 'abort: %s is not a repository' % path
            return 1
        os.chdir(path)
    if options['fork']:
        cmdoptions['fork'] = True
    if options['nofork'] or options['profile']:
        cmdoptions['nofork'] = True
    path = paths.find_root(os.getcwd())
    if path:
        cmdoptions['repository'] = path
        try:
            lui = ui.copy()
            lui.readconfig(os.path.join(path, ".hg", "hgrc"))
        except IOError:
            pass
    else:
        lui = ui

    hglib.wrapextensionsloader()  # enable blacklist of extensions
    extensions.loadall(lui)

    args += get_files_from_listfile()

    if options['quiet']:
        ui.quiet = True

    if cmd not in nonrepo_commands.split() and not path:
        raise error.RepoError(
            _("There is no Mercurial repository here"
              " (.hg not found)"))

    cmdoptions['mainapp'] = True
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
    return _runcommand(lui, options, cmd, d)
Пример #35
0
def run(ui, *pats, **opts):
    fname, target = '', ''
    cwd = os.getcwd()
    root = paths.find_root(cwd)
    try:
        fname = util.canonpath(root, cwd, pats[0])
        target = util.canonpath(root, cwd, pats[1])
    except util.Abort, e:
        return gdialog.Prompt(_('Invalid path'), str(e), None)
Пример #36
0
def run(ui, *pats, **opts):
    repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())
    try:
        # ManifestWidget expects integer revision
        rev = repo[opts.get('rev')].rev()
    except error.RepoLookupError, e:
        qtlib.ErrorMsgBox(_('Failed to open Manifest dialog'),
                          hglib.tounicode(e.message))
        return
Пример #37
0
def runcommand(ui, args):
    cmd, func, args, options, cmdoptions, alias = _parse(ui, args)
    cmdoptions['alias'] = alias
    ui.setconfig("ui", "verbose", str(bool(options["verbose"])))
    i18n.setlanguage(ui.config('tortoisehg', 'ui.language'))

    if options['help']:
        return help_(ui, cmd)

    if options['newworkbench']:
        cmdoptions['newworkbench'] = True

    path = options['repository']
    if path:
        if path.startswith('bundle:'):
            s = path[7:].split('+', 1)
            if len(s) == 1:
                path, bundle = os.getcwd(), s[0]
            else:
                path, bundle = s
            cmdoptions['bundle'] = os.path.abspath(bundle)
        path = ui.expandpath(path)
        if not os.path.exists(path) or not os.path.isdir(path+'/.hg'):
            print 'abort: %s is not a repository' % path
            return 1
        os.chdir(path)
    if options['fork']:
        cmdoptions['fork'] = True
    if options['nofork'] or options['profile']:
        cmdoptions['nofork'] = True
    path = paths.find_root(os.getcwd())
    if path:
        cmdoptions['repository'] = path
        try:
            lui = ui.copy()
            lui.readconfig(os.path.join(path, ".hg", "hgrc"))
        except IOError:
            pass
    else:
        lui = ui

    hglib.wrapextensionsloader()  # enable blacklist of extensions
    extensions.loadall(lui)

    args += get_files_from_listfile()

    if options['quiet']:
        ui.quiet = True

    if cmd not in nonrepo_commands.split() and not path:
        raise error.RepoError(_("There is no Mercurial repository here"
                                " (.hg not found)"))

    cmdoptions['mainapp'] = True
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
    return _runcommand(lui, options, cmd, d)
Пример #38
0
def __do_run(ui, command, *pats, **_opts):
    root = paths.find_root()
    repo = thgrepo.repository(ui, root)

    pats = hglib.canonpaths(pats)

    cmdline = [command] + pats

    instance = quickop.HeadlessQuickop(repo, cmdline)
    return instance
Пример #39
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    repo = thgrepo.repository(ui, path=paths.find_root())
    if opts.get('rev'):
        rev = opts.get('rev')
    elif len(pats) == 1:
        rev = pats[0]
    else:
        rev = 'tip'
    return BackoutDialog(rev, repo, None)
def getrepos(batch):
    roots = set()
    notifypaths = set()
    for path in batch:
        r = paths.find_root(path)
        if r is None:
            try:
                for n in os.listdir(path):
                    r = paths.find_root(os.path.join(path, n))
                    if (r is not None):
                        roots.add(r)
                        notifypaths.add(r)
            except Exception, e:
                # This exception raises in case of fixutf8 extension enabled
                # and folder name contains '0x5c'(backslash).
                logger.msg('Failed listdir %s (%s)' % (path, str(e)))
        else:
            roots.add(r);
            notifypaths.add(path)
Пример #41
0
def __do_run(ui, command, *pats, **_opts):
    root = paths.find_root()
    repo = thgrepo.repository(ui, root)

    pats = hglib.canonpaths(pats)

    cmdline = [command] + pats
 
    instance = quickop.HeadlessQuickop(repo, cmdline)
    return instance
Пример #42
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    repo = thgrepo.repository(ui, path=paths.find_root())
    if opts.get('rev'):
        rev = opts.get('rev')
    elif len(pats) == 1:
        rev = pats[0]
    else:
        rev = 'tip'
    return BackoutDialog(rev, repo, None)
Пример #43
0
def commit(ui, *pats, **opts):
    """commit tool"""
    # move cwd to repo root if repo is merged, so we can show
    # all the changed files
    repo = hg.repository(ui, path=paths.find_root())
    if len(repo.parents()) > 1:
        os.chdir(repo.root)
        pats = []
    from tortoisehg.hgtk.commit import run
    gtkrun(run, ui, *pats, **opts)
Пример #44
0
def run(ui, *pats, **opts):
    revs = opts.get('rev') or None
    if not revs and len(pats):
        revs = pats[0]
    repo = opts.get('repo') or thgrepo.repository(ui, path=paths.find_root())

    try:
        return PostReviewDialog(repo.ui, repo, revs)
    except error.RepoLookupError, e:
        qtlib.ErrorMsgBox(_('Failed to open Review Board dialog'),
                          hglib.tounicode(e.message))
Пример #45
0
def open_repo(path):
    root = paths.find_root(path)
    if root:
        try:
            repo = hg.repository(ui.ui(), path=root)
            return repo
        except error.RepoError:
            pass
        except StandardError, e:
            print "error while opening repo %s:" % path
            print e
Пример #46
0
def open_repo(path):
    root = paths.find_root(path)
    if root:
        try:
            repo = hg.repository(ui.ui(), path=root)
            return repo
        except error.RepoError:
            pass
        except StandardError, e:
            print "error while opening repo %s:" % path
            print e
Пример #47
0
 def newfolder_notify(newfolder):
     curpath = entry.get_text()
     newpath = os.path.join(curpath, newfolder)
     newpath = hglib.toutf(os.path.abspath(newpath))
     root = paths.find_root(newpath)
     if root:
         self.set_title(root + " - " + _("browser"))
     else:
         self.set_title(_("browser"))
     entry.set_text(newpath)
     browse.chdir(newpath)
Пример #48
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    repo = thgrepo.repository(ui, path=paths.find_root())
    if os.path.exists(repo.join('rebasestate')):
        qtlib.InfoMsgBox(_('Rebase already in progress'),
                          _('Resuming rebase already in progress'))
    elif not opts['source'] or not opts['dest']:
        qtlib.ErrorMsgBox(_('Abort'),
                          _('You must provide source and dest arguments'))
        import sys; sys.exit()
    return RebaseDialog(repo, None, **opts)
Пример #49
0
def run(ui, *pats, **opts):
    revs = opts.get('rev') or None
    if not revs and len(pats):
        revs = pats[0]
    repo = opts.get('repo') or thgrepo.repository(ui, path=paths.find_root())

    try:
        return PostReviewDialog(repo.ui, repo, revs)
    except error.RepoLookupError, e:
        qtlib.ErrorMsgBox(_('Failed to open Review Board dialog'),
                          hglib.tounicode(e.message))
Пример #50
0
def run(ui, *pats, **opts):
    from tortoisehg.util import paths
    rev = opts.get('rev') or None
    if not rev and len(pats):
        rev = pats[0]
    if not rev:
        import sys
        qtlib.InfoMsgBox(_('Unable to merge'),
                         _('Merge revision not specified or not found'))
        sys.exit()
    repo = thgrepo.repository(ui, path=paths.find_root())
    return MergeDialog(rev, repo, None)
Пример #51
0
def run(ui, *pats, **opts):
    kargs = {}
    tag = len(pats) > 0 and pats[0] or None
    if tag:
        kargs['tag'] = tag
    rev = opts.get('rev')
    if rev:
        kargs['rev'] = rev
    from tortoisehg.util import paths
    from tortoisehg.hgqt import thgrepo
    repo = thgrepo.repository(ui, path=paths.find_root())
    return TagDialog(repo, opts=opts, **kargs)
Пример #52
0
 def addNewRepo(self):
     'menu action handler for adding a new repository'
     caption = _('Select repository directory to add')
     FD = QFileDialog
     path = FD.getExistingDirectory(caption=caption,
                                    options=FD.ShowDirsOnly | FD.ReadOnly)
     if path:
         m = self.tview.model()
         uroot = paths.find_root(unicode(path))
         if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
             index = m.addRepo(uroot, parent=self.selitem)
             self._scanAddedRepo(index)
Пример #53
0
    def dragEnterEvent(self, event):
        if event.source() is self:
            # Use the default event handler for internal dragging
            super(RepoTreeView, self).dragEnterEvent(event)
            return

        d = event.mimeData()
        for u in d.urls():
            root = paths.find_root(hglib.fromunicode(u.toLocalFile()))
            if root:
                event.setDropAction(Qt.LinkAction)
                event.accept()
                self.setState(QAbstractItemView.DraggingState)
                break
Пример #54
0
def run(ui, *revs, **opts):
    from tortoisehg.util import paths
    repo = thgrepo.repository(ui, path=paths.find_root())

    revs = list(revs)
    revs.extend(opts['rev'])

    if os.path.exists(repo.join('graftstate')):
        qtlib.InfoMsgBox(_('Graft already in progress'),
                          _('Resuming graft already in progress'))
    elif not revs:
        qtlib.ErrorMsgBox(_('Abort'),
                          _('You must provide revisions to graft'))
        import sys; sys.exit()
    return GraftDialog(repo, None, source=revs)
Пример #55
0
 def get_repo_for_path(self, path):
     '''
     Find mercurial repository for vfs_file
     Returns hg.repo
     '''
     p = paths.find_root(path)
     if not p:
         return None
     try:
         return hg.repository(hglib.loadui(), path=p)
     except error.RepoError:
         return None
     except StandardError, e:
         debugf(e)
         return None
Пример #56
0
def run(ui, *pats, **opts):
    try:
        path = opts.get('bundle') or paths.find_root()
        repo = thgrepo.repository(ui, path=path)
    except error.RepoError:
        ui.warn(_('No repository found here') + '\n')
        return None

    pats = hglib.canonpaths(pats)
    if opts.get('canonpats'):
        pats = list(pats) + opts['canonpats']

    dlg = visualdiff(ui, repo, pats, opts)
    if not dlg:
        sys.exit()
    return dlg
Пример #57
0
 def notified(self, mon_uri=None, event_uri=None, event=None):
     debugf('notified from hgtk, %s', event, level='n')
     f = open(self.notify, 'a+')
     files = None
     try:
         files = [line[:-1] for line in f if line]
         if files:
             f.truncate(0)
     finally:
         f.close()
     if not files:
         return
     root = os.path.commonprefix(files)
     root = paths.find_root(root)
     if root:
         self.invalidate(files, root)
Пример #58
0
 def addNewRepo(self):
     'menu action handler for adding a new repository'
     caption = _('Select repository directory to add')
     FD = QFileDialog
     path = FD.getExistingDirectory(caption=caption,
                                    options=FD.ShowDirsOnly | FD.ReadOnly)
     if path:
         root = paths.find_root(hglib.fromunicode(path))
         if root and not self.tview.model().getRepoItem(root):
             try:
                 self.tview.model().addRepo(self.selitem, root)
             except error.RepoError:
                 qtlib.WarningMsgBox(_('Failed to add repository'),
                                     _('%s is not a valid repository') %
                                     path,
                                     parent=self)
                 return
Пример #59
0
def run(ui, *revs, **opts):
    # TODO: same options as patchbomb
    if opts.get('rev'):
        if revs:
            raise util.Abort(_('use only one form to specify the revision'))
        revs = opts.get('rev')

    # TODO: repo should be a required argument?
    repo = opts.get('repo') or thgrepo.repository(ui, paths.find_root())

    try:
        return EmailDialog(repo,
                           revs,
                           outgoing=opts.get('outgoing', False),
                           outgoingrevs=opts.get('outgoingrevs', None))
    except error.RepoLookupError, e:
        qtlib.ErrorMsgBox(_('Failed to open Email dialog'),
                          hglib.tounicode(e.message))