Mercurial > hg
changeset 3379:fef022f9a238
Merge with mpm
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Fri, 13 Oct 2006 00:26:46 -0700 |
parents | 1106e00e6847 (diff) 8c36b33a27c7 (current diff) |
children | bb9852b3bf06 |
files | |
diffstat | 7 files changed, 86 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Oct 12 14:49:19 2006 -0500 +++ b/hgext/mq.py Fri Oct 13 00:26:46 2006 -0700 @@ -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/localrepo.py Thu Oct 12 14:49:19 2006 -0500 +++ b/mercurial/localrepo.py Fri Oct 13 00:26:46 2006 -0700 @@ -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 Thu Oct 12 14:49:19 2006 -0500 +++ b/mercurial/patch.py Fri Oct 13 00:26:46 2006 -0700 @@ -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') %
--- a/tests/test-mq-qdelete Thu Oct 12 14:49:19 2006 -0500 +++ b/tests/test-mq-qdelete Fri Oct 13 00:26:46 2006 -0700 @@ -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 Thu Oct 12 14:49:19 2006 -0500 +++ b/tests/test-mq-qdelete.out Fri Oct 13 00:26:46 2006 -0700 @@ -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 Thu Oct 12 14:49:19 2006 -0500 +++ b/tests/test-rawcommit1 Fri Oct 13 00:26:46 2006 -0700 @@ -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 Thu Oct 12 14:49:19 2006 -0500 +++ b/tests/test-rawcommit1.out Fri Oct 13 00:26:46 2006 -0700 @@ -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 +