[PATCH 1 of 3 V2] ui: store pushloc as separate attribute

Gregory Szorc gregory.szorc at gmail.com
Sun Dec 6 20:59:32 UTC 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1449431342 28800
#      Sun Dec 06 11:49:02 2015 -0800
# Node ID 6594eeb85d16bebd5f4173062aeba38df858c3d2
# Parent  094073353710dad068f30a8e4d1d2524e5dc34ca
ui: store pushloc as separate attribute

The magic @property is going to interfere with the ability to print
path sub-options. We only access it in one location and it is trivial
to in-line, so do that.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5523,17 +5523,18 @@ def push(ui, repo, dest=None, **opts):
                 # if we try to push a deleted bookmark, translate it to null
                 # this lets simultaneous -r, -b options continue working
                 opts.setdefault('rev', []).append("null")
 
     path = ui.paths.getpath(dest, default='default')
     if not path:
         raise error.Abort(_('default repository not configured!'),
                          hint=_('see the "path" section in "hg help config"'))
-    dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
+    dest = path.pushloc or path.loc
+    branches = (path.branch, opts.get('branch') or [])
     ui.status(_('pushing to %s\n') % util.hidepassword(dest))
     revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
     other = hg.peer(repo, opts, dest)
 
     if revs:
         revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
         if not revs:
             raise error.Abort(_("specified revisions evaluate to an empty set"),
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1076,17 +1076,17 @@ class paths(dict):
         # Handle default-push, which is a one-off that defines the push URL for
         # the "default" path.
         defaultpush = ui.config('paths', 'default-push')
         if defaultpush:
             # "default-push" can be defined without "default" entry. This is a
             # bit weird, but is allowed for backwards compatibility.
             if 'default' not in self:
                 self['default'] = path('default', rawloc=defaultpush)
-            self['default']._pushloc = defaultpush
+            self['default'].pushloc = defaultpush
 
     def getpath(self, name, default=None):
         """Return a ``path`` from a string, falling back to a default.
 
         ``name`` can be a named path or locations. Locations are filesystem
         paths or URIs.
 
         Returns None if ``name`` is not a registered path, a URI, or a local
@@ -1144,35 +1144,31 @@ class path(object):
             u.fragment = None
 
         self.url = u
         self.branch = branch
 
         self.name = name
         self.rawloc = rawloc
         self.loc = str(u)
-        self._pushloc = pushloc
+        self.pushloc = pushloc
 
         # When given a raw location but not a symbolic name, validate the
         # location is valid.
         if not name and not u.scheme and not self._isvalidlocalpath(self.loc):
             raise ValueError('location is not a URL or path to a local '
                              'repo: %s' % rawloc)
 
     def _isvalidlocalpath(self, path):
         """Returns True if the given path is a potentially valid repository.
         This is its own function so that extensions can change the definition of
         'valid' in this case (like when pulling from a git repo into a hg
         one)."""
         return os.path.isdir(os.path.join(path, '.hg'))
 
-    @property
-    def pushloc(self):
-        return self._pushloc or self.loc
-
 # we instantiate one globally shared progress bar to avoid
 # competing progress bars when multiple UI objects get created
 _progresssingleton = None
 
 def getprogbar(ui):
     global _progresssingleton
     if _progresssingleton is None:
         # passing 'ui' object to the singleton is fishy,


More information about the Mercurial-devel mailing list