# HG changeset patch # User Matt Mackall # Date 1165968983 21600 # Node ID 1e0b94cfba0e84a62753efd647966c0c1af68450 # Parent c0a12e6441a5abb669fcd62cc9719220c255fcd5 Remove deprecated old-style branch support diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -268,7 +268,7 @@ class bugzilla(object): mapfile = self.ui.config('bugzilla', 'style') tmpl = self.ui.config('bugzilla', 'template') t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) + False, mapfile, False) if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') diff --git a/hgext/notify.py b/hgext/notify.py --- a/hgext/notify.py +++ b/hgext/notify.py @@ -113,7 +113,7 @@ class notifier(object): template = (self.ui.config('notify', hooktype) or self.ui.config('notify', 'template')) self.t = cmdutil.changeset_templater(self.ui, self.repo, - False, None, mapfile, False) + False, mapfile, False) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template if template: diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -199,12 +199,11 @@ def addremove(repo, pats=[], opts={}, wl class changeset_printer(object): '''show changeset information when templating not requested.''' - def __init__(self, ui, repo, patch, brinfo, buffered): + def __init__(self, ui, repo, patch, buffered): self.ui = ui self.repo = repo self.buffered = buffered self.patch = patch - self.brinfo = brinfo self.header = {} self.hunk = {} self.lastheader = None @@ -268,11 +267,6 @@ class changeset_printer(object): for parent in parents: self.ui.write(_("parent: %d:%s\n") % parent) - if self.brinfo: - br = self.repo.branchlookup([changenode]) - if br: - self.ui.write(_("branch: %s\n") % " ".join(br[changenode])) - if self.ui.debugflag: self.ui.write(_("manifest: %d:%s\n") % (self.repo.manifest.rev(changes[0]), hex(changes[0]))) @@ -320,8 +314,8 @@ class changeset_printer(object): class changeset_templater(changeset_printer): '''format changeset information.''' - def __init__(self, ui, repo, patch, brinfo, mapfile, buffered): - changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered) + def __init__(self, ui, repo, patch, mapfile, buffered): + changeset_printer.__init__(self, ui, repo, patch, buffered) self.t = templater.templater(mapfile, templater.common_filters, cache={'parent': '{rev}:{node|short} ', 'manifest': '{rev}:{node|short}', @@ -407,12 +401,6 @@ class changeset_templater(changeset_prin if branch: branch = util.tolocal(branch) return showlist('branch', [branch], plural='branches', **args) - # add old style branches if requested - if self.brinfo: - br = self.repo.branchlookup([changenode]) - if changenode in br: - return showlist('branch', br[changenode], - plural='branches', **args) def showparents(**args): parents = [[('rev', log.rev(p)), ('node', hex(p))] @@ -526,11 +514,6 @@ def show_changeset(ui, repo, opts, buffe if opts.get('patch'): patch = matchfn or util.always - br = None - if opts.get('branches'): - ui.warn(_("the --branches option is deprecated, " - "please use 'hg branches' instead\n")) - br = True tmpl = opts.get('template') mapfile = None if tmpl: @@ -552,12 +535,12 @@ def show_changeset(ui, repo, opts, buffe or templater.templatepath(mapfile)) if mapname: mapfile = mapname try: - t = changeset_templater(ui, repo, patch, br, mapfile, buffered) + t = changeset_templater(ui, repo, patch, mapfile, buffered) except SyntaxError, inst: raise util.Abort(inst.args[0]) if tmpl: t.use_template(tmpl) return t - return changeset_printer(ui, repo, patch, br, buffered) + return changeset_printer(ui, repo, patch, buffered) def finddate(ui, repo, date): """Find the tipmost changeset that matches the given date spec""" diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -240,8 +240,7 @@ def backout(ui, repo, rev, **opts): if op1 != node: if opts['merge']: ui.status(_('merging with changeset %s\n') % nice(op1)) - n = _lookup(repo, hex(op1)) - hg.merge(repo, n) + hg.merge(repo, hex(op1)) else: ui.status(_('the backout changeset is a new head - ' 'do not forget to merge\n')) @@ -1698,7 +1697,6 @@ def log(ui, repo, *pats, **opts): if opts["date"]: df = util.matchdate(opts["date"]) - displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) for st, rev, fns in changeiter: if st == 'add': @@ -1763,7 +1761,7 @@ def manifest(ui, repo, rev=None): ui.write("%3s " % (m.execf(f) and "755" or "644")) ui.write("%s\n" % f) -def merge(ui, repo, node=None, force=None, branch=None): +def merge(ui, repo, node=None, force=None): """Merge working directory with another revision Merge the contents of the current working directory and the @@ -1777,9 +1775,7 @@ def merge(ui, repo, node=None, force=Non revision to merge with must be provided. """ - if node or branch: - node = _lookup(repo, node, branch) - else: + if not node: heads = repo.heads() if len(heads) > 2: raise util.Abort(_('repo has %d heads - ' @@ -2478,7 +2474,7 @@ def unbundle(ui, repo, fname, **opts): modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) return postincoming(ui, repo, modheads, opts['update']) -def update(ui, repo, node=None, clean=False, branch=None, date=None): +def update(ui, repo, node=None, clean=False, date=None): """update or merge working directory Update the working directory to the specified revision. @@ -2498,36 +2494,11 @@ def update(ui, repo, node=None, clean=Fa raise util.Abort(_("you can't specify a revision and a date")) node = cmdutil.finddate(ui, repo, date) - node = _lookup(repo, node, branch) if clean: return hg.clean(repo, node) else: return hg.update(repo, node) -def _lookup(repo, node, branch=None): - if branch: - repo.ui.warn(_("the --branch option is deprecated, " - "please use 'hg branch' instead\n")) - br = repo.branchlookup(branch=branch) - found = [] - for x in br: - if branch in br[x]: - found.append(x) - if len(found) > 1: - repo.ui.warn(_("Found multiple heads for %s\n") % branch) - for x in found: - cmdutil.show_changeset(ui, repo, {}).show(changenode=x) - raise util.Abort("") - if len(found) == 1: - node = found[0] - repo.ui.warn(_("Using head %s for branch %s\n") - % (short(node), branch)) - else: - raise util.Abort(_("branch %s not found") % branch) - else: - node = node and repo.lookup(node) or repo.changelog.tip() - return node - def verify(ui, repo): """verify the integrity of the repository @@ -2733,8 +2704,7 @@ table = { _('hg grep [OPTION]... PATTERN [FILE]...')), "heads": (heads, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('', 'style', '', _('display using template map file')), + [('', 'style', '', _('display using template map file')), ('r', 'rev', '', _('show only heads which are descendants of rev')), ('', 'template', '', _('display with template'))], _('hg heads [-r REV]')), @@ -2745,7 +2715,7 @@ table = { [('p', 'strip', 1, _('directory strip option for patch. This has the same\n' 'meaning as the corresponding patch option')), - ('b', 'base', '', _('base path (DEPRECATED)')), + ('b', 'base', '', _('base path')), ('f', 'force', None, _('skip check for outstanding uncommitted changes'))] + commitopts, _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')), @@ -2775,8 +2745,7 @@ table = { _('hg locate [OPTION]... [PATTERN]...')), "^log|history": (log, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('f', 'follow', None, + [('f', 'follow', None, _('follow changeset history, or file history across copies and renames')), ('', 'follow-first', None, _('only follow the first parent of merge changesets')), @@ -2797,8 +2766,7 @@ table = { "manifest": (manifest, [], _('hg manifest [REV]')), "merge": (merge, - [('b', 'branch', '', _('merge with head of a specific branch (DEPRECATED)')), - ('f', 'force', None, _('force a merge with outstanding changes'))], + [('f', 'force', None, _('force a merge with outstanding changes'))], _('hg merge [-f] [REV]')), "outgoing|out": (outgoing, [('M', 'no-merges', None, _('do not show merges')), @@ -2813,8 +2781,7 @@ table = { _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')), "^parents": (parents, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('r', 'rev', '', _('show parents from the specified rev')), + [('r', 'rev', '', _('show parents from the specified rev')), ('', 'style', '', _('display using template map file')), ('', 'template', '', _('display with template'))], _('hg parents [-r REV] [FILE]')), @@ -2916,8 +2883,7 @@ table = { "tags": (tags, [], _('hg tags')), "tip": (tip, - [('b', 'branches', None, _('show branches (DEPRECATED)')), - ('', 'style', '', _('display using template map file')), + [('', 'style', '', _('display using template map file')), ('p', 'patch', None, _('show patch')), ('', 'template', '', _('display with template'))], _('hg tip [-p]')), @@ -2928,9 +2894,7 @@ table = { _('hg unbundle [-u] FILE')), "^update|up|checkout|co": (update, - [('b', 'branch', '', - _('checkout the head of a specific branch (DEPRECATED)')), - ('C', 'clean', None, _('overwrite locally modified files')), + [('C', 'clean', None, _('overwrite locally modified files')), ('d', 'date', '', _('tipmost revision matching date'))], _('hg update [-C] [REV]')), "verify": (verify, [], _('hg verify')), diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -993,112 +993,6 @@ class localrepository(repo.repository): heads.sort() return [n for (r, n) in heads] - # branchlookup returns a dict giving a list of branches for - # each head. A branch is defined as the tag of a node or - # the branch of the node's parents. If a node has multiple - # branch tags, tags are eliminated if they are visible from other - # branch tags. - # - # So, for this graph: a->b->c->d->e - # \ / - # aa -----/ - # a has tag 2.6.12 - # d has tag 2.6.13 - # e would have branch tags for 2.6.12 and 2.6.13. Because the node - # for 2.6.12 can be reached from the node 2.6.13, that is eliminated - # from the list. - # - # It is possible that more than one head will have the same branch tag. - # callers need to check the result for multiple heads under the same - # branch tag if that is a problem for them (ie checkout of a specific - # branch). - # - # passing in a specific branch will limit the depth of the search - # through the parents. It won't limit the branches returned in the - # result though. - def branchlookup(self, heads=None, branch=None): - if not heads: - heads = self.heads() - headt = [ h for h in heads ] - chlog = self.changelog - branches = {} - merges = [] - seenmerge = {} - - # traverse the tree once for each head, recording in the branches - # dict which tags are visible from this head. The branches - # dict also records which tags are visible from each tag - # while we traverse. - while headt or merges: - if merges: - n, found = merges.pop() - visit = [n] - else: - h = headt.pop() - visit = [h] - found = [h] - seen = {} - while visit: - n = visit.pop() - if n in seen: - continue - pp = chlog.parents(n) - tags = self.nodetags(n) - if tags: - for x in tags: - if x == 'tip': - continue - for f in found: - branches.setdefault(f, {})[n] = 1 - branches.setdefault(n, {})[n] = 1 - break - if n not in found: - found.append(n) - if branch in tags: - continue - seen[n] = 1 - if pp[1] != nullid and n not in seenmerge: - merges.append((pp[1], [x for x in found])) - seenmerge[n] = 1 - if pp[0] != nullid: - visit.append(pp[0]) - # traverse the branches dict, eliminating branch tags from each - # head that are visible from another branch tag for that head. - out = {} - viscache = {} - for h in heads: - def visible(node): - if node in viscache: - return viscache[node] - ret = {} - visit = [node] - while visit: - x = visit.pop() - if x in viscache: - ret.update(viscache[x]) - elif x not in ret: - ret[x] = 1 - if x in branches: - visit[len(visit):] = branches[x].keys() - viscache[node] = ret - return ret - if h not in branches: - continue - # O(n^2), but somewhat limited. This only searches the - # tags visible from a specific head, not all the tags in the - # whole repo. - for b in branches[h]: - vis = False - for bb in branches[h].keys(): - if b != bb: - if b in visible(bb): - vis = True - break - if not vis: - l = out.setdefault(h, []) - l[len(l):] = self.nodetags(b) - return out - def branches(self, nodes): if not nodes: nodes = [self.changelog.tip()] diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -441,6 +441,9 @@ def update(repo, node, branchmerge, forc wlock = working dir lock, if already held """ + if node is None: + node = "tip" + if not wlock: wlock = repo.wlock() diff --git a/tests/test-branch b/tests/test-branch deleted file mode 100755 --- a/tests/test-branch +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# test for branch handling -# -# XXX: need more tests - -hg init -echo a > a -echo b > b -hg ci -A -m 0 -d "1000000 0" -echo aa > a -echo bb > b -hg ci -m 1 -d "1000000 0" -hg tag -l foo -hg update 0 -hg parents -b - -# test update -hg update -b foo -hg parents - -# test merge -hg update 0 -echo c > c -hg ci -A -m 0.0 -d "1000000 0" -hg merge -b foo -hg parents -b - -# re-test with more branches -hg update -C 0 -echo d > d -hg ci -A -m 0.0 -d "1000000 0" -hg merge -b foo -hg parents -b diff --git a/tests/test-branch.out b/tests/test-branch.out deleted file mode 100644 --- a/tests/test-branch.out +++ /dev/null @@ -1,61 +0,0 @@ -adding a -adding b -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -the --branches option is deprecated, please use 'hg branches' instead -changeset: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0 - -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -changeset: 1:f4ac749470f2 -tag: foo -tag: tip -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 - -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -adding c -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -(branch merge, don't forget to commit) -the --branches option is deprecated, please use 'hg branches' instead -changeset: 2:1505d56ee00e -tag: tip -parent: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0.0 - -changeset: 1:f4ac749470f2 -tag: foo -branch: foo -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 - -2 files updated, 0 files merged, 1 files removed, 0 files unresolved -adding d -the --branch option is deprecated, please use 'hg branch' instead -Using head f4ac749470f2 for branch foo -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -(branch merge, don't forget to commit) -the --branches option is deprecated, please use 'hg branches' instead -changeset: 3:53b72df12ae5 -tag: tip -parent: 0:b544c4ac4389 -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 0.0 - -changeset: 1:f4ac749470f2 -tag: foo -branch: foo -user: test -date: Mon Jan 12 13:46:40 1970 +0000 -summary: 1 -