changeset 9567:02c43e8e0835

Merge with hg-i18n-stable
author Martin Geisler <mg@lazybytes.net>
date Wed, 30 Sep 2009 21:14:24 +0200
parents 08914fd0fddb (current diff) 449e85edc8f1 (diff)
children 620d6b20ef85
files hgext/convert/p4.py hgext/win32mbcs.py i18n/pt_BR.po mercurial/config.py mercurial/dispatch.py mercurial/localrepo.py mercurial/util.py
diffstat 12 files changed, 112 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/p4.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/hgext/convert/p4.py	Wed Sep 30 21:14:24 2009 +0200
@@ -53,7 +53,7 @@
     def _parse_view(self, path):
         "Read changes affecting the path"
         cmd = 'p4 -G changes -s submitted "%s"' % path
-        stdout = util.popen(cmd)
+        stdout = util.popen(cmd, mode='rb')
         for d in loaditer(stdout):
             c = d.get("change", None)
             if c:
@@ -72,7 +72,7 @@
                 views = {"//": ""}
         else:
             cmd = 'p4 -G client -o "%s"' % path
-            clientspec = marshal.load(util.popen(cmd))
+            clientspec = marshal.load(util.popen(cmd, mode='rb'))
 
             views = {}
             for client in clientspec:
@@ -105,7 +105,7 @@
         lastid = None
         for change in self.p4changes:
             cmd = "p4 -G describe %s" % change
-            stdout = util.popen(cmd)
+            stdout = util.popen(cmd, mode='rb')
             d = marshal.load(stdout)
 
             desc = self.recode(d["desc"])
@@ -147,7 +147,7 @@
 
     def getfile(self, name, rev):
         cmd = 'p4 -G print "%s#%s"' % (self.depotname[name], rev)
-        stdout = util.popen(cmd)
+        stdout = util.popen(cmd, mode='rb')
 
         mode = None
         contents = ""
