merge with stable
authorYuya Nishihara <yuya@tcha.org>
Fri, 22 Nov 2019 21:42:04 +0900
changeset 43735 7eb701e355bd
parent 43733 8ca92bcb3083 (current diff)
parent 43734 88a306478556 (diff)
child 43736 640bae94f2f3
merge with stable
hgext/remotefilelog/basestore.py
hgext/zeroconf/Zeroconf.py
mercurial/localrepo.py
mercurial/match.py
mercurial/patch.py
mercurial/util.py
--- a/hgext/remotefilelog/basestore.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/hgext/remotefilelog/basestore.py	Fri Nov 22 21:42:04 2019 +0900
@@ -441,7 +441,10 @@
             i = 0
             while i < self.numattempts:
                 if i > 0:
-                    retrylog(b're-attempting (n=%d) %s\n' % (i, funcname))
+                    retrylog(
+                        b're-attempting (n=%d) %s\n'
+                        % (i, pycompat.sysbytes(funcname))
+                    )
                     self.markforrefresh()
                 i += 1
                 try:
--- a/hgext/zeroconf/Zeroconf.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/hgext/zeroconf/Zeroconf.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1191,7 +1191,11 @@
                 list.append(b'='.join((key, suffix)))
             for item in list:
                 result = b''.join(
-                    (result, struct.pack(b'!c', chr(len(item))), item)
+                    (
+                        result,
+                        struct.pack(b'!c', pycompat.bytechr(len(item))),
+                        item,
+                    )
                 )
             self.text = result
         else:
