Commit 608c0f28 authored by michaeldewildt's avatar michaeldewildt
Browse files

sync: Implemented named branches, bookmarks and repo id for syncing

parent 493a9d3809e9
......@@ -132,19 +132,11 @@ class RepoFilterBar(QToolBar):
"""Update the list of branches"""
curbranch = self.branch()
def iterbranches(all=False):
allbranches = self._repo.branchtags()
if all:
return sorted(allbranches.keys())
openbrnodes = []
for br in allbranches.iterkeys():
openbrnodes.extend(self._repo.branchheads(br, closed=False))
dead = self._repo.deadbranches
return sorted(br for br, n in allbranches.iteritems()
if n in openbrnodes and br not in dead)
branches = list(iterbranches(all=self._cbranchAction.isChecked()))
if self._cbranchAction.isChecked():
branches = sorted(self._repo.branchtags().keys())
else:
branches = self._repo.namedbranches
self._branchCombo.clear()
self._branchCombo.addItems([''] + branches)
self._branchLabel.setEnabled(len(branches) > 1)
......
......@@ -128,7 +128,6 @@ class RepoWidget(QWidget):
self.repoview = view = HgRepoView(self.repo, self)
view.revisionSelected.connect(self.revision_selected)
view.revisionClicked.connect(self.revision_clicked)
view.revisionActivated.connect(self.revision_activated)
view.showMessage.connect(self.showMessage)
view.menuRequested.connect(self.viewMenuRequest)
......@@ -272,8 +271,7 @@ class RepoWidget(QWidget):
sw.outgoingNodes.connect(self.setOutgoingNodes)
sw.showMessage.connect(self.showMessage)
sw.incomingBundle.connect(self.setBundle)
ctx = self.repo.changectx(self.rev)
sw.refreshBookmarks(ctx.node())
sw.refreshTargets(self.rev)
return sw
@pyqtSlot(QString)
......@@ -313,20 +311,6 @@ class RepoWidget(QWidget):
self.syncDemand.pullBundle(self.bundle, None)
self.clearBundle()
def pullToRev(self):
self.taskTabsWidget.setCurrentIndex(self.syncTabIndex)
self.syncDemand.pullBundle(self.bundle, self.rev)
removed = [self.repo[self.rev]]
while removed:
ctx = removed.pop()
if ctx.node() in self.revset:
self.revset.remove(ctx.node())
removed.extend(ctx.parents())
self.repomodel.revset = self.revset
if not self.revset:
self.clearBundle()
self.refresh()
def rejectBundle(self):
self.clearBundle()
self.reload()
......@@ -535,16 +519,6 @@ class RepoWidget(QWidget):
# Perhaps we can update a GUI element later, to indicate full load
pass
def revision_clicked(self, rev):
'User clicked on a repoview row'
tw = self.taskTabsWidget
if type(rev) == str: # unapplied patch
tw.setCurrentIndex(self.logTabIndex)
elif rev is None:
tw.setCurrentIndex(self.commitTabIndex)
elif tw.currentWidget() in (self.commitDemand, self.syncDemand):
tw.setCurrentIndex(self.logTabIndex)
def revision_selected(self, rev):
'View selection changed, could be a reload'
if self.repomodel.graph is None:
......@@ -556,9 +530,7 @@ class RepoWidget(QWidget):
self.grepDemand.forward('setRevision', rev)
self.revDetailsWidget.revision_selected(rev)
ctx = self.repo.changectx(rev)
self.syncDemand.forward('refreshBookmarks', ctx.node())
self.syncDemand.forward('refreshTargets', rev)
self.revisionSelected.emit(rev)
......@@ -736,15 +708,7 @@ class RepoWidget(QWidget):
break
else:
allunapp = True
if self.bundle:
# Special menu for applied bundle
menu = QMenu(self) # TODO: save in repowidget
act = QAction(_('Pull to here'), self)
act.triggered.connect(self.pullToRev)
menu.addAction(act)
menu.exec_(point)
return
elif allunapp:
if allunapp:
self.unnapliedPatchMenu(point, selection)
elif len(selection) == 1:
self.singleSelectionMenu(point, selection)
......@@ -837,7 +801,6 @@ class RepoWidget(QWidget):
('bookmarks', fixed, _('Bookmark...'), 'bookmark',
self.bookmarkRevision),
(None, fixed, _('Backout...'), None, self.backoutToRevision),
(None, fixed, _('Push to here'), None, self.pushToRevision),
(None, isrev, _('Export patch'), None, self.exportRevisions),
(None, isrev, _('Email patch...'), None, self.emailRevision),
(None, isrev, _('Archive...'), None, self.archiveRevision),
......@@ -1034,10 +997,6 @@ class RepoWidget(QWidget):
cmdline = ['transplant', '--repository', self.repo.root, str(self.rev)]
self.runCommand(_('Transplant - TortoiseHg'), cmdline)
def pushToRevision(self):
self.taskTabsWidget.setCurrentIndex(self.syncTabIndex)
self.syncDemand.pushToRevision(self.rev)
def backoutToRevision(self):
dlg = backout.BackoutDialog(self.repo, str(self.rev), self)
dlg.finished.connect(dlg.deleteLater)
......
......@@ -19,6 +19,7 @@ from mercurial import merge as mergemod
from tortoisehg.util import hglib, wconfig
from tortoisehg.hgqt.i18n import _
from tortoisehg.hgqt import qtlib, cmdui, thgrepo, rebase, resolve
from binascii import hexlify
# TODO
# Write keyring help, connect to help button
......@@ -103,9 +104,11 @@ class SyncWidget(QWidget):
else:
self.p4pbutton = None
self.bookmarkcombo = QComboBox()
hbox.addWidget(QLabel(_('Bookmark:')))
hbox.addWidget(self.bookmarkcombo)
self.targetcombo = QComboBox()
self.targetcheckbox = QCheckBox(_('Target:'))
self.targetcheckbox.stateChanged.connect(self.toggleTargetCheckBox)
hbox.addWidget(self.targetcheckbox)
hbox.addWidget(self.targetcombo)
hbox.addStretch(1)
self.urllabel = QLabel()
......@@ -205,24 +208,50 @@ class SyncWidget(QWidget):
else:
self.curalias = None
def loadBookmarks(self):
self.bookmarkcombo.clear()
self.bookmarkcombo.addItem(_("<all>"), _("all"))
def toggleTargetCheckBox(self):
state = not self.targetcombo.isEnabled()
self.targetcombo.setEnabled(state)
def loadTargets(self, rev):
self.targetcombo.clear()
self.targetcombo.addItem("rev: " + str(rev), str(rev))
for name in self.repo.namedbranches:
if name != "default":
#We need to convert the branch name to hex because it may
#contain special chars like '-' that QComboBox::findData does
#not like
self.targetcombo.addItem("branch: " + name, hexlify(name))
for name, node in self.repo.bookmarks.items():
self.bookmarkcombo.addItem(name, node)
self.targetcombo.addItem("bookmark: " + name, node)
def refreshBookmarks(self, node):
def refreshTargets(self, rev):
if rev is None:
rev = "tip"
# Reload the bookmarks before selecting the revision
self.loadBookmarks()
index = self.bookmarkcombo.findData(node)
self.loadTargets(rev)
ctx = self.repo.changectx(rev)
if rev == "tip":
target = "tip"
else:
target = ctx.branch()
if target == "default":
target = ctx.node()
else:
target = hexlify(target)
index = self.targetcombo.findData(target)
if index < 0:
index = 0
self.bookmarkcombo.setCurrentIndex(index)
self.targetcombo.setCurrentIndex(index)
def applyBookmarkOption(self, cmdline):
bookmark = str(self.bookmarkcombo.currentText())
if bookmark != '<all>':
cmdline += ['--rev', bookmark]
def applyTargetOption(self, cmdline):
if not self.targetcheckbox.isChecked():
revtext = str(self.targetcombo.currentText())
rev = revtext.split(': ').pop().strip()
cmdline += ['--rev', rev]
return cmdline
def configChanged(self):
......@@ -270,7 +299,6 @@ class SyncWidget(QWidget):
pairs = [(alias, path) for path, alias in related.items()]
tm = PathsModel(pairs, self)
self.reltv.setModel(tm)
self.loadBookmarks()
def refreshUrl(self):
'User has changed schema/host/port/path'
......@@ -493,7 +521,7 @@ class SyncWidget(QWidget):
cmdline.append(val)
if 'rev' in details and '--rev' not in cmdline:
cmdline = self.applyBookmarkOption(cmdline)
cmdline = self.applyTargetOption(cmdline)
url = self.currentUrl(False)
if not url:
......@@ -535,30 +563,6 @@ class SyncWidget(QWidget):
else:
self.pushclicked()
def pullBundle(self, bundle, rev):
'accept bundle changesets'
if self.cmd.core.is_running():
self.showMessage.emit(_('sync command already running'))
return
save = self.currentUrl(False)
orev = self.opts.get('rev')
self.setUrl(bundle)
if rev is not None:
self.opts['rev'] = str(rev)
self.pullclicked()
self.setUrl(save)
self.opts['rev'] = orev
def pushToRevision(self, rev):
'push to specified revision'
if self.cmd.core.is_running():
self.showMessage.emit(_('sync command already running'))
return
orev = self.opts.get('rev')
self.opts['rev'] = str(rev)
self.pushclicked()
self.opts['rev'] = orev
##
## Sync dialog buttons
##
......@@ -1155,18 +1159,6 @@ class OptionsDialog(QDialog):
self.subrepocb.setChecked(opts.get('subrepos', False))
layout.addRow(self.subrepocb, None)
lbl = QLabel(_('Specify branch for push/pull:'))
self.branchle = QLineEdit()
if opts.get('branch'):
self.branchle.setText(hglib.tounicode(opts['branch']))
layout.addRow(lbl, self.branchle)
lbl = QLabel(_('Specify revision for push/pull:'))
self.revle = QLineEdit()
if opts.get('rev'):
self.revle.setText(hglib.tounicode(opts['rev']))
layout.addRow(lbl, self.revle)
lbl = QLabel(_('Remote command:'))
self.remotele = QLineEdit()
if opts.get('remotecmd'):
......
......@@ -382,6 +382,16 @@ def _extendrepo(repo):
installed.append(t)
return installed
@propertycache
def namedbranches(self):
allbranches = self.branchtags()
openbrnodes = []
for br in allbranches.iterkeys():
openbrnodes.extend(self.branchheads(br, closed=False))
dead = self.deadbranches
return sorted(br for br, n in allbranches.iteritems()
if n in openbrnodes and br not in dead)
@propertycache
def bookmarks(self):
if 'bookmarks' in self._exts and hasattr(self, '_bookmarks'):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment