changeset 14274:01472f8f5429

merge with crew
author Matt Mackall <mpm@selenic.com>
date Sun, 08 May 2011 16:41:41 -0500
parents 38af0f514134 (current diff) d6907a5674a2 (diff)
children 7f16ff9e45b4
files mercurial/localrepo.py
diffstat 3 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun May 08 20:45:47 2011 +0200
+++ b/mercurial/cmdutil.py	Sun May 08 16:41:41 2011 -0500
@@ -7,10 +7,10 @@
 
 from node import hex, nullid, nullrev, short
 from i18n import _
-import os, sys, errno, re, glob, tempfile
+import os, sys, errno, re, tempfile
 import util, scmutil, templater, patch, error, templatekw, wdutil
 import match as matchmod
-import similar, revset, subrepo
+import revset, subrepo
 
 expandpats = wdutil.expandpats
 match = wdutil.match
--- a/mercurial/localrepo.py	Sun May 08 20:45:47 2011 +0200
+++ b/mercurial/localrepo.py	Sun May 08 16:41:41 2011 -0500
@@ -21,7 +21,7 @@
 class localrepository(repo.repository):
     capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey',
                         'known', 'getbundle'))
-    supportedformats = set(('revlogv1',))
+    supportedformats = set(('revlogv1', 'generaldelta'))
     supported = supportedformats | set(('store', 'fncache', 'shared',
                                         'dotencode'))
 
@@ -61,6 +61,8 @@
                         '\0\0\0\2' # represents revlogv2
                         ' dummy changelog to prevent using the old repo layout'
                     )
+                if self.ui.configbool('format', 'generaldelta', False):
+                    requirements.append("generaldelta")
             else:
                 raise error.RepoError(_("repository %s not found") % path)
         elif create:
@@ -115,6 +117,8 @@
     def _applyrequirements(self, requirements):
         self.requirements = requirements
         self.sopener.options = {}
+        if 'generaldelta' in requirements:
+            self.sopener.options['generaldelta'] = 1
 
     def _writerequirements(self):
         reqfile = self.opener("requires", "w")
@@ -700,7 +704,7 @@
         if os.path.exists(bkname):
             util.copyfile(bkname, self.join('journal.bookmarks'))
         else:
-            self.opener('journal.bookmarks', 'w').write('')
+            self.opener.write('journal.bookmarks', '')
 
         return (self.sjoin('journal'), self.join('journal.dirstate'),
                 self.join('journal.branch'), self.join('journal.desc'),
--- a/mercurial/revlog.py	Sun May 08 20:45:47 2011 +0200
+++ b/mercurial/revlog.py	Sun May 08 16:41:41 2011 -0500
@@ -226,10 +226,13 @@
         self._nodepos = None
 
         v = REVLOG_DEFAULT_VERSION
-        if hasattr(opener, 'options') and 'defversion' in opener.options:
-            v = opener.options['defversion']
-            if v & REVLOGNG:
-                v |= REVLOGNGINLINEDATA
+        if hasattr(opener, 'options'):
+            if 'defversion' in opener.options:
+                v = opener.options['defversion']
+                if v & REVLOGNG:
+                    v |= REVLOGNGINLINEDATA
+            if v & REVLOGNG and 'generaldelta' in opener.options:
+                v |= REVLOGGENERALDELTA
 
         i = ''
         try:
@@ -1003,10 +1006,14 @@
             l = len(data[1]) + len(data[0])
             basecache = self._basecache
             if basecache and basecache[0] == rev:
-                base = basecache[1]
+                chainbase = basecache[1]
             else:
-                base = self.chainbase(rev)
-            dist = l + offset - self.start(base)
+                chainbase = self.chainbase(rev)
+            dist = l + offset - self.start(chainbase)
+            if self._generaldelta:
+                base = rev
+            else:
+                base = chainbase
             return dist, l, data, base
 
         curr = len(self)
@@ -1019,7 +1026,10 @@
 
         # should we try to build a delta?
         if prev != nullrev:
-            d = builddelta(prev)
+            if self._generaldelta:
+                d = builddelta(p1r)
+            else:
+                d = builddelta(prev)
             dist, l, data, base = d
 
         # full versions are inserted when the needed deltas