def test_branch_list_remote(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=True), []) self.git('remote', 'add', 'origin', '.') self.git('fetch', 'origin') self.assertEqual(gitcmds.branch_list(remote=True), ['origin/master']) self.git('remote', 'rm', 'origin') self.assertEqual(gitcmds.branch_list(remote=True), [])
def test_branch_list_remote(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=True), []) self.git('remote', 'add', 'origin', '.') self.git('fetch', 'origin') self.assertEqual(gitcmds.branch_list(remote=True), ['origin/master']) self.git('remote', 'rm', 'origin') self.assertEqual(gitcmds.branch_list(remote=True), [])
def test_branch_list_remote(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=True), []) self.shell(""" git remote add origin . && git fetch origin > /dev/null 2>&1 """) self.assertEqual(gitcmds.branch_list(remote=True), ['origin/master']) self.shell('git remote rm origin') self.assertEqual(gitcmds.branch_list(remote=True), [])
def test_branch_list_remote(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=True), []) self.shell(""" git remote add origin . && git fetch origin > /dev/null 2>&1 """) self.assertEqual(gitcmds.branch_list(remote=True), ['origin/master']) self.shell('git remote rm origin') self.assertEqual(gitcmds.branch_list(remote=True), [])
def update_remotes(self, *rest): """Update the remote name when a remote from the list is selected""" widget = self.remotes remotes = self.model.remotes selection = qtutils.selected_item(widget, remotes) if not selection: self.selected_remotes = [] return self.set_remote_name(selection) self.selected_remotes = qtutils.selected_items(self.remotes, self.model.remotes) all_branches = gitcmds.branch_list(remote=True) branches = [] patterns = [] for remote in self.selected_remotes: pat = remote + '/*' patterns.append(pat) for branch in all_branches: for pat in patterns: if fnmatch.fnmatch(branch, pat): branches.append(branch) break if branches: self.set_remote_branches(branches) else: self.set_remote_branches(all_branches) self.set_remote_branch('')
def update_remotes(self, *rest): """Update the remote name when a remote from the list is selected""" widget = self.remotes remotes = self.model.remotes selection = qtutils.selected_item(widget, remotes) if not selection: self.selected_remotes = [] return self.set_remote_name(selection) self.selected_remotes = qtutils.selected_items(self.remotes, self.model.remotes) all_branches = gitcmds.branch_list(remote=True) branches = [] patterns = [] for remote in self.selected_remotes: pat = remote + '/*' patterns.append(pat) for branch in all_branches: for pat in patterns: if fnmatch.fnmatch(branch, pat): branches.append(branch) break if branches: self.set_remote_branches(branches) else: self.set_remote_branches(all_branches) self.set_remote_branch('')
def test_branch_list_local(self): """Test branch_list(remote=False).""" context = self.context self.commit_files() expect = ['master'] actual = gitcmds.branch_list(context, remote=False) self.assertEqual(expect, actual)
def create_branch(self): """Creates a branch; called by the "Create Branch" button""" self.getopts() revision = self.opts.revision branch = self.opts.branch no_update = self.no_update_radio.isChecked() ffwd_only = self.ffwd_only_radio.isChecked() existing_branches = gitcmds.branch_list() check_branch = False if not branch or not revision: qtutils.critical(N_('Missing Data'), N_('Please provide both a branch ' 'name and revision expression.')) return if branch in existing_branches: if no_update: msg = N_('Branch "%s" already exists.') % branch qtutils.critical(N_('Branch Exists'), msg) return # Whether we should prompt the user for lost commits commits = gitcmds.rev_list_range(revision, branch) check_branch = bool(commits) if check_branch: msg = (N_('Resetting "%(branch)s" to "%(revision)s" ' 'will lose commits.') % dict(branch=branch, revision=revision)) if ffwd_only: qtutils.critical(N_('Branch Exists'), msg) return lines = [msg] for idx, commit in enumerate(commits): subject = commit[1][0:min(len(commit[1]),16)] if len(subject) < len(commit[1]): subject += '...' lines.append('\t' + commit[0][:8] +'\t' + subject) if idx >= 5: skip = len(commits) - 5 lines.append('\t(%s)' % (N_('%d skipped') % skip)) break line = N_('Recovering lost commits may not be easy.') lines.append(line) if not qtutils.confirm(N_('Reset Branch?'), '\n'.join(lines), (N_('Reset "%(branch)s" to "%(revision)s"?') % dict(branch=branch, revision=revision)), N_('Reset Branch'), default=False, icon=qtutils.theme_icon('edit-undo.svg')): return self.setEnabled(False) self.progress.setEnabled(True) QtGui.QApplication.setOverrideCursor(Qt.WaitCursor) # Show a nice progress bar self.progress.setLabelText(N_('Updating...')) self.progress.show() self.thread.start()
def __init__(self): observable.ObservableModel.__init__(self) self.git = git.instance() self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.left_combo = ['Local', 'Remote'] self.right_combo = ['Local', 'Remote'] self.left_combo_index = 0 self.right_combo_index = 1 self.left_list = [] self.right_list = [] self.left_list_index = -1 self.right_list_index = -1 self.left_list_selected = False self.right_list_selected = False self.diff_files = []
def test_branch_list_local(self): """Test branch_list(remote=False).""" context = self.context self.commit_files() expect = ['main'] actual = gitcmds.branch_list(context, remote=False) self.assertEqual(expect, actual)
def test_branch_list_remote(self): """Test branch_list(remote=False).""" context = self.context expect = [] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual) self.git('remote', 'add', 'origin', '.') self.git('fetch', 'origin') expect = ['origin/master'] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual) self.git('remote', 'rm', 'origin') expect = [] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual)
def set_remote(self, remote): if not remote: return self.set_param('remote', remote) branches = utils.grep('%s/\S+$' % remote, gitcmds.branch_list(remote=True), squash=False) self.set_remote_branches(branches)
def test_branch_list_remote(self): """Test branch_list(remote=False).""" context = self.context expect = [] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual) self.commit_files() self.run_git('remote', 'add', 'origin', '.') self.run_git('fetch', 'origin') expect = ['origin/master'] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual) self.run_git('remote', 'rm', 'origin') expect = [] actual = gitcmds.branch_list(context, remote=True) self.assertEqual(expect, actual)
def test_branch_list_remote(app_context): """Test branch_list(remote=False).""" expect = [] actual = gitcmds.branch_list(app_context, remote=True) assert expect == actual helper.commit_files() helper.run_git('remote', 'add', 'origin', '.') helper.run_git('fetch', 'origin') expect = ['origin/main'] actual = gitcmds.branch_list(app_context, remote=True) assert expect == actual helper.run_git('remote', 'rm', 'origin') expect = [] actual = gitcmds.branch_list(app_context, remote=True) assert expect == actual
def remote_ref(self, branch): """Returns the remote ref for 'git diff [local] [remote]' """ if branch == self.BRANCH_POINT: # Compare against the branch point so find the merge-base branch = gitcmds.current_branch() tracked_branch = gitcmds.tracked_branch() if tracked_branch: return gitcmds.merge_base(branch, tracked_branch) else: remote_branches = gitcmds.branch_list(remote=True) remote_branch = 'origin/%s' % branch if remote_branch in remote_branches: return gitcmds.merge_base(branch, remote_branch) elif 'origin/master' in remote_branches: return gitcmds.merge_base(branch, 'origin/master') else: return 'HEAD' else: # Compare against the remote branch return branch
def remote_ref(self, branch): """Returns the remote ref for 'git diff [local] [remote]' """ if branch == self.BRANCH_POINT: # Compare against the branch point so find the merge-base branch = gitcmds.current_branch() tracked_branch = gitcmds.tracked_branch() if tracked_branch: return gitcmds.merge_base(branch, tracked_branch) else: remote_branches = gitcmds.branch_list(remote=True) remote_branch = 'origin/%s' % branch if remote_branch in remote_branches: return gitcmds.merge_base(branch, remote_branch) elif 'origin/master' in remote_branches: return gitcmds.merge_base(branch, 'origin/master') else: return 'HEAD' else: # Compare against the remote branch return branch
def update_remotes(self,*rest): """Update the remote name when a remote from the list is selected""" widget = self.view.remotes remotes = self.model.remotes selection = qtutils.selected_item(widget, remotes) if not selection: return self.model.set_remotename(selection) self.view.remotename.selectAll() if self.action != 'pull': pass all_branches = gitcmds.branch_list(remote=True) branches = [] pat = selection + '/*' for branch in all_branches: if fnmatch.fnmatch(branch, pat): branches.append(branch) if branches: self.model.set_remote_branches(branches) else: self.model.set_remote_branches(all_branches) self.model.set_remote_branch('')
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts self.setWindowModality(Qt.ApplicationModal) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.setLayout(self.layt) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get('argprompt'): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.closebtn = create_button(text=N_('Close'), layout=self.btnlayt) self.runbtn = create_button(text=N_('Run'), layout=self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) # Widen the dialog by default self.resize(666, self.height()) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.BRANCH_POINT = N_('*** Branch Point ***') self.SANDBOX = N_('*** Sandbox ***') self.LOCAL = N_('Local') self.setWindowTitle(N_('Branch Diff Viewer')) self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.top_widget = QtGui.QWidget() self.bottom_widget = QtGui.QWidget() self.left_combo = QtGui.QComboBox() self.left_combo.addItem(N_('Local')) self.left_combo.addItem(N_('Remote')) self.left_combo.setCurrentIndex(0) self.right_combo = QtGui.QComboBox() self.right_combo.addItem(N_('Local')) self.right_combo.addItem(N_('Remote')) self.right_combo.setCurrentIndex(1) self.left_list = QtGui.QListWidget() self.right_list = QtGui.QListWidget() self.button_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.button_compare = QtGui.QPushButton() self.button_compare.setText(N_('Compare')) self.button_close = QtGui.QPushButton() self.button_close.setText(N_('Close')) self.diff_files = standard.TreeWidget() self.diff_files.headerItem().setText(0, N_('File Differences')) self.top_grid_layout = qtutils.grid(defs.no_margin, defs.spacing, (self.left_combo, 0, 0, 1, 1), (self.left_list, 1, 0, 1, 1), (self.right_combo, 0, 1, 1, 1), (self.right_list, 1, 1, 1, 1)) self.top_widget.setLayout(self.top_grid_layout) self.bottom_grid_layout = qtutils.grid( defs.no_margin, defs.spacing, (self.diff_files, 0, 0, 1, 4), (self.button_spacer, 1, 1, 1, 1), (self.button_compare, 1, 2, 1, 1), (self.button_close, 1, 3, 1, 1)) self.bottom_widget.setLayout(self.bottom_grid_layout) self.splitter = qtutils.splitter(Qt.Vertical, self.top_widget, self.bottom_widget) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.splitter) self.setLayout(self.main_layout) self.resize(658, 350) connect_button(self.button_close, self.accept) connect_button(self.button_compare, self.compare) self.connect(self.diff_files, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.compare) self.connect(self.left_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=True)) self.connect(self.right_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=False)) self.connect(self.left_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.connect(self.right_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.update_combo_boxes(left=True) self.update_combo_boxes(left=False) # Pre-select the 0th elements item = self.left_list.item(0) if item: self.left_list.setCurrentItem(item) self.left_list.setItemSelected(item, True) item = self.right_list.item(0) if item: self.right_list.setCurrentItem(item) self.right_list.setItemSelected(item, True)
def test_branch_list_local(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=False), ['master'])
def __init__(self, parent, name, opts): standard.StandardDialog.__init__(self, parent) self.name = name self.opts = opts self.layt = QtGui.QVBoxLayout() self.layt.setMargin(10) self.setLayout(self.layt) title = opts.get("title") if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get("prompt") if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if "argprompt" not in opts or opts.get("argprompt") is True: argprompt = i18n.gettext("Arguments") else: argprompt = opts.get("argprompt") self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get("argprompt"): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( ("Local Branch", gitcmds.branch_list(remote=False)), ("Tracking Branch", gitcmds.branch_list(remote=True)), ("Tag", gitcmds.tag_list()), ) if "revprompt" not in opts or opts.get("revprompt") is True: revprompt = i18n.gettext("Revision") else: revprompt = opts.get("revprompt") self.revselect = revselect.RevisionSelector(self, revs=revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get("revprompt"): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnspacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Minimum) self.btnlayt.addItem(self.btnspacer) self.closebtn = qt.create_button(self.tr("Close"), self.btnlayt) self.runbtn = qt.create_button(self.tr("Run"), self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) self.connect(self.closebtn, SIGNAL("clicked()"), self.reject) self.connect(self.runbtn, SIGNAL("clicked()"), self.accept) # Widen the dialog by default self.resize(666, self.height())
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.setWindowTitle(self.tr('Branch Diff Viewer')) self.resize(658, 350) self.main_layt = QtGui.QVBoxLayout(self) self.main_layt.setMargin(defs.margin) self.main_layt.setSpacing(defs.spacing) self.splitter = QtGui.QSplitter(self) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setHandleWidth(defs.handle_width) self.top_widget = QtGui.QWidget(self.splitter) self.top_grid_layt = QtGui.QGridLayout(self.top_widget) self.top_grid_layt.setMargin(0) self.top_grid_layt.setSpacing(defs.spacing) self.left_combo = QtGui.QComboBox(self.top_widget) self.left_combo.addItem(self.tr('Local')) self.left_combo.addItem(self.tr('Remote')) self.left_combo.setCurrentIndex(0) self.top_grid_layt.addWidget(self.left_combo, 0, 0, 1, 1) self.right_combo = QtGui.QComboBox(self.top_widget) self.right_combo.addItem(self.tr('Local')) self.right_combo.addItem(self.tr('Remote')) self.right_combo.setCurrentIndex(1) self.top_grid_layt.addWidget(self.right_combo, 0, 1, 1, 1) self.left_list = QtGui.QListWidget(self.top_widget) self.top_grid_layt.addWidget(self.left_list, 1, 0, 1, 1) self.right_list = QtGui.QListWidget(self.top_widget) self.top_grid_layt.addWidget(self.right_list, 1, 1, 1, 1) self.bottom_widget = QtGui.QWidget(self.splitter) self.bottom_grid_layt = QtGui.QGridLayout(self.bottom_widget) self.bottom_grid_layt.setMargin(0) self.bottom_grid_layt.setSpacing(defs.button_spacing) self.button_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.bottom_grid_layt.addItem(self.button_spacer, 1, 1, 1, 1) self.button_compare = QtGui.QPushButton(self.bottom_widget) self.button_compare.setText(self.tr('Compare')) self.bottom_grid_layt.addWidget(self.button_compare, 1, 2, 1, 1) self.button_close = QtGui.QPushButton(self.bottom_widget) self.button_close.setText(self.tr('Close')) self.bottom_grid_layt.addWidget(self.button_close, 1, 3, 1, 1) self.diff_files = QtGui.QTreeWidget(self.bottom_widget) self.diff_files.headerItem().setText(0, self.tr('File Differences')) self.diff_files.setRootIsDecorated(False) self.bottom_grid_layt.addWidget(self.diff_files, 0, 0, 1, 4) self.main_layt.addWidget(self.splitter) connect_button(self.button_close, self.accept) connect_button(self.button_compare, self.compare) self.connect(self.diff_files, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.compare) self.connect(self.left_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=True)) self.connect(self.right_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=False)) self.connect(self.left_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.connect(self.right_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.update_combo_boxes(left=True) self.update_combo_boxes(left=False) # Pre-select the 0th elements item = self.left_list.item(0) if item: self.left_list.setCurrentItem(item) self.left_list.setItemSelected(item, True) item = self.right_list.item(0) if item: self.right_list.setCurrentItem(item) self.right_list.setItemSelected(item, True)
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts try: values = self.VALUES[name] except KeyError: values = self.VALUES[name] = {} self.setWindowModality(Qt.ApplicationModal) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() if self.opts.get('argprompt'): try: # Remember the previous value saved_value = values['argstxt'] self.argstxt.setText(saved_value) except KeyError: pass else: self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.closebtn = qtutils.close_button() self.runbtn = qtutils.create_button(text=N_('Run'), default=True, icon=icons.ok()) self.argslayt = qtutils.hbox(defs.margin, defs.spacing, self.argslabel, self.argstxt) self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.closebtn, self.runbtn) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.prompt, self.argslayt, self.revselect, self.btnlayt) self.setLayout(self.layt) self.connect(self.argstxt, SIGNAL('textChanged(QString)'), self._argstxt_changed) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept) # Widen the dialog by default self.resize(666, self.height())
def test_branch_list_local(self): """Test branch_list(remote=False).""" self.assertEqual(gitcmds.branch_list(remote=False), ['master'])
def test_branch_list_local(app_context): """Test branch_list(remote=False).""" helper.commit_files() expect = ['main'] actual = gitcmds.branch_list(app_context, remote=False) assert expect == actual
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts try: values = self.VALUES[name] except KeyError: values = self.VALUES[name] = {} self.setWindowModality(Qt.ApplicationModal) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() if self.opts.get('argprompt'): try: # Remember the previous value saved_value = values['argstxt'] self.argstxt.setText(saved_value) except KeyError: pass else: self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.closebtn = create_button(text=N_('Close')) self.runbtn = create_button(text=N_('Run')) self.runbtn.setDefault(True) self.argslayt = qtutils.hbox(defs.margin, defs.spacing, self.argslabel, self.argstxt) self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.closebtn, self.runbtn) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.prompt, self.argslayt, self.revselect, self.btnlayt) self.setLayout(self.layt) self.connect(self.argstxt, SIGNAL('textChanged(QString)'), self._argstxt_changed) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept) # Widen the dialog by default self.resize(666, self.height())
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts self.setWindowModality(Qt.ApplicationModal) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.setLayout(self.layt) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.layt.addWidget(self.prompt) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() self.argslayt = QtGui.QHBoxLayout() self.argslayt.addWidget(self.argslabel) self.argslayt.addWidget(self.argstxt) self.layt.addLayout(self.argslayt) if not self.opts.get('argprompt'): self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) self.layt.addWidget(self.revselect) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.closebtn = qt.create_button(text=N_('Close'), layout=self.btnlayt) self.runbtn = qt.create_button(text=N_('Run'), layout=self.btnlayt) self.runbtn.setDefault(True) self.layt.addLayout(self.btnlayt) # Widen the dialog by default self.resize(666, self.height()) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.BRANCH_POINT = N_('*** Branch Point ***') self.SANDBOX = N_('*** Sandbox ***') self.LOCAL = N_('Local') self.setWindowTitle(N_('Branch Diff Viewer')) self.remote_branches = gitcmds.branch_list(remote=True) self.local_branches = gitcmds.branch_list(remote=False) self.top_widget = QtGui.QWidget() self.bottom_widget = QtGui.QWidget() self.left_combo = QtGui.QComboBox() self.left_combo.addItem(N_('Local')) self.left_combo.addItem(N_('Remote')) self.left_combo.setCurrentIndex(0) self.right_combo = QtGui.QComboBox() self.right_combo.addItem(N_('Local')) self.right_combo.addItem(N_('Remote')) self.right_combo.setCurrentIndex(1) self.left_list = QtGui.QListWidget() self.right_list = QtGui.QListWidget() self.button_spacer = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.button_compare = qtutils.create_button(text=N_('Compare'), icon=icons.diff()) self.button_close = qtutils.close_button() self.diff_files = standard.TreeWidget() self.diff_files.headerItem().setText(0, N_('File Differences')) self.top_grid_layout = qtutils.grid( defs.no_margin, defs.spacing, (self.left_combo, 0, 0, 1, 1), (self.left_list, 1, 0, 1, 1), (self.right_combo, 0, 1, 1, 1), (self.right_list, 1, 1, 1, 1)) self.top_widget.setLayout(self.top_grid_layout) self.bottom_grid_layout = qtutils.grid( defs.no_margin, defs.spacing, (self.diff_files, 0, 0, 1, 4), (self.button_spacer, 1, 1, 1, 1), (self.button_compare, 1, 2, 1, 1), (self.button_close, 1, 3, 1, 1)) self.bottom_widget.setLayout(self.bottom_grid_layout) self.splitter = qtutils.splitter(Qt.Vertical, self.top_widget, self.bottom_widget) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.splitter) self.setLayout(self.main_layout) self.resize(658, 350) connect_button(self.button_close, self.accept) connect_button(self.button_compare, self.compare) self.connect(self.diff_files, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.compare) self.connect(self.left_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=True)) self.connect(self.right_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.update_combo_boxes(left=False)) self.connect(self.left_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.connect(self.right_list, SIGNAL('itemSelectionChanged()'), self.update_diff_files) self.update_combo_boxes(left=True) self.update_combo_boxes(left=False) # Pre-select the 0th elements item = self.left_list.item(0) if item: self.left_list.setCurrentItem(item) self.left_list.setItemSelected(item, True) item = self.right_list.item(0) if item: self.right_list.setCurrentItem(item) self.right_list.setItemSelected(item, True)