diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -30,8 +30,10 @@ def addbranchrevs(lrepo, repo, branches, if branch == '.': if not lrepo or not lrepo.local(): raise util.Abort(_("dirstate branch not accessible")) - branch = lrepo.dirstate.branch() - butf8 = encoding.fromlocal(branch) + butf8 = lrepo.dirstate.branch() + branch = encoding.tolocal(butf8) + else: + butf8 = encoding.fromlocal(branch) if butf8 in branchmap: revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) else: diff --git a/tests/test-branch-option b/tests/test-branch-option --- a/tests/test-branch-option +++ b/tests/test-branch-option @@ -20,6 +20,14 @@ hg branch b echo b > foo hg ci -d '0 0' -mb hg up 0 +hg --encoding utf-8 branch æ +echo ae1 > foo +hg ci -d '0 0' -mae1 +hg up 0 +hg --encoding utf-8 branch -f æ +echo ae2 > foo +hg ci -d '0 0' -mae2 +hg up 0 hg branch -f b echo b2 > foo hg ci -d '0 0' -mb2 @@ -30,6 +38,10 @@ hg in -qr c -b a echo out branch . hg out -q ../branch#. hg out -q -b . +echo out branch . non-ascii +hg --encoding utf-8 up æ +hg --encoding latin1 out -q ../branch#. +hg --encoding latin1 out -q -b . echo clone branch b cd .. hg clone branch2#b branch3 diff --git a/tests/test-branch-option.out b/tests/test-branch-option.out --- a/tests/test-branch-option.out +++ b/tests/test-branch-option.out @@ -12,6 +12,12 @@ 1 files updated, 0 files merged, 0 files 0 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch b 1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch æ +created new head +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +marked working directory as branch æ +created new head +1 files updated, 0 files merged, 0 files removed, 0 files unresolved marked working directory as branch b in rev c branch a 1:dd6e60a716c6 @@ -20,9 +26,15 @@ 1:dd6e60a716c6 2:f25d57ab0566 out branch . 1:b84708d77ab7 -2:65511d0e2b55 +4:65511d0e2b55 1:b84708d77ab7 -2:65511d0e2b55 +4:65511d0e2b55 +out branch . non-ascii +1 files updated, 0 files merged, 0 files removed, 0 files unresolved +2:df5a44224d4e +3:4f4a5125ca10 +2:df5a44224d4e +3:4f4a5125ca10 clone branch b requesting all changes adding changesets