1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:07:57 -07:00

codereview: Mercurial 1.9 fix for hg diff @nnn

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4969063
This commit is contained in:
Russ Cox 2011-09-08 10:08:49 -04:00
parent cf0d8c0941
commit e7af22a64e

View File

@ -946,18 +946,20 @@ def CommandLineCL(ui, repo, pats, opts, defaultcc=None):
# which expands the syntax @clnumber to mean the files # which expands the syntax @clnumber to mean the files
# in that CL. # in that CL.
original_match = None original_match = None
def ReplacementForCmdutilMatch(repo, pats=None, opts=None, globbed=False, default='relpath'): global_repo = None
def ReplacementForCmdutilMatch(ctx, pats=None, opts=None, globbed=False, default='relpath'):
taken = [] taken = []
files = [] files = []
pats = pats or [] pats = pats or []
opts = opts or {} opts = opts or {}
for p in pats: for p in pats:
if p.startswith('@'): if p.startswith('@'):
taken.append(p) taken.append(p)
clname = p[1:] clname = p[1:]
if not GoodCLName(clname): if not GoodCLName(clname):
raise util.Abort("invalid CL name " + clname) raise util.Abort("invalid CL name " + clname)
cl, err = LoadCL(repo.ui, repo, clname, web=False) cl, err = LoadCL(global_repo.ui, global_repo, clname, web=False)
if err != '': if err != '':
raise util.Abort("loading CL " + clname + ": " + err) raise util.Abort("loading CL " + clname + ": " + err)
if not cl.files: if not cl.files:
@ -966,10 +968,9 @@ def ReplacementForCmdutilMatch(repo, pats=None, opts=None, globbed=False, defaul
pats = Sub(pats, taken) + ['path:'+f for f in files] pats = Sub(pats, taken) + ['path:'+f for f in files]
# work-around for http://selenic.com/hg/rev/785bbc8634f8 # work-around for http://selenic.com/hg/rev/785bbc8634f8
if hgversion >= '1.9' and not hasattr(repo, 'match'): if hgversion >= '1.9' and not hasattr(ctx, 'match'):
repo = repo[None] ctx = ctx[None]
return original_match(ctx, pats=pats, opts=opts, globbed=globbed, default=default)
return original_match(repo, pats=pats, opts=opts, globbed=globbed, default=default)
def RelativePath(path, cwd): def RelativePath(path, cwd):
n = len(cwd) n = len(cwd)
@ -1616,6 +1617,8 @@ def pending(ui, repo, *pats, **opts):
def reposetup(ui, repo): def reposetup(ui, repo):
global original_match global original_match
if original_match is None: if original_match is None:
global global_repo
global_repo = repo
start_status_thread() start_status_thread()
original_match = scmutil.match original_match = scmutil.match
scmutil.match = ReplacementForCmdutilMatch scmutil.match = ReplacementForCmdutilMatch