##// END OF EJS Templates
use repo.changectx(None) to get a workingctx
Matt Mackall -
r6740:b148e909 default
parent child Browse files
Show More
@@ -386,7 +386,7 b' def files(ui, repo, *pats, **opts):'
386 if opts.get('untracked'):
386 if opts.get('untracked'):
387 files += unknown
387 files += unknown
388 files.sort()
388 files.sort()
389 wctx = repo.workingctx()
389 wctx = repo.changectx(None)
390 islink = lambda p: 'l' in wctx.fileflags(p)
390 islink = lambda p: 'l' in wctx.fileflags(p)
391 kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
391 kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
392 cwd = pats and repo.getcwd() or ''
392 cwd = pats and repo.getcwd() or ''
@@ -359,7 +359,7 b' def branch(ui, repo, label=None, **opts)'
359
359
360 if label:
360 if label:
361 if not opts.get('force') and label in repo.branchtags():
361 if not opts.get('force') and label in repo.branchtags():
362 if label not in [p.branch() for p in repo.workingctx().parents()]:
362 if label not in [p.branch() for p in repo.changectx(None).parents()]:
363 raise util.Abort(_('a branch of the same name already exists'
363 raise util.Abort(_('a branch of the same name already exists'
364 ' (use --force to override)'))
364 ' (use --force to override)'))
365 repo.dirstate.setbranch(util.fromlocal(label))
365 repo.dirstate.setbranch(util.fromlocal(label))
@@ -1454,7 +1454,7 b' def identify(ui, repo, source=None,'
1454 "can't query remote revision number, branch, or tags")
1454 "can't query remote revision number, branch, or tags")
1455 output = [hexfunc(srepo.lookup(rev))]
1455 output = [hexfunc(srepo.lookup(rev))]
1456 elif not rev:
1456 elif not rev:
1457 ctx = repo.workingctx()
1457 ctx = repo.changectx(None)
1458 parents = ctx.parents()
1458 parents = ctx.parents()
1459 changed = False
1459 changed = False
1460 if default or id or num:
1460 if default or id or num:
@@ -1563,7 +1563,7 b' def import_(ui, repo, patch1, *patches, '
1563 message = None
1563 message = None
1564 ui.debug(_('message:\n%s\n') % message)
1564 ui.debug(_('message:\n%s\n') % message)
1565
1565
1566 wp = repo.workingctx().parents()
1566 wp = repo.changectx(None).parents()
1567 if opts.get('exact'):
1567 if opts.get('exact'):
1568 if not nodeid or not p1:
1568 if not nodeid or not p1:
1569 raise util.Abort(_('not a mercurial patch'))
1569 raise util.Abort(_('not a mercurial patch'))
@@ -1902,7 +1902,7 b' def merge(ui, repo, node=None, force=Non'
1902 node = rev
1902 node = rev
1903
1903
1904 if not node:
1904 if not node:
1905 branch = repo.workingctx().branch()
1905 branch = repo.changectx(None).branch()
1906 bheads = repo.branchheads()
1906 bheads = repo.branchheads()
1907 if len(bheads) > 2:
1907 if len(bheads) > 2:
1908 raise util.Abort(_("branch '%s' has %d heads - "
1908 raise util.Abort(_("branch '%s' has %d heads - "
@@ -1916,7 +1916,7 b' def merge(ui, repo, node=None, force=Non'
1916 "please merge with an explicit rev") %
1916 "please merge with an explicit rev") %
1917 branch)
1917 branch)
1918 msg = _('there is nothing to merge')
1918 msg = _('there is nothing to merge')
1919 if parent != repo.lookup(repo.workingctx().branch()):
1919 if parent != repo.lookup(repo.changectx(None).branch()):
1920 msg = _('%s - use "hg update" instead') % msg
1920 msg = _('%s - use "hg update" instead') % msg
1921 raise util.Abort(msg)
1921 raise util.Abort(msg)
1922
1922
@@ -1975,7 +1975,7 b' def parents(ui, repo, file_=None, **opts'
1975 if rev:
1975 if rev:
1976 ctx = repo.changectx(rev)
1976 ctx = repo.changectx(rev)
1977 else:
1977 else:
1978 ctx = repo.workingctx()
1978 ctx = repo.changectx(None)
1979
1979
1980 if file_:
1980 if file_:
1981 m = cmdutil.match(repo, (file_,), opts)
1981 m = cmdutil.match(repo, (file_,), opts)
@@ -2297,7 +2297,7 b' def resolve(ui, repo, *pats, **opts):'
2297 elif opts.get("unmark"):
2297 elif opts.get("unmark"):
2298 ms.mark(f, "u")
2298 ms.mark(f, "u")
2299 else:
2299 else:
2300 wctx = repo.workingctx()
2300 wctx = repo.changectx(None)
2301 mctx = wctx.parents()[-1]
2301 mctx = wctx.parents()[-1]
2302 ms.resolve(f, wctx, mctx)
2302 ms.resolve(f, wctx, mctx)
2303
2303
@@ -2670,12 +2670,11 b' def status(ui, repo, *pats, **opts):'
2670 if (opts['all'] or opts['copies']) and not opts['no_status']:
2670 if (opts['all'] or opts['copies']) and not opts['no_status']:
2671 ctxn = repo.changectx(nullid)
2671 ctxn = repo.changectx(nullid)
2672 ctx1 = repo.changectx(node1)
2672 ctx1 = repo.changectx(node1)
2673 ctx2 = repo.changectx(node2)
2673 added = stat[1]
2674 added = stat[1]
2674 if node2 is None:
2675 if node2 is None:
2675 added = stat[0] + stat[1] # merged?
2676 added = stat[0] + stat[1] # merged?
2676 ctx2 = repo.workingctx()
2677
2677 else:
2678 ctx2 = repo.changectx(node2)
2679 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items():
2678 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items():
2680 if k in added:
2679 if k in added:
2681 copy[k] = v
2680 copy[k] = v
@@ -485,12 +485,9 b' class localrepository(repo.repository):'
485
485
486 def changectx(self, changeid):
486 def changectx(self, changeid):
487 if changeid == None:
487 if changeid == None:
488 raise "nope!"
488 return context.workingctx(self)
489 return context.changectx(self, changeid)
489 return context.changectx(self, changeid)
490
490
491 def workingctx(self):
492 return context.workingctx(self)
493
494 def parents(self, changeid=None):
491 def parents(self, changeid=None):
495 '''
492 '''
496 get list of changectxs for parents of changeid or working directory
493 get list of changectxs for parents of changeid or working directory
@@ -1202,7 +1199,7 b' class localrepository(repo.repository):'
1202 return [n for (r, n) in heads]
1199 return [n for (r, n) in heads]
1203
1200
1204 def branchheads(self, branch=None, start=None):
1201 def branchheads(self, branch=None, start=None):
1205 branch = branch is None and self.workingctx().branch() or branch
1202 branch = branch is None and self.changectx(None).branch() or branch
1206 branches = self.branchtags()
1203 branches = self.branchtags()
1207 if branch not in branches:
1204 if branch not in branches:
1208 return []
1205 return []
@@ -409,7 +409,7 b' def update(repo, node, branchmerge, forc'
409
409
410 wlock = repo.wlock()
410 wlock = repo.wlock()
411 try:
411 try:
412 wc = repo.workingctx()
412 wc = repo.changectx(None)
413 if node is None:
413 if node is None:
414 # tip of current branch
414 # tip of current branch
415 try:
415 try:
@@ -1192,12 +1192,11 b' def diff(repo, node1=None, node2=None, m'
1192 if not modified and not added and not removed:
1192 if not modified and not added and not removed:
1193 return
1193 return
1194
1194
1195 ctx2 = repo.changectx(node2)
1195 if node2:
1196 if node2:
1196 ctx2 = repo.changectx(node2)
1197 execf2 = ctx2.manifest().execf
1197 execf2 = ctx2.manifest().execf
1198 linkf2 = ctx2.manifest().linkf
1198 linkf2 = ctx2.manifest().linkf
1199 else:
1199 else:
1200 ctx2 = repo.workingctx()
1201 execf2 = util.execfunc(repo.root, None)
1200 execf2 = util.execfunc(repo.root, None)
1202 linkf2 = util.linkfunc(repo.root, None)
1201 linkf2 = util.linkfunc(repo.root, None)
1203 if execf2 is None:
1202 if execf2 is None:
@@ -16,4 +16,4 b" os.utime('foo', (1000, 1000))"
16 repo.add(['foo'])
16 repo.add(['foo'])
17 repo.commit(text='commit1', date="0 0")
17 repo.commit(text='commit1', date="0 0")
18
18
19 print "workingfilectx.date =", repo.workingctx().filectx('foo').date()
19 print "workingfilectx.date =", repo.changectx(None).filectx('foo').date()
General Comments 0
You need to be logged in to leave comments. Login now