atom feed5 messages in com.selenic.mercurial[PATCH] mq: add --branch option to strip
FromSent OnAttachments
Brendan CullySep 22, 2006 8:30 pm 
Benoit BoissinotSep 29, 2006 3:53 am 
Brendan CullySep 29, 2006 11:12 am 
Benoit BoissinotSep 29, 2006 11:35 am 
Brendan CullySep 29, 2006 12:00 pm 
Subject:[PATCH] mq: add --branch option to strip
From:Brendan Cully (bren@kublai.com)
Date:Sep 22, 2006 8:30:40 pm
List:com.selenic.mercurial

# HG changeset patch # User Brendan Cully <bren@kublai.com> # Date 1158975113 25200 # Node ID 712e33efdbfe4fc0dae669200aa4966549d81626 # Parent f573c0e427f0b2f0435732cdcd6a6430ce60c24a mq: add --branch option to strip

This takes a sledgehammer to the problem of finding the branch root. There's probably a faster way.

diff -r f573c0e427f0 -r 712e33efdbfe hgext/mq.py --- a/hgext/mq.py Fri Sep 22 17:18:04 2006 -0700 +++ b/hgext/mq.py Fri Sep 22 18:31:53 2006 -0700 @@ -568,7 +568,8 @@ class queue: if commitfiles: self.refresh(repo, short=True)

- def strip(self, repo, rev, update=True, backup="all", wlock=None): + def strip(self, repo, rev, update=True, backup="all", branch=False, + wlock=None): def limitheads(chlog, stop): """return the list of all nodes that have no children""" p = {} @@ -645,10 +646,22 @@ class queue: filerev = 0 ff.strip(filerev, revnum)

+ chlog = repo.changelog + + if branch: + heads = repo.heads() + otherheads = [h for h in heads if h not in repo.heads(rev)] + arevs = [chlog.ancestor(head, rev) for head in otherheads] + arev = chlog.node(max([chlog.rev(n) for n in arevs])) + nb = chlog.nodesbetween([arev], [rev])[0] + if arev != revlog.nullid: + del nb[0] + if nb: + rev = nb[0] + if not wlock: wlock = repo.wlock() lock = repo.lock() - chlog = repo.changelog # TODO delete the undo files, and handle undo of merge sets pp = chlog.parents(rev) revnum = chlog.rev(rev) @@ -1834,7 +1847,8 @@ def strip(ui, repo, rev, **opts): elif opts['nobackup']: backup = 'none' update = repo.dirstate.parents()[0] != revlog.nullid - repo.mq.strip(repo, rev, backup=backup, update=update) + repo.mq.strip(repo, rev, backup=backup, update=update, + branch=opts.get('branch')) return 0

def select(ui, repo, *args, **opts): @@ -2101,7 +2115,8 @@ cmdtable = { (strip, [('f', 'force', None, 'force multi-head removal'), ('b', 'backup', None, 'bundle unrelated changesets'), - ('n', 'nobackup', None, 'no backups')], + ('n', 'nobackup', None, 'no backups'), + ('', 'branch', None, _('remove branch under REV'))], 'hg strip [-f] [-b] [-n] REV'), "qtop": (top, [], 'hg qtop'), "qunapplied": (unapplied, [], 'hg qunapplied [PATCH]'),