コード例 #1
0
    def get_body(self, vbox):
        # layout table
        table = gtklib.LayoutTable()
        vbox.pack_start(table, False, False, 2)
        self.table = table

        ## revision label & combobox
        self.revcombo = combo = gtk.combo_box_entry_new_text()
        entry = combo.child
        entry.set_width_chars(38)
        entry.connect('activate', lambda b: self.response(gtk.RESPONSE_OK))
        table.add_row(_('Update to:'), combo, padding=False)

        ## fill list of combo
        if self.rev != None:
            combo.append_text(str(self.rev))
        else:
            combo.append_text(self.repo.dirstate.branch())
        combo.set_active(0)
        for name in hglib.getlivebranch(self.repo):
            combo.append_text(name)

        tags = list(self.repo.tags())
        tags.sort()
        tags.reverse()
        for tag in tags:
            combo.append_text(hglib.toutf(tag))

        ## changeset summaries
        style = csinfo.labelstyle(contents=('%(rev)s', ' %(branch)s',
                       ' %(tags)s', '\n%(summary)s'), selectable=True, width=350)
        factory = csinfo.factory(self.repo, style=style)

        def add_with_pad(title, cslabel):
            label = gtk.Label(title)
            label.set_alignment(1, 0)
            headbox = gtk.VBox()
            headbox.pack_start(label, False, False, 2)
            headbox.pack_start(gtk.VBox())
            table.add_row(headbox, cslabel, yhopt=gtk.FILL|gtk.EXPAND)

        ## summary of target revision
        self.target_label = factory()
        add_with_pad(_('Target:'), self.target_label)

        ## summary of parent 1 revision
        self.parent1_label = factory()

        ## summary of parent 2 revision if needs
        self.ctxs = self.repo[None].parents()
        if len(self.ctxs) == 2:
            add_with_pad(_('Parent 1:'), self.parent1_label)
            self.parent2_label = factory()
            add_with_pad(_('Parent 2:'), self.parent2_label)
        else:
            add_with_pad(_('Parent:'), self.parent1_label)
            self.parent2_label = None

        ## option expander
        self.expander = gtk.Expander(_('Options:'))
        self.expander.connect('notify::expanded', self.options_expanded)

        ### update method (fixed)
        self.opt_clean = gtk.CheckButton(_('Discard local changes, '
                                           'no backup (-C/--clean)'))
        table.add_row(self.expander, self.opt_clean)

        ### other options (foldable), put later
        ### automatically merge, if possible (similar to command-line behavior)
        self.opt_merge = gtk.CheckButton(_('Always merge (when possible)'))

        ### always show command log widget
        self.opt_showlog = gtk.CheckButton(_('Always show log'))

        # signal handlers
        self.revcombo.connect('changed', lambda b: self.update_summaries())
        self.opt_clean.connect('toggled', lambda b: self.update_summaries())

        # prepare to show
        self.update_summaries()
コード例 #2
0
    def get_body(self, vbox):
        rev0, rev1 = self.revs
        prevs = [ctx.rev() for ctx in self.repo.parents()]
        if len(prevs) > 1:
            rev0, rev1 = prevs
        elif (not rev1 and rev1 != 0):
            gdialog.Prompt(_('Unable to merge'),
                           _('Must supply a target revision'), self).run()
            gtklib.idle_add_single_call(self.hide)
            return False
        elif (not rev0 and rev0 != 0):
            rev0 = prevs[0]
        elif rev1 == prevs[0]:
            # selected pair was backwards
            rev0, rev1 = rev1, rev0
        elif rev0 != prevs[0]:
            # working parent not in selected revision pair
            modified, added, removed, deleted = self.repo.status()[:4]
            if modified or added or removed or deleted:
                gdialog.Prompt(_('Unable to merge'),
                               _('Outstanding uncommitted changes'), self).run()
                gtklib.idle_add_single_call(self.hide)
                return False
            self.repo.ui.quiet = True
            commands.update(self.repo.ui, self.repo, rev=str(rev0), check=True)
            self.repo.ui.quiet = False

        # changeset info
        style = csinfo.panelstyle(contents=csinfo.PANEL_DEFAULT + ('ishead',),
                                  margin=5, padding=2)
        def markup_func(widget, item, value):
            if item == 'ishead' and value is False:
                text = _('Not a head revision!')
                return gtklib.markup(text, weight='bold')
            raise csinfo.UnknownItem(item)
        custom = csinfo.custom(markup=markup_func)
        factory = csinfo.factory(self.repo, custom, style, withupdate=True)

        info = factory(rev1, style={'label': _('Merge target (other)')})
        self.vbox.pack_start(info, False, False)
        self.otherframe = info
        self.otherrev = str(info.get_data('revnum'))

        info = factory(rev0, style={'label': _('Current revision (local)')})
        self.vbox.pack_start(info, False, False)
        self.localframe = info
        self.localrev = str(info.get_data('revnum'))

        # expander for advanced options
        expander = gtk.Expander(_('Advanced options'))
        self.vbox.pack_start(expander, False, False)

        # layout table for advanced options
        table = gtklib.LayoutTable()
        expander.add(table)
        
        vlist = gtk.ListStore(str,  # tool name
                              bool) # separator
        combo = gtk.ComboBoxEntry(vlist, 0)
        self.mergetool = combo
        combo.set_row_separator_func(lambda model, path: model[path][1])
        combo.child.set_width_chars(16)
        chtool = gtk.RadioButton(None, _('Use merge tool:'))
        self.mergelabel = chtool
        table.add_row(chtool, combo)
        prev = False
        for tool in hglib.mergetools(self.repo.ui):
            cur = tool.startswith('internal:')
            vlist.append((hglib.toutf(tool), prev != cur))
            prev = cur
        mtool = self.repo.ui.config('ui', 'merge', None)
        if mtool:
            combo.child.set_text(hglib.toutf(mtool))
        else:
            combo.child.set_text('')

        discard = gtk.RadioButton(chtool,
            _('Discard all changes from merge target (other) revision'))
        self.discard = discard
        table.add_row(discard)

        # prepare to show
        if len(self.repo.parents()) == 2:
            self.mergetool.set_sensitive(False)
            self.mergelabel.set_sensitive(False)
            self.discard.set_sensitive(False)
            self.buttons['merge'].set_sensitive(False)
            self.buttons['commit'].set_sensitive(True)
            self.buttons['undo'].set_sensitive(True)
        else:
            self.buttons['commit'].set_sensitive(False)
            self.buttons['undo'].set_sensitive(False)