##// END OF EJS Templates
commit: propagate --addremove to subrepos if -S is specified (issue3759)...
Matt Harbison -
r23537:f1b06a8a default
parent child Browse files
Show More
@@ -95,7 +95,7 b' def perfaddremove(ui, repo):'
95 oldquiet = repo.ui.quiet
95 oldquiet = repo.ui.quiet
96 repo.ui.quiet = True
96 repo.ui.quiet = True
97 matcher = scmutil.match(repo[None])
97 matcher = scmutil.match(repo[None])
98 timer(lambda: scmutil.addremove(repo, matcher, dry_run=True))
98 timer(lambda: scmutil.addremove(repo, matcher, "", dry_run=True))
99 finally:
99 finally:
100 repo.ui.quiet = oldquiet
100 repo.ui.quiet = oldquiet
101 fm.end()
101 fm.end()
@@ -1084,10 +1084,10 b' def overridesummary(orig, ui, repo, *pat'
1084 finally:
1084 finally:
1085 repo.lfstatus = False
1085 repo.lfstatus = False
1086
1086
1087 def scmutiladdremove(orig, repo, matcher, opts={}, dry_run=None,
1087 def scmutiladdremove(orig, repo, matcher, prefix, opts={}, dry_run=None,
1088 similarity=None):
1088 similarity=None):
1089 if not lfutil.islfilesrepo(repo):
1089 if not lfutil.islfilesrepo(repo):
1090 return orig(repo, matcher, opts, dry_run, similarity)
1090 return orig(repo, matcher, prefix, opts, dry_run, similarity)
1091 # Get the list of missing largefiles so we can remove them
1091 # Get the list of missing largefiles so we can remove them
1092 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1092 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1093 unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
1093 unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
@@ -1107,7 +1107,7 b' def scmutiladdremove(orig, repo, matcher'
1107 # function to take care of the rest. Make sure it doesn't do anything with
1107 # function to take care of the rest. Make sure it doesn't do anything with
1108 # largefiles by passing a matcher that will ignore them.
1108 # largefiles by passing a matcher that will ignore them.
1109 matcher = composenormalfilematcher(matcher, repo[None].manifest())
1109 matcher = composenormalfilematcher(matcher, repo[None].manifest())
1110 return orig(repo, matcher, opts, dry_run, similarity)
1110 return orig(repo, matcher, prefix, opts, dry_run, similarity)
1111
1111
1112 # Calling purge with --all will cause the largefiles to be deleted.
1112 # Calling purge with --all will cause the largefiles to be deleted.
1113 # Override repo.status to prevent this from happening.
1113 # Override repo.status to prevent this from happening.
@@ -2202,7 +2202,7 b' def commit(ui, repo, commitfunc, pats, o'
2202 # extract addremove carefully -- this function can be called from a command
2202 # extract addremove carefully -- this function can be called from a command
2203 # that doesn't support addremove
2203 # that doesn't support addremove
2204 if opts.get('addremove'):
2204 if opts.get('addremove'):
2205 if scmutil.addremove(repo, matcher, opts) != 0:
2205 if scmutil.addremove(repo, matcher, "", opts) != 0:
2206 raise util.Abort(
2206 raise util.Abort(
2207 _("failed to mark all new/missing files as added/removed"))
2207 _("failed to mark all new/missing files as added/removed"))
2208
2208
@@ -236,7 +236,7 b' def addremove(ui, repo, *pats, **opts):'
236 if sim < 0 or sim > 100:
236 if sim < 0 or sim > 100:
237 raise util.Abort(_('similarity must be between 0 and 100'))
237 raise util.Abort(_('similarity must be between 0 and 100'))
238 matcher = scmutil.match(repo[None], pats, opts)
238 matcher = scmutil.match(repo[None], pats, opts)
239 return scmutil.addremove(repo, matcher, opts, similarity=sim / 100.0)
239 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
240
240
241 @command('^annotate|blame',
241 @command('^annotate|blame',
242 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
242 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
@@ -94,7 +94,9 b' Interaction with Mercurial Commands'
94 -S/--subrepos, or setting "ui.commitsubrepos=True" in a
94 -S/--subrepos, or setting "ui.commitsubrepos=True" in a
95 configuration file (see :hg:`help config`). After there are no
95 configuration file (see :hg:`help config`). After there are no
96 longer any modified subrepositories, it records their state and
96 longer any modified subrepositories, it records their state and
97 finally commits it in the parent repository.
97 finally commits it in the parent repository. The --addremove
98 option also honors the -S/--subrepos option. However, Git and
99 Subversion subrepositories will print a warning and abort.
98
100
99 :diff: diff does not recurse in subrepos unless -S/--subrepos is
101 :diff: diff does not recurse in subrepos unless -S/--subrepos is
100 specified. Changes are displayed as usual, on the subrepositories
102 specified. Changes are displayed as usual, on the subrepositories
@@ -713,13 +713,28 b' def matchfiles(repo, files):'
713 '''Return a matcher that will efficiently match exactly these files.'''
713 '''Return a matcher that will efficiently match exactly these files.'''
714 return matchmod.exact(repo.root, repo.getcwd(), files)
714 return matchmod.exact(repo.root, repo.getcwd(), files)
715
715
716 def addremove(repo, matcher, opts={}, dry_run=None, similarity=None):
716 def addremove(repo, matcher, prefix, opts={}, dry_run=None, similarity=None):
717 m = matcher
717 m = matcher
718 if dry_run is None:
718 if dry_run is None:
719 dry_run = opts.get('dry_run')
719 dry_run = opts.get('dry_run')
720 if similarity is None:
720 if similarity is None:
721 similarity = float(opts.get('similarity') or 0)
721 similarity = float(opts.get('similarity') or 0)
722
722
723 ret = 0
724 join = lambda f: os.path.join(prefix, f)
725
726 wctx = repo[None]
727 for subpath in sorted(wctx.substate):
728 if opts.get('subrepos'):
729 sub = wctx.sub(subpath)
730 try:
731 submatch = matchmod.narrowmatcher(subpath, m)
732 if sub.addremove(submatch, prefix, opts, dry_run, similarity):
733 ret = 1
734 except error.LookupError:
735 repo.ui.status(_("skipping missing subrepository: %s\n")
736 % join(subpath))
737
723 rejected = []
738 rejected = []
724 origbad = m.bad
739 origbad = m.bad
725 def badfn(f, msg):
740 def badfn(f, msg):
@@ -737,9 +752,9 b' def addremove(repo, matcher, opts={}, dr'
737 for abs in sorted(toprint):
752 for abs in sorted(toprint):
738 if repo.ui.verbose or not m.exact(abs):
753 if repo.ui.verbose or not m.exact(abs):
739 if abs in unknownset:
754 if abs in unknownset:
740 status = _('adding %s\n') % m.uipath(abs)
755 status = _('adding %s\n') % m.uipath(join(abs))
741 else:
756 else:
742 status = _('removing %s\n') % m.uipath(abs)
757 status = _('removing %s\n') % m.uipath(join(abs))
743 repo.ui.status(status)
758 repo.ui.status(status)
744
759
745 renames = _findrenames(repo, m, added + unknown, removed + deleted,
760 renames = _findrenames(repo, m, added + unknown, removed + deleted,
@@ -751,7 +766,7 b' def addremove(repo, matcher, opts={}, dr'
751 for f in rejected:
766 for f in rejected:
752 if f in m.files():
767 if f in m.files():
753 return 1
768 return 1
754 return 0
769 return ret
755
770
756 def marktouched(repo, files, similarity=0.0):
771 def marktouched(repo, files, similarity=0.0):
757 '''Assert that files have somehow been operated upon. files are relative to
772 '''Assert that files have somehow been operated upon. files are relative to
@@ -437,6 +437,10 b' class abstractsubrepo(object):'
437 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly):
437 def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly):
438 return []
438 return []
439
439
440 def addremove(self, matcher, prefix, opts, dry_run, similarity):
441 self._ui.warn("%s: %s" % (prefix, _("addremove is not supported")))
442 return 1
443
440 def cat(self, ui, match, prefix, **opts):
444 def cat(self, ui, match, prefix, **opts):
441 return 1
445 return 1
442
446
@@ -619,6 +623,11 b' class hgsubrepo(abstractsubrepo):'
619 return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos,
623 return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos,
620 os.path.join(prefix, self._path), explicitonly)
624 os.path.join(prefix, self._path), explicitonly)
621
625
626 def addremove(self, m, prefix, opts, dry_run, similarity):
627 return scmutil.addremove(self._repo, m,
628 os.path.join(prefix, self._path), opts,
629 dry_run, similarity)
630
622 @annotatesubrepoerror
631 @annotatesubrepoerror
623 def cat(self, ui, match, prefix, **opts):
632 def cat(self, ui, match, prefix, **opts):
624 rev = self._state[1]
633 rev = self._state[1]
@@ -106,8 +106,8 b' Check that deep archiving works'
106 $ hg --config extensions.largefiles=! add sub1/sub2/test.txt
106 $ hg --config extensions.largefiles=! add sub1/sub2/test.txt
107 $ mkdir sub1/sub2/folder
107 $ mkdir sub1/sub2/folder
108 $ echo 'subfolder' > sub1/sub2/folder/test.txt
108 $ echo 'subfolder' > sub1/sub2/folder/test.txt
109 $ hg --config extensions.largefiles=! add sub1/sub2/folder/test.txt
109 $ hg ci -ASm "add test.txt"
110 $ hg ci -Sm "add test.txt"
110 adding sub1/sub2/folder/test.txt (glob)
111 committing subrepository sub1
111 committing subrepository sub1
112 committing subrepository sub1/sub2 (glob)
112 committing subrepository sub1/sub2 (glob)
113
113
@@ -128,6 +128,15 b' Check that deep archiving works'
128 R sub1/.hgsubstate
128 R sub1/.hgsubstate
129 R sub1/sub2/folder/test.txt
129 R sub1/sub2/folder/test.txt
130 $ hg update -Cq
130 $ hg update -Cq
131 $ rm sub1/sub2/folder/test.txt
132 $ rm sub1/sub2/test.txt
133 $ hg ci -ASm "remove test.txt"
134 removing sub1/sub2/folder/test.txt (glob)
135 removing sub1/sub2/test.txt (glob)
136 committing subrepository sub1
137 committing subrepository sub1/sub2 (glob)
138 $ hg rollback -q
139 $ hg up -Cq
131
140
132 $ hg --config extensions.largefiles=! archive -S ../archive_all
141 $ hg --config extensions.largefiles=! archive -S ../archive_all
133 $ find ../archive_all | sort
142 $ find ../archive_all | sort
General Comments 0
You need to be logged in to leave comments. Login now