Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

sync: add list of related paths

Changeset a990f2eedece

Parent bc2755b7b805

by Steve Borho

Changes to one file · Browse files at a990f2eedece Showing diff from parent bc2755b7b805 Diff from another changeset...

 
46
47
48
49
50
51
52
 
107
108
109
110
 
111
 
 
112
113
114
115
116
117
118
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
121
122
 
177
178
179
 
180
181
182
 
184
185
186
187
 
 
 
188
189
190
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
193
194
 
701
702
703
704
 
705
706
707
708
709
 
710
711
712
 
713
714
715
 
761
762
763
764
 
765
766
767
768
769
770
 
 
 
 
 
 
 
 
771
772
773
 
46
47
48
 
49
50
51
 
106
107
108
 
109
110
111
112
113
114
115
116
117
118
 
 
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 
191
192
193
194
195
196
197
 
199
200
201
 
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
 
737
738
739
 
740
741
742
743
744
745
746
747
748
 
749
750
751
752
 
798
799
800
 
801
802
803
804
 
 
 
805
806
807
808
809
810
811
812
813
814
815
@@ -46,7 +46,6 @@
  self.curuser = None   self.curpw = None   self.updateInProgress = False - self.tv = PathsTree(root, self)     if not embedded:   self.setWindowTitle(_('TortoiseHg Sync')) @@ -107,16 +106,31 @@
  self.p4pbutton = None   layout.addLayout(hbox)   - self.tv.clicked.connect(self.pathSelected) + hbox = QHBoxLayout()   + self.hgrctv = PathsTree(self, True) + self.hgrctv.clicked.connect(self.pathSelected)   pathsframe = QFrame()   pathsframe.setFrameStyle(QFrame.StyledPanel|QFrame.Raised)   pathsbox = QVBoxLayout()   pathsframe.setLayout(pathsbox)   lbl = QLabel(_('<b>Configured Paths</b>'))   pathsbox.addWidget(lbl) - pathsbox.addWidget(self.tv) - layout.addWidget(pathsframe, 1) + pathsbox.addWidget(self.hgrctv) + hbox.addWidget(pathsframe) + + self.reltv = PathsTree(self, False) + self.reltv.clicked.connect(self.pathSelected) + pathsframe = QFrame() + pathsframe.setFrameStyle(QFrame.StyledPanel|QFrame.Raised) + pathsbox = QVBoxLayout() + pathsframe.setLayout(pathsbox) + lbl = QLabel(_('<b>Related Paths</b>')) + pathsbox.addWidget(lbl) + pathsbox.addWidget(self.reltv) + hbox.addWidget(pathsframe) + + layout.addLayout(hbox, 1)     self.savebutton.clicked.connect(self.saveclicked)   self.authbutton.clicked.connect(self.authclicked) @@ -177,6 +191,7 @@
  self.reload()     def reload(self): + # Refresh configured paths   self.paths = {}   fn = os.path.join(self.root, '.hg', 'hgrc')   fn, cfg = loadIniFile([fn], self) @@ -184,11 +199,32 @@
  for alias in cfg['paths']:   self.paths[ alias ] = cfg['paths'][ alias ]   tm = PathsModel(self.paths, self) - self.tv.setModel(tm) + self.hgrctv.setModel(tm) + + # Refresh post-pull   self.cachedpp = self.repo.postpull   name = _('Post Pull: ') + self.repo.postpull.title()   self.postpullbutton.setText(name)   + # Refresh related paths + known = set(self.paths.values()) + known.add(self.repo.root) + related = {} + repoid = self.repo[0].node() + for repo in thgrepo._repocache.values(): + if repo[0].node() != repoid: + continue + if repo.root not in known: + related[repo.root] = repo.shortname + known.add(repo.root) + for alias, path in repo.ui.configitems('paths'): + if path not in known: + related[path] = alias + known.add(path) + pairs = [(alias, path) for path, alias in related.items()] + tm = PathsModel(pairs, self) + self.reltv.setModel(tm) +   def refreshUrl(self):   'User has changed schema/host/port/path'   if self.updateInProgress: @@ -701,15 +737,16 @@
     class PathsTree(QTreeView): - def __init__(self, root, parent=None): + def __init__(self, parent, editable):   QTreeView.__init__(self, parent)   self.setSelectionMode(QTreeView.SingleSelection)   self.setContextMenuPolicy(Qt.CustomContextMenu)   self.customContextMenuRequested.connect(self.menuRequest)   self.parent = parent + self.editable = editable     def keyPressEvent(self, event): - if event.matches(QKeySequence.Delete): + if self.editable and event.matches(QKeySequence.Delete):   self.deleteSelected()   else:   return super(PathsTree, self).keyPressEvent(event) @@ -761,13 +798,18 @@
  return self.selectionModel().selectedRows()    class PathsModel(QAbstractTableModel): - def __init__(self, pathdict, parent=None): + def __init__(self, pathdictorlist, parent=None):   QAbstractTableModel.__init__(self, parent)   self.headers = (_('Alias'), _('URL'))   self.rows = [] - for alias, path in pathdict.iteritems(): - safepath = url.hidepassword(path) - self.rows.append([alias, safepath, path]) + if isinstance(pathdictorlist, dict): + for alias, path in pathdictorlist.iteritems(): + safepath = url.hidepassword(path) + self.rows.append([alias, safepath, path]) + else: + for alias, path in pathdictorlist: + safepath = url.hidepassword(path) + self.rows.append([alias, safepath, path])     def rowCount(self, parent):   if parent.isValid():