--- a/mercurial/cffi/bdiffbuild.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/cffi/bdiffbuild.py	Fri Nov 22 21:42:04 2019 +0900
@@ -5,10 +5,10 @@
 
 ffi = cffi.FFI()
 with open(
-    os.path.join(os.path.join(os.path.dirname(__file__), b'..'), b'bdiff.c')
+    os.path.join(os.path.join(os.path.dirname(__file__), '..'), 'bdiff.c')
 ) as f:
     ffi.set_source(
-        b"mercurial.cffi._bdiff", f.read(), include_dirs=[b'mercurial']
+        "mercurial.cffi._bdiff", f.read(), include_dirs=['mercurial']
     )
 ffi.cdef(
     """
--- a/mercurial/cffi/mpatchbuild.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/cffi/mpatchbuild.py	Fri Nov 22 21:42:04 2019 +0900
@@ -5,11 +5,11 @@
 
 ffi = cffi.FFI()
 mpatch_c = os.path.join(
-    os.path.join(os.path.dirname(__file__), b'..', b'mpatch.c')
+    os.path.join(os.path.dirname(__file__), '..', 'mpatch.c')
 )
 with open(mpatch_c) as f:
     ffi.set_source(
-        b"mercurial.cffi._mpatch", f.read(), include_dirs=[b"mercurial"]
+        "mercurial.cffi._mpatch", f.read(), include_dirs=["mercurial"]
     )
 ffi.cdef(
     """
--- a/mercurial/cffi/osutilbuild.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/cffi/osutilbuild.py	Fri Nov 22 21:42:04 2019 +0900
@@ -4,7 +4,7 @@
 
 ffi = cffi.FFI()
 ffi.set_source(
-    b"mercurial.cffi._osutil",
+    "mercurial.cffi._osutil",
     """
 #include <sys/attr.h>
 #include <sys/vnode.h>
@@ -22,7 +22,7 @@
     off_t             datalength;
 } __attribute__((aligned(4), packed)) val_attrs_t;
 """,
-    include_dirs=[b'mercurial'],
+    include_dirs=['mercurial'],
 )
 ffi.cdef(
     '''
--- a/mercurial/localrepo.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/localrepo.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1568,7 +1568,7 @@
             else:
                 raise error.ProgrammingError(
                     b"unsupported changeid '%s' of type %s"
-                    % (changeid, pycompat.sysstr(type(changeid)))
+                    % (changeid, pycompat.bytestr(type(changeid)))
                 )
 
             return context.changectx(self, rev, node)
@@ -2086,11 +2086,10 @@
             tracktags(tr2)
             repo = reporef()
 
-            r = repo.ui.configsuboptions(
-                b'experimental', b'single-head-per-branch'
-            )
-            singlehead, singleheadsub = r
+            singleheadopt = (b'experimental', b'single-head-per-branch')
+            singlehead = repo.ui.configbool(*singleheadopt)
             if singlehead:
+                singleheadsub = repo.ui.configsuboptions(*singleheadopt)[1]
                 accountclosed = singleheadsub.get(
                     b"account-closed-heads", False
                 )
--- a/mercurial/match.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/match.py	Fri Nov 22 21:42:04 2019 +0900
@@ -543,7 +543,7 @@
 
 
 class patternmatcher(basematcher):
-    """Matches a set of (kind, pat, source) against a 'root' directory.
+    r"""Matches a set of (kind, pat, source) against a 'root' directory.
 
     >>> kindpats = [
     ...     (b're', br'.*\.c$', b''),
@@ -1152,7 +1152,7 @@
 
 
 def patkind(pattern, default=None):
-    '''If pattern is 'kind:pat' with a known kind, return kind.
+    r'''If pattern is 'kind:pat' with a known kind, return kind.
 
     >>> patkind(br're:.*\.c$')
     're'
--- a/mercurial/patch.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/patch.py	Fri Nov 22 21:42:04 2019 +0900
@@ -2290,7 +2290,7 @@
             try:
                 current_file = patcher(ui, gp, backend, store, eolmode=eolmode)
             except PatchError as inst:
-                ui.warn(str(inst) + b'\n')
+                ui.warn(stringutil.forcebytestr(inst) + b'\n')
                 current_file = None
                 rejects += 1
                 continue
--- a/mercurial/pure/base85.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/pure/base85.py	Fri Nov 22 21:42:04 2019 +0900
@@ -67,10 +67,10 @@
                 acc = acc * 85 + _b85dec[c]
             except KeyError:
                 raise ValueError(
-                    b'bad base85 character at position %d' % (i + j)
+                    'bad base85 character at position %d' % (i + j)
                 )
         if acc > 4294967295:
-            raise ValueError(b'Base85 overflow in hunk starting at byte %d' % i)
+            raise ValueError('Base85 overflow in hunk starting at byte %d' % i)
         out.append(acc)
 
     # Pad final chunk if necessary
--- a/mercurial/shelve.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/shelve.py	Fri Nov 22 21:42:04 2019 +0900
@@ -146,7 +146,7 @@
     def bundlerepo(self):
         path = self.vfs.join(self.fname)
         return bundlerepo.instance(
-            self.repo.baseui, b'bundle://%s+%s' % (self.repo.root, path)
+            self.repo.baseui, b'bundle://%s+%s' % (self.repo.root, path), False
         )
 
     def writebundle(self, bases, node):
@@ -603,8 +603,8 @@
     if not pats:
         raise error.Abort(_(b'no shelved changes specified!'))
     with repo.wlock():
-        try:
-            for name in pats:
+        for name in pats:
+            try:
                 for suffix in shelvefileextensions:
                     shfile = shelvedfile(repo, name, suffix)
                     # patch file is necessary, as it should
@@ -614,11 +614,11 @@
                     # bundle
                     if shfile.exists() or suffix == patchextension:
                         shfile.movetobackup()
+            except OSError as err:
+                if err.errno != errno.ENOENT:
+                    raise
+                raise error.Abort(_(b"shelved change '%s' not found") % name)
             cleanupoldbackups(repo)
-        except OSError as err:
-            if err.errno != errno.ENOENT:
-                raise
-            raise error.Abort(_(b"shelved change '%s' not found") % name)
 
 
 def listshelves(repo):
--- a/mercurial/util.py	Thu Nov 21 15:46:35 2019 -0500
+++ b/mercurial/util.py	Fri Nov 22 21:42:04 2019 +0900
@@ -1906,7 +1906,7 @@
                         ) & 0x7FFFFFFF
                         os.utime(dest, (advanced, advanced))
         except shutil.Error as inst:
-            raise error.Abort(str(inst))
+            raise error.Abort(stringutil.forcebytestr(inst))
 
 
 def copyfiles(src, dst, hardlink=None, progress=None):
--- a/tests/test-single-head.t	Thu Nov 21 15:46:35 2019 -0500
+++ b/tests/test-single-head.t	Fri Nov 22 21:42:04 2019 +0900
@@ -259,3 +259,35 @@
   abort: rejecting multiple heads on branch "branch_A"
   (3 heads: 49003e504178 5254bcccab93 42b9fe70a3c1)
   [255]
+
+
+Test that config can be overriden as the boolean it is
+------------------------------------------------------
+
+  $ cat <<EOF >> $TESTTMP/single-head-server/.hg/hgrc
+  > [experimental]
+  > single-head-per-branch = no
+  > EOF
+
+Because of previous test, we'll also push c_aL0 and c_aM0.
+
+  $ hg out -T "{desc}\n"
+  comparing with $TESTTMP/single-head-server
+  searching for changes
+  c_aL0
+  c_aM0
+
+Let's make a new head and push everythin. The server feedback will mention
+exactly one new head because c_aM0 is closed.
+
+  $ hg up 'desc("c_aG0")'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommit c_aN0
+  created new head
+  $ hg push -f
+  pushing to $TESTTMP/single-head-server
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 3 changesets with 3 changes to 3 files (+1 heads)