changeset 9570:7cea12e70129

merge with i18n-stable
author Matt Mackall <mpm@selenic.com>
date Thu, 08 Oct 2009 01:17:24 -0500
parents e151b66bcf38 (diff) 449e85edc8f1 (current diff)
children 7e03423def3c 5e44d9e562bc
files
diffstat 16 files changed, 149 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/color.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/color.py	Thu Oct 08 01:17:24 2009 -0500
@@ -162,9 +162,8 @@
     return retval
 
 _patch_effects = { 'applied': ['blue', 'bold', 'underline'],
-                   'missing': ['red', 'bold'],
-                   'unapplied': ['black', 'bold'], }
-
+                    'missing': ['red', 'bold'],
+                    'unapplied': ['black', 'bold'], }
 def colorwrap(orig, s):
     '''wrap ui.write for colored diff output'''
     lines = s.split('\n')
--- a/hgext/convert/common.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/convert/common.py	Thu Oct 08 01:17:24 2009 -0500
@@ -365,7 +365,7 @@
             return
         for i, line in enumerate(fp):
             try:
-                key, value = line[:-1].rsplit(' ', 1)
+                key, value = line.splitlines()[0].rsplit(' ', 1)
             except ValueError:
                 raise util.Abort(_('syntax error in %s(%d): key/value pair expected')
                                  % (self.path, i+1))
--- a/hgext/convert/darcs.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/convert/darcs.py	Thu Oct 08 01:17:24 2009 -0500
@@ -85,6 +85,17 @@
         self.checkexit(fp.close())
         return etree.getroot()
 
+    def manifest(self):
+        man = []
+        output, status = self.run('show', 'files', no_directories=True,
+                                  repodir=self.tmppath)
+        self.checkexit(status)
+        for line in output.split('\n'):
+            path = line[2:]
+            if path:
+                man.append(path)
+        return man
+
     def getheads(self):
         return self.parents[None]
 
@@ -107,18 +118,35 @@
             output, status = self.run('revert', all=True, repodir=self.tmppath)
             self.checkexit(status, output)
 
-    def getchanges(self, rev):
-        self.pull(rev)
+    def getchanges(self, rev):        
         copies = {}
         changes = []
+        man = None
         for elt in self.changes[rev].find('summary').getchildren():
             if elt.tag in ('add_directory', 'remove_directory'):
                 continue
             if elt.tag == 'move':
-                changes.append((elt.get('from'), rev))
-                copies[elt.get('from')] = elt.get('to')
+                if man is None:
+                    man = self.manifest()
+                source, dest = elt.get('from'), elt.get('to')
+                if source in man:
+                    # File move
+                    changes.append((source, rev))
+                    changes.append((dest, rev))
+                    copies[dest] = source
+                else:
+                    # Directory move, deduce file moves from manifest
+                    source = source + '/'
+                    for f in man:
+                        if not f.startswith(source):
+                            continue
+                        fdest = dest + '/' + f[len(source):]
+                        changes.append((f, rev))
+                        changes.append((fdest, rev))
+                        copies[fdest] = f
             else:
                 changes.append((elt.text.strip(), rev))
+        self.pull(rev)
         self.lastrev = rev
         return sorted(changes), copies
 
--- a/hgext/convert/hg.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/convert/hg.py	Thu Oct 08 01:17:24 2009 -0500
@@ -248,8 +248,7 @@
         return self.lastctx
 
     def parents(self, ctx):
-        return [p.node() for p in ctx.parents()
-                if p and self.keep(p.node())]
+        return [p for p in ctx.parents() if p and self.keep(p.node())]
 
     def getheads(self):
         if self.rev:
@@ -275,20 +274,20 @@
             if self.ignoreerrors:
                 # calling getcopies() is a simple way to detect missing
                 # revlogs and populate self.ignored
-                self.getcopies(ctx, files)
+                self.getcopies(ctx, parents, files)
             return [(f, rev) for f in files if f not in self.ignored], {}
         if self._changescache and self._changescache[0] == rev:
             m, a, r = self._changescache[1]
         else:
