168 '''kwfiles behaves similar to status, using pathto since 78b6add1f966.''' |
168 '''kwfiles behaves similar to status, using pathto since 78b6add1f966.''' |
169 try: |
169 try: |
170 return repo.pathto(f, cwd) |
170 return repo.pathto(f, cwd) |
171 except AttributeError: |
171 except AttributeError: |
172 return f |
172 return f |
|
173 |
|
174 '''Default match argument for commit, depending on version.''' |
|
175 if hasattr(cmdutil, 'match'): |
|
176 _defmatch = None |
|
177 else: |
|
178 _defmatch = util.always |
173 |
179 |
174 # commands.parse/cmdutil.parse returned nothing for |
180 # commands.parse/cmdutil.parse returned nothing for |
175 # "hg diff --rev" before 88803a69b24a due to bug in fancyopts |
181 # "hg diff --rev" before 88803a69b24a due to bug in fancyopts |
176 def _fancyopts(args, options, state): |
182 def _fancyopts(args, options, state): |
177 '''Fixed fancyopts from a9b7e425674f.''' |
183 '''Fixed fancyopts from a9b7e425674f.''' |
388 |
394 |
389 def _status(ui, repo, kwt, *pats, **opts): |
395 def _status(ui, repo, kwt, *pats, **opts): |
390 '''Bails out if [keyword] configuration is not active. |
396 '''Bails out if [keyword] configuration is not active. |
391 Returns status of working directory.''' |
397 Returns status of working directory.''' |
392 if kwt: |
398 if kwt: |
393 files, match, anypats = cmdutil.matchpats(repo, pats, opts) |
399 try: |
394 return repo.status(files=files, match=match, list_clean=True) |
400 # 0159b7a36184 ff. |
|
401 matcher = cmdutil.match(repo, pats, opts) |
|
402 return repo.status(match=matcher, list_clean=True) |
|
403 except AttributeError: |
|
404 files, match, anypats = cmdutil.matchpats(repo, pats, opts) |
|
405 return repo.status(files=files, match=match, list_clean=True) |
395 if ui.configitems('keyword'): |
406 if ui.configitems('keyword'): |
396 raise util.Abort(_('[keyword] patterns cannot match')) |
407 raise util.Abort(_('[keyword] patterns cannot match')) |
397 raise util.Abort(_('no [keyword] patterns configured')) |
408 raise util.Abort(_('no [keyword] patterns configured')) |
398 |
409 |
399 def _kwfwrite(ui, repo, expand, *pats, **opts): |
410 def _kwfwrite(ui, repo, expand, *pats, **opts): |
605 match, force, |
616 match, force, |
606 force_editor=force_editor, |
617 force_editor=force_editor, |
607 p1=p1, p2=p2, extra=extra) |
618 p1=p1, p2=p2, extra=extra) |
608 |
619 |
609 def commit(self, files=None, text='', user=None, date=None, |
620 def commit(self, files=None, text='', user=None, date=None, |
610 match=util.always, force=False, lock=None, wlock=None, |
621 match=_defmatch, force=False, lock=None, wlock=None, |
611 force_editor=False, p1=None, p2=None, extra={}, |
622 force_editor=False, p1=None, p2=None, extra={}, |
612 empty_ok=False): |
623 empty_ok=False): |
613 # (w)lock arguments removed in 126f527b3ba3 |
624 # (w)lock arguments removed in 126f527b3ba3 |
614 # so they are None or what was passed to commit |
625 # so they are None or what was passed to commit |
615 # use private _(w)lock for deletion |
626 # use private _(w)lock for deletion |
671 patchfile_init = patch.patchfile.__init__ |
682 patchfile_init = patch.patchfile.__init__ |
672 patch.patchfile.__init__ = kwpatchfile_init |
683 patch.patchfile.__init__ = kwpatchfile_init |
673 except AttributeError: |
684 except AttributeError: |
674 pass |
685 pass |
675 |
686 |
676 def kw_diff(repo, node1=None, node2=None, files=None, match=util.always, |
687 def kw_diff(repo, node1=None, node2=None, files=None, match=_defmatch, |
677 fp=None, changes=None, opts=None): |
688 fp=None, changes=None, opts=None): |
678 # only expand if comparing against working dir |
689 # only expand if comparing against working dir |
679 if node2 is not None: |
690 if node2 is not None: |
680 kwt.matcher = util.never |
691 kwt.matcher = util.never |
681 elif node1 is not None and node1 != repo.changectx().node(): |
692 elif node1 is not None and node1 != repo.changectx().node(): |
682 kwt.restrict = True |
693 kwt.restrict = True |
683 patch_diff(repo, node1, node2, files, match, fp, changes, opts) |
694 try: |
|
695 patch_diff(repo, node1, node2, files, match, fp, changes, opts) |
|
696 except TypeError: |
|
697 patch_diff(repo, node1, node2, match, fp, changes, opts) |
684 |
698 |
685 patch_diff = patch.diff |
699 patch_diff = patch.diff |
686 patch.diff = kw_diff |
700 patch.diff = kw_diff |
687 |
701 |
688 try: |
702 try: |