Patchwork D10409: relink: use `get_unique_pull_path`

login
register
mail settings
Submitter phabricator
Date April 14, 2021, 11:37 p.m.
Message ID <differential-rev-PHID-DREV-v5jqppbmy4kuqwacfx35-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48725/
State Superseded
Headers show

Comments

phabricator - April 14, 2021, 11:37 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The code does not support multiple destination and will probably never do so.
  So lets use the dedicated API for this case.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10409

AFFECTED FILES
  hgext/relink.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -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'))