def test_save_new(self): url = u'http://example.org/' repo = thgrepo.repository(path=self.hg.path) dlg = sync.SaveDialog(repo, 'default', url, parent=None, edit=False) dlg.accept() self.assertEqual(['[paths]', 'default = %s' % url], self.hg.fread('.hg/hgrc').splitlines()[-2:])
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)
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)
def _newwebconf(repopath, webconfpath): """create config obj for hgweb""" if webconfpath: # TODO: handle file not found c = wconfig.readfile(webconfpath) c.path = os.path.abspath(webconfpath) return c elif repopath: # imitate webconf for single repo c = wconfig.config() try: repo = thgrepo.repository(None, repopath) roots = [root for root in recursiveRepoSearch(repo)] if len(roots) == 1: # no _asconfigliststr(repopath) for now, because ServeDialog # cannot parse it as a list in single-repo mode. c.set("paths", "/", repopath) else: # since hg 8cbb59124e67, path entry is parsed as a list base = hglib.fromunicode(repo.shortname) c.set("paths", base, _asconfigliststr(repopath)) for root in roots[1:]: c.set("paths", base + root[len(repopath) :], _asconfigliststr(root)) except (EnvironmentError, error.Abort, error.RepoError): c.set("paths", "/", repopath) return c
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
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
def _newwebconf(repopath, webconfpath): """create config obj for hgweb""" if webconfpath: # TODO: handle file not found c = wconfig.readfile(webconfpath) c.path = os.path.abspath(webconfpath) return c elif repopath: # imitate webconf for single repo c = wconfig.config() try: repo = thgrepo.repository(None, repopath) roots = [root for root in recursiveRepoSearch(repo)] if len(roots) == 1: # no _asconfigliststr(repopath) for now, because ServeDialog # cannot parse it as a list in single-repo mode. c.set('paths', '/', repopath) else: # since hg 8cbb59124e67, path entry is parsed as a list base = hglib.fromunicode(repo.shortname) c.set('paths', base, _asconfigliststr(repopath)) for root in roots[1:]: c.set('paths', base + root[len(repopath):], _asconfigliststr(root)) except (EnvironmentError, error.Abort, error.RepoError): c.set('paths', '/', repopath) return c
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)
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.'))
def create_fixture_repo(name, dirname=None): """Create the fixture repo and return thgrepo object""" path = os.path.join(_reposdir, dirname or name) repo = thgrepo.repository(ui.ui(), path, create=True) commands.import_(repo.ui, repo, os.path.join(FIXTURES_DIR, name + '.diff'), base='', strip=1, exact=True) return repo
def get_fixture_repo(name): """Return the thgrepo object for the specified fixture repo""" path = os.path.join(_reposdir, name) try: return thgrepo.repository(ui.ui(), path) except error.RepoError: return create_fixture_repo(name)
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.'))
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)
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)
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)
def vdiff(ui, repoagent, *pats, **opts): """launch configured visual diff tool""" from tortoisehg.hgqt import visdiff repo = repoagent.rawRepo() if opts.get('bundle'): repo = thgrepo.repository(ui, opts.get('bundle')) pats = hglib.canonpaths(pats) return visdiff.visualdiff(ui, repo, pats, opts)
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)
def setUpClass(cls): hg = helpers.HgClient(os.path.join(_tmpdir, cls.__name__)) hg.init() hg.ftouch('a') hg.addremove() hg.commit('-m', 'commit to default') hg.commit('--close-branch', '-m', 'close default branch') cls.repo = thgrepo.repository(path=hg.path)
def __init__(self, repo, pctx, pats, opts, parent=None): super(StatusThread, self).__init__() self.repo = thgrepo.repository(repo.ui, repo.root) self.pctx = pctx self.pats = pats self.opts = opts self.wctx = None self.patchecked = {}
def test_save_unchanged(self, mock_msgbox): url = u'http://example.org/' self.hg.fwrite('.hg/hgrc', '[paths]\ndefault = %s\n' % url) repo = thgrepo.repository(path=self.hg.path) dlg = sync.SaveDialog(repo, 'default', url, parent=None, edit=False) dlg.accept() self.assertEqual(['[paths]', 'default = %s' % url], self.hg.fread('.hg/hgrc').splitlines()[-2:])
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
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
def test_edit_alias(self): url = u'http://example.org/' self.hg.fwrite('.hg/hgrc', '[paths]\ndefault = %s\n' % url) repo = thgrepo.repository(path=self.hg.path) dlg = sync.SaveDialog(repo, 'default', url, parent=None, edit=True) dlg.aliasentry.setText('default-push') dlg.accept() self.assertEqual(['[paths]', 'default-push = %s' % url], self.hg.fread('.hg/hgrc').splitlines()[-2:])
def test_edit_url(self, mock_msgbox): origurl = u'http://example.org/' newurl = u'http://example.org/new/' self.hg.fwrite('.hg/hgrc', '[paths]\ndefault = %s\n' % origurl) repo = thgrepo.repository(path=self.hg.path) dlg = sync.SaveDialog(repo, 'default', origurl, parent=None, edit=True) dlg.urlentry.setText(newurl) dlg.accept() self.assertEqual(['[paths]', 'default = %s' % newurl], self.hg.fread('.hg/hgrc').splitlines()[-2:])
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
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 qinitOrCommit(self): if os.path.isdir(self.repo.mq.join('.hg')): from tortoisehg.hgqt import commit mqrepo = thgrepo.repository(None, self.repo.mq.path) dlg = commit.CommitDialog(mqrepo, [], {}, self) dlg.finished.connect(dlg.deleteLater) dlg.exec_() self.reload() else: self.repo.incrementBusyCount() self.cmd.run(['qinit', '-c', '-R', self.repo.root])
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)
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))
def setUpClass(cls): hg = helpers.HgClient(os.path.join(_tmpdir, cls.__name__)) hg.init() hg.ftouch('foo', 'bar', 'baz/bax', 'baz/box') hg.addremove() hg.commit('-m', 'foobar') hg.fwrite('bar', 'hello\n') hg.remove('baz/box') hg.ftouch('zzz') hg.addremove() hg.commit('-m', 'remove baz/box, add zzz, modify bar') cls.repo = thgrepo.repository(path=hg.path)
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)
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)
def __call__(self, dlgfunc, ui, *args, **opts): portable_fork(ui, opts) if self._mainapp: self._opendialog(dlgfunc, ui, *args, **opts) return QSettings.setDefaultFormat(QSettings.IniFormat) self._mainapp = QApplication(sys.argv) self._gc = GarbageCollector(self, self.debug) try: # default org is used by QSettings self._mainapp.setApplicationName('TortoiseHgQt') self._mainapp.setOrganizationName('TortoiseHg') self._mainapp.setOrganizationDomain('tortoisehg.org') self._mainapp.setApplicationVersion(thgversion.version()) self._installtranslator() qtlib.setup_font_substitutions() qtlib.fix_application_font() qtlib.configstyles(ui) qtlib.initfontcache(ui) self._mainapp.setWindowIcon(qtlib.geticon('thg-logo')) if 'repository' in opts: try: # Ensure we can open the repository before opening any # dialog windows. Since thgrepo instances are cached, this # is not wasted. from tortoisehg.hgqt import thgrepo thgrepo.repository(ui, opts['repository']) except error.RepoError, e: qtlib.WarningMsgBox(_('Repository Error'), hglib.tounicode(str(e))) return dlg = dlgfunc(ui, *args, **opts) if dlg: dlg.show() dlg.raise_()
def __call__(self, dlgfunc, ui, *args, **opts): portable_fork(ui, opts) if self._mainapp: self._opendialog(dlgfunc, ui, *args, **opts) return QSettings.setDefaultFormat(QSettings.IniFormat) self._mainapp = QApplication(sys.argv) self._gc = GarbageCollector(self, self.debug) try: # default org is used by QSettings self._mainapp.setApplicationName('TortoiseHgQt') self._mainapp.setOrganizationName('TortoiseHg') self._mainapp.setOrganizationDomain('tortoisehg.org') self._mainapp.setApplicationVersion(thgversion.version()) self._installtranslator() qtlib.setup_font_substitutions() qtlib.fix_application_font() qtlib.configstyles(ui) qtlib.initfontcache(ui) self._mainapp.setWindowIcon(qtlib.geticon('thg-logo')) if 'repository' in opts: try: # Ensure we can open the repository before opening any # dialog windows. Since thgrepo instances are cached, this # is not wasted. from tortoisehg.hgqt import thgrepo thgrepo.repository(ui, opts['repository']) except error.RepoError, e: qtlib.WarningMsgBox(hglib.tounicode(_('Repository Error')), hglib.tounicode(str(e))) return dlg = dlgfunc(ui, *args, **opts) if dlg: dlg.show() dlg.raise_()
def _openRepo(self, root, reuse): if root and not root.startswith('ssh://'): if reuse: for rw in self._findrepowidget(root): self.repoTabsWidget.setCurrentWidget(rw) return try: repo = thgrepo.repository(path=root) self.addRepoTab(repo) except RepoError: upath = hglib.tounicode(root) qtlib.WarningMsgBox(_('Failed to open repository'), _('%s is not a valid repository') % upath)
def setUpClass(cls): hg = helpers.HgClient(os.path.join(_tmpdir, cls.__name__)) hg.init() hg.ftouch('a') hg.addremove() hg.commit('-m', 'commit to default') for name in ('foo', 'bar', 'baz'): hg.update('0') hg.fappend('a', name + '\n') hg.branch(name) hg.commit('-m', 'create %s branch' % name) hg.commit('--close-branch', '-m', 'close baz branch') hg.update('foo') # current branch will be listed first cls.repo = thgrepo.repository(path=hg.path)
def setUpClass(cls): # TODO: make this compatible with binary-unsafe filesystem if os.name != 'posix' or sys.platform == 'darwin': raise SkipTest cls.encodingpatch = helpers.patchencoding('euc-jp') # include non-ascii char in repo path to test concatenation hg = helpers.HgClient(os.path.join( _tmpdir, cls.__name__ + _aloha_ja.encode('euc-jp'))) hg.init() hg.ftouch(_aloha_ja.encode('euc-jp')) hg.ftouch(_aloha_ja.encode('euc-jp') + '.txt') hg.addremove() hg.commit('-m', 'add aloha') cls.repo = thgrepo.repository(path=hg.path)
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)
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
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))
def _findsub(self, paths): """Find the nearest (sub-)repository for the given paths All paths should be in the same repository. Otherwise, unmatched paths are silently omitted. """ if not paths: return self.repo, [], self.ctx.rev() repopath, _relpath, ctx = hglib.getDeepestSubrepoContainingFile( paths[0], self.ctx) if not repopath: return self.repo, paths, self.ctx.rev() repo = thgrepo.repository(self.repo.ui, self.repo.wjoin(repopath)) pfx = repopath + '/' relpaths = [e[len(pfx):] for e in paths if e.startswith(pfx)] return repo, relpaths, ctx.rev()