2792 def commit(ui, repo, commitfunc, pats, opts): |
2792 def commit(ui, repo, commitfunc, pats, opts): |
2793 '''commit the specified files or all outstanding changes''' |
2793 '''commit the specified files or all outstanding changes''' |
2794 date = opts.get(b'date') |
2794 date = opts.get(b'date') |
2795 if date: |
2795 if date: |
2796 opts[b'date'] = dateutil.parsedate(date) |
2796 opts[b'date'] = dateutil.parsedate(date) |
2797 message = logmessage(ui, opts) |
|
2798 matcher = scmutil.match(repo[None], pats, opts) |
|
2799 |
2797 |
2800 dsguard = None |
2798 dsguard = None |
2801 # extract addremove carefully -- this function can be called from a command |
2799 # extract addremove carefully -- this function can be called from a command |
2802 # that doesn't support addremove |
2800 # that doesn't support addremove |
2803 if opts.get(b'addremove'): |
2801 if opts.get(b'addremove'): |
2804 dsguard = dirstateguard.dirstateguard(repo, b'commit') |
2802 dsguard = dirstateguard.dirstateguard(repo, b'commit') |
2805 with dsguard or util.nullcontextmanager(): |
2803 with dsguard or util.nullcontextmanager(): |
2806 if dsguard: |
2804 message = logmessage(ui, opts) |
2807 relative = scmutil.anypats(pats, opts) |
2805 matcher = scmutil.match(repo[None], pats, opts) |
2808 uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=relative) |
2806 if True: |
2809 if scmutil.addremove(repo, matcher, b"", uipathfn, opts) != 0: |
2807 # extract addremove carefully -- this function can be called from a |
2810 raise error.Abort( |
2808 # command that doesn't support addremove |
2811 _(b"failed to mark all new/missing files as added/removed") |
2809 if opts.get(b'addremove'): |
|
2810 relative = scmutil.anypats(pats, opts) |
|
2811 uipathfn = scmutil.getuipathfn( |
|
2812 repo, |
|
2813 legacyrelativevalue=relative, |
2812 ) |
2814 ) |
2813 |
2815 r = scmutil.addremove( |
2814 return commitfunc(ui, repo, message, matcher, opts) |
2816 repo, |
|
2817 matcher, |
|
2818 b"", |
|
2819 uipathfn, |
|
2820 opts, |
|
2821 ) |
|
2822 m = _(b"failed to mark all new/missing files as added/removed") |
|
2823 if r != 0: |
|
2824 raise error.Abort(m) |
|
2825 |
|
2826 return commitfunc(ui, repo, message, matcher, opts) |
2815 |
2827 |
2816 |
2828 |
2817 def samefile(f, ctx1, ctx2): |
2829 def samefile(f, ctx1, ctx2): |
2818 if f in ctx1.manifest(): |
2830 if f in ctx1.manifest(): |
2819 a = ctx1.filectx(f) |
2831 a = ctx1.filectx(f) |