Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.1, 2.0.2, and 2.0.3

stable sync: use thgrepo.relatedRepositories(), directly read unopened repo configs

This should improve sync widget startup time, and avoid creating thgrepo
instances (and their poll overhead) for every related repository.

Changeset fa180caa9d69

Parent 14c1e491a04c

by Steve Borho

Changes to one file · Browse files at fa180caa9d69 Showing diff from parent 14c1e491a04c Diff from another changeset...

 
19
20
21
22
23
 
24
25
26
 
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
368
369
 
19
20
21
 
 
22
23
24
25
 
343
344
345
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
@@ -19,8 +19,7 @@
   from tortoisehg.util import hglib, wconfig  from tortoisehg.hgqt.i18n import _ -from tortoisehg.hgqt import qtlib, cmdui, thgrepo, rebase, resolve, \ - reporegistry, repotreemodel +from tortoisehg.hgqt import qtlib, cmdui, thgrepo, rebase, resolve    _schemes = ['local', 'ssh', 'http', 'https']   @@ -344,26 +343,23 @@
  known = set(self.paths.values())   known.add(self.repo.root)   related = {} - repoid = self.repo[0].node() - f = QFile(reporegistry.settingsfilename()) - f.open(QIODevice.ReadOnly) - try: - for e in repotreemodel.iterRepoItemFromXml(f): - if e.basenode() != repoid: - continue - try: - repo = thgrepo.repository(path=e.rootpath()) - except error.RepoError: - 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) - finally: - f.close() + for root, shortname in thgrepo.relatedRepositories(self.repo[0].node()): + if root not in known: + related[root] = shortname + known.add(root) + if root in thgrepo._repocache: + # repositories already opened keep their ui instances in sync + repo = thgrepo._repocache[root] + ui = repo.ui + else: + # directly read the repository's configuration file + tempui = self.repo.ui.copy() + tempui.readconfig(os.path.join(root, '.hg', 'hgrc')) + ui = tempui + for alias, path in 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)