--- a/contrib/check-code.py Wed Feb 08 17:45:10 2012 +0100
+++ b/contrib/check-code.py Fri Feb 10 13:47:57 2012 -0600
@@ -54,7 +54,7 @@
(r'head -c', "don't use 'head -c', use 'dd'"),
(r'sha1sum', "don't use sha1sum, use $TESTDIR/md5sum.py"),
(r'ls.*-\w*R', "don't use 'ls -R', use 'find'"),
- (r'printf.*\\\d\d\d', "don't use 'printf \NNN', use Python"),
+ (r'printf.*\\\d{1,3}', "don't use 'printf \NNN', use Python"),
(r'printf.*\\x', "don't use printf \\x, use Python"),
(r'\$\(.*\)', "don't use $(expr), use `expr`"),
(r'rm -rf \*', "don't use naked rm -rf, target a directory"),
--- a/hgext/fetch.py Wed Feb 08 17:45:10 2012 +0100
+++ b/hgext/fetch.py Fri Feb 10 13:47:57 2012 -0600
@@ -85,7 +85,7 @@
newchildren = repo.changelog.nodesbetween([parent], newheads)[2]
if len(newheads) == 1 and len(newchildren):
if newchildren[0] != parent:
- return hg.clean(repo, newchildren[0])
+ return hg.update(repo, newchildren[0])
else:
return 0
--- a/hgext/mq.py Wed Feb 08 17:45:10 2012 +0100
+++ b/hgext/mq.py Fri Feb 10 13:47:57 2012 -0600
@@ -257,22 +257,28 @@
ci += 1
del self.comments[ci]
-def newcommit(repo, *args, **kwargs):
+def newcommit(repo, phase, *args, **kwargs):
"""helper dedicated to ensure a commit respect mq.secret setting
It should be used instead of repo.commit inside the mq source for operation
creating new changeset.
"""
- if not repo.ui.configbool('mq', 'secret', False):
- return repo.commit(*args, **kwargs)
-
- backup = repo.ui.backupconfig('phases', 'new-commit')
+ if phase is None:
+ if repo.ui.configbool('mq', 'secret', False):
+ phase = phases.secret
+ if phase is not None:
+ backup = repo.ui.backupconfig('phases', 'new-commit')
+ # Marking the repository as committing an mq patch can be used
+ # to optimize operations like _branchtags().
+ repo._committingpatch = True
try:
- # ensure we create a secret changeset
- repo.ui.setconfig('phases', 'new-commit', phases.secret)
+ if phase is not None:
+ repo.ui.setconfig('phases', 'new-commit', phase)
return repo.commit(*args, **kwargs)
finally:
- repo.ui.restoreconfig(backup)
+ repo._committingpatch = False
+ if phase is not None:
+ repo.ui.restoreconfig(backup)
class queue(object):
def __init__(self, ui, path, patchdir=None):
@@ -576,7 +582,7 @@
ret = hg.merge(repo, rev)
if ret:
raise util.Abort(_("update returned %d") % ret)
- n = newcommit(repo, ctx.description(), ctx.user(), force=True)
+ n = newcommit(repo, None, ctx.description(), ctx.user(), force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
try:
@@ -616,7 +622,7 @@
# the first patch in the queue is never a merge patch
#
pname = ".hg.patches.merge.marker"
- n = repo.commit('[mq]: merge marker', force=True)
+ n = newcommit(repo, None, '[mq]: merge marker', force=True)
self.removeundo(repo)
self.applied.append(statusentry(n, pname))
self.applieddirty = True
@@ -747,8 +753,8 @@
match = scmutil.matchfiles(repo, files or [])
oldtip = repo['tip']
- n = newcommit(repo, message, ph.user, ph.date, match=match,
- force=True)
+ n = newcommit(repo, None, message, ph.user, ph.date, match=match,
+ force=True)
if repo['tip'] == oldtip:
raise util.Abort(_("qpush exactly duplicates child changeset"))
if n is None:
@@ -988,8 +994,8 @@
if util.safehasattr(msg, '__call__'):
msg = msg()
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
- n = newcommit(repo, commitmsg, user, date, match=match,
- force=True)
+ n = newcommit(repo, None, commitmsg, user, date, match=match,
+ force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
try:
@@ -1540,15 +1546,11 @@
try:
# might be nice to attempt to roll back strip after this
- backup = repo.ui.backupconfig('phases', 'new-commit')
- try:
- # Ensure we create a new changeset in the same phase than
- # the old one.
- repo.ui.setconfig('phases', 'new-commit', oldphase)
- n = repo.commit(message, user, ph.date, match=match,
- force=True)
- finally:
- repo.ui.restoreconfig(backup)
+
+ # Ensure we create a new changeset in the same phase than
+ # the old one.
+ n = newcommit(repo, oldphase, message, user, ph.date,
+ match=match, force=True)
# only write patch after a successful commit
patchf.close()
self.applied.append(statusentry(n, patchfn))
@@ -3257,16 +3259,20 @@
def _branchtags(self, partial, lrev):
q = self.mq
+ cl = self.changelog
+ qbase = None
if not q.applied:
- return super(mqrepo, self)._branchtags(partial, lrev)
-
- cl = self.changelog
- qbasenode = q.applied[0].node
- try:
- qbase = cl.rev(qbasenode)
- except error.LookupError:
- self.ui.warn(_('mq status file refers to unknown node %s\n')
- % short(qbasenode))
+ if getattr(self, '_committingpatch', False):
+ # Committing a new patch, must be tip
+ qbase = len(cl) - 1
+ else:
+ qbasenode = q.applied[0].node
+ try:
+ qbase = cl.rev(qbasenode)
+ except error.LookupError:
+ self.ui.warn(_('mq status file refers to unknown node %s\n')
+ % short(qbasenode))
+ if qbase is None:
return super(mqrepo, self)._branchtags(partial, lrev)
start = lrev + 1
--- a/tests/test-diffstat.t Wed Feb 08 17:45:10 2012 +0100
+++ b/tests/test-diffstat.t Fri Feb 10 13:47:57 2012 -0600
@@ -35,7 +35,7 @@
$ hg ci -m appenda
- $ printf '\0' > c
+ >>> open("c", "wb").write("\0")
$ touch d
$ hg add c d
@@ -54,7 +54,7 @@
$ hg ci -m createb
- $ printf '\0' > "file with spaces"
+ >>> open("file with spaces", "wb").write("\0")
$ hg add "file with spaces"
Filename with spaces diffstat:
--- a/tests/test-keyword.t Wed Feb 08 17:45:10 2012 +0100
+++ b/tests/test-keyword.t Fri Feb 10 13:47:57 2012 -0600
@@ -169,10 +169,10 @@
hg status of kw-ignored binary file starting with '\1\n'
- $ printf '\1\nfoo' > i
+ >>> open("i", "wb").write("\1\nfoo")
$ hg -q commit -Am metasep i
$ hg status
- $ printf '\1\nbar' > i
+ >>> open("i", "wb").write("\1\nbar")
$ hg status
M i
$ hg -q commit -m "modify metasep" i
@@ -556,7 +556,6 @@
Commit and show expansion in original and copy
$ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
- invalidating branch cache (tip differs)
c
c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
overwriting c expanding keywords
--- a/tests/test-mq-caches.t Wed Feb 08 17:45:10 2012 +0100
+++ b/tests/test-mq-caches.t Fri Feb 10 13:47:57 2012 -0600
@@ -29,16 +29,14 @@
$ hg qnew -d '0 0' p1
$ show_branch_cache
tip: 0
- d986d5caac23a7d44a46efc0ddaf5eb9665844cf 0
- d986d5caac23a7d44a46efc0ddaf5eb9665844cf default
+ No branch cache
$ echo > pfile
$ hg add pfile
$ hg qrefresh -m 'patch 1'
$ show_branch_cache
tip: 0
- a7977e38ed2c2942fa6c278030badfef3d180979 0
- a7977e38ed2c2942fa6c278030badfef3d180979 default
+ No branch cache
some regular revisions
@@ -67,8 +65,8 @@
now at: p1
$ show_branch_cache
tip: 2
- 982611f6955f9c48d3365decea203217c945ef0d 2
- 982611f6955f9c48d3365decea203217c945ef0d bar
+ c229711f16da3d7591f89b1b8d963b79bda22714 1
+ c229711f16da3d7591f89b1b8d963b79bda22714 bar
dc25e3827021582e979f600811852e36cbe57341 foo
$ hg qnew -d '0 0' p2
@@ -77,8 +75,8 @@
$ hg qrefresh -m 'patch 2'
$ show_branch_cache 1
tip: 3
- 982611f6955f9c48d3365decea203217c945ef0d 2
- 982611f6955f9c48d3365decea203217c945ef0d bar
+ c229711f16da3d7591f89b1b8d963b79bda22714 1
+ c229711f16da3d7591f89b1b8d963b79bda22714 bar
dc25e3827021582e979f600811852e36cbe57341 foo
branch foo: 3
branch bar: 2
@@ -121,6 +119,6 @@
now at: p2
$ show_branch_cache
tip: 3
- 3fe2e3b237359b5c55cec6ed172ac41d3850fade 1
- 3fe2e3b237359b5c55cec6ed172ac41d3850fade foo
+ dc25e3827021582e979f600811852e36cbe57341 0
+ dc25e3827021582e979f600811852e36cbe57341 foo
--- a/tests/test-status.t Wed Feb 08 17:45:10 2012 +0100
+++ b/tests/test-status.t Fri Feb 10 13:47:57 2012 -0600
@@ -279,12 +279,12 @@
$ hg init repo5
$ cd repo5
- $ printf '\1\nfoo' > 010a
+ >>> open("010a", "wb").write("\1\nfoo")
$ hg ci -q -A -m 'initial checkin'
$ hg status -A
C 010a
- $ printf '\1\nbar' > 010a
+ >>> open("010a", "wb").write("\1\nbar")
$ hg status -A
M 010a
$ hg ci -q -m 'modify 010a'
--- a/tests/test-subrepo-paths.t Wed Feb 08 17:45:10 2012 +0100
+++ b/tests/test-subrepo-paths.t Fri Feb 10 13:47:57 2012 -0600
@@ -17,7 +17,7 @@
hg debugsub with remapping
$ echo '[subpaths]' >> .hg/hgrc
- $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc
+ $ printf 'http://example.net/lib(.*) = C:\\libs\\\\1-lib\\\n' >> .hg/hgrc # no-check-code
$ hg debugsub
path sub