[Commented On] D10445: urlutil: add a `copy` method to `path

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Sat Apr 17 23:44:49 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 27014.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D10445?vs=26954&id=27014

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D10445/new/

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

AFFECTED FILES
  mercurial/utils/urlutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/urlutil.py b/mercurial/utils/urlutil.py
--- a/mercurial/utils/urlutil.py
+++ b/mercurial/utils/urlutil.py
@@ -707,7 +707,7 @@
 class path(object):
     """Represents an individual path and its configuration."""
 
-    def __init__(self, ui, name, rawloc=None, suboptions=None):
+    def __init__(self, ui=None, name=None, rawloc=None, suboptions=None):
         """Construct a path from its config options.
 
         ``ui`` is the ``ui`` instance the path is coming from.
@@ -719,6 +719,13 @@
         filesystem path with a .hg directory or b) a URL. If not,
         ``ValueError`` is raised.
         """
+        if ui is None:
+            # used in copy
+            assert name is None
+            assert rawloc is None
+            assert suboptions is None
+            return
+
         if not rawloc:
             raise ValueError(b'rawloc must be defined')
 
@@ -774,6 +781,16 @@
             suboptions.update(self._own_sub_opts)
             self._apply_suboptions(ui, suboptions)
 
+    def copy(self):
+        """make a copy of this path object"""
+        new = self.__class__()
+        for k, v in self.__dict__.items():
+            new_copy = getattr(v, 'copy', None)
+            if new_copy is not None:
+                v = new_copy()
+            new.__dict__[k] = v
+        return new
+
     def _validate_path(self):
         # When given a raw location but not a symbolic name, validate the
         # location is valid.



To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210417/ff7cc8c2/attachment-0002.html>


More information about the Mercurial-patches mailing list