Mercurial > hg
changeset 3094:41e5ecfb6c24
merge with brendan
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Fri, 15 Sep 2006 00:51:27 +0200 |
parents | edefbb3a3b08 (current diff) 7fa3d38a99b6 (diff) |
children | 25857e00af8e |
files | |
diffstat | 12 files changed, 215 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/churn.py Wed Sep 13 18:24:58 2006 -0700 +++ b/contrib/churn.py Fri Sep 15 00:51:27 2006 +0200 @@ -14,7 +14,7 @@ from mercurial.demandload import * from mercurial.i18n import gettext as _ demandload(globals(), 'time sys signal os') -demandload(globals(), 'mercurial:hg,mdiff,fancyopts,commands,ui,util,templater,node') +demandload(globals(), 'mercurial:hg,mdiff,fancyopts,cmdutil,ui,util,templater,node') def __gather(ui, repo, node1, node2): def dirtywork(f, mmap1, mmap2): @@ -150,7 +150,7 @@ amap = get_aliases(f) f.close() - revs = [int(r) for r in commands.revrange(ui, repo, opts['rev'])] + revs = [int(r) for r in cmdutil.revrange(ui, repo, opts['rev'])] revs.sort() stats = gather_stats(ui, repo, amap, revs, opts.get('progress'))
--- a/hgext/extdiff.py Wed Sep 13 18:24:58 2006 -0700 +++ b/hgext/extdiff.py Fri Sep 15 00:51:27 2006 +0200 @@ -45,7 +45,7 @@ from mercurial.demandload import demandload from mercurial.i18n import gettext as _ from mercurial.node import * -demandload(globals(), 'mercurial:commands,cmdutil,util os shutil tempfile') +demandload(globals(), 'mercurial:cmdutil,util os shutil tempfile') def dodiff(ui, repo, diffcmd, diffopts, pats, opts): def snapshot_node(files, node): @@ -90,7 +90,7 @@ fp.write(chunk) return dirname - node1, node2 = commands.revpair(ui, repo, opts['rev']) + node1, node2 = cmdutil.revpair(ui, repo, opts['rev']) files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) modified, added, removed, deleted, unknown = repo.status( node1, node2, files, match=matchfn)[:5]
--- a/hgext/mq.py Wed Sep 13 18:24:58 2006 -0700 +++ b/hgext/mq.py Fri Sep 15 00:51:27 2006 +0200 @@ -40,7 +40,7 @@ class statusentry: def __init__(self, rev, name=None): if not name: - fields = rev.split(':') + fields = rev.split(':', 1) if len(fields) == 2: self.rev, self.name = fields else: @@ -483,24 +483,35 @@ tr.close() return (err, n) - def delete(self, repo, patches, keep=False): + 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: + if info and not forget: 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) + appliedbase += 1 realpatches.append(patch) - if not keep: + if not opts.get('keep'): r = self.qrepo() if r: r.remove(realpatches, True) else: os.unlink(self.join(patch)) + if forget: + del self.applied[:appliedbase] + self.applied_dirty = 1 indices = [self.find_series(p) for p in realpatches] indices.sort() for i in indices[-1::-1]: @@ -995,6 +1006,8 @@ r = list(util.unique(dd)) a = list(util.unique(aa)) filelist = filter(matchfn, util.unique(m + r + a)) + if opts.get('git'): + self.diffopts().git = True patch.diff(repo, patchparent, files=filelist, match=matchfn, fp=patchf, changes=(m, a, r, [], u), opts=self.diffopts()) @@ -1304,10 +1317,15 @@ def delete(ui, repo, patch, *patches, **opts): """remove patches from queue - The patches must not be applied. - With -k, the patch files are preserved in the patch directory.""" + With --forget, mq will stop managing the named patches. The + patches must be applied and at the base of the stack. This option + is useful when the patches have been applied upstream. + + Otherwise, the patches must not be applied. + + With --keep, the patch files are preserved in the patch directory.""" q = repo.mq - q.delete(repo, (patch,) + patches, keep=opts.get('keep')) + q.delete(repo, (patch,) + patches, opts) q.save_dirty() return 0 @@ -1651,13 +1669,6 @@ name = patch patch = None - if name in q.series: - raise util.Abort(_('A patch named %s already exists in the series file') % name) - - absdest = q.join(name) - if os.path.exists(absdest): - raise util.Abort(_('%s already exists') % absdest) - if patch: patch = q.lookup(patch) else: @@ -1665,6 +1676,15 @@ ui.write(_('No patches applied\n')) return patch = q.lookup('qtip') + absdest = q.join(name) + if os.path.isdir(absdest): + name = os.path.join(name, os.path.basename(patch)) + absdest = q.join(name) + if os.path.exists(absdest): + raise util.Abort(_('%s already exists') % absdest) + + if name in q.series: + raise util.Abort(_('A patch named %s already exists in the series file') % name) if ui.verbose: ui.write('Renaming %s to %s\n' % (patch, name)) @@ -1736,7 +1756,8 @@ backup = 'strip' elif opts['nobackup']: backup = 'none' - repo.mq.strip(repo, rev, backup=backup) + update = repo.dirstate.parents()[0] != revlog.nullid + repo.mq.strip(repo, rev, backup=backup, update=update) return 0 def select(ui, repo, *args, **opts): @@ -1912,8 +1933,9 @@ 'hg qdiff [-I] [-X] [FILE]...'), "qdelete|qremove|qrm": (delete, - [('k', 'keep', None, _('keep patch file'))], - 'hg qdelete [-k] PATCH'), + [('f', 'forget', None, _('stop managing an applied patch')), + ('k', 'keep', None, _('keep patch file'))], + 'hg qdelete [-f] [-k] PATCH'), 'qfold': (fold, [('e', 'edit', None, _('edit patch header')), @@ -1964,6 +1986,7 @@ [('e', 'edit', None, _('edit commit message')), ('m', 'message', '', _('change commit message with <text>')), ('l', 'logfile', '', _('change commit message with <file> content')), + ('g', 'git', None, _('use git extended diff format')), ('s', 'short', None, 'short refresh'), ('I', 'include', [], _('include names matching the given patterns')), ('X', 'exclude', [], _('exclude names matching the given patterns'))], @@ -1995,7 +2018,7 @@ (series, [('m', 'missing', None, 'print patches not in series'), ('s', 'summary', None, _('print first line of patch header'))], - 'hg qseries [-m]'), + 'hg qseries [-ms]'), "^strip": (strip, [('f', 'force', None, 'force multi-head removal'),
--- a/mercurial/cmdutil.py Wed Sep 13 18:24:58 2006 -0700 +++ b/mercurial/cmdutil.py Fri Sep 15 00:51:27 2006 +0200 @@ -11,6 +11,76 @@ demandload(globals(), 'mdiff util') demandload(globals(), 'os sys') +revrangesep = ':' + +def revfix(repo, val, defval): + '''turn user-level id of changeset into rev number. + user-level id can be tag, changeset, rev number, or negative rev + number relative to number of revs (-1 is tip, etc).''' + if not val: + return defval + try: + num = int(val) + if str(num) != val: + raise ValueError + if num < 0: + num += repo.changelog.count() + if num < 0: + num = 0 + elif num >= repo.changelog.count(): + raise ValueError + except ValueError: + try: + num = repo.changelog.rev(repo.lookup(val)) + except KeyError: + raise util.Abort(_('invalid revision identifier %s') % val) + return num + +def revpair(ui, repo, revs): + '''return pair of nodes, given list of revisions. second item can + be None, meaning use working dir.''' + if not revs: + return repo.dirstate.parents()[0], None + end = None + if len(revs) == 1: + start = revs[0] + if revrangesep in start: + start, end = start.split(revrangesep, 1) + start = revfix(repo, start, 0) + end = revfix(repo, end, repo.changelog.count() - 1) + else: + start = revfix(repo, start, None) + elif len(revs) == 2: + if revrangesep in revs[0] or revrangesep in revs[1]: + raise util.Abort(_('too many revisions specified')) + start = revfix(repo, revs[0], None) + end = revfix(repo, revs[1], None) + else: + raise util.Abort(_('too many revisions specified')) + if end is not None: end = repo.lookup(str(end)) + return repo.lookup(str(start)), end + +def revrange(ui, repo, revs): + """Yield revision as strings from a list of revision specifications.""" + seen = {} + for spec in revs: + if revrangesep in spec: + start, end = spec.split(revrangesep, 1) + start = revfix(repo, start, 0) + end = revfix(repo, end, repo.changelog.count() - 1) + step = start > end and -1 or 1 + for rev in xrange(start, end+step, step): + if rev in seen: + continue + seen[rev] = 1 + yield str(rev) + else: + rev = revfix(repo, spec, None) + if rev in seen: + continue + seen[rev] = 1 + yield str(rev) + def make_filename(repo, pat, node, total=None, seqno=None, revwidth=None, pathname=None): node_expander = {
--- a/mercurial/commands.py Wed Sep 13 18:24:58 2006 -0700 +++ b/mercurial/commands.py Fri Sep 15 00:51:27 2006 +0200 @@ -108,7 +108,7 @@ defrange = '%s:0' % start else: defrange = 'tip:0' - revs = map(int, revrange(ui, repo, opts['rev'] or [defrange])) + revs = map(int, cmdutil.revrange(ui, repo, opts['rev'] or [defrange])) wanted = {} slowpath = anypats fncache = {} @@ -252,76 +252,6 @@ yield 'iter', rev, None return iterate(), getchange, matchfn -revrangesep = ':' - -def revfix(repo, val, defval): - '''turn user-level id of changeset into rev number. - user-level id can be tag, changeset, rev number, or negative rev - number relative to number of revs (-1 is tip, etc).''' - if not val: - return defval - try: - num = int(val) - if str(num) != val: - raise ValueError - if num < 0: - num += repo.changelog.count() - if num < 0: - num = 0 - elif num >= repo.changelog.count(): - raise ValueError - except ValueError: - try: - num = repo.changelog.rev(repo.lookup(val)) - except KeyError: - raise util.Abort(_('invalid revision identifier %s') % val) - return num - -def revpair(ui, repo, revs): - '''return pair of nodes, given list of revisions. second item can - be None, meaning use working dir.''' - if not revs: - return repo.dirstate.parents()[0], None - end = None - if len(revs) == 1: - start = revs[0] - if revrangesep in start: - start, end = start.split(revrangesep, 1) - start = revfix(repo, start, 0) - end = revfix(repo, end, repo.changelog.count() - 1) - else: - start = revfix(repo, start, None) - elif len(revs) == 2: - if revrangesep in revs[0] or revrangesep in revs[1]: - raise util.Abort(_('too many revisions specified')) - start = revfix(repo, revs[0], None) - end = revfix(repo, revs[1], None) - else: - raise util.Abort(_('too many revisions specified')) - if end is not None: end = repo.lookup(str(end)) - return repo.lookup(str(start)), end - -def revrange(ui, repo, revs): - """Yield revision as strings from a list of revision specifications.""" - seen = {} - for spec in revs: - if revrangesep in spec: - start, end = spec.split(revrangesep, 1) - start = revfix(repo, start, 0) - end = revfix(repo, end, repo.changelog.count() - 1) - step = start > end and -1 or 1 - for rev in xrange(start, end+step, step): - if rev in seen: - continue - seen[rev] = 1 - yield str(rev) - else: - rev = revfix(repo, spec, None) - if rev in seen: - continue - seen[rev] = 1 - yield str(rev) - def write_bundle(cg, filename=None, compress=True): """Write a bundle file and return its filename. @@ -1344,7 +1274,7 @@ it detects as binary. With -a, diff will generate a diff anyway, probably with undesirable results. """ - node1, node2 = revpair(ui, repo, opts['rev']) + node1, node2 = cmdutil.revpair(ui, repo, opts['rev']) fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts) @@ -1380,7 +1310,7 @@ """ if not changesets: raise util.Abort(_("export requires at least one changeset")) - revs = list(revrange(ui, repo, changesets)) + revs = list(cmdutil.revrange(ui, repo, changesets)) if len(revs) > 1: ui.note(_('exporting patches:\n')) else:
--- a/mercurial/revlog.py Wed Sep 13 18:24:58 2006 -0700 +++ b/mercurial/revlog.py Fri Sep 15 00:51:27 2006 +0200 @@ -143,7 +143,7 @@ # the revlog may have grown since we've started running, # but we don't have space in self.index for more entries. # limit blocksize so that we don't get too much data. - blocksize = self.datasize - blockstart + blocksize = max(self.datasize - blockstart, 0) data = self.dataf.read(blocksize) lend = len(data) / self.s i = blockstart / self.s
--- a/mercurial/sshrepo.py Wed Sep 13 18:24:58 2006 -0700 +++ b/mercurial/sshrepo.py Fri Sep 15 00:51:27 2006 +0200 @@ -32,13 +32,6 @@ remotecmd = self.ui.config("ui", "remotecmd", "hg") if create: - try: - self.validate_repo(ui, sshcmd, args, remotecmd) - except hg.RepoError: - pass - else: - raise hg.RepoError(_("repository %s already exists") % path) - cmd = '%s %s "%s init %s"' cmd = cmd % (sshcmd, args, remotecmd, self.path)
--- a/tests/test-init.out Wed Sep 13 18:24:58 2006 -0700 +++ b/tests/test-init.out Fri Sep 15 00:51:27 2006 +0200 @@ -3,7 +3,6 @@ #test failure abort: repository local already exists! # init+push to remote2 -remote: abort: repository remote2 not found! changeset: 0:c4e059d443be tag: tip user: test @@ -17,26 +16,25 @@ remote: adding file changes remote: added 1 changesets with 1 changes to 1 files # clone to remote1 -remote: abort: repository remote1 not found! searching for changes remote: adding changesets remote: adding manifests remote: adding file changes remote: added 1 changesets with 1 changes to 1 files # init to existing repo -abort: repository ssh://user@dummy/remote1 already exists! +abort: repository remote1 already exists! +abort: could not create remote repo! # clone to existing repo -abort: repository ssh://user@dummy/remote1 already exists! +abort: repository remote1 already exists! +abort: could not create remote repo! # output of dummyssh -Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5: Got arguments 1:user@dummy 2:hg init remote2 3: 4: 5: Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5: Got arguments 1:user@dummy 2:hg -R remote2 serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5: Got arguments 1:user@dummy 2:hg init remote1 3: 4: 5: Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5: -Got arguments 1:user@dummy 2:hg -R remote1 serve --stdio 3: 4: 5: +Got arguments 1:user@dummy 2:hg init remote1 3: 4: 5: +Got arguments 1:user@dummy 2:hg init remote1 3: 4: 5: # comparing repositories 0:c4e059d443be 0:c4e059d443be
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-qdelete Fri Sep 15 00:51:27 2006 +0200 @@ -0,0 +1,35 @@ +#!/bin/sh + +echo "[extensions]" >> $HGRCPATH +echo "mq=" >> $HGRCPATH + +hg init a +cd a + +echo 'base' > base +hg ci -Ambase -d '1 0' + +hg qnew a +hg qnew b +hg qnew c + +hg qdel c +hg qpop +hg qdel c +hg qseries +ls .hg/patches +hg qpop +hg qdel -k b +ls .hg/patches +hg qdel -f a +hg qapplied +hg log --template '{rev} {desc}\n' + +hg qnew d +hg qnew e +hg qnew f + +hg qdel -f e +hg qdel -f d e +hg qapplied +hg log --template '{rev} {desc}\n'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-qdelete.out Fri Sep 15 00:51:27 2006 +0200 @@ -0,0 +1,23 @@ +adding base +abort: cannot delete applied patch c +Now at: b +a +b +a +b +series +status +Now at: a +a +b +series +status +1 New patch: a +0 base +abort: patch e not at base +f +4 New patch: f +3 New patch: e +2 New patch: d +1 New patch: a +0 base
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-mq-qrename Fri Sep 15 00:51:27 2006 +0200 @@ -0,0 +1,25 @@ +#!/bin/sh + +echo "[extensions]" >> $HGRCPATH +echo "mq=" >> $HGRCPATH + +hg init a +cd a + +echo 'base' > base +hg ci -Ambase -d '1 0' + +hg qnew -mmqbase mqbase +hg qrename mqbase renamed +mkdir .hg/patches/foo +hg qrename renamed foo +hg qseries +ls .hg/patches/foo +mkdir .hg/patches/bar +hg qrename foo/renamed bar +hg qseries +ls .hg/patches/bar +hg qrename bar/renamed baz +hg qseries +ls .hg/patches/baz +