--- a/hgext/win32mbcs.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/hgext/win32mbcs.py	Wed Sep 30 21:14:24 2009 +0200
@@ -123,7 +123,7 @@
 funcs = '''os.path.join os.path.split os.path.splitext
  os.path.splitunc os.path.normpath os.path.normcase os.makedirs
  mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase
- mercurial.util.fspath mercurial.util.pconvert'''
+ mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath'''
 
 # codec and alias names of sjis and big5 to be faked.
 problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs
--- a/i18n/pt_BR.po	Tue Sep 29 00:54:15 2009 +0200
+++ b/i18n/pt_BR.po	Wed Sep 30 21:14:24 2009 +0200
@@ -7193,47 +7193,50 @@
 "\n"
 "    With no arguments, show all repository head changesets.\n"
 "\n"
-"    Repository \"heads\" are changesets that don't have child\n"
-"    changesets. They are where development generally takes place and\n"
-"    are the usual targets for update and merge operations.\n"
+"    Repository \"heads\" are changesets with no child changesets. They are\n"
+"    where development generally takes place and are the usual targets\n"
+"    for update and merge operations.\n"
 "\n"
 "    If one or more REV is given, the \"branch heads\" will be shown for\n"
-"    the named branch associated with that revision. The name of the\n"
-"    branch is called the revision's branch tag.\n"
-"\n"
-"    Branch heads are revisions on a given named branch that do not have\n"
-"    any descendants on the same branch. A branch head could be a true head\n"
-"    or it could be the last changeset on a branch before a new branch\n"
-"    was created. If none of the branch heads are true heads, the branch\n"
-"    is considered inactive. If -c/--closed is specified, also show branch\n"
-"    heads marked closed (see hg commit --close-branch).\n"
-"\n"
-"    If STARTREV is specified only those heads (or branch heads) that\n"
-"    are descendants of STARTREV will be displayed.\n"
+"    the named branch associated with the specified changeset(s).\n"
+"\n"
+"    Branch heads are changesets on a named branch with no descendants on\n"
+"    the same branch. A branch head could be a \"true\" (repository) head,\n"
+"    or it could be the last changeset on that branch before it was\n"
+"    merged into another branch, or it could be the last changeset on the\n"
+"    branch before a new branch was created. If none of the branch heads\n"
+"    are true heads, the branch is considered inactive.\n"
+"\n"
+"    If -c/--closed is specified, also show branch heads marked closed\n"
+"    (see hg commit --close-branch).\n"
+"\n"
+"    If STARTREV is specified, only those heads that are descendants of\n"
+"    STARTREV will be displayed.\n"
 "    "
 msgstr ""
 "mostra as cabeças atuais do repositório ou cabeças de ramo\n"
 "\n"
 "    Sem argumentos, mostra todas as cabeças do repositório.\n"
 "\n"
-"    \"Cabeças\" do repositório são changesets que não têm nenhum\n"
-"    changeset filho. Elas são onde o desenvolvimento geralmente\n"
+"    \"Cabeças\" do repositório são revisões que não têm nenhuma\n"
+"    revisão filha. Elas são onde o desenvolvimento geralmente\n"
 "    acontece e são os alvos costumeiros para operações update e\n"
 "    merge.\n"
 "\n"
 "    Se um ou mais argumentos REV forem dados, as \"cabeças de ramo\"\n"
-"    serão mostradas para os ramos nomeados associados a tais\n"
-"    revisões. O nome do ramo é chamado de etiqueta de ramo da\n"
-"    revisão.\n"
+"    serão mostradas para os ramos nomeados associados às revisões\n"
+"    especificadas.\n"
 "\n"
 "    Cabeças de ramo são revisões em um determinado ramo nomeado que\n"
 "    não têm nenhum descendente nesse mesmo ramo. Uma cabeça de\n"
-"    ramo pode ser uma cabeça verdadeira ou pode ser o último\n"
-"    changeset em um ramo antes que um novo ramo nomeado fosse criado.\n"
-"    Se nenhuma das cabeças de ramo forem cabeças verdadeiras, o ramo\n"
-"    é considerado inativo. Se -c/--closed for especificado, mostra\n"
-"    também cabeças de ramos marcados como fechados (veja hg commit\n"
-"    --close-branch).\n"
+"    ramo pode ser uma cabeça \"verdadeira\" (do repositório), a\n"
+"    última revisão nesse ramo antes de uma mesclagem com outro ramo,\n"
+"    ou a última revisão nesse ramo antes de um novo ramo ter sido\n"
+"    criado. Se nenhuma das cabeças de ramo for uma cabeça verdadeira,\n"
+"    o ramo é considerado inativo.\n"
+"\n"
+"    Se -c/--closed for especificado, mostra também cabeças de ramos\n"
+"    marcados como fechados (veja hg commit --close-branch).\n"
 "\n"
 "    Se REVINICIAL for especificada, serão mostradas apenas cabeças\n"
 "    (ou cabeças de ramo) descendentes de REVINICIAL.\n"
@@ -8483,6 +8486,9 @@
 "    -d/--date.\n"
 "    "
 
+msgid "cannot specify both -c/--check and -C/--clean"
+msgstr "não se pode especificar ao mesmo tempo -c/--check e -C/--clean"
+
 msgid "uncommitted local changes"
 msgstr "alterações locais pendentes"
 
--- a/mercurial/config.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/mercurial/config.py	Wed Sep 30 21:14:24 2009 +0200
@@ -93,6 +93,7 @@
                     self.set(section, item, v, "%s:%d" % (src, line))
                     continue
                 item = None
+                cont = False
             m = includere.match(l)
             if m:
                 inc = m.group(1)
--- a/mercurial/dispatch.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/mercurial/dispatch.py	Wed Sep 30 21:14:24 2009 +0200
@@ -24,6 +24,9 @@
     except util.Abort, inst:
         sys.stderr.write(_("abort: %s\n") % inst)
         return -1
+    except error.ConfigError, inst:
+        sys.stderr.write(_("hg: %s\n") % inst)
+        return -1
     return _runcatch(u, args)
 
 def _runcatch(ui, args):
--- a/mercurial/localrepo.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/mercurial/localrepo.py	Wed Sep 30 21:14:24 2009 +0200
@@ -1159,17 +1159,24 @@
         return [n for (r, n) in sorted(heads)]
 
     def branchheads(self, branch=None, start=None, closed=False):
+        '''return a (possibly filtered) list of heads for the given branch
+
+        Heads are returned in topological order, from newest to oldest.
+        If branch is None, use the dirstate branch.
+        If start is not None, return only heads reachable from start.
+        If closed is True, return heads that are marked as closed as well.
+        '''
         if branch is None:
             branch = self[None].branch()
         branches = self.branchmap()
         if branch not in branches:
             return []
-        bheads = branches[branch]
         # the cache returns heads ordered lowest to highest
-        bheads.reverse()
+        bheads = list(reversed(branches[branch]))
         if start is not None:
             # filter out the heads that cannot be reached from startrev
-            bheads = self.changelog.nodesbetween([start], bheads)[2]
+            fbheads = set(self.changelog.nodesbetween([start], bheads)[2])
+            bheads = [h for h in bheads if h in fbheads]
         if not closed:
             bheads = [h for h in bheads if
                       ('close' not in self.changelog.read(h)[5])]
@@ -1468,19 +1475,16 @@
         inc = self.findincoming(remote, common, remote_heads, force=force)
 
         update, updated_heads = self.findoutgoing(remote, common, remote_heads)
-        if revs is not None:
-            msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
-        else:
-            bases, heads = update, self.changelog.heads()
+        msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
 
-        def checkbranch(lheads, rheads, updatelh):
+        def checkbranch(lheads, rheads, updatelb):
             '''
             check whether there are more local heads than remote heads on
             a specific branch.
 
             lheads: local branch heads
             rheads: remote branch heads