-            m, a, r = self.repo.status(parents[0], ctx.node())[:3]
+            m, a, r = self.repo.status(parents[0].node(), ctx.node())[:3]
         # getcopies() detects missing revlogs early, run it before
         # filtering the changes.
-        copies = self.getcopies(ctx, m + a)
+        copies = self.getcopies(ctx, parents, m + a)
         changes = [(name, rev) for name in m + a + r
                    if name not in self.ignored]
         return sorted(changes), copies
 
-    def getcopies(self, ctx, files):
+    def getcopies(self, ctx, parents, files):
         copies = {}
         for name in files:
             if name in self.ignored:
@@ -297,6 +296,14 @@
                 copysource, copynode = ctx.filectx(name).renamed()
                 if copysource in self.ignored or not self.keep(copynode):
                     continue
+                # Ignore copy sources not in parent revisions
+                found = False
+                for p in parents:
+                    if copysource in p:
+                        found = True
+                        break
+                if not found:
+                    continue
                 copies[name] = copysource
             except TypeError:
                 pass
@@ -309,7 +316,7 @@
 
     def getcommit(self, rev):
         ctx = self.changectx(rev)
-        parents = [hex(p) for p in self.parents(ctx)]
+        parents = [p.hex() for p in self.parents(ctx)]
         if self.saverev:
             crev = rev
         else:
@@ -332,7 +339,7 @@
             changes = [], ctx.manifest().keys(), []
         else:
             i = i or 0
-            changes = self.repo.status(parents[i], ctx.node())[:3]
+            changes = self.repo.status(parents[i].node(), ctx.node())[:3]
         changes = [[f for f in l if f not in self.ignored] for l in changes]
 
         if i == 0:
--- a/hgext/convert/subversion.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/convert/subversion.py	Thu Oct 08 01:17:24 2009 -0500
@@ -153,11 +153,13 @@
 def issvnurl(url):
     try:
         proto, path = url.split('://', 1)
-        path = urllib.url2pathname(path)
+        if proto == 'file':
+            path = urllib.url2pathname(path)
     except ValueError:
         proto = 'file'
         path = os.path.abspath(url)
-    path = path.replace(os.sep, '/')
+    if proto == 'file':
+        path = path.replace(os.sep, '/')
     check = protomap.get(proto, lambda p, p2: False)
     while '/' in path:
         if check(path, proto):
--- a/hgext/extdiff.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/hgext/extdiff.py	Thu Oct 08 01:17:24 2009 -0500
@@ -173,11 +173,11 @@
     that revision is compared to the working directory, and, when no
     revisions are specified, the working directory files are compared
     to its parent.'''
-    program = opts['program'] or 'diff'
-    if opts['program']:
-        option = opts['option']
-    else:
-        option = opts['option'] or ['-Npru']
+    program = opts.get('program')
+    option = opts.get('option')
+    if not program:
+        program = 'diff'
+        option = option or ['-Npru']
     return dodiff(ui, repo, program, option, pats, opts)
 
 cmdtable = {
--- a/mercurial/streamclone.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/mercurial/streamclone.py	Thu Oct 08 01:17:24 2009 -0500
@@ -48,8 +48,7 @@
         try:
             repo.ui.debug(_('scanning\n'))
             for name, ename, size in repo.store.walk():
-                # for backwards compat, name was partially encoded
-                entries.append((store.encodedir(name), size))
+                entries.append((name, size))
                 total_bytes += size
         finally:
             lock.release()
@@ -62,6 +61,7 @@
     yield '%d %d\n' % (len(entries), total_bytes)
     for name, size in entries:
         repo.ui.debug(_('sending %s (%d bytes)\n') % (name, size))
-        yield '%s\0%d\n' % (name, size)
+        # partially encode name over the wire for backwards compat
+        yield '%s\0%d\n' % (store.encodedir(name), size)
         for chunk in util.filechunkiter(repo.sopener(name), limit=size):
             yield chunk
--- a/mercurial/subrepo.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/mercurial/subrepo.py	Thu Oct 08 01:17:24 2009 -0500
@@ -168,7 +168,7 @@
         self._repo.ui.note(_('removing subrepo %s\n') % self._path)
         hg.clean(self._repo, node.nullid, False)
 
-    def get(self, state):
+    def _get(self, state):
         source, revision = state
         try:
             self._repo.lookup(revision)
@@ -179,9 +179,13 @@
             other = hg.repository(self._repo.ui, srcurl)
             self._repo.pull(other)
 
+    def get(self, state):
+        self._get(state)
+        source, revision = state
         hg.clean(self._repo, revision, False)
 
     def merge(self, state):
+        self._get(state)
         hg.merge(self._repo, state[1], remind=False)
 
     def push(self, force):
--- a/mercurial/util.py	Mon Sep 28 20:14:39 2009 -0300
+++ b/mercurial/util.py	Thu Oct 08 01:17:24 2009 -0500
@@ -444,7 +444,14 @@
 
         temp = tempname(dst)
         os.rename(dst, temp)
-        os.unlink(temp)
+        try:
+            os.unlink(temp)
+        except:
+            # Some rude AV-scanners on Windows may cause the unlink to
+            # fail. Not aborting here just leaks the temp file, whereas
+            # aborting at this point may leave serious inconsistencies.
+            # Ideally, we would notify the user here.
+            pass
         os.rename(src, dst)
 
 def unlink(f):
@@ -1270,6 +1277,11 @@
                 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/tests/hghave	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/hghave	Thu Oct 08 01:17:24 2009 -0500
@@ -51,7 +51,7 @@
     return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
 
 def has_darcs():
-    return matchoutput('darcs', r'darcs version', True)
+    return matchoutput('darcs --version', r'2\.[2-9]', True)
 
 def has_mtn():
     return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
--- a/tests/test-convert-darcs	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-convert-darcs	Thu Oct 08 01:17:24 2009 -0500
@@ -1,19 +1,13 @@
 #!/bin/sh
 
 "$TESTDIR/hghave" darcs || exit 80
-if darcs --version 2>&1 | grep '^2\.' > /dev/null; then
-    # FIXME: darcs 2 will fail with
-    ### Abort: timeout after 180 seconds.
-    echo 'skipped: test currently disabled for darcs 2'
-    exit 80
-fi
 
 echo "[extensions]" >> $HGRCPATH
 echo "convert=" >> $HGRCPATH
 echo 'hgext.graphlog =' >> $HGRCPATH
 
 DARCS_EMAIL='test@example.org'; export DARCS_EMAIL
-HOME=do_not_use_HOME_darcs; export HOME
+HOME=`pwd`/do_not_use_HOME_darcs; export HOME
 
 # skip if we can't import elementtree
 mkdir dummy
@@ -47,8 +41,21 @@
 
 echo % merge branch
 darcs pull -a ../darcs-clone
+sleep 1
 echo e > a
+echo f > f
+mkdir dir
+echo d > dir/d
+echo d > dir/d2
 darcs record -a -l -m p2
+
+echo % test file and directory move
+darcs mv f ff
+# Test remove + move
+darcs remove dir/d2
+rm dir/d2
+darcs mv dir dir2
+darcs record -a -l -m p3
 cd ..
 
 glog()
@@ -56,7 +63,7 @@
     hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
 }
 
-hg convert darcs-repo darcs-repo-hg 2>&1 | grep -v hGetLine | grep -v '^$'
+hg convert darcs-repo darcs-repo-hg
 # The converter does not currently handle patch conflicts very well.
 # When they occur, it reverts *all* changes and moves forward,
 # letting the conflict resolving patch fix collisions.
--- a/tests/test-convert-darcs.out	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-convert-darcs.out	Thu Oct 08 01:17:24 2009 -0500
@@ -5,19 +5,25 @@
 % update source
 Finished recording patch 'p1.2'
 % merge branch
+Backing up ./a(-darcs-backup0)
 We have conflicts in the following files:
 ./a
 Finished pulling and applying.
 Finished recording patch 'p2'
+% test file and directory move
+Finished recording patch 'p3'
 initializing destination darcs-repo-hg repository
 scanning source...
 sorting...
 converting...
-3 p0
-2 p1.2
-1 p1.1
-0 p2
-o  3 "p2" files: a
+4 p0
+3 p1.2
+2 p1.1
+1 p2
+0 p3
+o  4 "p3" files: dir/d dir/d2 dir2/d f ff
+|
+o  3 "p2" files: a dir/d dir/d2 f
 |
 o  2 "p1.1" files:
 |
@@ -27,3 +33,5 @@
 
 7225b30cdf38257d5cc7780772c051b6f33e6d6b 644   a
 1e88685f5ddec574a34c70af492f95b6debc8741 644   b
+d278f41640da5fc303a4cf9894af31c2983fc11d 644   dir2/d
+ef5c76581d78340f568d5f48d679bf307452cbc9 644   ff
--- a/tests/test-convert-hg-source	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-convert-hg-source	Thu Oct 08 01:17:24 2009 -0500
@@ -38,6 +38,25 @@
 hg out ../orig
 cd ..
 
+echo '% check shamap LF and CRLF handling'
+cat > rewrite.py <<EOF
+import sys
+# Interlace LF and CRLF
+lines = [(l.rstrip() + ((i % 2) and '\n' or '\r\n'))
+         for i, l in enumerate(file(sys.argv[1]))]
+file(sys.argv[1], 'wb').write(''.join(lines))
+EOF
+python rewrite.py new/.hg/shamap
+cd orig
+hg up -qC 1
+echo foo >> foo
+hg ci -qm 'change foo again'
+hg up -qC 2
+echo foo >> foo
+hg ci -qm 'change foo again again'
+cd ..
+hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
+
 echo % init broken repository
 hg init broken
 cd broken
--- a/tests/test-convert-hg-source.out	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-convert-hg-source.out	Thu Oct 08 01:17:24 2009 -0500
@@ -20,6 +20,12 @@
 comparing with ../orig
 searching for changes
 no changes found
+% check shamap LF and CRLF handling
+scanning source...
+sorting...
+converting...
+1 change foo again again
+0 change foo again
 % init broken repository
 created new head
 % break it
--- a/tests/test-http	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-http	Thu Oct 08 01:17:24 2009 -0500
@@ -5,6 +5,11 @@
 hg init test
 cd test
 echo foo>foo
+mkdir foo.d foo.d/bAr.hg.d foo.d/baR.d.hg
+echo foo>foo.d/foo
+echo bar>foo.d/bAr.hg.d/BaR
+echo bar>foo.d/baR.d.hg/bAR
+
 hg commit -A -m 1
 hg --config server.uncompressed=True serve -p $HGPORT -d --pid-file=../hg1.pid
 hg serve -p $HGPORT1 -d --pid-file=../hg2.pid
--- a/tests/test-http.out	Mon Sep 28 20:14:39 2009 -0300
+++ b/tests/test-http.out	Thu Oct 08 01:17:24 2009 -0500
@@ -1,4 +1,7 @@
 adding foo
+adding foo.d/bAr.hg.d/BaR
+adding foo.d/baR.d.hg/bAR
+adding foo.d/foo
 abort: cannot start server at ':20060':
 % clone via stream
 streaming all changes
@@ -10,31 +13,31 @@
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-1 files, 1 changesets, 1 total revisions
+4 files, 1 changesets, 4 total revisions
 % try to clone via stream, should use pull instead
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files
+added 1 changesets with 4 changes to 4 files
 updating working directory
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % clone via pull
 requesting all changes
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files
+added 1 changesets with 4 changes to 4 files
 updating working directory
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 checking changesets
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-1 files, 1 changesets, 1 total revisions
+4 files, 1 changesets, 4 total revisions
 adding bar
 % pull
-changegroup hook: HG_NODE=cfbd11a1fa315300a080c3de8fe36b0fc5820acf HG_SOURCE=pull HG_URL=http://localhost/ 
+changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=http://localhost/ 
 pulling from http://localhost/
 searching for changes
 adding changesets