hgext/evolve.py
changeset 219 cfdab01ca8a0
parent 211 69a37d56c7fb
child 228 5a17c0d41a00
equal deleted inserted replaced
218:ace5608350b6 219:cfdab01ca8a0
    15 from mercurial import error
    15 from mercurial import error
    16 from mercurial import extensions
    16 from mercurial import extensions
    17 from mercurial import commands
    17 from mercurial import commands
    18 from mercurial import bookmarks
    18 from mercurial import bookmarks
    19 from mercurial import phases
    19 from mercurial import phases
       
    20 from mercurial import commands
    20 from mercurial import context
    21 from mercurial import context
    21 from mercurial import commands
    22 from mercurial import copies
    22 from mercurial import util
    23 from mercurial import util
    23 from mercurial.i18n import _
    24 from mercurial.i18n import _
    24 from mercurial.commands import walkopts, commitopts, commitopts2, logopts
    25 from mercurial.commands import walkopts, commitopts, commitopts2, logopts
    25 from mercurial import hg
    26 from mercurial import hg
    26 
    27 
    67         # commit a new version of the old changeset, including the update
    68         # commit a new version of the old changeset, including the update
    68         # collect all files which might be affected
    69         # collect all files which might be affected
    69         files = set(old.files())
    70         files = set(old.files())
    70         for u in updates:
    71         for u in updates:
    71             files.update(u.files())
    72             files.update(u.files())
       
    73 
       
    74         # Recompute copies (avoid recording a -> b -> a)
       
    75         copied = copies.pathcopies(base, head)
       
    76 
       
    77 
    72         # prune files which were reverted by the updates
    78         # prune files which were reverted by the updates
    73         def samefile(f):
    79         def samefile(f):
    74             if f in head.manifest():
    80             if f in head.manifest():
    75                 a = head.filectx(f)
    81                 a = head.filectx(f)
    76                 if f in base.manifest():
    82                 if f in base.manifest():
    77                     b = base.filectx(f)
    83                     b = base.filectx(f)
    78                     return (a.data() == b.data()
    84                     return (a.data() == b.data()
    79                             and a.flags() == b.flags()
    85                             and a.flags() == b.flags())
    80                             and a.renamed() == b.renamed())
       
    81                 else:
    86                 else:
    82                     return False
    87                     return False
    83             else:
    88             else:
    84                 return f not in base.manifest()
    89                 return f not in base.manifest()
    85         files = [f for f in files if not samefile(f)]
    90         files = [f for f in files if not samefile(f)]
    86         # commit version of these files as defined by head
    91         # commit version of these files as defined by head
    87         headmf = head.manifest()
    92         headmf = head.manifest()
    88         def filectxfn(repo, ctx, path):
    93         def filectxfn(repo, ctx, path):
    89             if path in headmf:
    94             if path in headmf:
    90                 return head.filectx(path)
    95                 fctx = head[path]
       
    96                 flags = fctx.flags()
       
    97                 mctx = context.memfilectx(fctx.path(), fctx.data(),
       
    98                                           islink='l' in flags,
       
    99                                           isexec='x' in flags,
       
   100                                           copied=copied.get(path))
       
   101                 return mctx
    91             raise IOError()
   102             raise IOError()
    92         if commitopts.get('message') and commitopts.get('logfile'):
   103         if commitopts.get('message') and commitopts.get('logfile'):
    93             raise util.Abort(_('options --message and --logfile are mutually'
   104             raise util.Abort(_('options --message and --logfile are mutually'
    94                                ' exclusive'))
   105                                ' exclusive'))
    95         if commitopts.get('logfile'):
   106         if commitopts.get('logfile'):