mercurial/commit.py
changeset 45323 aea6a812f7cb
parent 45251 0041a42c6f28
child 45324 6c56277317c2
equal deleted inserted replaced
45322:c3376a724e32 45323:aea6a812f7cb
    62 
    62 
    63     p1, p2 = ctx.p1(), ctx.p2()
    63     p1, p2 = ctx.p1(), ctx.p2()
    64     user = ctx.user()
    64     user = ctx.user()
    65 
    65 
    66     with repo.lock(), repo.transaction(b"commit") as tr:
    66     with repo.lock(), repo.transaction(b"commit") as tr:
    67         r = _prepare_files(tr, ctx, error=error, origctx=origctx)
    67         mn, files = _prepare_files(tr, ctx, error=error, origctx=origctx)
    68         mn, files, p1copies, p2copies, filesadded, filesremoved = r
       
    69 
    68 
    70         extra = ctx.extra().copy()
    69         extra = ctx.extra().copy()
    71 
    70 
    72         files = sorted(files)
       
    73         if extra is not None:
    71         if extra is not None:
    74             for name in (
    72             for name in (
    75                 b'p1copies',
    73                 b'p1copies',
    76                 b'p2copies',
    74                 b'p2copies',
    77                 b'filesadded',
    75                 b'filesadded',
    78                 b'filesremoved',
    76                 b'filesremoved',
    79             ):
    77             ):
    80                 extra.pop(name, None)
    78                 extra.pop(name, None)
    81         if repo.changelog._copiesstorage == b'extra':
    79         if repo.changelog._copiesstorage == b'extra':
    82             extra = _extra_with_copies(
    80             extra = _extra_with_copies(repo, extra, files)
    83                 repo, extra, files, p1copies, p2copies, filesadded, filesremoved
       
    84             )
       
    85 
    81 
    86         # update changelog
    82         # update changelog
    87         repo.ui.note(_(b"committing changelog\n"))
    83         repo.ui.note(_(b"committing changelog\n"))
    88         repo.changelog.delayupdate(tr)
    84         repo.changelog.delayupdate(tr)
    89         n = repo.changelog.add(
    85         n = repo.changelog.add(
    90             mn,
    86             mn,
    91             files,
    87             files.touched,
    92             ctx.description(),
    88             ctx.description(),
    93             tr,
    89             tr,
    94             p1.node(),
    90             p1.node(),
    95             p2.node(),
    91             p2.node(),
    96             user,
    92             user,
    97             ctx.date(),
    93             ctx.date(),
    98             extra,
    94             extra,
    99             p1copies,
    95             files.copied_from_p1,
   100             p2copies,
    96             files.copied_from_p2,
   101             filesadded,
    97             files.added,
   102             filesremoved,
    98             files.removed,
   103         )
    99         )
   104         xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
   100         xp1, xp2 = p1.hex(), p2 and p2.hex() or b''
   105         repo.hook(
   101         repo.hook(
   106             b'pretxncommit', throw=True, node=hex(n), parent1=xp1, parent2=xp2,
   102             b'pretxncommit', throw=True, node=hex(n), parent1=xp1, parent2=xp2,
   107         )
   103         )
   147             filesadded = added
   143             filesadded = added
   148 
   144 
   149     if origctx and origctx.manifestnode() == mn:
   145     if origctx and origctx.manifestnode() == mn:
   150         touched = origctx.files()
   146         touched = origctx.files()
   151 
   147 
   152     return mn, touched, p1copies, p2copies, filesadded, filesremoved
   148     files = metadata.ChangingFiles()
       
   149     if touched:
       
   150         files.update_touched(touched)
       
   151     if p1copies:
       
   152         files.update_copies_from_p1(p1copies)
       
   153     if p2copies:
       
   154         files.update_copies_from_p2(p2copies)
       
   155     if filesadded:
       
   156         files.update_added(filesadded)
       
   157     if filesremoved:
       
   158         files.update_removed(filesremoved)
       
   159 
       
   160     return mn, files
   153 
   161 
   154 
   162 
   155 def _process_files(tr, ctx, error=False):
   163 def _process_files(tr, ctx, error=False):
   156     repo = ctx.repo()
   164     repo = ctx.repo()
   157     p1 = ctx.p1()
   165     p1 = ctx.p1()
   411         mn = p1.manifestnode()
   419         mn = p1.manifestnode()
   412 
   420 
   413     return mn
   421     return mn
   414 
   422 
   415 
   423 
   416 def _extra_with_copies(
   424 def _extra_with_copies(repo, extra, files):
   417     repo, extra, files, p1copies, p2copies, filesadded, filesremoved
       
   418 ):
       
   419     """encode copy information into a `extra` dictionnary"""
   425     """encode copy information into a `extra` dictionnary"""
       
   426     p1copies = files.copied_from_p1
       
   427     p2copies = files.copied_from_p2
       
   428     filesadded = files.added
       
   429     filesremoved = files.removed
       
   430     files = sorted(files.touched)
   420     if not _write_copy_meta(repo)[1]:
   431     if not _write_copy_meta(repo)[1]:
   421         # If writing only to changeset extras, use None to indicate that
   432         # If writing only to changeset extras, use None to indicate that
   422         # no entry should be written. If writing to both, write an empty
   433         # no entry should be written. If writing to both, write an empty
   423         # entry to prevent the reader from falling back to reading
   434         # entry to prevent the reader from falling back to reading
   424         # filelogs.
   435         # filelogs.