Merge with i18n stable
authorMatt Mackall <mpm@selenic.com>
Wed, 28 Apr 2010 13:45:21 -0500
branchstable
changeset 11031 409c0e4d79e9
parent 11028 0425f1fdf3a8 (current diff)
parent 11010 18e81d42ee5c (diff)
child 11033 0179840ab0d3
child 11034 3b89899934a6
Merge with i18n
--- a/doc/hgrc.5.txt	Sat Apr 24 01:30:24 2010 -0300
+++ b/doc/hgrc.5.txt	Wed Apr 28 13:45:21 2010 -0500
@@ -110,6 +110,11 @@
 A line with ``%unset name`` will remove ``name`` from the current
 section, if it has been set previously.
 
+The values are either free-form text strings, lists of text strings,
+or Boolean values. Lists are split on whitespace and commas. Boolean
+values can be set to true using any of "1", "yes", "true", or "on" and
+to false using "0", "no", "false", or "off" (all case insensitive).
+
 
 Sections
 --------
--- a/hgext/convert/git.py	Sat Apr 24 01:30:24 2010 -0300
+++ b/hgext/convert/git.py	Wed Apr 28 13:45:21 2010 -0500
@@ -16,7 +16,7 @@
     # cannot remove environment variable. Just assume none have
     # both issues.
     if hasattr(os, 'unsetenv'):
-        def gitcmd(self, s):
+        def gitopen(self, s):
             prevgitdir = os.environ.get('GIT_DIR')
             os.environ['GIT_DIR'] = self.path
             try:
@@ -27,9 +27,14 @@
                 else:
                     os.environ['GIT_DIR'] = prevgitdir
     else:
-        def gitcmd(self, s):
+        def gitopen(self, s):
             return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb')
 
+    def gitread(self, s):
+        fh = self.gitopen(s)
+        data = fh.read()
+        return data, fh.close()
+
     def __init__(self, ui, path, rev=None):
         super(convert_git, self).__init__(ui, path, rev=rev)
 
@@ -44,17 +49,22 @@
 
     def getheads(self):
         if not self.rev:
-            fh = self.gitcmd('git rev-parse --branches --remotes')
-            return fh.read().splitlines()
+            heads, ret = self.gitread('git rev-parse --branches --remotes')
+            heads = heads.splitlines()
         else:
-            fh = self.gitcmd("git rev-parse --verify %s" % self.rev)
-            return [fh.read()[:-1]]
+            heads, ret = self.gitread("git rev-parse --verify %s" % self.rev)
+            heads = [heads[:-1]]
+        if ret:
+            raise util.Abort(_('cannot retrieve git heads'))
+        return heads
 
     def catfile(self, rev, type):
         if rev == "0" * 40:
             raise IOError()
-        fh = self.gitcmd("git cat-file %s %s" % (type, rev))
-        return fh.read()
+        data, ret = self.gitread("git cat-file %s %s" % (type, rev))
+        if ret:
+            raise util.Abort(_('cannot read %r object at %s') % (type, rev))
+        return data
 
     def getfile(self, name, rev):
         return self.catfile(rev, "blob")
@@ -64,7 +74,7 @@
 
     def getchanges(self, version):
         self.modecache = {}
-        fh = self.gitcmd("git diff-tree -z --root -m -r %s" % version)
+        fh = self.gitopen("git diff-tree -z --root -m -r %s" % version)
         changes = []
         seen = set()
         entry = None
@@ -84,6 +94,8 @@
                 self.modecache[(f, h)] = (p and "x") or (s and "l") or ""
                 changes.append((f, h))
             entry = None
+        if fh.close():
+            raise util.Abort(_('cannot read changes in %s') % version)
         return (changes, {})
 
     def getcommit(self, version):
@@ -123,7 +135,7 @@
 
     def gettags(self):
         tags = {}
-        fh = self.gitcmd('git ls-remote --tags "%s"' % self.path)
+        fh = self.gitopen('git ls-remote --tags "%s"' % self.path)
         prefix = 'refs/tags/'
         for line in fh:
             line = line.strip()
@@ -134,23 +146,25 @@
                 continue
             tag = tag[len(prefix):-3]
             tags[tag] = node
+        if fh.close():
+            raise util.Abort(_('cannot read tags from %s') % self.path)
 
         return tags
 
     def getchangedfiles(self, version, i):
         changes = []
         if i is None:
-            fh = self.gitcmd("git diff-tree --root -m -r %s" % version)
+            fh = self.gitopen("git diff-tree --root -m -r %s" % version)
             for l in fh:
                 if "\t" not in l:
                     continue
                 m, f = l[:-1].split("\t")
                 changes.append(f)
-            fh.close()
         else:
