##// END OF EJS Templates
merge: add options to warn or ignore on colliding unknown files...
Siddharth Agarwal -
r27657:7b5c8c8a default
parent child Browse files
Show More
@@ -987,6 +987,19 b' proxy.'
987 987 Optional. Always use the proxy, even for localhost and any entries
988 988 in ``http_proxy.no``. (default: False)
989 989
990 ``merge``
991 ---------
992
993 This section specifies behavior during merges and updates.
994
995 ``checkunknown``
996 Controls behavior when an unknown file on disk has the same name as a tracked
997 file in the changeset being merged or updated to, and has different
998 contents. Options are ``abort``, ``warn`` and ``ignore``. With ``abort``,
999 abort on such files. With ``warn``, warn on such files and back them up as
1000 .orig. With ``ignore``, don't print a warning and back them up as
1001 .orig. (default: ``abort``)
1002
990 1003 ``merge-patterns``
991 1004 ------------------
992 1005
@@ -573,6 +573,14 b' def _checkunknownfiles(repo, wctx, mctx,'
573 573 """
574 574 conflicts = set()
575 575 if not force:
576 config = repo.ui.config('merge', 'checkunknown', default='abort')
577 valid = ['abort', 'ignore', 'warn']
578 if config not in valid:
579 validstr = ', '.join(["'" + v + "'" for v in valid])
580 raise error.ConfigError(_("merge.checkunknown not valid "
581 "('%s' is none of %s)")
582 % (config, validstr))
583
576 584 for f, (m, args, msg) in actions.iteritems():
577 585 if m in ('c', 'dc'):
578 586 if _checkunknownfile(repo, wctx, mctx, f):
@@ -581,16 +589,21 b' def _checkunknownfiles(repo, wctx, mctx,'
581 589 if _checkunknownfile(repo, wctx, mctx, f, args[0]):
582 590 conflicts.add(f)
583 591
592 if config == 'abort':
584 593 for f in sorted(conflicts):
585 594 repo.ui.warn(_("%s: untracked file differs\n") % f)
586 595 if conflicts:
587 raise error.Abort(_("untracked files in working directory differ "
588 "from files in requested revision"))
596 raise error.Abort(_("untracked files in working directory "
597 "differ from files in requested revision"))
598 elif config == 'warn':
599 for f in sorted(conflicts):
600 repo.ui.warn(_("%s: replacing untracked file\n") % f)
589 601
590 602 for f, (m, args, msg) in actions.iteritems():
603 backup = f in conflicts
591 604 if m == 'c':
592 605 flags, = args
593 actions[f] = ('g', (flags, False), msg)
606 actions[f] = ('g', (flags, backup), msg)
594 607 elif m == 'cm':
595 608 fl2, anc = args
596 609 different = _checkunknownfile(repo, wctx, mctx, f)
@@ -598,7 +611,7 b' def _checkunknownfiles(repo, wctx, mctx,'
598 611 actions[f] = ('m', (f, f, None, False, anc),
599 612 "remote differs from untracked local")
600 613 else:
601 actions[f] = ('g', (fl2, False), "remote created")
614 actions[f] = ('g', (fl2, backup), "remote created")
602 615
603 616 def _forgetremoved(wctx, mctx, branchmerge):
604 617 """
@@ -124,7 +124,43 b" symlinks shouldn't be followed"
124 124 $ echo This is file b2 > b
125 125 #endif
126 126
127 merge of b expected
127 bad config
128 $ hg merge 1 --config merge.checkunknown=x
129 abort: merge.checkunknown not valid ('x' is none of 'abort', 'ignore', 'warn')
130 [255]
131 this merge should fail
132 $ hg merge 1 --config merge.checkunknown=abort
133 b: untracked file differs
134 abort: untracked files in working directory differ from files in requested revision
135 [255]
136
137 this merge should warn
138 $ hg merge 1 --config merge.checkunknown=warn
139 b: replacing untracked file
140 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 (branch merge, don't forget to commit)
142 $ cat b.orig
143 This is file b2
144 $ hg up --clean 2
145 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
146 $ mv b.orig b
147
148 this merge should silently ignore
149 $ cat b
150 This is file b2
151 $ hg merge 1 --config merge.checkunknown=ignore
152 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
153 (branch merge, don't forget to commit)
154
155 $ cat b.orig
156 This is file b2
157 $ hg up --clean 2
158 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
159 $ mv b.orig b
160
161 this merge of b should work
162 $ cat b
163 This is file b2
128 164 $ hg merge -f 1
129 165 merging b
130 166 merging for b
General Comments 0
You need to be logged in to leave comments. Login now