comparison mercurial/commands.py @ 7369:87158be081b8

cmdutil: use change contexts for cset-printer and cset-templater
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 14 Nov 2008 13:59:25 +0100
parents ad7f736f3214
children e17dbf140035
comparison
equal deleted inserted replaced
7368:595ba2537d4f 7369:87158be081b8
7 7
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from repo import RepoError, NoCapability 9 from repo import RepoError, NoCapability
10 from i18n import _, gettext 10 from i18n import _, gettext
11 import os, re, sys 11 import os, re, sys
12 import hg, util, revlog, bundlerepo, extensions, copies 12 import hg, util, revlog, bundlerepo, extensions, copies, context
13 import difflib, patch, time, help, mdiff, tempfile, url 13 import difflib, patch, time, help, mdiff, tempfile, url
14 import version 14 import version
15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect 15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
16 import merge as merge_ 16 import merge as merge_
17 17
286 displayer = cmdutil.show_changeset(ui, repo, {}) 286 displayer = cmdutil.show_changeset(ui, repo, {})
287 transition = (good and "good" or "bad") 287 transition = (good and "good" or "bad")
288 if len(nodes) == 1: 288 if len(nodes) == 1:
289 # narrowed it down to a single revision 289 # narrowed it down to a single revision
290 ui.write(_("The first %s revision is:\n") % transition) 290 ui.write(_("The first %s revision is:\n") % transition)
291 displayer.show(changenode=nodes[0]) 291 displayer.show(repo[nodes[0]])
292 else: 292 else:
293 # multiple possible revisions 293 # multiple possible revisions
294 ui.write(_("Due to skipped revisions, the first " 294 ui.write(_("Due to skipped revisions, the first "
295 "%s revision could be any of:\n") % transition) 295 "%s revision could be any of:\n") % transition)
296 for n in nodes: 296 for n in nodes:
297 displayer.show(changenode=n) 297 displayer.show(repo[n])
298 298
299 def check_state(state, interactive=True): 299 def check_state(state, interactive=True):
300 if not state['good'] or not state['bad']: 300 if not state['good'] or not state['bad']:
301 if (good or bad or skip or reset) and interactive: 301 if (good or bad or skip or reset) and interactive:
302 return 302 return
1268 heads.extend(bheads) 1268 heads.extend(bheads)
1269 if not heads: 1269 if not heads:
1270 return 1 1270 return 1
1271 displayer = cmdutil.show_changeset(ui, repo, opts) 1271 displayer = cmdutil.show_changeset(ui, repo, opts)
1272 for n in heads: 1272 for n in heads:
1273 displayer.show(changenode=n) 1273 displayer.show(repo[n])
1274 1274
1275 def help_(ui, name=None, with_version=False): 1275 def help_(ui, name=None, with_version=False):
1276 """show help for a given topic or a help overview 1276 """show help for a given topic or a help overview
1277 1277
1278 With no arguments, print a list of commands and short help. 1278 With no arguments, print a list of commands and short help.
1727 break 1727 break
1728 parents = [p for p in other.changelog.parents(n) if p != nullid] 1728 parents = [p for p in other.changelog.parents(n) if p != nullid]
1729 if opts.get('no_merges') and len(parents) == 2: 1729 if opts.get('no_merges') and len(parents) == 2:
1730 continue 1730 continue
1731 count += 1 1731 count += 1
1732 displayer.show(changenode=n) 1732 displayer.show(other[n])
1733 finally: 1733 finally:
1734 if hasattr(other, 'close'): 1734 if hasattr(other, 'close'):
1735 other.close() 1735 other.close()
1736 if cleanup: 1736 if cleanup:
1737 os.unlink(cleanup) 1737 os.unlink(cleanup)
1865 only_branches = opts.get('only_branch') 1865 only_branches = opts.get('only_branch')
1866 1866
1867 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) 1867 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1868 for st, rev, fns in changeiter: 1868 for st, rev, fns in changeiter:
1869 if st == 'add': 1869 if st == 'add':
1870 changenode = repo.changelog.node(rev)
1871 parents = [p for p in repo.changelog.parentrevs(rev) 1870 parents = [p for p in repo.changelog.parentrevs(rev)
1872 if p != nullrev] 1871 if p != nullrev]
1873 if opts.get('no_merges') and len(parents) == 2: 1872 if opts.get('no_merges') and len(parents) == 2:
1874 continue 1873 continue
1875 if opts.get('only_merges') and len(parents) != 2: 1874 if opts.get('only_merges') and len(parents) != 2:
1911 if opts.get('copies') and rev: 1910 if opts.get('copies') and rev:
1912 for fn in get(rev)[3]: 1911 for fn in get(rev)[3]:
1913 rename = getrenamed(fn, rev) 1912 rename = getrenamed(fn, rev)
1914 if rename: 1913 if rename:
1915 copies.append((fn, rename[0])) 1914 copies.append((fn, rename[0]))
1916 displayer.show(rev, changenode, copies=copies) 1915 displayer.show(context.changectx(repo, rev), copies=copies)
1917 elif st == 'iter': 1916 elif st == 'iter':
1918 if count == limit: break 1917 if count == limit: break
1919 if displayer.flush(rev): 1918 if displayer.flush(rev):
1920 count += 1 1919 count += 1
1921 1920
2024 break 2023 break
2025 parents = [p for p in repo.changelog.parents(n) if p != nullid] 2024 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2026 if opts.get('no_merges') and len(parents) == 2: 2025 if opts.get('no_merges') and len(parents) == 2:
2027 continue 2026 continue
2028 count += 1 2027 count += 1
2029 displayer.show(changenode=n) 2028 displayer.show(repo[n])
2030 2029
2031 def parents(ui, repo, file_=None, **opts): 2030 def parents(ui, repo, file_=None, **opts):
2032 """show the parents of the working dir or revision 2031 """show the parents of the working dir or revision
2033 2032
2034 Print the working directory's parent revisions. If a 2033 Print the working directory's parent revisions. If a
2064 p = [cp.node() for cp in ctx.parents()] 2063 p = [cp.node() for cp in ctx.parents()]
2065 2064
2066 displayer = cmdutil.show_changeset(ui, repo, opts) 2065 displayer = cmdutil.show_changeset(ui, repo, opts)
2067 for n in p: 2066 for n in p:
2068 if n != nullid: 2067 if n != nullid:
2069 displayer.show(changenode=n) 2068 displayer.show(repo[n])
2070 2069
2071 def paths(ui, repo, search=None): 2070 def paths(ui, repo, search=None):
2072 """show definition of symbolic path names 2071 """show definition of symbolic path names
2073 2072
2074 Show definition of symbolic path name NAME. If no name is given, show 2073 Show definition of symbolic path name NAME. If no name is given, show
2840 If you have just made a commit, that commit will be the tip. If 2839 If you have just made a commit, that commit will be the tip. If
2841 you have just pulled changes from another repository, the tip of 2840 you have just pulled changes from another repository, the tip of
2842 that repository becomes the current tip. The "tip" tag is special 2841 that repository becomes the current tip. The "tip" tag is special
2843 and cannot be renamed or assigned to a different changeset. 2842 and cannot be renamed or assigned to a different changeset.
2844 """ 2843 """
2845 cmdutil.show_changeset(ui, repo, opts).show(len(repo) - 1) 2844 cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
2846 2845
2847 def unbundle(ui, repo, fname1, *fnames, **opts): 2846 def unbundle(ui, repo, fname1, *fnames, **opts):
2848 """apply one or more changegroup files 2847 """apply one or more changegroup files
2849 2848
2850 Apply one or more compressed changegroup files generated by the 2849 Apply one or more compressed changegroup files generated by the