Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 8813:db3c1ab0e632
commit: recurse into subrepositories
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 15 Jun 2009 02:45:38 -0500 |
parents | 87d1fd40f57e |
children | 9db1c8e1cf17 105343f9f744 |
comparison
equal
deleted
inserted
replaced
8812:859f841937d0 | 8813:db3c1ab0e632 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. | 6 # GNU General Public License version 2, incorporated herein by reference. |
7 | 7 |
8 from node import bin, hex, nullid, nullrev, short | 8 from node import bin, hex, nullid, nullrev, short |
9 from i18n import _ | 9 from i18n import _ |
10 import repo, changegroup | 10 import repo, changegroup, subrepo |
11 import changelog, dirstate, filelog, manifest, context | 11 import changelog, dirstate, filelog, manifest, context |
12 import lock, transaction, store, encoding | 12 import lock, transaction, store, encoding |
13 import util, extensions, hook, error | 13 import util, extensions, hook, error |
14 import match as match_ | 14 import match as match_ |
15 import merge as merge_ | 15 import merge as merge_ |
805 match.bad = fail | 805 match.bad = fail |
806 | 806 |
807 wlock = self.wlock() | 807 wlock = self.wlock() |
808 try: | 808 try: |
809 p1, p2 = self.dirstate.parents() | 809 p1, p2 = self.dirstate.parents() |
810 wctx = self[None] | |
810 | 811 |
811 if (not force and p2 != nullid and match and | 812 if (not force and p2 != nullid and match and |
812 (match.files() or match.anypats())): | 813 (match.files() or match.anypats())): |
813 raise util.Abort(_('cannot partially commit a merge ' | 814 raise util.Abort(_('cannot partially commit a merge ' |
814 '(do not specify files or patterns)')) | 815 '(do not specify files or patterns)')) |
815 | 816 |
816 changes = self.status(match=match, clean=force) | 817 changes = self.status(match=match, clean=force) |
817 if force: | 818 if force: |
818 changes[0].extend(changes[6]) # mq may commit unchanged files | 819 changes[0].extend(changes[6]) # mq may commit unchanged files |
819 | 820 |
821 # check subrepos | |
822 subs = [] | |
823 for s in wctx.substate: | |
824 if match(s) and wctx.sub(s).dirty(): | |
825 subs.append(s) | |
826 if subs and '.hgsubstate' not in changes[0]: | |
827 changes[0].insert(0, '.hgsubstate') | |
828 | |
820 # make sure all explicit patterns are matched | 829 # make sure all explicit patterns are matched |
821 if not force and match.files(): | 830 if not force and match.files(): |
822 matched = set(changes[0] + changes[1] + changes[2]) | 831 matched = set(changes[0] + changes[1] + changes[2]) |
823 | 832 |
824 for f in match.files(): | 833 for f in match.files(): |
825 if f == '.' or f in matched: # matched | 834 if f == '.' or f in matched or f in wctx.substate: |
826 continue | 835 continue |
827 if f in changes[3]: # missing | 836 if f in changes[3]: # missing |
828 fail(f, _('file not found!')) | 837 fail(f, _('file not found!')) |
829 if f in vdirs: # visited directory | 838 if f in vdirs: # visited directory |
830 d = f + '/' | 839 d = f + '/' |
850 | 859 |
851 cctx = context.workingctx(self, (p1, p2), text, user, date, | 860 cctx = context.workingctx(self, (p1, p2), text, user, date, |
852 extra, changes) | 861 extra, changes) |
853 if editor: | 862 if editor: |
854 cctx._text = editor(self, cctx) | 863 cctx._text = editor(self, cctx) |
864 | |
865 # commit subs | |
866 if subs: | |
867 state = wctx.substate.copy() | |
868 for s in subs: | |
869 self.ui.status(_('committing subrepository %s\n') % s) | |
870 sr = wctx.sub(s).commit(cctx._text, user, date) | |
871 state[s] = (state[s][0], sr) | |
872 subrepo.writestate(self, state) | |
873 | |
855 ret = self.commitctx(cctx, True) | 874 ret = self.commitctx(cctx, True) |
856 | 875 |
857 # update dirstate and mergestate | 876 # update dirstate and mergestate |
858 for f in changes[0] + changes[1]: | 877 for f in changes[0] + changes[1]: |
859 self.dirstate.normal(f) | 878 self.dirstate.normal(f) |