-            updatelh: outgoing local branch heads
+            updatelb: outgoing local branch bases
             '''
 
             warn = 0
@@ -1488,13 +1492,15 @@
             if not revs and len(lheads) > len(rheads):
                 warn = 1
             else:
+                # add local heads involved in the push
                 updatelheads = [self.changelog.heads(x, lheads)
-                                for x in updatelh]
+                                for x in updatelb]
                 newheads = set(sum(updatelheads, [])) & set(lheads)
 
                 if not newheads:
                     return True
 
+                # add heads we don't have or that are not involved in the push
                 for r in rheads:
                     if r in self.changelog.nodemap:
                         desc = self.changelog.heads(r, heads)
@@ -1510,7 +1516,7 @@
                 if not rheads: # new branch requires --force
                     self.ui.warn(_("abort: push creates new"
                                    " remote branch '%s'!\n") %
-                                   self[updatelh[0]].branch())
+                                   self[updatelb[0]].branch())
                 else:
                     self.ui.warn(_("abort: push creates new remote heads!\n"))
 
@@ -1553,11 +1559,11 @@
                         else:
                             rheads = []
                         lheads = localhds[lh]
-                        updatelh = [upd for upd in update
+                        updatelb = [upd for upd in update
                                     if self[upd].branch() == lh]
-                        if not updatelh:
+                        if not updatelb:
                             continue
-                        if not checkbranch(lheads, rheads, updatelh):
+                        if not checkbranch(lheads, rheads, updatelb):
                             return None, 0
                 else:
                     if not checkbranch(heads, remote_heads, update):
--- a/mercurial/util.py	Tue Sep 29 00:54:15 2009 +0200
+++ b/mercurial/util.py	Wed Sep 30 21:14:24 2009 +0200
@@ -14,7 +14,7 @@
 """
 
 from i18n import _
-import error, osutil
+import error, osutil, encoding
 import cStringIO, errno, re, shutil, sys, tempfile, traceback
 import os, stat, time, calendar, random, textwrap
 import imp
@@ -1278,7 +1278,14 @@
         # adjust for weird terminal size
         width = max(78, hangindent + 1)
     padding = '\n' + ' ' * hangindent
-    return padding.join(textwrap.wrap(line, width=width - hangindent))
+    # To avoid corrupting multi-byte characters in line, we must wrap
+    # a Unicode string instead of a bytestring.
+    try:
+        u = line.decode(encoding.encoding)
+        w = padding.join(textwrap.wrap(u, width=width - hangindent))
+        return w.encode(encoding.encoding)
+    except UnicodeDecodeError:
+        return padding.join(textwrap.wrap(line, width=width - hangindent))
 
 def iterlines(iterator):
     for chunk in iterator:
--- a/tests/test-bheads.out	Tue Sep 29 00:54:15 2009 +0200
+++ b/tests/test-bheads.out	Wed Sep 30 21:14:24 2009 +0200
@@ -68,8 +68,8 @@
 3: Adding b branch head 1
 0
 -------
+6: Merging b branch head 2 and b branch head 3
 3: Adding b branch head 1
-6: Merging b branch head 2 and b branch head 3
 0
 -------
 no changes on branch b containing . are reachable from 7
--- a/tests/test-hgrc	Tue Sep 29 00:54:15 2009 +0200
+++ b/tests/test-hgrc	Wed Sep 30 21:14:24 2009 +0200
@@ -16,3 +16,9 @@
 cat .hg/hgrc |sed -e "s:$p:...:"
 hg paths |sed -e "s:$p:...:"
 hg showconfig |sed -e "s:$p:...:"
+
+# issue1829: wrong indentation
+cd ..
+echo '[foo]' >> $HGRCPATH
+echo '  x = y' >> $HGRCPATH
+hg version 2>&1 | sed -e "s|$HGRCPATH|\$HGRCPATH|"
--- a/tests/test-hgrc.out	Tue Sep 29 00:54:15 2009 +0200
+++ b/tests/test-hgrc.out	Wed Sep 30 21:14:24 2009 +0200
@@ -10,3 +10,4 @@
 defaults.tag=-d "0 0"
 paths.default=.../foo%bar
 ui.slash=True
+hg: config error at $HGRCPATH:8: '  x = y'
--- a/tests/test-push-warn	Tue Sep 29 00:54:15 2009 +0200
+++ b/tests/test-push-warn	Wed Sep 30 21:14:24 2009 +0200
@@ -123,4 +123,21 @@
 hg -q ci -d "1000000 0" -m 11
 hg push -r 10 -r 11 ../f; echo $?
 
+echo % checking prepush logic does not allow silently pushing multiple new heads
+cd ..
+hg init g
+echo init > g/init
+hg -R g ci -Am init
+echo a > g/a
+hg -R g ci -Am a
+hg clone g h
+hg -R g up 0
+echo b > g/b
+hg -R g ci -Am b
+hg -R h up 0
+echo c > h/c
+hg -R h ci -Am c
+hg -R h push g
+echo
+
 exit 0
--- a/tests/test-push-warn.out	Tue Sep 29 00:54:15 2009 +0200
+++ b/tests/test-push-warn.out	Wed Sep 30 21:14:24 2009 +0200
@@ -124,3 +124,20 @@
 adding file changes
 added 2 changesets with 2 changes to 1 files
 0
+% checking prepush logic does not allow silently pushing multiple new heads
+abort: repository g already exists!
+adding init
+adding a
+updating working directory
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+adding b
+created new head
+1 files updated, 0 files merged, 2 files removed, 0 files unresolved
+adding c
+created new head
+pushing to g
+searching for changes
+abort: push creates new remote heads!
+(did you forget to merge? use push -f to force)
+