--- a/contrib/check-code.py Wed Nov 09 19:01:10 2011 +0100
+++ b/contrib/check-code.py Thu Nov 10 10:59:03 2011 -0600
@@ -131,7 +131,8 @@
(r'[^\n]\Z', "no trailing newline"),
(r'(\S[ \t]+|^[ \t]+)\n', "trailing whitespace"),
# (r'^\s+[^_ \n][^_. \n]+_[^_\n]+\s*=', "don't use underbars in identifiers"),
-# (r'\w*[a-z][A-Z]\w*\s*=', "don't use camelcase in identifiers"),
+ (r'^\s+(self\.)?[A-za-z][a-z0-9]+[A-Z]\w* = ',
+ "don't use camelcase in identifiers"),
(r'^\s*(if|while|def|class|except|try)\s[^[\n]*:\s*[^\\n]#\s]+',
"linebreak after :"),
(r'class\s[^( \n]+:', "old-style class, use class foo(object)"),
--- a/hgext/convert/darcs.py Wed Nov 09 19:01:10 2011 +0100
+++ b/hgext/convert/darcs.py Thu Nov 10 10:59:03 2011 -0600
@@ -24,7 +24,7 @@
try:
from elementtree.ElementTree import ElementTree, XMLParser
except ImportError:
- ElementTree = None
+ pass
class darcs_source(converter_source, commandline):
def __init__(self, ui, path, rev=None):
@@ -42,7 +42,7 @@
raise util.Abort(_('darcs version 2.1 or newer needed (found %r)') %
version)
- if ElementTree is None:
+ if "ElementTree" not in globals():
raise util.Abort(_("Python ElementTree module is not available"))
self.path = os.path.realpath(path)
--- a/mercurial/context.py Wed Nov 09 19:01:10 2011 +0100
+++ b/mercurial/context.py Thu Nov 10 10:59:03 2011 -0600
@@ -118,6 +118,11 @@
def bookmarks(self):
return self._repo.nodebookmarks(self._node)
def phase(self):
+ if self._rev == -1:
+ return 0
+ if self._rev >= len(self._repo._phaserev):
+ # outdated cache
+ del self._repo._phaserev
return self._repo._phaserev[self._rev]
def hidden(self):
return self._rev in self._repo.changelog.hiddenrevs
--- a/mercurial/localrepo.py Wed Nov 09 19:01:10 2011 +0100
+++ b/mercurial/localrepo.py Thu Nov 10 10:59:03 2011 -0600
@@ -36,6 +36,7 @@
self.wopener = scmutil.opener(self.root)
self.baseui = baseui
self.ui = baseui.copy()
+ self._dirtyphases = False
try:
self.ui.readconfig(self.join("hgrc"), self.root)
@@ -172,7 +173,10 @@
@filecache('phaseroots')
def _phaseroots(self):
- return phases.readroots(self)
+ self._dirtyphases = False
+ phaseroots = phases.readroots(self)
+ phases.filterunknown(self, phaseroots)
+ return phaseroots
@propertycache
def _phaserev(self):
@@ -756,10 +760,16 @@
util.copyfile(bkname, self.join('journal.bookmarks'))
else:
self.opener.write('journal.bookmarks', '')
+ phasesname = self.sjoin('phaseroots')
+ if os.path.exists(phasesname):
+ util.copyfile(phasesname, self.sjoin('journal.phaseroots'))
+ else:
+ self.sopener.write('journal.phaseroots', '')
return (self.sjoin('journal'), self.join('journal.dirstate'),
self.join('journal.branch'), self.join('journal.desc'),
- self.join('journal.bookmarks'))
+ self.join('journal.bookmarks'),
+ self.sjoin('journal.phaseroots'))
def recover(self):
lock = self.lock()
@@ -824,6 +834,9 @@
if os.path.exists(self.join('undo.bookmarks')):
util.rename(self.join('undo.bookmarks'),
self.join('bookmarks'))
+ if os.path.exists(self.sjoin('undo.phaseroots')):
+ util.rename(self.sjoin('undo.phaseroots'),
+ self.sjoin('phaseroots'))
self.invalidate()
parentgone = (parents[0] not in self.changelog.nodemap or
@@ -910,6 +923,8 @@
def unlock():
self.store.write()
+ if self._dirtyphases:
+ phases.writeroots(self)
for k, ce in self._filecache.items():
if k == 'dirstate':
continue
--- a/mercurial/phases.py Wed Nov 09 19:01:10 2011 +0100
+++ b/mercurial/phases.py Thu Nov 10 10:59:03 2011 -0600
@@ -8,7 +8,8 @@
# GNU General Public License version 2 or any later version.
import errno
-from node import nullid, bin, hex
+from node import nullid, bin, hex, short
+from i18n import _
allphases = range(2)
trackedphases = allphases[1:]
@@ -37,5 +38,46 @@
for phase, roots in enumerate(repo._phaseroots):
for h in roots:
f.write('%i %s\n' % (phase, hex(h)))
+ repo._dirtyphases = False
finally:
f.close()
+
+def filterunknown(repo, phaseroots=None):
+ """remove unknown nodes from the phase boundary
+
+ no data is lost as unknown node only old data for their descentants
+ """
+ if phaseroots is None:
+ phaseroots = repo._phaseroots
+ for phase, nodes in enumerate(phaseroots):
+ missing = [node for node in nodes if node not in repo]
+ if missing:
+ for mnode in missing:
+ msg = _('Removing unknown node %(n)s from %(p)i-phase boundary')
+ repo.ui.debug(msg, {'n': short(mnode), 'p': phase})
+ nodes.symmetric_difference_update(missing)
+ repo._dirtyphases = True
+
+def moveboundary(repo, target_phase, nodes):
+ """Add nodes to a phase changing other nodes phases if necessary.
+
+ Simplify boundary to contains phase roots only."""
+
+ # move roots of lower states
+ for phase in xrange(target_phase + 1, len(allphases)):
+ # filter nodes that are not in a compatible phase already
+ # XXX rev phase cache might have been invalidated by a previous loop
+ # XXX we need to be smarter here
+ nodes = [n for n in nodes if repo[n].phase() >= phase]
+ if not nodes:
+ break # no roots to move anymore
+ roots = repo._phaseroots[phase]
+ olds = roots.copy()
+ ctxs = list(repo.set('roots((%ln::) - (%ln::%ln))', olds, olds, nodes))
+ roots.clear()
+ roots.update(ctx.node() for ctx in ctxs)
+ if olds != roots:
+ # invalidate cache (we probably could be smarter here
+ if '_phaserev' in vars(repo):
+ del repo._phaserev
+ repo._dirtyphases = True
--- a/mercurial/repair.py Wed Nov 09 19:01:10 2011 +0100
+++ b/mercurial/repair.py Thu Nov 10 10:59:03 2011 -0600
@@ -6,7 +6,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-from mercurial import changegroup, bookmarks
+from mercurial import changegroup, bookmarks, phases
from mercurial.node import short
from mercurial.i18n import _
import os
@@ -145,7 +145,9 @@
for m in updatebm:
bm[m] = repo['.'].node()
bookmarks.write(repo)
-
+ # remove potential unknown phase
+ # XXX using to_strip data would be faster
+ phases.filterunknown(repo)
except:
if backupfile:
ui.warn(_("strip failed, full bundle stored in '%s'\n")
--- a/setup.py Wed Nov 09 19:01:10 2011 +0100
+++ b/setup.py Thu Nov 10 10:59:03 2011 -0600
@@ -186,6 +186,12 @@
except ImportError:
version = 'unknown'
+class hgbuild(build):
+ # Insert hgbuildmo first so that files in mercurial/locale/ are found
+ # when build_py is run next.
+ sub_commands = [('build_mo', None),
+ ] + build.sub_commands
+
class hgbuildmo(build):
description = "build translations (.mo files)"
@@ -217,13 +223,18 @@
self.make_file([pofile], mobuildfile, spawn, (cmd,))
-# Insert hgbuildmo first so that files in mercurial/locale/ are found
-# when build_py is run next.
-build.sub_commands.insert(0, ('build_mo', None))
+class hgdist(Distribution):
+ pure = 0
-Distribution.pure = 0
-Distribution.global_options.append(('pure', None, "use pure (slow) Python "
- "code instead of C extensions"))
+ global_options = Distribution.global_options + \
+ [('pure', None, "use pure (slow) Python "
+ "code instead of C extensions"),
+ ]
+
+ def has_ext_modules(self):
+ # self.ext_modules is emptied in hgbuildpy.finalize_options which is
+ # too late for some cases
+ return not self.pure and Distribution.has_ext_modules(self)
class hgbuildext(build_ext):
@@ -335,7 +346,8 @@
fp.write(data)
fp.close()
-cmdclass = {'build_mo': hgbuildmo,
+cmdclass = {'build': hgbuild,
+ 'build_mo': hgbuildmo,
'build_ext': hgbuildext,
'build_py': hgbuildpy,
'build_hgextindex': buildhgextindex,
@@ -435,6 +447,7 @@
data_files=datafiles,
package_data=packagedata,
cmdclass=cmdclass,
+ distclass=hgdist,
options=dict(py2exe=dict(packages=['hgext', 'email']),
bdist_mpkg=dict(zipdist=True,
license='COPYING',
--- a/tests/test-fncache.t Wed Nov 09 19:01:10 2011 +0100
+++ b/tests/test-fncache.t Thu Nov 10 10:59:03 2011 -0600
@@ -80,6 +80,7 @@
.hg/undo.branch
.hg/undo.desc
.hg/undo.dirstate
+ .hg/undo.phaseroots
$ cd ..
Non fncache repo:
@@ -103,6 +104,7 @@
.hg/store/data/tst.d.hg
.hg/store/data/tst.d.hg/_foo.i
.hg/store/undo
+ .hg/store/undo.phaseroots
.hg/undo.bookmarks
.hg/undo.branch
.hg/undo.desc
--- a/tests/test-hardlinks.t Wed Nov 09 19:01:10 2011 +0100
+++ b/tests/test-hardlinks.t Thu Nov 10 10:59:03 2011 -0600
@@ -48,6 +48,7 @@
1 r1/.hg/store/data/f1.i
1 r1/.hg/store/fncache
1 r1/.hg/store/undo
+ 1 r1/.hg/store/undo.phaseroots
Create hardlinked clone r2:
@@ -76,6 +77,7 @@
2 r1/.hg/store/data/f1.i
2 r1/.hg/store/fncache
1 r1/.hg/store/undo
+ 1 r1/.hg/store/undo.phaseroots
$ nlinksdir r2/.hg/store
2 r2/.hg/store/00changelog.i
@@ -93,6 +95,7 @@
1 r3/.hg/store/data/f1.i
1 r3/.hg/store/fncache
1 r3/.hg/store/undo
+ 1 r3/.hg/store/undo.phaseroots
Create a non-inlined filelog in r3:
@@ -113,6 +116,7 @@
1 r3/.hg/store/data/f1.i
1 r3/.hg/store/fncache
1 r3/.hg/store/undo
+ 1 r3/.hg/store/undo.phaseroots
Push to repo r1 should break up most hardlinks in r2:
@@ -196,6 +200,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/store/undo.phaseroots
2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
@@ -225,6 +230,7 @@
2 r4/.hg/store/data/f1.i
2 r4/.hg/store/fncache
2 r4/.hg/store/undo
+ 2 r4/.hg/store/undo.phaseroots
2 r4/.hg/undo.bookmarks
2 r4/.hg/undo.branch
2 r4/.hg/undo.desc
--- a/tests/test-hup.t Wed Nov 09 19:01:10 2011 +0100
+++ b/tests/test-hup.t Thu Nov 10 10:59:03 2011 -0600
@@ -17,4 +17,4 @@
rollback completed
killed!
$ echo .hg/* .hg/store/*
- .hg/00changelog.i .hg/journal.bookmarks .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a
+ .hg/00changelog.i .hg/journal.bookmarks .hg/journal.branch .hg/journal.desc .hg/journal.dirstate .hg/requires .hg/store .hg/store/00changelog.i .hg/store/00changelog.i.a .hg/store/journal.phaseroots
--- a/tests/test-inherit-mode.t Wed Nov 09 19:01:10 2011 +0100
+++ b/tests/test-inherit-mode.t Thu Nov 10 10:59:03 2011 -0600
@@ -77,6 +77,7 @@
00660 ./.hg/store/data/foo.i
00660 ./.hg/store/fncache
00660 ./.hg/store/undo
+ 00660 ./.hg/store/undo.phaseroots
00660 ./.hg/undo.bookmarks
00660 ./.hg/undo.branch
00660 ./.hg/undo.desc
@@ -118,6 +119,7 @@
00660 ../push/.hg/store/data/foo.i
00660 ../push/.hg/store/fncache
00660 ../push/.hg/store/undo
+ 00660 ../push/.hg/store/undo.phaseroots
00660 ../push/.hg/undo.bookmarks
00660 ../push/.hg/undo.branch
00660 ../push/.hg/undo.desc