-            fh = self.gitcmd('git diff-tree --name-only --root -r %s "%s^%s" --'
+            fh = self.gitopen('git diff-tree --name-only --root -r %s "%s^%s" --'
                              % (version, version, i + 1))
             changes = [f.rstrip('\n') for f in fh]
-            fh.close()
+        if fh.close():
+            raise util.Abort(_('cannot read changes in %s') % version)
 
         return changes
--- a/mercurial/commands.py	Sat Apr 24 01:30:24 2010 -0300
+++ b/mercurial/commands.py	Wed Apr 28 13:45:21 2010 -0500
@@ -2349,10 +2349,16 @@
     Path names are defined in the [paths] section of /etc/mercurial/hgrc
     and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
 
-    The names 'default' and 'default-push' have a special meaning.
-    They are the locations used when pulling and pushing respectively
-    unless a location is specified. When cloning a repository, the
-    clone source is written as 'default' in .hg/hgrc.
+    The path names ``default`` and ``default-push`` have a special
+    meaning.  When performing a push or pull operation, they are used
+    as fallbacks if no location is specified on the command-line.
+    When ``default-push`` is set, it will be used for push and
+    ``default`` will be used for pull; otherwise ``default`` is used
+    as the fallback for both.  When cloning a repository, the clone
+    source is written as ``default`` in ``.hg/hgrc``.  Note that
+    ``default`` and ``default-push`` apply to all inbound (e.g. ``hg
+    incoming``) and outbound (e.g. ``hg outgoing``, ``hg email`` and
+    ``hg bundle``) operations.
 
     See 'hg help urls' for more information.
     """
--- a/mercurial/posix.py	Sat Apr 24 01:30:24 2010 -0300
+++ b/mercurial/posix.py	Wed Apr 28 13:45:21 2010 -0500
@@ -264,3 +264,27 @@
 
 def gethgcmd():
     return sys.argv[:1]
+
+def termwidth_():
+    try:
+        import termios, array, fcntl
+        for dev in (sys.stderr, sys.stdout, sys.stdin):
+            try:
+                try:
+                    fd = dev.fileno()
+                except AttributeError:
+                    continue
+                if not os.isatty(fd):
+                    continue
+                arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
+                return array.array('h', arri)[1]
+            except ValueError:
+                pass
+            except IOError, e:
+                if e[0] == errno.EINVAL:
+                    pass
+                else:
+                    raise
+    except ImportError:
+        pass
+    return 80
--- a/mercurial/util.py	Sat Apr 24 01:30:24 2010 -0300
+++ b/mercurial/util.py	Wed Apr 28 13:45:21 2010 -0500
@@ -1245,35 +1245,6 @@
     # Avoid double backslash in Windows path repr()
     return repr(s).replace('\\\\', '\\')
 
-def termwidth():
-    if 'COLUMNS' in os.environ:
-        try:
-            return int(os.environ['COLUMNS'])
-        except ValueError:
-            pass
-    try:
-        import termios, array, fcntl
-        for dev in (sys.stderr, sys.stdout, sys.stdin):
-            try:
-                try:
-                    fd = dev.fileno()
-                except AttributeError:
-                    continue
-                if not os.isatty(fd):
-                    continue
-                arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
-                return array.array('h', arri)[1]
-            except ValueError:
-                pass
-            except IOError, e:
-                if e[0] == errno.EINVAL:
-                    pass
-                else:
-                    raise
-    except ImportError:
-        pass
-    return 80
-
 def wrap(line, hangindent, width=None):
     if width is None:
         width = termwidth() - 2
@@ -1357,3 +1328,11 @@
             if not i:
                 return False
         return True
+
+def termwidth():
+    if 'COLUMNS' in os.environ:
+        try:
+            return int(os.environ['COLUMNS'])
+        except ValueError:
+            pass
+    return termwidth_()
--- a/mercurial/windows.py	Sat Apr 24 01:30:24 2010 -0300
+++ b/mercurial/windows.py	Wed Apr 28 13:45:21 2010 -0500
@@ -356,6 +356,13 @@
 def gethgcmd():
     return [sys.executable] + sys.argv[:1]
 
+def termwidth_():
+    # cmd.exe does not handle CR like a unix console, the CR is
+    # counted in the line length. On 80 columns consoles, if 80
+    # characters are written, the following CR won't apply on the
+    # current line but on the new one. Keep room for it.
+    return 79
+
 try:
     # override functions with win32 versions if possible
     from win32 import *
--- a/tests/test-convert-git	Sat Apr 24 01:30:24 2010 -0300
+++ b/tests/test-convert-git	Wed Apr 28 13:45:21 2010 -0500
@@ -170,4 +170,17 @@
 echo '% --sourceorder should fail'
 hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
 
+echo '% damage git repository and convert again'
+cat > damage.py <<EOF
+import os
+for root, dirs, files in os.walk('git-repo4/.git/objects'):
+    if files:
+        path = os.path.join(root, files[0])
+        os.remove(path)
+        break
+EOF
+python damage.py
+hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
+    grep 'abort:' | sed 's/abort:.*/abort:/g'
+
 true
--- a/tests/test-convert-git.out	Sat Apr 24 01:30:24 2010 -0300
+++ b/tests/test-convert-git.out	Wed Apr 28 13:45:21 2010 -0500
@@ -127,3 +127,5 @@
 % --sourceorder should fail
 initializing destination git-repo4-sourcesort-hg repository
 abort: --sourcesort is not supported by this data source
+% damage git repository and convert again
+abort: