changeset 2638:8dadff054acf

merge
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Wed, 19 Jul 2006 07:51:56 -0700
parents fcfd46c4a27a (current diff) b1436559f1e9 (diff)
children 001703ec311d
files contrib/vim/hgcommand.vim
diffstat 14 files changed, 110 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt	Wed Jul 19 09:28:59 2006 +0200
+++ b/doc/hgrc.5.txt	Wed Jul 19 07:51:56 2006 -0700
@@ -317,7 +317,7 @@
   Assigns symbolic names to repositories.  The left side is the
   symbolic name, and the right gives the directory or URL that is the
   location of the repository.  Default paths can be declared by
- setting the following entries.
+  setting the following entries.
   default;;
     Directory or URL to use when pulling if no source is specified.
     Default is set to repository from which the current repository
@@ -326,6 +326,18 @@
     Optional.  Directory or URL to use when pushing if no destination
     is specified.
 
+server::
+  Controls generic server settings.
+  uncompressed;;
+    Whether to allow clients to clone a repo using the uncompressed
+    streaming protocol.  This transfers about 40% more data than a
+    regular clone, but uses less memory and CPU on both server and
+    client.  Over a LAN (100Mbps or better) or a very fast WAN, an
+    uncompressed streaming clone is a lot faster (~10x) than a regular
+    clone.  Over most WAN connections (anything slower than about
+    6Mbps), uncompressed streaming is slower, because of the extra
+    data transfer overhead.  Default is False.
+
 ui::
   User interface controls.
   debug;;
--- a/mercurial/commands.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/commands.py	Wed Jul 19 07:51:56 2006 -0700
@@ -128,13 +128,17 @@
     if not slowpath:
         # Only files, no patterns.  Check the history of each file.
         def filerevgen(filelog):
+            cl_count = repo.changelog.count()
             for i, window in increasing_windows(filelog.count()-1, -1):
                 revs = []
                 for j in xrange(i - window, i + 1):
                     revs.append(filelog.linkrev(filelog.node(j)))
                 revs.reverse()
                 for rev in revs:
-                    yield rev
+                    # only yield rev for which we have the changelog, it can
+                    # happen while doing "hg log" during a pull or commit
+                    if rev < cl_count:
+                        yield rev
 
         minrev, maxrev = min(revs), max(revs)
         for file_ in files:
@@ -970,7 +974,7 @@
     ui.setconfig_remoteopts(**opts)
     hg.clone(ui, ui.expandpath(source), dest,
              pull=opts['pull'],
-             stream=opts['stream'],
+             stream=opts['uncompressed'],
              rev=opts['rev'],
              update=not opts['noupdate'])
 
@@ -2863,7 +2867,8 @@
           ('r', 'rev', [],
            _('a changeset you would like to have after cloning')),
           ('', 'pull', None, _('use pull protocol to copy metadata')),
-          ('', 'stream', None, _('use streaming protocol (fast over LAN)')),
+          ('', 'uncompressed', None,
+           _('use uncompressed transfer (fast over LAN)')),
           ('e', 'ssh', '', _('specify ssh command to use')),
           ('', 'remotecmd', '',
            _('specify hg command to run on the remote side'))],
@@ -3322,7 +3327,7 @@
         except (util.SignalInterrupt, KeyboardInterrupt):
             raise
         except Exception, inst:
-            u.warn(_("*** failed to import extension %s: %s\n") % (x[0], inst))
+            u.warn(_("*** failed to import extension %s: %s\n") % (ext_name, inst))
             if u.print_exc():
                 return 1
 
@@ -3513,7 +3518,9 @@
         return inst.code
     except:
         u.warn(_("** unknown exception encountered, details follow\n"))
-        u.warn(_("** report bug details to mercurial@selenic.com\n"))
+        u.warn(_("** report bug details to "
+                 "http://www.selenic.com/mercurial/bts\n"))
+        u.warn(_("** or mercurial@selenic.com\n"))
         u.warn(_("** Mercurial Distributed SCM (version %s)\n")
                % version.get_version())
         raise
--- a/mercurial/context.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/context.py	Wed Jul 19 07:51:56 2006 -0700
@@ -39,21 +39,23 @@
 
     def parents(self):
         """return contexts for each parent changeset"""
-        p = self.repo.changelog.parents(self._node)
+        p = self._repo.changelog.parents(self._node)
         return [ changectx(self._repo, x) for x in p ]
 
     def children(self):
         """return contexts for each child changeset"""
-        c = self.repo.changelog.children(self._node)
+        c = self._repo.changelog.children(self._node)
         return [ changectx(self._repo, x) for x in c ]
 
     def filenode(self, path):
         node, flag = self._repo.manifest.find(self.changeset()[0], path)
         return node
 
-    def filectx(self, path):
+    def filectx(self, path, fileid=None):
         """get a file context from this changeset"""
-        return filectx(self._repo, path, fileid=self.filenode(path))
+        if fileid is None:
+            fileid = self.filenode(path)
+        return filectx(self._repo, path, fileid=fileid)
 
     def filectxs(self):
         """generate a file context for each file in this changeset's
@@ -77,10 +79,10 @@
 
         if self._id:
             # if given a changeset id, go ahead and look up the file
-            self._changeset = changectx(repo, self._id)
+            self._changeset = self._repo.changelog.read(self._id)
             node, flag = self._repo.manifest.find(self._changeset[0], path)
-            self._node = node
-            self._filelog = self.repo.file(self._path)
+            self._filelog = self._repo.file(self._path)
+            self._filenode = node
         elif self._fileid:
             # else be lazy
             self._filelog = self._repo.file(self._path)
--- a/mercurial/hg.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/hg.py	Wed Jul 19 07:51:56 2006 -0700
@@ -97,7 +97,8 @@
 
     pull: always pull from source repository, even in local case
 
-    stream: stream from repository (fast over LAN, slow over WAN)
+    stream: stream raw data uncompressed from repository (fast over
+    LAN, slow over WAN)
 
     rev: revision to clone up to (implies pull=True)
 
@@ -156,9 +157,9 @@
         # we lock here to avoid premature writing to the target
         dest_lock = lock.lock(os.path.join(dest_path, ".hg", "lock"))
 
-	# we need to remove the (empty) data dir in dest so copyfiles
-	# can do its work
-	os.rmdir(os.path.join(dest_path, ".hg", "data"))
+        # we need to remove the (empty) data dir in dest so copyfiles
+        # can do its work
+        os.rmdir(os.path.join(dest_path, ".hg", "data"))
         files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i"
         for f in files.split():
             src = os.path.join(source, ".hg", f)
@@ -169,8 +170,8 @@
                 if inst.errno != errno.ENOENT:
                     raise
 
-	# we need to re-init the repo after manually copying the data
-	# into it
+        # we need to re-init the repo after manually copying the data
+        # into it
         dest_repo = repository(ui, dest)
 
     else:
--- a/mercurial/hgweb/hgweb_mod.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jul 19 07:51:56 2006 -0700
@@ -860,7 +860,10 @@
                   or self.t("error", error="%r not found" % fname))
 
     def do_capabilities(self, req):
-        resp = 'unbundle stream=%d' % (self.repo.revlogversion,)
+        caps = ['unbundle']
+        if self.repo.ui.configbool('server', 'uncompressed'):
+            caps.append('stream=%d' % self.repo.revlogversion)
+        resp = ' '.join(caps)
         req.httphdr("application/mercurial-0.1", length=len(resp))
         req.write(resp)
 
--- a/mercurial/localrepo.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/localrepo.py	Wed Jul 19 07:51:56 2006 -0700
@@ -2204,8 +2204,11 @@
             return 1
 
     def stream_in(self, remote):
+        fp = remote.stream_out()
+        resp = int(fp.readline())
+        if resp != 0:
+            raise util.Abort(_('operation forbidden by server'))
         self.ui.status(_('streaming all changes\n'))
-        fp = remote.stream_out()
         total_files, total_bytes = map(int, fp.readline().split(' ', 1))
         self.ui.status(_('%d files to transfer, %s of data\n') %
                        (total_files, util.bytecount(total_bytes)))
@@ -2230,14 +2233,15 @@
 
         keyword arguments:
         heads: list of revs to clone (forces use of pull)
-        pull: force use of pull, even if remote can stream'''
+        stream: use streaming clone if possible'''
 
-        # now, all clients that can stream can read repo formats
-        # supported by all servers that can stream.
+        # now, all clients that can request uncompressed clones can
+        # read repo formats supported by all servers that can serve
+        # them.
 
         # if revlog format changes, client will have to check version
-        # and format flags on "stream" capability, and stream only if
-        # compatible.
+        # and format flags on "stream" capability, and use
+        # uncompressed only if compatible.
 
         if stream and not heads and remote.capable('stream'):
             return self.stream_in(remote)
--- a/mercurial/sshserver.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/sshserver.py	Wed Jul 19 07:51:56 2006 -0700
@@ -60,8 +60,10 @@
         capabilities: space separated list of tokens
         '''
 
-        r = "capabilities: unbundle stream=%d\n" % (self.repo.revlogversion,)
-        self.respond(r)
+        caps = ['unbundle']
+        if self.ui.configbool('server', 'uncompressed'):
+            caps.append('stream=%d' % self.repo.revlogversion)
+        self.respond("capabilities: %s\n" % (' '.join(caps),))
 
     def do_lock(self):
         '''DEPRECATED - allowing remote client to lock repo is not safe'''
--- a/mercurial/streamclone.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/streamclone.py	Wed Jul 19 07:51:56 2006 -0700
@@ -40,7 +40,8 @@
         yield x
     # write manifest before changelog
     meta = list(walk(root, False))
-    meta.sort(reverse=True)
+    meta.sort()
+    meta.reverse()
     for x in meta:
         yield x
 
@@ -59,6 +60,13 @@
 def stream_out(repo, fileobj):
     '''stream out all metadata files in repository.
     writes to file-like object, must support write() and optional flush().'''
+
+    if not repo.ui.configbool('server', 'uncompressed'):
+        fileobj.write('1\n')
+        return
+
+    fileobj.write('0\n')
+
     # get consistent snapshot of repo. lock during scan so lock not
     # needed while we stream, and commits can happen.
     lock = repo.lock()
--- a/mercurial/ui.py	Wed Jul 19 09:28:59 2006 +0200
+++ b/mercurial/ui.py	Wed Jul 19 07:51:56 2006 -0700
@@ -209,7 +209,7 @@
 
     def expandpath(self, loc, default=None):
         """Return repository location relative to cwd or from [paths]"""
-        if "://" in loc or os.path.exists(loc):
+        if "://" in loc or os.path.isdir(loc):
             return loc
 
         path = self.config("paths", loc)
--- a/tests/test-backout.out	Wed Jul 19 09:28:59 2006 +0200
+++ b/tests/test-backout.out	Wed Jul 19 07:51:56 2006 -0700
@@ -29,3 +29,23 @@
 the backout changeset is a new head - do not forget to merge
 (use "backout -m" if you want to auto-merge)
 b: No such file or directory
+adding a
+adding b
+adding c
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding d
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+# backout of merge should fail
+abort: cannot back out a merge changeset without --parent
+# backout of merge with bad parent should fail
+abort: cb9a9f314b8b is not a parent of b2f3bb92043e
+# backout of non-merge with parent should fail
+abort: cannot use --parent on non-merge changeset
+# backout with valid parent should be ok
+removing d
+changeset 5:11fbd9be634c backs out changeset 4:b2f3bb92043e
+rolling back last transaction
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+removing c
+changeset 5:1a5f1a63bf2c backs out changeset 4:b2f3bb92043e
--- a/tests/test-http	Wed Jul 19 09:28:59 2006 +0200
+++ b/tests/test-http	Wed Jul 19 07:51:56 2006 -0700
@@ -1,23 +1,23 @@
 #!/bin/sh
 
-mkdir test
+hg init test
 cd test
 echo foo>foo
-hg init
-hg addremove
-hg commit -m 1
-hg verify
-hg serve -p 20059 -d --pid-file=hg.pid
-cat hg.pid >> $DAEMON_PIDS
+hg commit -A -d '0 0' -m 1
+hg --config server.uncompressed=True serve -p 20059 -d --pid-file=hg1.pid
+cat hg1.pid >> $DAEMON_PIDS
+hg serve -p 20060 -d --pid-file=hg2.pid
+cat hg2.pid >> $DAEMON_PIDS
 cd ..
 
 echo % clone via stream
-http_proxy= hg clone --stream http://localhost:20059/ copy 2>&1 | \
+http_proxy= hg clone --uncompressed http://localhost:20059/ copy 2>&1 | \
   sed -e 's/[0-9][0-9.]*/XXX/g'
 cd copy
 hg verify
 
-cd ..
+echo % try to clone via stream, should use pull instead
+http_proxy= hg clone --uncompressed http://localhost:20060/ copy2
 
 echo % clone via pull
 http_proxy= hg clone http://localhost:20059/ copy-pull
--- a/tests/test-http-proxy	Wed Jul 19 09:28:59 2006 +0200
+++ b/tests/test-http-proxy	Wed Jul 19 07:51:56 2006 -0700
@@ -4,7 +4,7 @@
 cd a
 echo a > a
 hg ci -Ama -d '1123456789 0'
-hg serve -p 20059 -d --pid-file=hg.pid
+hg --config server.uncompressed=True serve -p 20059 -d --pid-file=hg.pid
 cat hg.pid >> $DAEMON_PIDS
 
 cd ..
@@ -14,7 +14,7 @@
 sleep 2
 
 echo %% url for proxy, stream
-http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone --stream http://localhost:20059/ b | \
+http_proxy=http://localhost:20060/ hg --config http_proxy.always=True clone --uncompressed http://localhost:20059/ b | \
   sed -e 's/[0-9][0-9.]*/XXX/g'
 cd b
 hg verify
--- a/tests/test-http.out	Wed Jul 19 09:28:59 2006 +0200
+++ b/tests/test-http.out	Wed Jul 19 07:51:56 2006 -0700
@@ -1,10 +1,4 @@
-(the addremove command is deprecated; use add and remove --after instead)
 adding foo
-checking changesets
-checking manifests
-crosschecking files in changesets and manifests
-checking files
-1 files, 1 changesets, 1 total revisions
 % clone via stream
 streaming all changes
 XXX files to transfer, XXX bytes of data
@@ -15,6 +9,13 @@
 crosschecking files in changesets and manifests
 checking files
 1 files, 1 changesets, 1 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
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % clone via pull
 requesting all changes
 adding changesets
--- a/tests/test-ssh	Wed Jul 19 09:28:59 2006 +0200
+++ b/tests/test-ssh	Wed Jul 19 07:51:56 2006 -0700
@@ -27,11 +27,13 @@
 cd remote
 echo this > foo
 hg ci -A -m "init" -d "1000000 0" foo
+echo '[server]' > .hg/hgrc
+echo 'uncompressed = True' >> .hg/hgrc
 
 cd ..
 
 echo "# clone remote via stream"
-hg clone -e ./dummyssh --stream ssh://user@dummy/remote local-stream 2>&1 | \
+hg clone -e ./dummyssh --uncompressed ssh://user@dummy/remote local-stream 2>&1 | \
   sed -e 's/[0-9][0-9.]*/XXX/g'
 cd local-stream
 hg verify