diff --git a/hgext/remotefilelog/basestore.py b/hgext/remotefilelog/basestore.py --- a/hgext/remotefilelog/basestore.py +++ b/hgext/remotefilelog/basestore.py @@ -441,7 +441,10 @@ class baseunionstore(object): 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: diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py --- a/hgext/zeroconf/Zeroconf.py +++ b/hgext/zeroconf/Zeroconf.py @@ -1191,7 +1191,11 @@ class ServiceInfo(object): 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: diff --git a/mercurial/cffi/bdiffbuild.py b/mercurial/cffi/bdiffbuild.py --- a/mercurial/cffi/bdiffbuild.py +++ b/mercurial/cffi/bdiffbuild.py @@ -5,10 +5,10 @@ import os 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( """ diff --git a/mercurial/cffi/mpatchbuild.py b/mercurial/cffi/mpatchbuild.py --- a/mercurial/cffi/mpatchbuild.py +++ b/mercurial/cffi/mpatchbuild.py @@ -5,11 +5,11 @@ import os 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( """ diff --git a/mercurial/cffi/osutilbuild.py b/mercurial/cffi/osutilbuild.py --- a/mercurial/cffi/osutilbuild.py +++ b/mercurial/cffi/osutilbuild.py @@ -4,7 +4,7 @@ import cffi ffi = cffi.FFI() ffi.set_source( - b"mercurial.cffi._osutil", + "mercurial.cffi._osutil", """ #include #include @@ -22,7 +22,7 @@ typedef struct val_attrs { off_t datalength; } __attribute__((aligned(4), packed)) val_attrs_t; """, - include_dirs=[b'mercurial'], + include_dirs=['mercurial'], ) ffi.cdef( ''' diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1568,7 +1568,7 @@ class localrepository(object): 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 @@ class localrepository(object): 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 ) diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -543,7 +543,7 @@ class predicatematcher(basematcher): 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 @@ class unionmatcher(basematcher): 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' diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -2290,7 +2290,7 @@ def _applydiff( 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 diff --git a/mercurial/pure/base85.py b/mercurial/pure/base85.py --- a/mercurial/pure/base85.py +++ b/mercurial/pure/base85.py @@ -67,10 +67,10 @@ def b85decode(text): 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 diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -146,7 +146,7 @@ class shelvedfile(object): 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 @@ def deletecmd(ui, repo, pats): 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 @@ def deletecmd(ui, repo, pats): # 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): diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1906,7 +1906,7 @@ def copyfile(src, dest, hardlink=False, ) & 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): diff --git a/tests/test-single-head.t b/tests/test-single-head.t --- a/tests/test-single-head.t +++ b/tests/test-single-head.t @@ -259,3 +259,35 @@ Test that closing heads can be explicitl 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 <> $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)