Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 13750:7eb82f88e157
# User Dan Villiom Podlaski Christiansen <danchr@gmail.com>
# Date 1289564504 -3600
# Node ID b75264c15cc888cf38c3c7b8f619801e3c2589c7
# Parent 89b2e5d940f669e590096c6be70eee61c9172fff
revsets: overload the branch() revset to also take a branch name.
This should only change semantics in the specific case of a tag/branch
conflict where the tag wasn't done on the branch with the same
name. Previously, branch(whatever) would resolve to the branch of the
tag in that case, whereas now it will resolve to the branch of the
name. The previous behaviour, while documented, seemed very
counter-intuitive to me.
An alternate approach would be to introduce a new revset such as
branchname() or namedbranch(). While this would retain backwards
compatibility, the distinction between it and branch() would not be
readily apparent to users. The most intuitive behaviour would be to
have branch(x) require 'x' to be a branch name, and something like
branchof(x) or samebranch(x) do what branch(x) currently
does. Unfortunately, our backwards compatibility guarantees prevent us
from doing that.
Please note that while 'hg tag' guards against shadowing a branch, 'hg
branch' does not. Besides, even if it did, that wouldn't solve the
issue of conversions with such tags and branches...
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 23 Mar 2011 19:28:16 -0500 |
parents | 15b97a1cd60b |
children | 02c3d4d44a92 |
comparison
equal
deleted
inserted
replaced
13749:8bb03283e9b9 | 13750:7eb82f88e157 |
---|---|
296 if p in s: | 296 if p in s: |
297 cs.add(r) | 297 cs.add(r) |
298 return [r for r in subset if r in cs] | 298 return [r for r in subset if r in cs] |
299 | 299 |
300 def branch(repo, subset, x): | 300 def branch(repo, subset, x): |
301 """``branch(set)`` | 301 """``branch(string or set)`` |
302 All changesets belonging to the branches of changesets in set. | 302 All changesets belonging to the given branch or the branches of the given |
303 """ | 303 changesets. |
304 """ | |
305 try: | |
306 b = getstring(x, '') | |
307 if b in repo.branchmap(): | |
308 return [r for r in subset if repo[r].branch() == b] | |
309 except error.ParseError: | |
310 # not a string, but another revspec, e.g. tip() | |
311 pass | |
312 | |
304 s = getset(repo, range(len(repo)), x) | 313 s = getset(repo, range(len(repo)), x) |
305 b = set() | 314 b = set() |
306 for r in s: | 315 for r in s: |
307 b.add(repo[r].branch()) | 316 b.add(repo[r].branch()) |
308 s = set(s) | 317 s = set(s) |