##// END OF EJS Templates
Remove deprecated old-style branch support
Matt Mackall -
r3876:1e0b94cf default
parent child Browse files
Show More
@@ -268,7 +268,7 b' class bugzilla(object):'
268 mapfile = self.ui.config('bugzilla', 'style')
268 mapfile = self.ui.config('bugzilla', 'style')
269 tmpl = self.ui.config('bugzilla', 'template')
269 tmpl = self.ui.config('bugzilla', 'template')
270 t = cmdutil.changeset_templater(self.ui, self.repo,
270 t = cmdutil.changeset_templater(self.ui, self.repo,
271 False, None, mapfile, False)
271 False, mapfile, False)
272 if not mapfile and not tmpl:
272 if not mapfile and not tmpl:
273 tmpl = _('changeset {node|short} in repo {root} refers '
273 tmpl = _('changeset {node|short} in repo {root} refers '
274 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
274 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
@@ -113,7 +113,7 b' class notifier(object):'
113 template = (self.ui.config('notify', hooktype) or
113 template = (self.ui.config('notify', hooktype) or
114 self.ui.config('notify', 'template'))
114 self.ui.config('notify', 'template'))
115 self.t = cmdutil.changeset_templater(self.ui, self.repo,
115 self.t = cmdutil.changeset_templater(self.ui, self.repo,
116 False, None, mapfile, False)
116 False, mapfile, False)
117 if not mapfile and not template:
117 if not mapfile and not template:
118 template = deftemplates.get(hooktype) or single_template
118 template = deftemplates.get(hooktype) or single_template
119 if template:
119 if template:
@@ -199,12 +199,11 b' def addremove(repo, pats=[], opts={}, wl'
199 class changeset_printer(object):
199 class changeset_printer(object):
200 '''show changeset information when templating not requested.'''
200 '''show changeset information when templating not requested.'''
201
201
202 def __init__(self, ui, repo, patch, brinfo, buffered):
202 def __init__(self, ui, repo, patch, buffered):
203 self.ui = ui
203 self.ui = ui
204 self.repo = repo
204 self.repo = repo
205 self.buffered = buffered
205 self.buffered = buffered
206 self.patch = patch
206 self.patch = patch
207 self.brinfo = brinfo
208 self.header = {}
207 self.header = {}
209 self.hunk = {}
208 self.hunk = {}
210 self.lastheader = None
209 self.lastheader = None
@@ -268,11 +267,6 b' class changeset_printer(object):'
268 for parent in parents:
267 for parent in parents:
269 self.ui.write(_("parent: %d:%s\n") % parent)
268 self.ui.write(_("parent: %d:%s\n") % parent)
270
269
271 if self.brinfo:
272 br = self.repo.branchlookup([changenode])
273 if br:
274 self.ui.write(_("branch: %s\n") % " ".join(br[changenode]))
275
276 if self.ui.debugflag:
270 if self.ui.debugflag:
277 self.ui.write(_("manifest: %d:%s\n") %
271 self.ui.write(_("manifest: %d:%s\n") %
278 (self.repo.manifest.rev(changes[0]), hex(changes[0])))
272 (self.repo.manifest.rev(changes[0]), hex(changes[0])))
@@ -320,8 +314,8 b' class changeset_printer(object):'
320 class changeset_templater(changeset_printer):
314 class changeset_templater(changeset_printer):
321 '''format changeset information.'''
315 '''format changeset information.'''
322
316
323 def __init__(self, ui, repo, patch, brinfo, mapfile, buffered):
317 def __init__(self, ui, repo, patch, mapfile, buffered):
324 changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered)
318 changeset_printer.__init__(self, ui, repo, patch, buffered)
325 self.t = templater.templater(mapfile, templater.common_filters,
319 self.t = templater.templater(mapfile, templater.common_filters,
326 cache={'parent': '{rev}:{node|short} ',
320 cache={'parent': '{rev}:{node|short} ',
327 'manifest': '{rev}:{node|short}',
321 'manifest': '{rev}:{node|short}',
@@ -407,12 +401,6 b' class changeset_templater(changeset_prin'
407 if branch:
401 if branch:
408 branch = util.tolocal(branch)
402 branch = util.tolocal(branch)
409 return showlist('branch', [branch], plural='branches', **args)
403 return showlist('branch', [branch], plural='branches', **args)
410 # add old style branches if requested
411 if self.brinfo:
412 br = self.repo.branchlookup([changenode])
413 if changenode in br:
414 return showlist('branch', br[changenode],
415 plural='branches', **args)
416
404
417 def showparents(**args):
405 def showparents(**args):
418 parents = [[('rev', log.rev(p)), ('node', hex(p))]
406 parents = [[('rev', log.rev(p)), ('node', hex(p))]
@@ -526,11 +514,6 b' def show_changeset(ui, repo, opts, buffe'
526 if opts.get('patch'):
514 if opts.get('patch'):
527 patch = matchfn or util.always
515 patch = matchfn or util.always
528
516
529 br = None
530 if opts.get('branches'):
531 ui.warn(_("the --branches option is deprecated, "
532 "please use 'hg branches' instead\n"))
533 br = True
534 tmpl = opts.get('template')
517 tmpl = opts.get('template')
535 mapfile = None
518 mapfile = None
536 if tmpl:
519 if tmpl:
@@ -552,12 +535,12 b' def show_changeset(ui, repo, opts, buffe'
552 or templater.templatepath(mapfile))
535 or templater.templatepath(mapfile))
553 if mapname: mapfile = mapname
536 if mapname: mapfile = mapname
554 try:
537 try:
555 t = changeset_templater(ui, repo, patch, br, mapfile, buffered)
538 t = changeset_templater(ui, repo, patch, mapfile, buffered)
556 except SyntaxError, inst:
539 except SyntaxError, inst:
557 raise util.Abort(inst.args[0])
540 raise util.Abort(inst.args[0])
558 if tmpl: t.use_template(tmpl)
541 if tmpl: t.use_template(tmpl)
559 return t
542 return t
560 return changeset_printer(ui, repo, patch, br, buffered)
543 return changeset_printer(ui, repo, patch, buffered)
561
544
562 def finddate(ui, repo, date):
545 def finddate(ui, repo, date):
563 """Find the tipmost changeset that matches the given date spec"""
546 """Find the tipmost changeset that matches the given date spec"""
@@ -240,8 +240,7 b' def backout(ui, repo, rev, **opts):'
240 if op1 != node:
240 if op1 != node:
241 if opts['merge']:
241 if opts['merge']:
242 ui.status(_('merging with changeset %s\n') % nice(op1))
242 ui.status(_('merging with changeset %s\n') % nice(op1))
243 n = _lookup(repo, hex(op1))
243 hg.merge(repo, hex(op1))
244 hg.merge(repo, n)
245 else:
244 else:
246 ui.status(_('the backout changeset is a new head - '
245 ui.status(_('the backout changeset is a new head - '
247 'do not forget to merge\n'))
246 'do not forget to merge\n'))
@@ -1698,7 +1697,6 b' def log(ui, repo, *pats, **opts):'
1698 if opts["date"]:
1697 if opts["date"]:
1699 df = util.matchdate(opts["date"])
1698 df = util.matchdate(opts["date"])
1700
1699
1701
1702 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1700 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1703 for st, rev, fns in changeiter:
1701 for st, rev, fns in changeiter:
1704 if st == 'add':
1702 if st == 'add':
@@ -1763,7 +1761,7 b' def manifest(ui, repo, rev=None):'
1763 ui.write("%3s " % (m.execf(f) and "755" or "644"))
1761 ui.write("%3s " % (m.execf(f) and "755" or "644"))
1764 ui.write("%s\n" % f)
1762 ui.write("%s\n" % f)
1765
1763
1766 def merge(ui, repo, node=None, force=None, branch=None):
1764 def merge(ui, repo, node=None, force=None):
1767 """Merge working directory with another revision
1765 """Merge working directory with another revision
1768
1766
1769 Merge the contents of the current working directory and the
1767 Merge the contents of the current working directory and the
@@ -1777,9 +1775,7 b' def merge(ui, repo, node=None, force=Non'
1777 revision to merge with must be provided.
1775 revision to merge with must be provided.
1778 """
1776 """
1779
1777
1780 if node or branch:
1778 if not node:
1781 node = _lookup(repo, node, branch)
1782 else:
1783 heads = repo.heads()
1779 heads = repo.heads()
1784 if len(heads) > 2:
1780 if len(heads) > 2:
1785 raise util.Abort(_('repo has %d heads - '
1781 raise util.Abort(_('repo has %d heads - '
@@ -2478,7 +2474,7 b' def unbundle(ui, repo, fname, **opts):'
2478 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2474 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2479 return postincoming(ui, repo, modheads, opts['update'])
2475 return postincoming(ui, repo, modheads, opts['update'])
2480
2476
2481 def update(ui, repo, node=None, clean=False, branch=None, date=None):
2477 def update(ui, repo, node=None, clean=False, date=None):
2482 """update or merge working directory
2478 """update or merge working directory
2483
2479
2484 Update the working directory to the specified revision.
2480 Update the working directory to the specified revision.
@@ -2498,36 +2494,11 b' def update(ui, repo, node=None, clean=Fa'
2498 raise util.Abort(_("you can't specify a revision and a date"))
2494 raise util.Abort(_("you can't specify a revision and a date"))
2499 node = cmdutil.finddate(ui, repo, date)
2495 node = cmdutil.finddate(ui, repo, date)
2500
2496
2501 node = _lookup(repo, node, branch)
2502 if clean:
2497 if clean:
2503 return hg.clean(repo, node)
2498 return hg.clean(repo, node)
2504 else:
2499 else:
2505 return hg.update(repo, node)
2500 return hg.update(repo, node)
2506
2501
2507 def _lookup(repo, node, branch=None):
2508 if branch:
2509 repo.ui.warn(_("the --branch option is deprecated, "
2510 "please use 'hg branch' instead\n"))
2511 br = repo.branchlookup(branch=branch)
2512 found = []
2513 for x in br:
2514 if branch in br[x]:
2515 found.append(x)
2516 if len(found) > 1:
2517 repo.ui.warn(_("Found multiple heads for %s\n") % branch)
2518 for x in found:
2519 cmdutil.show_changeset(ui, repo, {}).show(changenode=x)
2520 raise util.Abort("")
2521 if len(found) == 1:
2522 node = found[0]
2523 repo.ui.warn(_("Using head %s for branch %s\n")
2524 % (short(node), branch))
2525 else:
2526 raise util.Abort(_("branch %s not found") % branch)
2527 else:
2528 node = node and repo.lookup(node) or repo.changelog.tip()
2529 return node
2530
2531 def verify(ui, repo):
2502 def verify(ui, repo):
2532 """verify the integrity of the repository
2503 """verify the integrity of the repository
2533
2504
@@ -2733,8 +2704,7 b' table = {'
2733 _('hg grep [OPTION]... PATTERN [FILE]...')),
2704 _('hg grep [OPTION]... PATTERN [FILE]...')),
2734 "heads":
2705 "heads":
2735 (heads,
2706 (heads,
2736 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2707 [('', 'style', '', _('display using template map file')),
2737 ('', 'style', '', _('display using template map file')),
2738 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2708 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2739 ('', 'template', '', _('display with template'))],
2709 ('', 'template', '', _('display with template'))],
2740 _('hg heads [-r REV]')),
2710 _('hg heads [-r REV]')),
@@ -2745,7 +2715,7 b' table = {'
2745 [('p', 'strip', 1,
2715 [('p', 'strip', 1,
2746 _('directory strip option for patch. This has the same\n'
2716 _('directory strip option for patch. This has the same\n'
2747 'meaning as the corresponding patch option')),
2717 'meaning as the corresponding patch option')),
2748 ('b', 'base', '', _('base path (DEPRECATED)')),
2718 ('b', 'base', '', _('base path')),
2749 ('f', 'force', None,
2719 ('f', 'force', None,
2750 _('skip check for outstanding uncommitted changes'))] + commitopts,
2720 _('skip check for outstanding uncommitted changes'))] + commitopts,
2751 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
2721 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
@@ -2775,8 +2745,7 b' table = {'
2775 _('hg locate [OPTION]... [PATTERN]...')),
2745 _('hg locate [OPTION]... [PATTERN]...')),
2776 "^log|history":
2746 "^log|history":
2777 (log,
2747 (log,
2778 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2748 [('f', 'follow', None,
2779 ('f', 'follow', None,
2780 _('follow changeset history, or file history across copies and renames')),
2749 _('follow changeset history, or file history across copies and renames')),
2781 ('', 'follow-first', None,
2750 ('', 'follow-first', None,
2782 _('only follow the first parent of merge changesets')),
2751 _('only follow the first parent of merge changesets')),
@@ -2797,8 +2766,7 b' table = {'
2797 "manifest": (manifest, [], _('hg manifest [REV]')),
2766 "manifest": (manifest, [], _('hg manifest [REV]')),
2798 "merge":
2767 "merge":
2799 (merge,
2768 (merge,
2800 [('b', 'branch', '', _('merge with head of a specific branch (DEPRECATED)')),
2769 [('f', 'force', None, _('force a merge with outstanding changes'))],
2801 ('f', 'force', None, _('force a merge with outstanding changes'))],
2802 _('hg merge [-f] [REV]')),
2770 _('hg merge [-f] [REV]')),
2803 "outgoing|out": (outgoing,
2771 "outgoing|out": (outgoing,
2804 [('M', 'no-merges', None, _('do not show merges')),
2772 [('M', 'no-merges', None, _('do not show merges')),
@@ -2813,8 +2781,7 b' table = {'
2813 _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')),
2781 _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')),
2814 "^parents":
2782 "^parents":
2815 (parents,
2783 (parents,
2816 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2784 [('r', 'rev', '', _('show parents from the specified rev')),
2817 ('r', 'rev', '', _('show parents from the specified rev')),
2818 ('', 'style', '', _('display using template map file')),
2785 ('', 'style', '', _('display using template map file')),
2819 ('', 'template', '', _('display with template'))],
2786 ('', 'template', '', _('display with template'))],
2820 _('hg parents [-r REV] [FILE]')),
2787 _('hg parents [-r REV] [FILE]')),
@@ -2916,8 +2883,7 b' table = {'
2916 "tags": (tags, [], _('hg tags')),
2883 "tags": (tags, [], _('hg tags')),
2917 "tip":
2884 "tip":
2918 (tip,
2885 (tip,
2919 [('b', 'branches', None, _('show branches (DEPRECATED)')),
2886 [('', 'style', '', _('display using template map file')),
2920 ('', 'style', '', _('display using template map file')),
2921 ('p', 'patch', None, _('show patch')),
2887 ('p', 'patch', None, _('show patch')),
2922 ('', 'template', '', _('display with template'))],
2888 ('', 'template', '', _('display with template'))],
2923 _('hg tip [-p]')),
2889 _('hg tip [-p]')),
@@ -2928,9 +2894,7 b' table = {'
2928 _('hg unbundle [-u] FILE')),
2894 _('hg unbundle [-u] FILE')),
2929 "^update|up|checkout|co":
2895 "^update|up|checkout|co":
2930 (update,
2896 (update,
2931 [('b', 'branch', '',
2897 [('C', 'clean', None, _('overwrite locally modified files')),
2932 _('checkout the head of a specific branch (DEPRECATED)')),
2933 ('C', 'clean', None, _('overwrite locally modified files')),
2934 ('d', 'date', '', _('tipmost revision matching date'))],
2898 ('d', 'date', '', _('tipmost revision matching date'))],
2935 _('hg update [-C] [REV]')),
2899 _('hg update [-C] [REV]')),
2936 "verify": (verify, [], _('hg verify')),
2900 "verify": (verify, [], _('hg verify')),
@@ -993,112 +993,6 b' class localrepository(repo.repository):'
993 heads.sort()
993 heads.sort()
994 return [n for (r, n) in heads]
994 return [n for (r, n) in heads]
995
995
996 # branchlookup returns a dict giving a list of branches for
997 # each head. A branch is defined as the tag of a node or
998 # the branch of the node's parents. If a node has multiple
999 # branch tags, tags are eliminated if they are visible from other
1000 # branch tags.
1001 #
1002 # So, for this graph: a->b->c->d->e
1003 # \ /
1004 # aa -----/
1005 # a has tag 2.6.12
1006 # d has tag 2.6.13
1007 # e would have branch tags for 2.6.12 and 2.6.13. Because the node
1008 # for 2.6.12 can be reached from the node 2.6.13, that is eliminated
1009 # from the list.
1010 #
1011 # It is possible that more than one head will have the same branch tag.
1012 # callers need to check the result for multiple heads under the same
1013 # branch tag if that is a problem for them (ie checkout of a specific
1014 # branch).
1015 #
1016 # passing in a specific branch will limit the depth of the search
1017 # through the parents. It won't limit the branches returned in the
1018 # result though.
1019 def branchlookup(self, heads=None, branch=None):
1020 if not heads:
1021 heads = self.heads()
1022 headt = [ h for h in heads ]
1023 chlog = self.changelog
1024 branches = {}
1025 merges = []
1026 seenmerge = {}
1027
1028 # traverse the tree once for each head, recording in the branches
1029 # dict which tags are visible from this head. The branches
1030 # dict also records which tags are visible from each tag
1031 # while we traverse.
1032 while headt or merges:
1033 if merges:
1034 n, found = merges.pop()
1035 visit = [n]
1036 else:
1037 h = headt.pop()
1038 visit = [h]
1039 found = [h]
1040 seen = {}
1041 while visit:
1042 n = visit.pop()
1043 if n in seen:
1044 continue
1045 pp = chlog.parents(n)
1046 tags = self.nodetags(n)
1047 if tags:
1048 for x in tags:
1049 if x == 'tip':
1050 continue
1051 for f in found:
1052 branches.setdefault(f, {})[n] = 1
1053 branches.setdefault(n, {})[n] = 1
1054 break
1055 if n not in found:
1056 found.append(n)
1057 if branch in tags:
1058 continue
1059 seen[n] = 1
1060 if pp[1] != nullid and n not in seenmerge:
1061 merges.append((pp[1], [x for x in found]))
1062 seenmerge[n] = 1
1063 if pp[0] != nullid:
1064 visit.append(pp[0])
1065 # traverse the branches dict, eliminating branch tags from each
1066 # head that are visible from another branch tag for that head.
1067 out = {}
1068 viscache = {}
1069 for h in heads:
1070 def visible(node):
1071 if node in viscache:
1072 return viscache[node]
1073 ret = {}
1074 visit = [node]
1075 while visit:
1076 x = visit.pop()
1077 if x in viscache:
1078 ret.update(viscache[x])
1079 elif x not in ret:
1080 ret[x] = 1
1081 if x in branches:
1082 visit[len(visit):] = branches[x].keys()
1083 viscache[node] = ret
1084 return ret
1085 if h not in branches:
1086 continue
1087 # O(n^2), but somewhat limited. This only searches the
1088 # tags visible from a specific head, not all the tags in the
1089 # whole repo.
1090 for b in branches[h]:
1091 vis = False
1092 for bb in branches[h].keys():
1093 if b != bb:
1094 if b in visible(bb):
1095 vis = True
1096 break
1097 if not vis:
1098 l = out.setdefault(h, [])
1099 l[len(l):] = self.nodetags(b)
1100 return out
1101
1102 def branches(self, nodes):
996 def branches(self, nodes):
1103 if not nodes:
997 if not nodes:
1104 nodes = [self.changelog.tip()]
998 nodes = [self.changelog.tip()]
@@ -441,6 +441,9 b' def update(repo, node, branchmerge, forc'
441 wlock = working dir lock, if already held
441 wlock = working dir lock, if already held
442 """
442 """
443
443
444 if node is None:
445 node = "tip"
446
444 if not wlock:
447 if not wlock:
445 wlock = repo.wlock()
448 wlock = repo.wlock()
446
449
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now