changeset 46942:b5e7cdb93abc

relink: use `get_unique_pull_path` The code does not support multiple destination and will probably never do so. So lets use the dedicated API for this case. Differential Revision: https://phab.mercurial-scm.org/D10409
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 14 Apr 2021 12:29:44 +0200
parents d689d48527ea
children 30ee1224b9a2
files hgext/relink.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/relink.py	Wed Apr 14 12:01:27 2021 +0200
+++ b/hgext/relink.py	Wed Apr 14 12:29:44 2021 +0200
@@ -19,7 +19,10 @@
     registrar,
     util,
 )
-from mercurial.utils import stringutil
+from mercurial.utils import (
+    stringutil,
+    urlutil,
+)
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -62,10 +65,11 @@
         util, b'samedevice'
     ):
         raise error.Abort(_(b'hardlinks are not supported on this system'))
-    src = hg.repository(
-        repo.baseui,
-        ui.expandpath(origin or b'default-relink', origin or b'default'),
-    )
+
+    if origin is None and b'default-relink' in ui.paths:
+        origin = b'default-relink'
+    path, __ = urlutil.get_unique_pull_path(b'relink', repo, ui, origin)
+    src = hg.repository(repo.baseui, path)
     ui.status(_(b'relinking %s to %s\n') % (src.store.path, repo.store.path))
     if repo.root == src.root:
         ui.status(_(b'there is nothing to relink\n'))