Show More
@@ -38,7 +38,10 b" def fetch(ui, repo, source='default', **" | |||
|
38 | 38 | |
|
39 | 39 | parent, p2 = repo.dirstate.parents() |
|
40 | 40 | branch = repo.dirstate.branch() |
|
41 | branchnode = repo.branchtags().get(branch) | |
|
41 | try: | |
|
42 | branchnode = repo.branchtip(branch) | |
|
43 | except error.RepoLookupError: | |
|
44 | branchnode = None | |
|
42 | 45 | if parent != branchnode: |
|
43 | 46 | raise util.Abort(_('working dir not at branch tip ' |
|
44 | 47 | '(use "hg update" to check out branch tip)')) |
@@ -7,7 +7,7 b'' | |||
|
7 | 7 | |
|
8 | 8 | from mercurial.i18n import _ |
|
9 | 9 | from mercurial.node import hex |
|
10 | from mercurial import encoding, util | |
|
10 | from mercurial import encoding, error, util | |
|
11 | 11 | import errno, os |
|
12 | 12 | |
|
13 | 13 | def valid(mark): |
@@ -140,8 +140,8 b' def unsetcurrent(repo):' | |||
|
140 | 140 | |
|
141 | 141 | def updatecurrentbookmark(repo, oldnode, curbranch): |
|
142 | 142 | try: |
|
143 |
return update(repo, oldnode, repo.brancht |
|
|
144 |
except |
|
|
143 | return update(repo, oldnode, repo.branchtip(curbranch)) | |
|
144 | except error.RepoLookupError: | |
|
145 | 145 | if curbranch == "default": # no default branch! |
|
146 | 146 | return update(repo, oldnode, repo.lookup("tip")) |
|
147 | 147 | else: |
@@ -827,7 +827,7 b' def bookmark(ui, repo, mark=None, rev=No' | |||
|
827 | 827 | if mark in marks and not force: |
|
828 | 828 | raise util.Abort(_("bookmark '%s' already exists " |
|
829 | 829 | "(use -f to force)") % mark) |
|
830 |
if ((mark in repo.branch |
|
|
830 | if ((mark in repo.branchmap() or mark == repo.dirstate.branch()) | |
|
831 | 831 | and not force): |
|
832 | 832 | raise util.Abort( |
|
833 | 833 | _("a bookmark cannot have the name of an existing branch")) |
@@ -903,7 +903,7 b' def branch(ui, repo, label=None, **opts)' | |||
|
903 | 903 | repo.dirstate.setbranch(label) |
|
904 | 904 | ui.status(_('reset working directory to branch %s\n') % label) |
|
905 | 905 | elif label: |
|
906 |
if not opts.get('force') and label in repo.branch |
|
|
906 | if not opts.get('force') and label in repo.branchmap(): | |
|
907 | 907 | if label not in [p.branch() for p in repo.parents()]: |
|
908 | 908 | raise util.Abort(_('a branch of the same name already' |
|
909 | 909 | ' exists'), |
@@ -78,10 +78,12 b' class changectx(object):' | |||
|
78 | 78 | self._node = repo._tagscache.tags[changeid] |
|
79 | 79 | self._rev = repo.changelog.rev(self._node) |
|
80 | 80 | return |
|
81 | if changeid in repo.branchtags(): | |
|
82 |
self._node = repo.brancht |
|
|
81 | try: | |
|
82 | self._node = repo.branchtip(changeid) | |
|
83 | 83 | self._rev = repo.changelog.rev(self._node) |
|
84 | 84 | return |
|
85 | except error.RepoLookupError: | |
|
86 | pass | |
|
85 | 87 | |
|
86 | 88 | self._node = repo.changelog._partialmatch(changeid) |
|
87 | 89 | if self._node is not None: |
@@ -794,7 +794,11 b' def graph(web, req, tmpl):' | |||
|
794 | 794 | desc = cgi.escape(templatefilters.nonempty(desc)) |
|
795 | 795 | user = cgi.escape(templatefilters.person(ctx.user())) |
|
796 | 796 | branch = ctx.branch() |
|
797 | branch = branch, web.repo.branchtags().get(branch) == ctx.node() | |
|
797 | try: | |
|
798 | branchnode = web.repo.branchtip(branch) | |
|
799 | except error.RepoLookupError: | |
|
800 | branchnode = None | |
|
801 | branch = branch, branchnode == ctx.node() | |
|
798 | 802 | data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), |
|
799 | 803 | ctx.bookmarks())) |
|
800 | 804 |
@@ -98,16 +98,23 b' def nodebranchdict(repo, ctx):' | |||
|
98 | 98 | branches = [] |
|
99 | 99 | branch = ctx.branch() |
|
100 | 100 | # If this is an empty repo, ctx.node() == nullid, |
|
101 |
# ctx.branch() == 'default' |
|
|
102 | # an empty dict. Using dict.get avoids a traceback. | |
|
103 | if repo.branchtags().get(branch) == ctx.node(): | |
|
101 | # ctx.branch() == 'default'. | |
|
102 | try: | |
|
103 | branchnode = repo.branchtip(branch) | |
|
104 | except error.RepoLookupError: | |
|
105 | branchnode = None | |
|
106 | if branchnode == ctx.node(): | |
|
104 | 107 | branches.append({"name": branch}) |
|
105 | 108 | return branches |
|
106 | 109 | |
|
107 | 110 | def nodeinbranch(repo, ctx): |
|
108 | 111 | branches = [] |
|
109 | 112 | branch = ctx.branch() |
|
110 | if branch != 'default' and repo.branchtags().get(branch) != ctx.node(): | |
|
113 | try: | |
|
114 | branchnode = repo.branchtip(branch) | |
|
115 | except error.RepoLookupError: | |
|
116 | branchnode = None | |
|
117 | if branch != 'default' and branchnode != ctx.node(): | |
|
111 | 118 | branches.append({"name": branch}) |
|
112 | 119 | return branches |
|
113 | 120 |
@@ -507,17 +507,27 b' class localrepository(repo.repository):' | |||
|
507 | 507 | self.updatebranchcache() |
|
508 | 508 | return self._branchcache |
|
509 | 509 | |
|
510 | def _branchtip(self, heads): | |
|
511 | '''return the tipmost branch head in heads''' | |
|
512 | tip = heads[-1] | |
|
513 | for h in reversed(heads): | |
|
514 | if 'close' not in self.changelog.read(h)[5]: | |
|
515 | tip = h | |
|
516 | break | |
|
517 | return tip | |
|
518 | ||
|
519 | def branchtip(self, branch): | |
|
520 | '''return the tip node for a given branch''' | |
|
521 | if branch not in self.branchmap(): | |
|
522 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) | |
|
523 | return self._branchtip(self.branchmap()[branch]) | |
|
524 | ||
|
510 | 525 | def branchtags(self): |
|
511 | 526 | '''return a dict where branch names map to the tipmost head of |
|
512 | 527 | the branch, open heads come before closed''' |
|
513 | 528 | bt = {} |
|
514 | 529 | for bn, heads in self.branchmap().iteritems(): |
|
515 | tip = heads[-1] | |
|
516 | for h in reversed(heads): | |
|
517 | if 'close' not in self.changelog.read(h)[5]: | |
|
518 | tip = h | |
|
519 | break | |
|
520 | bt[bn] = tip | |
|
530 | bt[bn] = self._branchtip(heads) | |
|
521 | 531 | return bt |
|
522 | 532 | |
|
523 | 533 | def _readbranchcache(self): |
@@ -7,7 +7,7 b'' | |||
|
7 | 7 | |
|
8 | 8 | from node import nullid, nullrev, hex, bin |
|
9 | 9 | from i18n import _ |
|
10 | import scmutil, util, filemerge, copies, subrepo | |
|
10 | import error, scmutil, util, filemerge, copies, subrepo | |
|
11 | 11 | import errno, os, shutil |
|
12 | 12 | |
|
13 | 13 | class mergestate(object): |
@@ -529,8 +529,8 b' def update(repo, node, branchmerge, forc' | |||
|
529 | 529 | if node is None: |
|
530 | 530 | # tip of current branch |
|
531 | 531 | try: |
|
532 |
node = repo.brancht |
|
|
533 |
except |
|
|
532 | node = repo.branchtip(wc.branch()) | |
|
533 | except error.RepoLookupError: | |
|
534 | 534 | if wc.branch() == "default": # no default branch! |
|
535 | 535 | node = repo.lookup("tip") # update to tip |
|
536 | 536 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now