comparison mercurial/commands.py @ 1618:ff339dd21976

Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 12 Jan 2006 13:35:09 +0100
parents 83238c1db6de
children 1ba0d7041ac4
comparison
equal deleted inserted replaced
1617:ece5d785e87a 1618:ff339dd21976
261 mode) 261 mode)
262 262
263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always, 263 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
264 changes=None, text=False): 264 changes=None, text=False):
265 if not changes: 265 if not changes:
266 (c, a, d, u) = repo.changes(node1, node2, files, match=match) 266 changes = repo.changes(node1, node2, files, match=match)
267 else: 267 modified, added, removed, unknown = changes
268 (c, a, d, u) = changes
269 if files: 268 if files:
270 c, a, d = map(lambda x: filterfiles(files, x), (c, a, d)) 269 modified, added, removed = map(lambda x: filterfiles(x, files),
271 270 (modified, added, removed))
272 if not c and not a and not d: 271
272 if not modified and not added and not removed:
273 return 273 return
274 274
275 if node2: 275 if node2:
276 change = repo.changelog.read(node2) 276 change = repo.changelog.read(node2)
277 mmap2 = repo.manifest.read(change[0]) 277 mmap2 = repo.manifest.read(change[0])
293 293
294 change = repo.changelog.read(node1) 294 change = repo.changelog.read(node1)
295 mmap = repo.manifest.read(change[0]) 295 mmap = repo.manifest.read(change[0])
296 date1 = util.datestr(change[2]) 296 date1 = util.datestr(change[2])
297 297
298 for f in c: 298 for f in modified:
299 to = None 299 to = None
300 if f in mmap: 300 if f in mmap:
301 to = repo.file(f).read(mmap[f]) 301 to = repo.file(f).read(mmap[f])
302 tn = read(f) 302 tn = read(f)
303 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) 303 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text))
304 for f in a: 304 for f in added:
305 to = None 305 to = None
306 tn = read(f) 306 tn = read(f)
307 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) 307 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text))
308 for f in d: 308 for f in removed:
309 to = repo.file(f).read(mmap[f]) 309 to = repo.file(f).read(mmap[f])
310 tn = None 310 tn = None
311 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text)) 311 fp.write(mdiff.unidiff(to, date1, tn, date2, f, r, text=text))
312 312
313 def trimuser(ui, name, rev, revcache): 313 def trimuser(ui, name, rev, revcache):
783 783
784 if opts['addremove']: 784 if opts['addremove']:
785 addremove(ui, repo, *pats, **opts) 785 addremove(ui, repo, *pats, **opts)
786 fns, match, anypats, cwd = matchpats(repo, pats, opts) 786 fns, match, anypats, cwd = matchpats(repo, pats, opts)
787 if pats: 787 if pats:
788 c, a, d, u = repo.changes(files=fns, match=match) 788 modified, added, removed, unknown = (
789 files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r'] 789 repo.changes(files=fns, match=match))
790 files = (modified + added +
791 [fn for fn in removed if repo.dirstate.state(fn) == 'r'])
790 else: 792 else:
791 files = [] 793 files = []
792 try: 794 try:
793 repo.commit(files, message, opts['user'], opts['date'], match) 795 repo.commit(files, message, opts['user'], opts['date'], match)
794 except ValueError, inst: 796 except ValueError, inst:
1377 if not parents: 1379 if not parents:
1378 ui.write(_("unknown\n")) 1380 ui.write(_("unknown\n"))
1379 return 1381 return
1380 1382
1381 hexfunc = ui.verbose and hex or short 1383 hexfunc = ui.verbose and hex or short
1382 (c, a, d, u) = repo.changes() 1384 modified, added, removed, unknown = repo.changes()
1383 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]), 1385 output = ["%s%s" % ('+'.join([hexfunc(parent) for parent in parents]),
1384 (c or a or d) and "+" or "")] 1386 (modified or added or removed) and "+" or "")]
1385 1387
1386 if not ui.quiet: 1388 if not ui.quiet:
1387 # multiple tags for a single parent separated by '/' 1389 # multiple tags for a single parent separated by '/'
1388 parenttags = ['/'.join(tags) 1390 parenttags = ['/'.join(tags)
1389 for tags in map(repo.nodetags, parents) if tags] 1391 for tags in map(repo.nodetags, parents) if tags]
1408 safety check, not to import a real mail message. 1410 safety check, not to import a real mail message.
1409 """ 1411 """
1410 patches = (patch1,) + patches 1412 patches = (patch1,) + patches
1411 1413
1412 if not opts['force']: 1414 if not opts['force']:
1413 (c, a, d, u) = repo.changes() 1415 modified, added, removed, unknown = repo.changes()
1414 if c or a or d: 1416 if modified or added or removed:
1415 raise util.Abort(_("outstanding uncommitted changes")) 1417 raise util.Abort(_("outstanding uncommitted changes"))
1416 1418
1417 d = opts["base"] 1419 d = opts["base"]
1418 strip = opts["strip"] 1420 strip = opts["strip"]
1419 1421
1825 entire project history. If the files still exist in the working 1827 entire project history. If the files still exist in the working
1826 directory, they will be deleted from it. 1828 directory, they will be deleted from it.
1827 """ 1829 """
1828 names = [] 1830 names = []
1829 def okaytoremove(abs, rel, exact): 1831 def okaytoremove(abs, rel, exact):
1830 c, a, d, u = repo.changes(files = [abs]) 1832 modified, added, removed, unknown = repo.changes(files=[abs])
1831 reason = None 1833 reason = None
1832 if c: 1834 if modified:
1833 reason = _('is modified') 1835 reason = _('is modified')
1834 elif a: 1836 elif added:
1835 reason = _('has been marked for add') 1837 reason = _('has been marked for add')
1836 elif u: 1838 elif unknown:
1837 reason = _('is not managed') 1839 reason = _('is not managed')
1838 if reason: 1840 if reason:
1839 if exact: 1841 if exact:
1840 ui.warn(_('not removing %s: file %s\n') % (rel, reason)) 1842 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
1841 else: 1843 else:
1889 """ 1891 """
1890 node = opts['rev'] and repo.lookup(opts['rev']) or \ 1892 node = opts['rev'] and repo.lookup(opts['rev']) or \
1891 repo.dirstate.parents()[0] 1893 repo.dirstate.parents()[0]
1892 1894
1893 files, choose, anypats, cwd = matchpats(repo, pats, opts) 1895 files, choose, anypats, cwd = matchpats(repo, pats, opts)
1894 (c, a, d, u) = repo.changes(match=choose) 1896 modified, added, removed, unknown = repo.changes(match=choose)
1895 repo.forget(a) 1897 repo.forget(added)
1896 repo.undelete(d) 1898 repo.undelete(removed)
1897 1899
1898 return repo.update(node, False, True, choose, False) 1900 return repo.update(node, False, True, choose, False)
1899 1901
1900 def root(ui, repo): 1902 def root(ui, repo):
1901 """print the root (top) of the current working dir 1903 """print the root (top) of the current working dir
2022 R = removed 2024 R = removed
2023 ? = not tracked 2025 ? = not tracked
2024 """ 2026 """
2025 2027
2026 files, matchfn, anypats, cwd = matchpats(repo, pats, opts) 2028 files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
2027 (c, a, d, u) = [[util.pathto(cwd, x) for x in n] 2029 modified, added, removed, unknown = [
2028 for n in repo.changes(files=files, match=matchfn)] 2030 [util.pathto(cwd, x) for x in n]
2029 2031 for n in repo.changes(files=files, match=matchfn)]
2030 changetypes = [(_('modified'), 'M', c), 2032
2031 (_('added'), 'A', a), 2033 changetypes = [(_('modified'), 'M', modified),
2032 (_('removed'), 'R', d), 2034 (_('added'), 'A', added),
2033 (_('unknown'), '?', u)] 2035 (_('removed'), 'R', removed),
2036 (_('unknown'), '?', unknown)]
2034 2037
2035 end = opts['print0'] and '\0' or '\n' 2038 end = opts['print0'] and '\0' or '\n'
2036 2039
2037 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]] 2040 for opt, char, changes in ([ct for ct in changetypes if opts[ct[0]]]
2038 or changetypes): 2041 or changetypes):
2076 2079
2077 if opts['local']: 2080 if opts['local']:
2078 repo.opener("localtags", "a").write("%s %s\n" % (r, name)) 2081 repo.opener("localtags", "a").write("%s %s\n" % (r, name))
2079 return 2082 return
2080 2083
2081 (c, a, d, u) = repo.changes() 2084 for x in repo.changes():
2082 for x in (c, a, d, u):
2083 if ".hgtags" in x: 2085 if ".hgtags" in x:
2084 raise util.Abort(_("working copy of .hgtags is changed " 2086 raise util.Abort(_("working copy of .hgtags is changed "
2085 "(please commit .hgtags manually)")) 2087 "(please commit .hgtags manually)"))
2086 2088
2087 repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name)) 2089 repo.wfile(".hgtags", "ab").write("%s %s\n" % (r, name))