Mercurial > hg
changeset 2757:787e18b84893
merge patches from brendan cully that did not apply clean against tip.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 01 Aug 2006 15:40:28 -0700 |
parents | caa6d992608b (current diff) 5dfeda163bb7 (diff) |
children | c9359142cba3 |
files | hgext/mq.py |
diffstat | 3 files changed, 73 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/darcs2hg.py Tue Aug 01 15:24:18 2006 -0700 +++ b/contrib/darcs2hg.py Tue Aug 01 15:40:28 2006 -0700 @@ -92,7 +92,7 @@ def darcs_pull(hg_repo, darcs_repo, chash): old_tip = darcs_tip(darcs_repo) - res = cmd("darcs pull '%s' --all --match='hash %s'" % (darcs_repo, chash), hg_repo) + res = cmd("darcs pull \"%s\" --all --match=\"hash %s\"" % (darcs_repo, chash), hg_repo) print res new_tip = darcs_tip(darcs_repo) if not new_tip != old_tip + 1: @@ -110,7 +110,8 @@ old_tip = hg_tip(hg_repo) cmd("hg add -X _darcs", hg_repo) cmd("hg remove -X _darcs --after", hg_repo) - res = cmd("hg commit -l %s -u '%s' -d '%s 0'" % (tmpfile, author, date), hg_repo) + res = cmd("hg commit -l %s -u \"%s\" -d \"%s 0\"" % (tmpfile, author, date), hg_repo) + os.close(fd) os.unlink(tmpfile) new_tip = hg_tip(hg_repo) if not new_tip == old_tip + 1: @@ -156,7 +157,7 @@ print "Given HG repository must not exist when no SKIP is specified." sys.exit(-1) if skip == None: - cmd("hg init '%s'" % (hg_repo)) + cmd("hg init \"%s\"" % (hg_repo)) cmd("darcs initialize", hg_repo) # Get the changes from the Darcs repository change_number = 0
--- a/hgext/mq.py Tue Aug 01 15:24:18 2006 -0700 +++ b/hgext/mq.py Tue Aug 01 15:40:28 2006 -0700 @@ -382,13 +382,19 @@ tr.close() return (err, n) - def delete(self, repo, patch): + def delete(self, repo, patch, force=False): patch = self.lookup(patch, strict=True) info = self.isapplied(patch) 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 force: + r = self.qrepo() + if r: + r.remove([patch], True) + else: + os.unlink(os.path.join(self.path, patch)) i = self.find_series(patch) del self.full_series[i] self.read_series(self.full_series) @@ -1165,9 +1171,12 @@ qrepo.add(added) def delete(ui, repo, patch, **opts): - """remove a patch from the series file""" + """remove a patch from the series file + + The patch must not be applied. + With -f, deletes the patch file as well as the series entry.""" q = repo.mq - q.delete(repo, patch) + q.delete(repo, patch, force=opts.get('force')) q.save_dirty() return 0 @@ -1448,6 +1457,56 @@ q.save_dirty() return 0 +def rename(ui, repo, patch, name=None, **opts): + """rename a patch + + With one argument, renames the current patch to PATCH1. + With two arguments, renames PATCH1 to PATCH2.""" + + q = repo.mq + + if not name: + name = patch + patch = None + + if name in q.series: + raise util.Abort(_('A patch named %s already exists in the series file') % name) + + absdest = os.path.join(q.path, name) + if os.path.exists(absdest): + raise util.Abort(_('%s already exists') % absdest) + + if patch: + patch = q.lookup(patch) + else: + if not q.applied: + ui.write(_('No patches applied\n')) + return + patch = q.lookup('qtip') + + if ui.verbose: + ui.write('Renaming %s to %s\n' % (patch, name)) + i = q.find_series(patch) + q.full_series[i] = name + q.read_series(q.full_series) + q.series_dirty = 1 + + info = q.isapplied(patch) + if info: + q.applied[info[0]] = info[1] + ':' + name + q.applied_dirty = 1 + + util.rename(os.path.join(q.path, patch), absdest) + r = q.qrepo() + if r: + wlock = r.wlock() + if r.dirstate.state(name) == 'r': + r.undelete([name], wlock) + r.copy(patch, name, wlock) + r.remove([patch], False, wlock) + + q.save_dirty() + def restore(ui, repo, rev, **opts): """restore the queue state saved by a rev""" rev = repo.lookup(rev) @@ -1546,7 +1605,10 @@ commands.table["^commit|ci"][1], 'hg qcommit [OPTION]... [FILE]...'), "^qdiff": (diff, [], 'hg qdiff [FILE]...'), - "qdelete": (delete, [], 'hg qdelete PATCH'), + "qdelete": + (delete, + [('f', 'force', None, _('delete patch file'))], + 'hg qdelete [-f] PATCH'), 'qfold': (fold, [('e', 'edit', None, _('edit patch header')), @@ -1594,6 +1656,8 @@ ('l', 'logfile', '', _('change commit message with <file> content')), ('s', 'short', None, 'short refresh')], 'hg qrefresh [-e] [-m TEXT] [-l FILE] [-s]'), + 'qrename|qmv': + (rename, [], 'hg qrename PATCH1 [PATCH2]'), "qrestore": (restore, [('d', 'delete', None, 'delete save entry'),
--- a/tests/test-mq.out Tue Aug 01 15:24:18 2006 -0700 +++ b/tests/test-mq.out Tue Aug 01 15:40:28 2006 -0700 @@ -39,6 +39,7 @@ qprev print the name of the previous patch qpush push the next patch onto the stack qrefresh update the current patch + qrename rename a patch qrestore restore the queue state saved by a rev qsave save current queue state qseries print the entire series file