--- a/hgext/mq.py Fri Oct 13 17:58:04 2006 -0500
+++ b/hgext/mq.py Sat Oct 14 10:39:40 2006 +0200
@@ -488,31 +488,43 @@
def delete(self, repo, patches, opts):
realpatches = []
- appliedbase = 0
- forget = opts.get('forget')
for patch in patches:
patch = self.lookup(patch, strict=True)
info = self.isapplied(patch)
- if info and not forget:
+ if info:
raise util.Abort(_("cannot delete applied patch %s") % patch)
if patch not in self.series:
raise util.Abort(_("patch %s not in series file") % patch)
- if forget:
- if not info:
- raise util.Abort(_("cannot forget unapplied patch %s") % patch)
- if info[0] != appliedbase:
- raise util.Abort(_("patch %s not at base") % patch)
+ realpatches.append(patch)
+
+ appliedbase = 0
+ if opts.get('rev'):
+ if not self.applied:
+ raise util.Abort(_('no patches applied'))
+ revs = [int(r) for r in cmdutil.revrange(ui, repo, opts['rev'])]
+ if len(revs) > 1 and revs[0] > revs[1]:
+ revs.reverse()
+ for rev in revs:
+ if appliedbase >= len(self.applied):
+ raise util.Abort(_("revision %d is not managed") % rev)
+
+ base = revlog.bin(self.applied[appliedbase].rev)
+ node = repo.changelog.node(rev)
+ if node != base:
+ raise util.Abort(_("cannot delete revision %d above "
+ "applied patches") % rev)
+ realpatches.append(self.applied[appliedbase].name)
appliedbase += 1
- realpatches.append(patch)
if not opts.get('keep'):
r = self.qrepo()
if r:
r.remove(realpatches, True)
else:
- os.unlink(self.join(patch))
+ for p in realpatches:
+ os.unlink(self.join(p))
- if forget:
+ if appliedbase:
del self.applied[:appliedbase]
self.applied_dirty = 1
indices = [self.find_series(p) for p in realpatches]
@@ -1351,10 +1363,10 @@
if qrepo:
qrepo.add(added)
-def delete(ui, repo, patch, *patches, **opts):
+def delete(ui, repo, *patches, **opts):
"""remove patches from queue
- With --forget, mq will stop managing the named patches. The
+ With --rev, mq will stop managing the named revisions. The
patches must be applied and at the base of the stack. This option
is useful when the patches have been applied upstream.
@@ -1362,7 +1374,7 @@
With --keep, the patch files are preserved in the patch directory."""
q = repo.mq
- q.delete(repo, (patch,) + patches, opts)
+ q.delete(repo, patches, opts)
q.save_dirty()
return 0
@@ -2018,9 +2030,9 @@
'hg qdiff [-I] [-X] [FILE]...'),
"qdelete|qremove|qrm":
(delete,
- [('f', 'forget', None, _('stop managing an applied patch')),
- ('k', 'keep', None, _('keep patch file'))],
- 'hg qdelete [-f] [-k] PATCH'),
+ [('k', 'keep', None, _('keep patch file')),
+ ('r', 'rev', [], _('stop managing a revision'))],
+ 'hg qdelete [-k] [-r REV]... PATCH...'),
'qfold':
(fold,
[('e', 'edit', None, _('edit patch header')),
--- a/mercurial/commands.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/commands.py Sat Oct 14 10:39:40 2006 +0200
@@ -1840,6 +1840,9 @@
break
if rev in rcache[fn]:
return rcache[fn][rev]
+ mr = repo.manifest.rev(man)
+ if repo.manifest.parentrevs(mr) != (mr - 1, -1):
+ return ncache[fn].get(repo.manifest.find(man, fn)[0])
if not dcache or dcache[0] != man:
dcache[:] = [man, repo.manifest.readdelta(man)]
if fn in dcache[1]:
--- a/mercurial/hgweb/hgweb_mod.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/hgweb/hgweb_mod.py Sat Oct 14 10:39:40 2006 +0200
@@ -584,10 +584,7 @@
# find tag, changeset, file
def cleanpath(self, path):
- p = util.normpath(path)
- if p[:2] == "..":
- raise Exception("suspicious path")
- return p
+ return util.canonpath(self.repo.root, '', path)
def run(self):
if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
--- a/mercurial/localrepo.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/localrepo.py Sat Oct 14 10:39:40 2006 +0200
@@ -510,6 +510,7 @@
m1 = self.manifest.read(c1[0]).copy()
m2 = self.manifest.read(c2[0])
changed = []
+ removed = []
if orig_parent == p1:
update_dirstate = 1
@@ -530,13 +531,15 @@
del m1[f]
if update_dirstate:
self.dirstate.forget([f])
+ removed.append(f)
except:
# deleted from p2?
pass
mnode = self.manifest.add(m1, tr, linkrev, c1[0], c2[0])
user = user or self.ui.username()
- n = self.changelog.add(mnode, changed, text, tr, p1, p2, user, date)
+ n = self.changelog.add(mnode, changed + removed, text,
+ tr, p1, p2, user, date)
tr.close()
if update_dirstate:
self.dirstate.setparents(n, nullid)
--- a/mercurial/patch.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/patch.py Sat Oct 14 10:39:40 2006 +0200
@@ -9,8 +9,8 @@
from i18n import gettext as _
from node import *
demandload(globals(), "base85 cmdutil mdiff util")
-demandload(globals(), "cStringIO email.Parser errno os re shutil sha sys")
-demandload(globals(), "tempfile zlib")
+demandload(globals(), "cStringIO email.Parser errno os popen2 re shutil sha")
+demandload(globals(), "sys tempfile zlib")
# helper functions
@@ -191,18 +191,22 @@
def dogitpatch(patchname, gitpatches, cwd=None):
"""Preprocess git patch so that vanilla patch can handle it"""
def extractbin(fp):
- line = fp.readline()
+ line = fp.readline().rstrip()
while line and not line.startswith('literal '):
- line = fp.readline()
+ line = fp.readline().rstrip()
if not line:
return
- size = int(line[8:].rstrip())
+ size = int(line[8:])
dec = []
- line = fp.readline()
+ line = fp.readline().rstrip()
while line:
- line = line[1:-1]
- dec.append(base85.b85decode(line))
- line = fp.readline()
+ l = line[0]
+ if l <= 'Z' and l >= 'A':
+ l = ord(l) - ord('A') + 1
+ else:
+ l = ord(l) - ord('a') + 27
+ dec.append(base85.b85decode(line[1:])[:l])
+ line = fp.readline().rstrip()
text = zlib.decompress(''.join(dec))
if len(text) != size:
raise util.Abort(_('binary patch is %d bytes, not %d') %
@@ -522,7 +526,7 @@
if repo.ui.quiet:
r = None
else:
- hexfunc = repo.ui.verbose and hex or short
+ hexfunc = repo.ui.debugflag and hex or short
r = [hexfunc(node) for node in [node1, node2] if node]
if opts.git:
--- a/mercurial/sshrepo.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/sshrepo.py Sat Oct 14 10:39:40 2006 +0200
@@ -18,7 +18,7 @@
m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path)
if not m:
- raise hg.RepoError(_("couldn't parse location %s") % path)
+ self.repoerror(_("couldn't parse location %s") % path)
self.user = m.group(2)
self.host = m.group(3)
@@ -38,7 +38,7 @@
ui.note('running %s\n' % cmd)
res = os.system(cmd)
if res != 0:
- raise hg.RepoError(_("could not create remote repo"))
+ self.repoerror(_("could not create remote repo"))
self.validate_repo(ui, sshcmd, args, remotecmd)
@@ -70,7 +70,7 @@
lines.append(l)
max_noise -= 1
else:
- raise hg.RepoError(_("no suitable response from remote hg"))
+ self.repoerror(_("no suitable response from remote hg"))
self.capabilities = ()
lines.reverse()
@@ -87,6 +87,10 @@
if not l: break
self.ui.status(_("remote: "), l)
+ def repoerror(self, msg):
+ self.cleanup()
+ raise hg.RepoError(msg)
+
def cleanup(self):
try:
self.pipeo.close()
@@ -117,7 +121,7 @@
try:
l = int(l)
except:
- raise hg.RepoError(_("unexpected response '%s'") % l)
+ self.repoerror(_("unexpected response '%s'") % l)
return r.read(l)
def lock(self):
@@ -132,7 +136,7 @@
try:
return map(bin, d[:-1].split(" "))
except:
- raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
+ self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def branches(self, nodes):
n = " ".join(map(hex, nodes))
@@ -141,7 +145,7 @@
br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ]
return br
except:
- raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
+ self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def between(self, pairs):
n = "\n".join(["-".join(map(hex, p)) for p in pairs])
@@ -150,7 +154,7 @@
p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
return p
except:
- raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "..."))
+ self.repoerror(_("unexpected response '%s'") % (d[:400] + "..."))
def changegroup(self, nodes, kind):
n = " ".join(map(hex, nodes))
@@ -159,7 +163,7 @@
def unbundle(self, cg, heads, source):
d = self.call("unbundle", heads=' '.join(map(hex, heads)))
if d:
- raise hg.RepoError(_("push refused: %s") % d)
+ self.repoerror(_("push refused: %s") % d)
while 1:
d = cg.read(4096)
@@ -185,7 +189,7 @@
def addchangegroup(self, cg, source, url):
d = self.call("addchangegroup")
if d:
- raise hg.RepoError(_("push refused: %s") % d)
+ self.repoerror(_("push refused: %s") % d)
while 1:
d = cg.read(4096)
if not d: break
--- a/mercurial/ui.py Fri Oct 13 17:58:04 2006 -0500
+++ b/mercurial/ui.py Sat Oct 14 10:39:40 2006 +0200
@@ -8,7 +8,7 @@
from i18n import gettext as _
from demandload import *
demandload(globals(), "errno getpass os re socket sys tempfile")
-demandload(globals(), "ConfigParser mdiff templater traceback util")
+demandload(globals(), "ConfigParser traceback util")
def dupconfig(orig):
new = ConfigParser.SafeConfigParser(orig.defaults())
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-diff-hashes Sat Oct 14 10:39:40 2006 +0200
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+hg init a
+cd a
+echo bar > foo
+hg add foo
+hg ci -m 'add foo' -d '1000000 0'
+
+echo foobar > foo
+hg ci -m 'change foo' -d '1000001 0'
+
+echo 'quiet:'
+hg --quiet diff -r 0 -r 1
+echo
+
+echo 'normal:'
+hg diff -r 0 -r 1
+echo
+
+echo 'verbose:'
+hg --verbose diff -r 0 -r 1
+echo
+
+echo 'debug:'
+hg --debug diff -r 0 -r 1
+echo
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-diff-hashes.out Sat Oct 14 10:39:40 2006 +0200
@@ -0,0 +1,31 @@
+quiet:
+--- a/foo Mon Jan 12 13:46:40 1970 +0000
++++ b/foo Mon Jan 12 13:46:41 1970 +0000
+@@ -1,1 +1,1 @@ bar
+-bar
++foobar
+
+normal:
+diff -r 74de3f1392e2 -r b8b5f023a6ad foo
+--- a/foo Mon Jan 12 13:46:40 1970 +0000
++++ b/foo Mon Jan 12 13:46:41 1970 +0000
+@@ -1,1 +1,1 @@ bar
+-bar
++foobar
+
+verbose:
+diff -r 74de3f1392e2 -r b8b5f023a6ad foo
+--- a/foo Mon Jan 12 13:46:40 1970 +0000
++++ b/foo Mon Jan 12 13:46:41 1970 +0000
+@@ -1,1 +1,1 @@ bar
+-bar
++foobar
+
+debug:
+diff -r 74de3f1392e2d67856fb155963441f2610494e1a -r b8b5f023a6ad77fc378bd95cf3fa00cd1414d107 foo
+--- a/foo Mon Jan 12 13:46:40 1970 +0000
++++ b/foo Mon Jan 12 13:46:41 1970 +0000
+@@ -1,1 +1,1 @@ bar
+-bar
++foobar
+
--- a/tests/test-log Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-log Sat Oct 14 10:39:40 2006 +0200
@@ -32,6 +32,13 @@
echo % log copies
hg log -vC --template '{rev} {file_copies%filecopy}\n'
+echo % log copies, non-linear manifest
+hg up -C 3
+hg mv dir/b e
+echo foo > foo
+hg ci -Ame2 -d '6 0'
+hg log -vC --template '{rev} {file_copies%filecopy}\n' -r 5
+
# log --follow tests
hg init ../follow
cd ../follow
--- a/tests/test-log.out Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-log.out Sat Oct 14 10:39:40 2006 +0200
@@ -82,6 +82,10 @@
2 dir/b (b)
1 b (a)
0
+% log copies, non-linear manifest
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+adding foo
+5 e (dir/b)
adding base
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
adding b1
--- a/tests/test-mq-qdelete Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-mq-qdelete Sat Oct 14 10:39:40 2006 +0200
@@ -21,7 +21,7 @@
hg qpop
hg qdel -k b
ls .hg/patches
-hg qdel -f a
+hg qdel -r a
hg qapplied
hg log --template '{rev} {desc}\n'
@@ -29,7 +29,7 @@
hg qnew e
hg qnew f
-hg qdel -f e
-hg qdel -f d e
+hg qdel -r e
+hg qdel -r qbase:e
hg qapplied
hg log --template '{rev} {desc}\n'
--- a/tests/test-mq-qdelete.out Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-mq-qdelete.out Sat Oct 14 10:39:40 2006 +0200
@@ -14,7 +14,7 @@
status
1 New patch: a
0 base
-abort: patch e not at base
+abort: cannot delete revision 3 above applied patches
f
4 New patch: f
3 New patch: e
--- a/tests/test-rawcommit1 Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-rawcommit1 Sat Oct 14 10:39:40 2006 +0200
@@ -10,24 +10,24 @@
echo this is c1 > c
hg rawcommit -p 1 -d "1000000 0" -m2 c
hg manifest 2
-hg parents
+hg -v parents
rm b
hg rawcommit -p 2 -d "1000000 0" -m3 b
hg manifest 3
-hg parents
+hg -v parents
echo this is a22 > a
hg rawcommit -p 3 -d "1000000 0" -m4 a
hg manifest 4
-hg parents
+hg -v parents
echo this is c22 > c
hg rawcommit -p 1 -d "1000000 0" -m5 c
hg manifest 5
-hg parents
+hg -v parents
# merge, but no files changed
hg rawcommit -p 4 -p 5 -d "1000000 0" -m6
hg manifest 6
-hg parents
+hg -v parents
# no changes what-so-ever
hg rawcommit -p 6 -d "1000000 0" -m7
hg manifest 7
-hg parents
+hg -v parents
--- a/tests/test-rawcommit1.out Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-rawcommit1.out Sat Oct 14 10:39:40 2006 +0200
@@ -8,52 +8,70 @@
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 2
+files: c
+description:
+2
+
(the rawcommit command is deprecated)
05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
-changeset: 3:0f9843914735
+changeset: 3:20652cf30cc0
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 3
+files: b
+description:
+3
+
(the rawcommit command is deprecated)
d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
-changeset: 4:909a3d1d3ee1
+changeset: 4:42556b925639
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 4
+files: a
+description:
+4
+
(the rawcommit command is deprecated)
05f9e54f4c9b86b09099803d8b49a50edcb4eaab 644 a
54837d97f2932a8194e69745a280a2c11e61ff9c 644 b
3570202ceac2b52517df64ebd0a062cb0d8fe33a 644 c
-changeset: 4:909a3d1d3ee1
+changeset: 4:42556b925639
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 4
+files: a
+description:
+4
+
(the rawcommit command is deprecated)
d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
-changeset: 6:725fdd0728db
+changeset: 6:8a0c9254b0ab
tag: tip
-parent: 4:909a3d1d3ee1
+parent: 4:42556b925639
parent: 5:f56d4c64ab98
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 6
+files:
+description:
+6
+
(the rawcommit command is deprecated)
d6e3c4976c13feb1728cd3ac851abaf7256a5c23 644 a
76d5e637cbec1bcc04a5a3fa4bcc7d13f6847c00 644 c
-changeset: 7:2c11b55105cb
+changeset: 7:a5a6e1f312b9
tag: tip
user: test
date: Mon Jan 12 13:46:40 1970 +0000
-summary: 7
+files:
+description:
+7
+
--- a/tests/test-ssh.out Fri Oct 13 17:58:04 2006 -0500
+++ b/tests/test-ssh.out Sat Oct 14 10:39:40 2006 +0200
@@ -1,7 +1,7 @@
# creating 'remote'
# repo not found error
+remote: abort: repository nonexistent not found!
abort: no suitable response from remote hg!
-remote: abort: repository nonexistent not found!
# clone remote via stream
streaming all changes
XXX files to transfer, XXX bytes of data