2770 def currentwlock(self): |
2770 def currentwlock(self): |
2771 """Returns the wlock if it's held, or None if it's not.""" |
2771 """Returns the wlock if it's held, or None if it's not.""" |
2772 return self._currentlock(self._wlockref) |
2772 return self._currentlock(self._wlockref) |
2773 |
2773 |
2774 def _filecommit( |
2774 def _filecommit( |
2775 self, |
2775 self, fctx, manifest1, manifest2, linkrev, tr, includecopymeta, |
2776 fctx, |
|
2777 manifest1, |
|
2778 manifest2, |
|
2779 linkrev, |
|
2780 tr, |
|
2781 changelist, |
|
2782 includecopymeta, |
|
2783 ): |
2776 ): |
2784 """ |
2777 """ |
2785 commit an individual file as part of a larger transaction |
2778 commit an individual file as part of a larger transaction |
2786 |
2779 |
2787 input: |
2780 input: |
2789 fctx: a file context with the content we are trying to commit |
2782 fctx: a file context with the content we are trying to commit |
2790 manifest1: manifest of changeset first parent |
2783 manifest1: manifest of changeset first parent |
2791 manifest2: manifest of changeset second parent |
2784 manifest2: manifest of changeset second parent |
2792 linkrev: revision number of the changeset being created |
2785 linkrev: revision number of the changeset being created |
2793 tr: current transation |
2786 tr: current transation |
2794 changelist: list of file being changed (modified inplace) |
|
2795 individual: boolean, set to False to skip storing the copy data |
2787 individual: boolean, set to False to skip storing the copy data |
2796 (only used by the Google specific feature of using |
2788 (only used by the Google specific feature of using |
2797 changeset extra as copy source of truth). |
2789 changeset extra as copy source of truth). |
2798 |
2790 |
2799 output: |
2791 output: (filenode, touched) |
2800 |
2792 |
2801 The resulting filenode |
2793 filenode: the filenode that should be used by this changeset |
|
2794 touched: one of: None, 'added' or 'modified' |
2802 """ |
2795 """ |
2803 |
2796 |
2804 fname = fctx.path() |
2797 fname = fctx.path() |
2805 fparent1 = manifest1.get(fname, nullid) |
2798 fparent1 = manifest1.get(fname, nullid) |
2806 fparent2 = manifest2.get(fname, nullid) |
2799 fparent2 = manifest2.get(fname, nullid) |
|
2800 touched = None |
|
2801 if fparent1 == fparent2 == nullid: |
|
2802 touched = 'added' |
|
2803 |
2807 if isinstance(fctx, context.filectx): |
2804 if isinstance(fctx, context.filectx): |
2808 node = fctx.filenode() |
2805 node = fctx.filenode() |
2809 if node in [fparent1, fparent2]: |
2806 if node in [fparent1, fparent2]: |
2810 self.ui.debug(b'reusing %s filelog entry\n' % fname) |
2807 self.ui.debug(b'reusing %s filelog entry\n' % fname) |
2811 if ( |
2808 if ( |
2813 and manifest1.flags(fname) != fctx.flags() |
2810 and manifest1.flags(fname) != fctx.flags() |
2814 ) or ( |
2811 ) or ( |
2815 fparent2 != nullid |
2812 fparent2 != nullid |
2816 and manifest2.flags(fname) != fctx.flags() |
2813 and manifest2.flags(fname) != fctx.flags() |
2817 ): |
2814 ): |
2818 changelist.append(fname) |
2815 touched = 'modified' |
2819 return node |
2816 return node, touched |
2820 |
2817 |
2821 flog = self.file(fname) |
2818 flog = self.file(fname) |
2822 meta = {} |
2819 meta = {} |
2823 cfname = fctx.copysource() |
2820 cfname = fctx.copysource() |
|
2821 fnode = None |
|
2822 |
2824 if cfname and cfname != fname: |
2823 if cfname and cfname != fname: |
2825 # Mark the new revision of this file as a copy of another |
2824 # Mark the new revision of this file as a copy of another |
2826 # file. This copy data will effectively act as a parent |
2825 # file. This copy data will effectively act as a parent |
2827 # of this new revision. If this is a merge, the first |
2826 # of this new revision. If this is a merge, the first |
2828 # parent will be the nullid (meaning "look up the copy data") |
2827 # parent will be the nullid (meaning "look up the copy data") |
2895 fparent1, fparent2 = fparent2, nullid |
2894 fparent1, fparent2 = fparent2, nullid |
2896 |
2895 |
2897 # is the file changed? |
2896 # is the file changed? |
2898 text = fctx.data() |
2897 text = fctx.data() |
2899 if fparent2 != nullid or meta or flog.cmp(fparent1, text): |
2898 if fparent2 != nullid or meta or flog.cmp(fparent1, text): |
2900 changelist.append(fname) |
2899 if touched is None: # do not overwrite added |
2901 return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
2900 touched = 'modified' |
|
2901 fnode = flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
2902 # are just the flags changed during merge? |
2902 # are just the flags changed during merge? |
2903 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
2903 elif fname in manifest1 and manifest1.flags(fname) != fctx.flags(): |
2904 changelist.append(fname) |
2904 touched = 'modified' |
2905 |
2905 fnode = fparent1 |
2906 return fparent1 |
2906 else: |
|
2907 fnode = fparent1 |
|
2908 return fnode, touched |
2907 |
2909 |
2908 def checkcommitpatterns(self, wctx, match, status, fail): |
2910 def checkcommitpatterns(self, wctx, match, status, fail): |
2909 """check for commit arguments that aren't committable""" |
2911 """check for commit arguments that aren't committable""" |
2910 if match.isexact() or match.prefix(): |
2912 if match.isexact() or match.prefix(): |
2911 matched = set(status.modified + status.added + status.removed) |
2913 matched = set(status.modified + status.added + status.removed) |
3129 fctx = ctx[f] |
3131 fctx = ctx[f] |
3130 if fctx is None: |
3132 if fctx is None: |
3131 removed.append(f) |
3133 removed.append(f) |
3132 else: |
3134 else: |
3133 added.append(f) |
3135 added.append(f) |
3134 m[f] = self._filecommit( |
3136 m[f], is_touched = self._filecommit( |
3135 fctx, |
3137 fctx, m1, m2, linkrev, trp, writefilecopymeta, |
3136 m1, |
|
3137 m2, |
|
3138 linkrev, |
|
3139 trp, |
|
3140 changed, |
|
3141 writefilecopymeta, |
|
3142 ) |
3138 ) |
|
3139 if is_touched: |
|
3140 changed.append(f) |
3143 m.setflag(f, fctx.flags()) |
3141 m.setflag(f, fctx.flags()) |
3144 except OSError: |
3142 except OSError: |
3145 self.ui.warn( |
3143 self.ui.warn( |
3146 _(b"trouble committing %s!\n") % uipathfn(f) |
3144 _(b"trouble committing %s!\n") % uipathfn(f) |
3147 ) |
3145 ) |