[PATCH 2 of 2] reporegistry: pop up if the repo is already in the registry or if it is not a repo

6 views
Skip to first unread message

Antonio Muci

unread,
Jun 7, 2023, 2:16:42 PM6/7/23
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1686161231 -7200
# Wed Jun 07 20:07:11 2023 +0200
# Node ID 8d6215213b256d401056118ba2fde989b271e84e
# Parent dec41ba937da893e81d6ad49d03e820e85c1094d
reporegistry: pop up if the repo is already in the registry or if it is not a repo

Fixes #5894 (https://foss.heptapod.net/mercurial/tortoisehg/thg/-/issues/5894)

diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
--- a/tortoisehg/hgqt/reporegistry.py
+++ b/tortoisehg/hgqt/reporegistry.py
@@ -584,9 +584,21 @@ class RepoRegistryView(QDockWidget):
m = self.tview.model()
assert m is not None
uroot = paths.find_root(path)
- if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
- index = m.addRepo(uroot, parent=self.tview.currentIndex())
- self._scanAddedRepo(index)
+ if not uroot:
+ qtlib.WarningMsgBox(
+ _('Repository not found'),
+ _('The selected directory (%s) does not appear to be a mercurial repository' % path),
+ parent=self)
+ return
+ if m.isKnownRepoRoot(uroot, standalone=True):
+ qtlib.InfoMsgBox(
+ _('Repository already in registry'),
+ _('The selected repository (%s) is already present in the registry. Not adding it again.' % uroot),
+ parent=self)
+ return
+ # this is a new mercurial repo, let's add it to the registry
+ index = m.addRepo(uroot, parent=self.tview.currentIndex())
+ self._scanAddedRepo(index)

def addSubrepo(self):
'menu action handler for adding a new subrepository'

Antonio Muci

unread,
Jun 7, 2023, 2:16:42 PM6/7/23
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1686161089 -7200
# Wed Jun 07 20:04:49 2023 +0200
# Node ID dec41ba937da893e81d6ad49d03e820e85c1094d
# Parent 7db478c35f420f92c4cdd3fe819480bb2b017e6b
reporegistry: handle pressing the Cancel before handling the general case

This change inverts the logic handling the cancel button, exiting early if the
user cancelled, and is in preparation for the next commit.

No functional changes.

diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
--- a/tortoisehg/hgqt/reporegistry.py
+++ b/tortoisehg/hgqt/reporegistry.py
@@ -578,13 +578,15 @@ class RepoRegistryView(QDockWidget):
FD = QFileDialog
path = FD.getExistingDirectory(caption=caption,
options=QFileDialog.Option.ShowDirsOnly | QFileDialog.Option.ReadOnly)
- if path:
- m = self.tview.model()
- assert m is not None
- uroot = paths.find_root(path)
- if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
- index = m.addRepo(uroot, parent=self.tview.currentIndex())
- self._scanAddedRepo(index)
+ if not path:
+ # the used pressed "cancel"
+ return
+ m = self.tview.model()
+ assert m is not None
+ uroot = paths.find_root(path)
+ if uroot and not m.isKnownRepoRoot(uroot, standalone=True):

Yuya Nishihara

unread,
Jun 8, 2023, 9:27:12 AM6/8/23
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Wed, 07 Jun 2023 20:16:40 +0200, 'Antonio Muci' via TortoiseHg Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1686161231 -7200
> # Wed Jun 07 20:07:11 2023 +0200
> # Node ID 8d6215213b256d401056118ba2fde989b271e84e
> # Parent dec41ba937da893e81d6ad49d03e820e85c1094d
> reporegistry: pop up if the repo is already in the registry or if it is not a repo

Nice. Queued, thanks.

> diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
> --- a/tortoisehg/hgqt/reporegistry.py
> +++ b/tortoisehg/hgqt/reporegistry.py
> @@ -584,9 +584,21 @@ class RepoRegistryView(QDockWidget):
> m = self.tview.model()
> assert m is not None
> uroot = paths.find_root(path)
> - if uroot and not m.isKnownRepoRoot(uroot, standalone=True):
> - index = m.addRepo(uroot, parent=self.tview.currentIndex())
> - self._scanAddedRepo(index)
> + if not uroot:
> + qtlib.WarningMsgBox(
> + _('Repository not found'),
> + _('The selected directory (%s) does not appear to be a mercurial repository' % path),

Fixed i18n string in flight. _("literal" % var) should be _("literal") % var.
Otherwise _("literal") wouldn't be translated.
Reply all
Reply to author
Forward
0 new messages