Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/cmdutil.py @ 3887:79e5a6e7c451
Merge with main
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 14 Dec 2006 13:49:33 -0800 |
parents | abaee83ce0a6 |
children | 6b4127c7d52a |
comparison
equal
deleted
inserted
replaced
3884:d83b125b7d7e | 3887:79e5a6e7c451 |
---|---|
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
5 # This software may be used and distributed according to the terms | 5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 from demandload import demandload | |
9 from node import * | 8 from node import * |
10 from i18n import gettext as _ | 9 from i18n import gettext as _ |
11 demandload(globals(), 'os sys') | 10 import os, sys, mdiff, util, templater, patch |
12 demandload(globals(), 'mdiff util templater patch') | |
13 | 11 |
14 revrangesep = ':' | 12 revrangesep = ':' |
15 | 13 |
16 def revpair(repo, revs): | 14 def revpair(repo, revs): |
17 '''return pair of nodes, given list of revisions. second item can | 15 '''return pair of nodes, given list of revisions. second item can |
197 repo.copy(old, new, wlock=wlock) | 195 repo.copy(old, new, wlock=wlock) |
198 | 196 |
199 class changeset_printer(object): | 197 class changeset_printer(object): |
200 '''show changeset information when templating not requested.''' | 198 '''show changeset information when templating not requested.''' |
201 | 199 |
202 def __init__(self, ui, repo, patch, brinfo, buffered): | 200 def __init__(self, ui, repo, patch, buffered): |
203 self.ui = ui | 201 self.ui = ui |
204 self.repo = repo | 202 self.repo = repo |
205 self.buffered = buffered | 203 self.buffered = buffered |
206 self.patch = patch | 204 self.patch = patch |
207 self.brinfo = brinfo | |
208 self.header = {} | 205 self.header = {} |
209 self.hunk = {} | 206 self.hunk = {} |
210 self.lastheader = None | 207 self.lastheader = None |
211 | 208 |
212 def flush(self, rev): | 209 def flush(self, rev): |
266 for tag in self.repo.nodetags(changenode): | 263 for tag in self.repo.nodetags(changenode): |
267 self.ui.write(_("tag: %s\n") % tag) | 264 self.ui.write(_("tag: %s\n") % tag) |
268 for parent in parents: | 265 for parent in parents: |
269 self.ui.write(_("parent: %d:%s\n") % parent) | 266 self.ui.write(_("parent: %d:%s\n") % parent) |
270 | 267 |
271 if self.brinfo: | |
272 br = self.repo.branchlookup([changenode]) | |
273 if br: | |
274 self.ui.write(_("branch: %s\n") % " ".join(br[changenode])) | |
275 | |
276 if self.ui.debugflag: | 268 if self.ui.debugflag: |
277 self.ui.write(_("manifest: %d:%s\n") % | 269 self.ui.write(_("manifest: %d:%s\n") % |
278 (self.repo.manifest.rev(changes[0]), hex(changes[0]))) | 270 (self.repo.manifest.rev(changes[0]), hex(changes[0]))) |
279 self.ui.write(_("user: %s\n") % changes[1]) | 271 self.ui.write(_("user: %s\n") % changes[1]) |
280 self.ui.write(_("date: %s\n") % date) | 272 self.ui.write(_("date: %s\n") % date) |
318 self.ui.write("\n") | 310 self.ui.write("\n") |
319 | 311 |
320 class changeset_templater(changeset_printer): | 312 class changeset_templater(changeset_printer): |
321 '''format changeset information.''' | 313 '''format changeset information.''' |
322 | 314 |
323 def __init__(self, ui, repo, patch, brinfo, mapfile, buffered): | 315 def __init__(self, ui, repo, patch, mapfile, buffered): |
324 changeset_printer.__init__(self, ui, repo, patch, brinfo, buffered) | 316 changeset_printer.__init__(self, ui, repo, patch, buffered) |
325 self.t = templater.templater(mapfile, templater.common_filters, | 317 self.t = templater.templater(mapfile, templater.common_filters, |
326 cache={'parent': '{rev}:{node|short} ', | 318 cache={'parent': '{rev}:{node|short} ', |
327 'manifest': '{rev}:{node|short}', | 319 'manifest': '{rev}:{node|short}', |
328 'filecopy': '{name} ({source})'}) | 320 'filecopy': '{name} ({source})'}) |
329 | 321 |
405 def showbranches(**args): | 397 def showbranches(**args): |
406 branch = changes[5].get("branch") | 398 branch = changes[5].get("branch") |
407 if branch: | 399 if branch: |
408 branch = util.tolocal(branch) | 400 branch = util.tolocal(branch) |
409 return showlist('branch', [branch], plural='branches', **args) | 401 return showlist('branch', [branch], plural='branches', **args) |
410 # add old style branches if requested | |
411 if self.brinfo: | |
412 br = self.repo.branchlookup([changenode]) | |
413 if changenode in br: | |
414 return showlist('branch', br[changenode], | |
415 plural='branches', **args) | |
416 | 402 |
417 def showparents(**args): | 403 def showparents(**args): |
418 parents = [[('rev', log.rev(p)), ('node', hex(p))] | 404 parents = [[('rev', log.rev(p)), ('node', hex(p))] |
419 for p in log.parents(changenode) | 405 for p in log.parents(changenode) |
420 if self.ui.debugflag or p != nullid] | 406 if self.ui.debugflag or p != nullid] |
524 # options | 510 # options |
525 patch = False | 511 patch = False |
526 if opts.get('patch'): | 512 if opts.get('patch'): |
527 patch = matchfn or util.always | 513 patch = matchfn or util.always |
528 | 514 |
529 br = None | |
530 if opts.get('branches'): | |
531 ui.warn(_("the --branches option is deprecated, " | |
532 "please use 'hg branches' instead\n")) | |
533 br = True | |
534 tmpl = opts.get('template') | 515 tmpl = opts.get('template') |
535 mapfile = None | 516 mapfile = None |
536 if tmpl: | 517 if tmpl: |
537 tmpl = templater.parsestring(tmpl, quoted=False) | 518 tmpl = templater.parsestring(tmpl, quoted=False) |
538 else: | 519 else: |
550 if not os.path.split(mapfile)[0]: | 531 if not os.path.split(mapfile)[0]: |
551 mapname = (templater.templatepath('map-cmdline.' + mapfile) | 532 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
552 or templater.templatepath(mapfile)) | 533 or templater.templatepath(mapfile)) |
553 if mapname: mapfile = mapname | 534 if mapname: mapfile = mapname |
554 try: | 535 try: |
555 t = changeset_templater(ui, repo, patch, br, mapfile, buffered) | 536 t = changeset_templater(ui, repo, patch, mapfile, buffered) |
556 except SyntaxError, inst: | 537 except SyntaxError, inst: |
557 raise util.Abort(inst.args[0]) | 538 raise util.Abort(inst.args[0]) |
558 if tmpl: t.use_template(tmpl) | 539 if tmpl: t.use_template(tmpl) |
559 return t | 540 return t |
560 return changeset_printer(ui, repo, patch, br, buffered) | 541 return changeset_printer(ui, repo, patch, buffered) |
561 | 542 |
562 def finddate(ui, repo, date): | 543 def finddate(ui, repo, date): |
563 """Find the tipmost changeset that matches the given date spec""" | 544 """Find the tipmost changeset that matches the given date spec""" |
564 df = util.matchdate(date + " to " + date) | 545 df = util.matchdate(date + " to " + date) |
565 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) | 546 get = util.cachefunc(lambda r: repo.changectx(r).changeset()) |