remove localrepository.changes.

use localrepository.status instead.
This commit is contained in:
Vadim Gelfer 2006-08-12 16:40:12 -07:00
parent 13d751feaf
commit 80d6f2f7c7
10 changed files with 51 additions and 63 deletions

View File

@ -80,8 +80,8 @@ def dodiff(ui, repo, diffcmd, pats, opts):
node1, node2 = commands.revpair(ui, repo, opts['rev'])
files, matchfn, anypats = commands.matchpats(repo, pats, opts)
modified, added, removed, deleted, unknown = repo.changes(
node1, node2, files, match=matchfn)
modified, added, removed, deleted, unknown = repo.status(
node1, node2, files, match=matchfn)[:5]
if not (modified or added or removed):
return 0

View File

@ -221,7 +221,7 @@ def sign(ui, repo, *revs, **opts):
repo.opener("localsigs", "ab").write(sigmessage)
return
for x in repo.changes():
for x in repo.status()[:5]:
if ".hgsigs" in x and not opts["force"]:
raise util.Abort(_("working copy of .hgsigs is changed "
"(please commit .hgsigs manually "

View File

@ -23,10 +23,10 @@ def lookup_rev(ui, repo, rev=None):
return parents.pop()
def check_clean(ui, repo):
modified, added, removed, deleted, unknown = repo.changes()
if modified or added or removed:
ui.warn("Repository is not clean, please commit or revert\n")
sys.exit(1)
modified, added, removed, deleted, unknown = repo.status()[:5]
if modified or added or removed:
ui.warn("Repository is not clean, please commit or revert\n")
sys.exit(1)
class bisect(object):
"""dichotomic search in the DAG of changesets"""

View File

@ -14,7 +14,7 @@ def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
return time.asctime(time.gmtime(c[2][0]))
if not changes:
changes = repo.changes(node1, node2, files, match=match)
changes = repo.status(node1, node2, files, match=match)[:5]
modified, added, removed, deleted, unknown = changes
if files:
modified, added, removed = map(lambda x: filterfiles(files, x),
@ -67,12 +67,12 @@ def difftree(ui, repo, node1=None, node2=None, **opts):
if node2:
change = repo.changelog.read(node2)
mmap2 = repo.manifest.read(change[0])
modified, added, removed, deleted, unknown = repo.changes(node1, node2)
modified, added, removed, deleted, unknown = repo.status(node1, node2)[:5]
def read(f): return repo.file(f).read(mmap2[f])
date2 = date(change)
else:
date2 = time.asctime()
modified, added, removed, deleted, unknown = repo.changes(node1)
modified, added, removed, deleted, unknown = repo.status(node1)[:5]
if not node1:
node1 = repo.dirstate.parents()[0]
def read(f): return file(os.path.join(repo.root, f)).read()

View File

@ -533,19 +533,20 @@ class queue:
raise util.Abort(_("queue top not at same revision as working directory"))
return top
return None
def check_localchanges(self, repo):
(c, a, r, d, u) = repo.changes(None, None)
if c or a or d or r:
raise util.Abort(_("local changes found, refresh first"))
def check_localchanges(self, repo, force=False, refresh=True):
m, a, r, d = repo.status()[:4]
if m or a or r or d:
if not force:
if refresh:
raise util.Abort(_("local changes found, refresh first"))
else:
raise util.Abort(_("local changes found"))
return m, a, r, d
def new(self, repo, patch, msg=None, force=None):
if os.path.exists(self.join(patch)):
raise util.Abort(_('patch "%s" already exists') % patch)
commitfiles = []
(c, a, r, d, u) = repo.changes(None, None)
if c or a or d or r:
if not force:
raise util.Abort(_("local changes found, refresh first"))
commitfiles = c + a + r
m, a, r, d = self.check_localchanges(repo, force)
commitfiles = m + a + r
self.check_toppatch(repo)
wlock = repo.wlock()
insert = self.full_series_end()
@ -659,9 +660,7 @@ class queue:
revnum = chlog.rev(rev)
if update:
(c, a, r, d, u) = repo.changes(None, None)
if c or a or d or r:
raise util.Abort(_("local changes found"))
self.check_localchanges(repo, refresh=False)
urev = self.qparents(repo, rev)
hg.clean(repo, urev, wlock=wlock)
repo.dirstate.write()
@ -899,15 +898,15 @@ class queue:
qp = self.qparents(repo, rev)
changes = repo.changelog.read(qp)
mmap = repo.manifest.read(changes[0])
(c, a, r, d, u) = repo.changes(qp, top)
m, a, r, d, u = repo.status(qp, top)[:5]
if d:
raise util.Abort("deletions found between repo revs")
for f in c:
for f in m:
getfile(f, mmap[f])
for f in r:
getfile(f, mmap[f])
util.set_exec(repo.wjoin(f), mmap.execf(f))
repo.dirstate.update(c + r, 'n')
repo.dirstate.update(m + r, 'n')
for f in a:
try: os.unlink(repo.wjoin(f))
except: raise
@ -970,30 +969,30 @@ class queue:
# patch already
#
# this should really read:
#(cc, dd, aa, aa2, uu) = repo.changes(tip, patchparent)
# mm, dd, aa, aa2, uu = repo.status(tip, patchparent)[:5]
# but we do it backwards to take advantage of manifest/chlog
# caching against the next repo.changes call
# caching against the next repo.status call
#
(cc, aa, dd, aa2, uu) = repo.changes(patchparent, tip)
mm, aa, dd, aa2, uu = repo.status(patchparent, tip)[:5]
if short:
filelist = cc + aa + dd
filelist = mm + aa + dd
else:
filelist = None
(c, a, r, d, u) = repo.changes(None, None, filelist)
m, a, r, d, u = repo.status(files=filelist)[:5]
# we might end up with files that were added between tip and
# the dirstate parent, but then changed in the local dirstate.
# in this case, we want them to only show up in the added section
for x in c:
for x in m:
if x not in aa:
cc.append(x)
mm.append(x)
# we might end up with files added by the local dirstate that
# were deleted by the patch. In this case, they should only
# show up in the changed section.
for x in a:
if x in dd:
del dd[dd.index(x)]
cc.append(x)
mm.append(x)
else:
aa.append(x)
# make sure any files deleted in the local dirstate
@ -1004,23 +1003,23 @@ class queue:
del aa[aa.index(x)]
forget.append(x)
continue
elif x in cc:
del cc[cc.index(x)]
elif x in mm:
del mm[mm.index(x)]
dd.append(x)
c = list(util.unique(cc))
m = list(util.unique(mm))
r = list(util.unique(dd))
a = list(util.unique(aa))
filelist = list(util.unique(c + r + a ))
filelist = list(util.unique(m + r + a))
self.printdiff(repo, patchparent, files=filelist,
changes=(c, a, r, [], u), fp=patchf)
changes=(m, a, r, [], u), fp=patchf)
patchf.close()
changes = repo.changelog.read(tip)
repo.dirstate.setparents(*cparents)
repo.dirstate.update(a, 'a')
repo.dirstate.update(r, 'r')
repo.dirstate.update(c, 'n')
repo.dirstate.update(m, 'n')
repo.dirstate.forget(forget)
if not msg:

View File

@ -21,7 +21,7 @@ class AmbiguousCommand(Exception):
"""Exception raised if command shortcut matches more than one command."""
def bail_if_changed(repo):
modified, added, removed, deleted, unknown = repo.changes()
modified, added, removed, deleted = repo.status()[:4]
if modified or added or removed or deleted:
raise util.Abort(_("outstanding uncommitted changes"))
@ -443,7 +443,7 @@ class changeset_printer(object):
self.ui.status(_("date: %s\n") % date)
if self.ui.debugflag:
files = self.repo.changes(log.parents(changenode)[0], changenode)
files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
for key, value in zip([_("files:"), _("files+:"), _("files-:")],
files):
if value:
@ -969,8 +969,7 @@ def commit(ui, repo, *pats, **opts):
addremove_lock(ui, repo, pats, opts)
fns, match, anypats = matchpats(repo, pats, opts)
if pats:
modified, added, removed, deleted, unknown = (
repo.changes(files=fns, match=match))
modified, added, removed = repo.status(files=fns, match=match)[:3]
files = modified + added + removed
else:
files = []
@ -1636,7 +1635,7 @@ def identify(ui, repo):
return
hexfunc = ui.verbose and hex or short
modified, added, removed, deleted, unknown = repo.changes()
modified, added, removed, deleted = repo.status()[:4]
output = ["%s%s" %
('+'.join([hexfunc(parent) for parent in parents]),
(modified or added or removed or deleted) and "+" or "")]
@ -2247,7 +2246,7 @@ def remove(ui, repo, *pats, **opts):
raise util.Abort(_('no files specified'))
files, matchfn, anypats = matchpats(repo, pats, opts)
exact = dict.fromkeys(files)
mardu = map(dict.fromkeys, repo.changes(files=files, match=matchfn))
mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5]
modified, added, removed, deleted, unknown = mardu
remove, forget = [], []
for src, abs, rel, exact in walk(repo, pats, opts):
@ -2370,7 +2369,7 @@ def revert(ui, repo, *pats, **opts):
names[abs] = (rel, exact)
target_only[abs] = True
changes = repo.changes(match=names.has_key, wlock=wlock)
changes = repo.status(match=names.has_key, wlock=wlock)[:5]
modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
revert = ([], _('reverting %s\n'))

View File

@ -198,7 +198,7 @@ class localrepository(repo.repository):
self.hook('tag', node=node, tag=name, local=local)
return
for x in self.changes():
for x in self.status()[:5]:
if '.hgtags' in x:
raise util.Abort(_('working copy of .hgtags is changed '
'(please commit .hgtags manually)'))
@ -532,7 +532,7 @@ class localrepository(repo.repository):
else:
self.ui.warn(_("%s not tracked!\n") % f)
else:
modified, added, removed, deleted, unknown = self.changes(match=match)
modified, added, removed, deleted, unknown = self.status(match=match)[:5]
commit = modified + added
remove = removed
@ -751,16 +751,6 @@ class localrepository(repo.repository):
l.sort()
return (modified, added, removed, deleted, unknown, ignored, clean)
def changes(self, node1=None, node2=None, files=[], match=util.always,
wlock=None, list_ignored=False, list_clean=False):
'''DEPRECATED - use status instead'''
marduit = self.status(node1, node2, files, match, wlock,
list_ignored, list_clean)
if list_ignored:
return marduit[:-1]
else:
return marduit[:-2]
def add(self, list, wlock=None):
if not wlock:
wlock = self.wlock()

View File

@ -75,7 +75,7 @@ def update(repo, node, branchmerge=False, force=False, partial=None,
raise util.Abort(_("update spans branches, use 'hg merge' "
"or 'hg update -C' to lose changes"))
modified, added, removed, deleted, unknown = repo.changes()
modified, added, removed, deleted, unknown = repo.status()[:5]
if branchmerge and not forcemerge:
if modified or added or removed:
raise util.Abort(_("outstanding uncommitted changes"))

View File

@ -267,13 +267,13 @@ def diff(repo, node1=None, node2=None, files=None, match=util.always,
if not node1:
node1 = repo.dirstate.parents()[0]
# reading the data for node1 early allows it to play nicely
# with repo.changes and the revlog cache.
# with repo.status and the revlog cache.
change = repo.changelog.read(node1)
mmap = repo.manifest.read(change[0])
date1 = util.datestr(change[2])
if not changes:
changes = repo.changes(node1, node2, files, match=match)
changes = repo.status(node1, node2, files, match=match)[:5]
modified, added, removed, deleted, unknown = changes
if files:
def filterfiles(filters):

View File

@ -459,7 +459,7 @@ class changeset_templater(object):
yield x
if self.ui.debugflag:
files = self.repo.changes(log.parents(changenode)[0], changenode)
files = self.repo.status(log.parents(changenode)[0], changenode)[:3]
def showfiles(**args):
for x in showlist('file', files[0], **args): yield x
def showadds(**args):