##// END OF EJS Templates
cmdutil: extract samefile function from amend()
Hannes Oldenburg -
r29819:2cec6eaf default
parent child Browse files
Show More
@@ -2604,6 +2604,18 def commit(ui, repo, commitfunc, pats, o
2604
2604
2605 return commitfunc(ui, repo, message, matcher, opts)
2605 return commitfunc(ui, repo, message, matcher, opts)
2606
2606
2607 def samefile(f, ctx1, ctx2):
2608 if f in ctx1.manifest():
2609 a = ctx1.filectx(f)
2610 if f in ctx2.manifest():
2611 b = ctx2.filectx(f)
2612 return (not a.cmp(b)
2613 and a.flags() == b.flags())
2614 else:
2615 return False
2616 else:
2617 return f not in ctx2.manifest()
2618
2607 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2619 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2608 # avoid cycle context -> subrepo -> cmdutil
2620 # avoid cycle context -> subrepo -> cmdutil
2609 from . import context
2621 from . import context
@@ -2687,19 +2699,7 def amend(ui, repo, commitfunc, old, ext
2687 # we can discard X from our list of files. Likewise if X
2699 # we can discard X from our list of files. Likewise if X
2688 # was deleted, it's no longer relevant
2700 # was deleted, it's no longer relevant
2689 files.update(ctx.files())
2701 files.update(ctx.files())
2690
2702 files = [f for f in files if not samefile(f, ctx, base)]
2691 def samefile(f):
2692 if f in ctx.manifest():
2693 a = ctx.filectx(f)
2694 if f in base.manifest():
2695 b = base.filectx(f)
2696 return (not a.cmp(b)
2697 and a.flags() == b.flags())
2698 else:
2699 return False
2700 else:
2701 return f not in base.manifest()
2702 files = [f for f in files if not samefile(f)]
2703
2703
2704 def filectxfn(repo, ctx_, path):
2704 def filectxfn(repo, ctx_, path):
2705 try:
2705 try:
General Comments 0
You need to be logged in to leave comments. Login now