comparison mercurial/localrepo.py @ 10960:ca739acf1a98

commands: add more robust support for 'hg log -b' (issue2078) Fixes issue2078 and adds tests to cover various 'hg log -b' uses. This change adds a localrepo.lookupbranch(key, remote=None) function. This will look up the branch of the revision with the given key. The algorithm works like this: * If a remote repo is given and KEY is the name of a branch in that repo, return KEY. * If no remote repo is given and KEY is the name of a branch in the local repo object, return KEY. * Otherwise look up the revision with the identifier KEY in the local repo and return its branch. This change also makes 'hg log -b' use this new functionality and adds a few tests for it.
author Steve Losh <steve@stevelosh.com>
date Mon, 12 Apr 2010 19:33:25 -0400
parents 4d81cbd8a851
children ca052b484e56
comparison
equal deleted inserted replaced
10959:d1f4657f55e4 10960:ca739acf1a98
452 if len(key) == 20: 452 if len(key) == 20:
453 key = hex(key) 453 key = hex(key)
454 except: 454 except:
455 pass 455 pass
456 raise error.RepoLookupError(_("unknown revision '%s'") % key) 456 raise error.RepoLookupError(_("unknown revision '%s'") % key)
457
458 def lookupbranch(self, key, remote=None):
459 repo = remote or self
460 if key in repo.branchmap():
461 return key
462
463 repo = (remote and remote.local()) and remote or self
464 return repo[key].branch()
457 465
458 def local(self): 466 def local(self):
459 return True 467 return True
460 468
461 def join(self, f): 469 def join(self, f):