Mercurial > hg
annotate mercurial/subrepo.py @ 35169:898c6f812a51 stable
fancyopts: add early-options parser compatible with getopt()
The next patch will add a flag for strict parsing of early options, where
we'll have to parse all early options at once instead of processing them
one-by-one by dispatch._earlygetopt(). That's why I decided to hook
fancyopts().
All dispatch._early*opt() functions is planned to be replaced with this
function. But in this stable series, only the strict mode will be handled
by fancyopts.earlygetopt().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 23 Nov 2017 22:04:53 +0900 |
parents | 5c6b96b832c2 |
children | ee64e677c3cf |
rev | line source |
---|---|
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # subrepo.py - sub-repository handling for Mercurial |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
10324
55d134ef8ab7
subrepo: correct copyright
David Soria Parra <dsp@php.net>
parents:
10299
diff
changeset
|
3 # Copyright 2009-2010 Matt Mackall <mpm@selenic.com> |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
10263 | 6 # GNU General Public License version 2 or any later version. |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
8 from __future__ import absolute_import |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
9 |
23540
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
10 import copy |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
11 import errno |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29243
diff
changeset
|
12 import hashlib |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
13 import os |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
14 import posixpath |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
15 import re |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
16 import stat |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
17 import subprocess |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
18 import sys |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
19 import tarfile |
19788
c26690fe5f08
subrepo: move import of xml.minidom.dom to its own line for check-code
Augie Fackler <raf@durin42.com>
parents:
19637
diff
changeset
|
20 import xml.dom.minidom |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
21 |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
22 |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
23 from .i18n import _ |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
24 from . import ( |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
25 cmdutil, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
26 config, |
30635
a150173da1c1
py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30615
diff
changeset
|
27 encoding, |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
28 error, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
29 exchange, |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
30 filemerge, |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
31 match as matchmod, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
32 node, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
33 pathutil, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
34 phases, |
30615
bb77654dc7ae
py3: replace os.sep with pycompat.ossep (part 3 of 4)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30060
diff
changeset
|
35 pycompat, |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
36 scmutil, |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
37 util, |
31236
8a0687a2be75
vfs: use 'vfs' module directly in 'mercurial.subrepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31102
diff
changeset
|
38 vfs as vfsmod, |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
39 ) |
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
40 |
9092
9aebeea7ac00
subrepo: use hg.repository instead of creating localrepo directly
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
9049
diff
changeset
|
41 hg = None |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
42 propertycache = util.propertycache |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
43 |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
44 nullstate = ('', '', 'empty') |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
45 |
18940
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
46 def _expandedabspath(path): |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
47 ''' |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
48 get a path or url and if it is a path expand it and return an absolute path |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
49 ''' |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
50 expandedpath = util.urllocalpath(util.expandpath(path)) |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
51 u = util.url(expandedpath) |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
52 if not u.scheme: |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
53 path = util.normpath(os.path.abspath(u.path)) |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
54 return path |
18936
1fa4edb8456e
subrepo: introduce storeclean helper functions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18851
diff
changeset
|
55 |
1fa4edb8456e
subrepo: introduce storeclean helper functions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18851
diff
changeset
|
56 def _getstorehashcachename(remotepath): |
1fa4edb8456e
subrepo: introduce storeclean helper functions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18851
diff
changeset
|
57 '''get a unique filename for the store hash cache of a remote repository''' |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29243
diff
changeset
|
58 return hashlib.sha1(_expandedabspath(remotepath)).hexdigest()[0:12] |
18936
1fa4edb8456e
subrepo: introduce storeclean helper functions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18851
diff
changeset
|
59 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
60 class SubrepoAbort(error.Abort): |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
61 """Exception class used to avoid handling a subrepo error more than once""" |
18263
9aa6bee6e9f9
subrepo: add subrepo property to SubrepoAbort exceptions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18109
diff
changeset
|
62 def __init__(self, *args, **kw): |
29510
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29389
diff
changeset
|
63 self.subrepo = kw.pop('subrepo', None) |
19205a0e2bf1
error: make hintable exceptions reject unknown keyword arguments (API)
Yuya Nishihara <yuya@tcha.org>
parents:
29389
diff
changeset
|
64 self.cause = kw.pop('cause', None) |
18296
a74101cd6965
subrepo: fix python2.4 compatibility after 9aa6bee6e9f9
Brendan Cully <brendan@kublai.com>
parents:
18263
diff
changeset
|
65 error.Abort.__init__(self, *args, **kw) |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
66 |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
67 def annotatesubrepoerror(func): |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
68 def decoratedmethod(self, *args, **kargs): |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
69 try: |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
70 res = func(self, *args, **kargs) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
71 except SubrepoAbort as ex: |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
72 # This exception has already been handled |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
73 raise ex |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
74 except error.Abort as ex: |
18263
9aa6bee6e9f9
subrepo: add subrepo property to SubrepoAbort exceptions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18109
diff
changeset
|
75 subrepo = subrelpath(self) |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
76 errormsg = str(ex) + ' ' + _('(in subrepository "%s")') % subrepo |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
77 # avoid handling this exception by raising a SubrepoAbort exception |
18964
ca480d710fe6
subrepo: chain the original exception to SubrepoAbort
Matt Harbison <matt_harbison@yahoo.com>
parents:
18943
diff
changeset
|
78 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo, |
ca480d710fe6
subrepo: chain the original exception to SubrepoAbort
Matt Harbison <matt_harbison@yahoo.com>
parents:
18943
diff
changeset
|
79 cause=sys.exc_info()) |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
80 return res |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
81 return decoratedmethod |
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
82 |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
83 def state(ctx, ui): |
11571 | 84 """return a state dict, mapping subrepo paths configured in .hgsub |
85 to tuple: (source from .hgsub, revision from .hgsubstate, kind | |
86 (key in types dict)) | |
87 """ | |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
88 p = config.config() |
25768
7a9ef8608a1d
subrepo: prefetch ctx.repo() for efficiency and centralization
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25660
diff
changeset
|
89 repo = ctx.repo() |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
90 def read(f, sections=None, remap=None): |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 if f in ctx: |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
92 try: |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
93 data = ctx[f].data() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
94 except IOError as err: |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
95 if err.errno != errno.ENOENT: |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
96 raise |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
97 # handle missing subrepo spec files as removed |
24645
b39afa36006a
subrepo: precisely identify the missing subrepo spec file
Matt Harbison <matt_harbison@yahoo.com>
parents:
24471
diff
changeset
|
98 ui.warn(_("warning: subrepo spec file \'%s\' not found\n") % |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
99 repo.pathto(f)) |
13017
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
100 return |
d0e21c5fde41
subrepo: handle missing subrepo spec file as removed
Patrick Mezard <pmezard@gmail.com>
parents:
13015
diff
changeset
|
101 p.parse(f, data, sections, remap, read) |
10174
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
102 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
103 raise error.Abort(_("subrepo spec file \'%s\' not found") % |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
104 repo.pathto(f)) |
10174
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
105 if '.hgsub' in ctx: |
65b6dc44cdbf
subrepo: fix includes support in .hgsub
Matt Mackall <mpm@selenic.com>
parents:
10069
diff
changeset
|
106 read('.hgsub') |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
108 for path, src in ui.configitems('subpaths'): |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
109 p.set('subpaths', path, src, ui.configsource('subpaths', path)) |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
110 |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 rev = {} |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 if '.hgsubstate' in ctx: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
113 try: |
16596
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
114 for i, l in enumerate(ctx['.hgsubstate'].data().splitlines()): |
16595
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
115 l = l.lstrip() |
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
116 if not l: |
2de6ac4ac17c
subrepo: ignore blank lines in .hgsubstate (issue3424)
Patrick Mezard <patrick@mezard.eu>
parents:
16555
diff
changeset
|
117 continue |
16596
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
118 try: |
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
119 revision, path = l.split(" ", 1) |
95ca6c8b38da
subrepo: do not traceback on .hgsubstate parsing errors
Patrick Mezard <patrick@mezard.eu>
parents:
16595
diff
changeset
|
120 except ValueError: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
121 raise error.Abort(_("invalid subrepository revision " |
24645
b39afa36006a
subrepo: precisely identify the missing subrepo spec file
Matt Harbison <matt_harbison@yahoo.com>
parents:
24471
diff
changeset
|
122 "specifier in \'%s\' line %d") |
25769
2538b87660be
subrepo: use repo.pathto instead of util.pathto to simplify invocation
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25768
diff
changeset
|
123 % (repo.pathto('.hgsubstate'), (i + 1))) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
124 rev[path] = revision |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
125 except IOError as err: |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
126 if err.errno != errno.ENOENT: |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
127 raise |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
128 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
129 def remap(src): |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
130 for pattern, repl in p.items('subpaths'): |
11961
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
131 # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
132 # does a string decode. |
31451
53865692a354
util: wrap s.encode('string_escape') call for future py3 compatibility
Yuya Nishihara <yuya@tcha.org>
parents:
31325
diff
changeset
|
133 repl = util.escapestr(repl) |
11961
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
134 # However, we still want to allow back references to go |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
135 # through unharmed, so we turn r'\\1' into r'\1'. Again, |
f3075ffa6b30
subrepos: handle backslashes in subpaths
Martin Geisler <mg@lazybytes.net>
parents:
11775
diff
changeset
|
136 # extra escapes are needed because re.sub string decodes. |
34068
6d21737c35bf
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org>
parents:
34022
diff
changeset
|
137 repl = re.sub(br'\\\\([0-9]+)', br'\\\1', repl) |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
138 try: |
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
139 src = re.sub(pattern, repl, src, 1) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
140 except re.error as e: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
141 raise error.Abort(_("bad subrepository pattern in %s: %s") |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
142 % (p.source('subpaths', pattern), e)) |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
143 return src |
11775
a8614c5a5e9a
subrepos: support remapping of .hgsub source paths
Martin Geisler <mg@lazybytes.net>
parents:
11572
diff
changeset
|
144 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
145 state = {} |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
146 for path, src in p[''].items(): |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
147 kind = 'hg' |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
148 if src.startswith('['): |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
149 if ']' not in src: |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
150 raise error.Abort(_('missing ] in subrepository source')) |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
151 kind, src = src.split(']', 1) |
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
152 kind = kind[1:] |
15150
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
153 src = src.lstrip() # strip any extra whitespace after ']' |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
154 |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
155 if not util.url(src).isabs(): |
25768
7a9ef8608a1d
subrepo: prefetch ctx.repo() for efficiency and centralization
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25660
diff
changeset
|
156 parent = _abssource(repo, abort=False) |
15150
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
157 if parent: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
158 parent = util.url(parent) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
159 parent.path = posixpath.join(parent.path or '', src) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
160 parent.path = posixpath.normpath(parent.path) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
161 joined = str(parent) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
162 # Remap the full joined path and use it if it changes, |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
163 # else remap the original source. |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
164 remapped = remap(joined) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
165 if remapped == joined: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
166 src = remap(src) |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
167 else: |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
168 src = remapped |
91dc8878f888
subrepo: try remapping subpaths using the "final" path
Martin Geisler <mg@aragost.com>
parents:
15149
diff
changeset
|
169 |
15149
eaec9cf91aea
subrepo: refactor state function
Martin Geisler <mg@aragost.com>
parents:
15061
diff
changeset
|
170 src = remap(src) |
15723
1581da01d5c4
windows: use normalized path as path to subrepo
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15531
diff
changeset
|
171 state[util.pconvert(path)] = (src.strip(), rev.get(path, ''), kind) |
8812
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
172 |
859f841937d0
subrepo: introduce basic state parsing
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
173 return state |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
174 |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
175 def writestate(repo, state): |
11571 | 176 """rewrite .hgsubstate in (outer) repo with these subrepo states""" |
24858
a99931201d1b
subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24786
diff
changeset
|
177 lines = ['%s %s\n' % (state[s][1], s) for s in sorted(state) |
a99931201d1b
subrepo: don't write .hgsubstate lines with empty subrepo state (issue4622)
Matt Harbison <matt_harbison@yahoo.com>
parents:
24786
diff
changeset
|
178 if state[s][1] != nullstate[1]] |
14443
6fe6defdc924
subrepo: refactor writestate for clarity
Martin Geisler <mg@aragost.com>
parents:
14440
diff
changeset
|
179 repo.wwrite('.hgsubstate', ''.join(lines), '') |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
180 |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
181 def submerge(repo, wctx, mctx, actx, overwrite, labels=None): |
11571 | 182 """delegated from merge.applyupdates: merging of .hgsubstate file |
183 in working context, merging context and ancestor context""" | |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
184 if mctx == actx: # backwards? |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
185 actx = wctx.p1() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
186 s1 = wctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
187 s2 = mctx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
188 sa = actx.substate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
189 sm = {} |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
190 |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
191 repo.ui.debug("subrepo merge %s %s %s\n" % (wctx, mctx, actx)) |
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
192 |
9779
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
193 def debug(s, msg, r=""): |
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
194 if r: |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
195 r = "%s:%s:%s" % r |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
196 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r)) |
9779
58a6f3f4d553
subrepo: add some debug output to submerge
Matt Mackall <mpm@selenic.com>
parents:
9752
diff
changeset
|
197 |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
198 promptssrc = filemerge.partextras(labels) |
18364
6252b4f1c4b4
subrepos: process subrepos in sorted order
Mads Kiilerich <mads@kiilerich.com>
parents:
18297
diff
changeset
|
199 for s, l in sorted(s1.iteritems()): |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
200 prompts = None |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
201 a = sa.get(s, nullstate) |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
202 ld = l # local state with possible dirty flag for compares |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
203 if wctx.sub(s).dirty(): |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
204 ld = (l[0], l[1] + "+") |
11470
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
205 if wctx == actx: # overwrite |
34e33d50c26b
subrepo: correctly handle update -C with modified subrepos (issue2022)
Matt Mackall <mpm@selenic.com>
parents:
11463
diff
changeset
|
206 a = ld |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
207 |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
208 prompts = promptssrc.copy() |
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
209 prompts['s'] = s |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
210 if s in s2: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
211 r = s2[s] |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
212 if ld == r or r == a: # no change or local is newer |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
213 sm[s] = l |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
214 continue |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
215 elif ld == a: # other side changed |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
216 debug(s, "other changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
217 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
218 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
219 elif ld[0] != r[0]: # sources differ |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
220 prompts['lo'] = l[0] |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
221 prompts['ro'] = r[0] |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
222 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
223 _(' subrepository sources for %(s)s differ\n' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
224 'use (l)ocal%(l)s source (%(lo)s)' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
225 ' or (r)emote%(o)s source (%(ro)s)?' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
226 '$$ &Local $$ &Remote') % prompts, 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
227 debug(s, "prompt changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
228 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
229 sm[s] = r |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
230 elif ld[1] == a[1]: # local side is unchanged |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
231 debug(s, "other side changed, get", r) |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
232 wctx.sub(s).get(r, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
233 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
234 else: |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
235 debug(s, "both sides changed") |
21401
2c364f7801c8
subrepo: use subrepo shortid method to generate subrepo diverged promptchoice
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21400
diff
changeset
|
236 srepo = wctx.sub(s) |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
237 prompts['sl'] = srepo.shortid(l[1]) |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
238 prompts['sr'] = srepo.shortid(r[1]) |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
239 option = repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
240 _(' subrepository %(s)s diverged (local revision: %(sl)s, ' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
241 'remote revision: %(sr)s)\n' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
242 '(M)erge, keep (l)ocal%(l)s or keep (r)emote%(o)s?' |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
243 '$$ &Merge $$ &Local $$ &Remote') |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
244 % prompts, 0) |
19811
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
245 if option == 0: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
246 wctx.sub(s).merge(r) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
247 sm[s] = l |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
248 debug(s, "merge with", r) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
249 elif option == 1: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
250 sm[s] = l |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
251 debug(s, "keep local subrepo revision", l) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
252 else: |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
253 wctx.sub(s).get(r, overwrite) |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
254 sm[s] = r |
5e10d41e7b9c
merge: let the user choose to merge, keep local or keep remote subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19788
diff
changeset
|
255 debug(s, "get remote subrepo revision", r) |
11463
f0ea93557133
subrepo: fix recording of + in .hgsubstate (issue2217)
Matt Mackall <mpm@selenic.com>
parents:
11455
diff
changeset
|
256 elif ld == a: # remote removed, local unchanged |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
257 debug(s, "remote removed, remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
258 wctx.sub(s).remove() |
14417
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
259 elif a == nullstate: # not present in remote or ancestor |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
260 debug(s, "local added, keep") |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
261 sm[s] = l |
25137d99a5ed
subrepo: handle local added subrepo case correctly
Matt Mackall <mpm@selenic.com>
parents:
14316
diff
changeset
|
262 continue |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
263 else: |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
264 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
265 _(' local%(l)s changed subrepository %(s)s' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
266 ' which remote%(o)s removed\n' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
267 'use (c)hanged version or (d)elete?' |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
268 '$$ &Changed $$ &Delete') % prompts, 0): |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
269 debug(s, "prompt remove") |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
270 wctx.sub(s).remove() |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
271 |
13857
ba1f98f877ec
subrepo: process merge substate in sorted order in submerge()
Adrian Buehlmann <adrian@cadifra.com>
parents:
13771
diff
changeset
|
272 for s, r in sorted(s2.items()): |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
273 prompts = None |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
274 if s in s1: |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
275 continue |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
276 elif s not in sa: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
277 debug(s, "remote added, get", r) |
10175
fc32b2fc468e
subrepo: load from a context where the subrepo exists
Augie Fackler <durin42@gmail.com>
parents:
10174
diff
changeset
|
278 mctx.sub(s).get(r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
279 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
280 elif r != sa[s]: |
31516
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
281 prompts = promptssrc.copy() |
2915cc1d3429
subrepo: move prompts out of the if (issue5505)
Simon Farnsworth <simonfar@fb.com>
parents:
30755
diff
changeset
|
282 prompts['s'] = s |
9048
86b4a9b0ddda
ui: extract choice from prompt
Simon Heimberg <simohe@besonet.ch>
parents:
8997
diff
changeset
|
283 if repo.ui.promptchoice( |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
284 _(' remote%(o)s changed subrepository %(s)s' |
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
285 ' which local%(l)s removed\n' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
286 'use (c)hanged version or (d)elete?' |
30060
a145161debed
merge: use labels in subrepo merge
Simon Farnsworth <simonfar@fb.com>
parents:
29510
diff
changeset
|
287 '$$ &Changed $$ &Delete') % prompts, 0) == 0: |
9782
c1c40511c276
subrepo: add more debugging output, lose _ markers
Matt Mackall <mpm@selenic.com>
parents:
9781
diff
changeset
|
288 debug(s, "prompt recreate", r) |
24110
756c5c8331b0
subrepo: add tests for change/remove conflicts
Martin von Zweigbergk <martinvonz@google.com>
parents:
23963
diff
changeset
|
289 mctx.sub(s).get(r) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
290 sm[s] = r |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
291 |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
292 # record merged .hgsubstate |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
293 writestate(repo, sm) |
19637
cc338115d3b2
subrepo: make submerge() return the merged substate
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
19226
diff
changeset
|
294 return sm |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
295 |
35025
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
296 def precommit(ui, wctx, status, match, force=False): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
297 """Calculate .hgsubstate changes that should be applied before committing |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
298 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
299 Returns (subs, commitsubs, newstate) where |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
300 - subs: changed subrepos (including dirty ones) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
301 - commitsubs: dirty subrepos which the caller needs to commit recursively |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
302 - newstate: new state dict which the caller must write to .hgsubstate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
303 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
304 This also updates the given status argument. |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
305 """ |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
306 subs = [] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
307 commitsubs = set() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
308 newstate = wctx.substate.copy() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
309 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
310 # only manage subrepos and .hgsubstate if .hgsub is present |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
311 if '.hgsub' in wctx: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
312 # we'll decide whether to track this ourselves, thanks |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
313 for c in status.modified, status.added, status.removed: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
314 if '.hgsubstate' in c: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
315 c.remove('.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
316 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
317 # compare current state to last committed state |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
318 # build new substate based on last committed state |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
319 oldstate = wctx.p1().substate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
320 for s in sorted(newstate.keys()): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
321 if not match(s): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
322 # ignore working copy, use old state if present |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
323 if s in oldstate: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
324 newstate[s] = oldstate[s] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
325 continue |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
326 if not force: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
327 raise error.Abort( |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
328 _("commit with new subrepo %s excluded") % s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
329 dirtyreason = wctx.sub(s).dirtyreason(True) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
330 if dirtyreason: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
331 if not ui.configbool('ui', 'commitsubrepos'): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
332 raise error.Abort(dirtyreason, |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
333 hint=_("use --subrepos for recursive commit")) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
334 subs.append(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
335 commitsubs.add(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
336 else: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
337 bs = wctx.sub(s).basestate() |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
338 newstate[s] = (newstate[s][0], bs, newstate[s][2]) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
339 if oldstate.get(s, (None, None, None))[1] != bs: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
340 subs.append(s) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
341 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
342 # check for removed subrepos |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
343 for p in wctx.parents(): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
344 r = [s for s in p.substate if s not in newstate] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
345 subs += [s for s in r if match(s)] |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
346 if subs: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
347 if (not match('.hgsub') and |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
348 '.hgsub' in (wctx.modified() + wctx.added())): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
349 raise error.Abort(_("can't commit subrepos without .hgsub")) |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
350 status.modified.insert(0, '.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
351 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
352 elif '.hgsub' in status.removed: |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
353 # clean up .hgsubstate when .hgsub is removed |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
354 if ('.hgsubstate' in wctx and |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
355 '.hgsubstate' not in (status.modified + status.added + |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
356 status.removed)): |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
357 status.removed.insert(0, '.hgsubstate') |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
358 |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
359 return subs, commitsubs, newstate |
5c6b96b832c2
subrepo: extract preprocess of repo.commit() to free function
Yuya Nishihara <yuya@tcha.org>
parents:
34989
diff
changeset
|
360 |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
361 def _updateprompt(ui, sub, dirty, local, remote): |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
362 if dirty: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
363 msg = (_(' subrepository sources for %s differ\n' |
22590
d4c972b97fee
subrepo: remove superfluous newline from subrepo prompt
Mads Kiilerich <madski@unity3d.com>
parents:
21891
diff
changeset
|
364 'use (l)ocal source (%s) or (r)emote source (%s)?' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
365 '$$ &Local $$ &Remote') |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
366 % (subrelpath(sub), local, remote)) |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
367 else: |
16683 | 368 msg = (_(' subrepository sources for %s differ (in checked out ' |
369 'version)\n' | |
22590
d4c972b97fee
subrepo: remove superfluous newline from subrepo prompt
Mads Kiilerich <madski@unity3d.com>
parents:
21891
diff
changeset
|
370 'use (l)ocal source (%s) or (r)emote source (%s)?' |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
371 '$$ &Local $$ &Remote') |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
372 % (subrelpath(sub), local, remote)) |
19226
c58b6ab4c26f
ui: merge prompt text components into a singe string
Matt Mackall <mpm@selenic.com>
parents:
19156
diff
changeset
|
373 return ui.promptchoice(msg, 0) |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
374 |
24785
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
375 def reporelpath(repo): |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
376 """return path to this (sub)repo as seen from outermost repo""" |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
377 parent = repo |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
378 while util.safehasattr(parent, '_subparent'): |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
379 parent = parent._subparent |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
380 return repo.root[len(pathutil.normasprefix(parent.root)):] |
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
381 |
12752
18b5b6392fcf
subrepo: rename relpath to subrelpath and introduce reporelpath
Mads Kiilerich <mads@kiilerich.com>
parents:
12506
diff
changeset
|
382 def subrelpath(sub): |
11571 | 383 """return path to this subrepo as seen from outermost repo""" |
24673
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
384 return sub._relpath |
11112
4a9bee613737
subrepo: print paths relative to upper repo root for push/pull/commit
Edouard Gomez <ed.gomez@free.fr>
parents:
11111
diff
changeset
|
385 |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
386 def _abssource(repo, push=False, abort=True): |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
387 """return pull/push path of repo - either based on parent repo .hgsub info |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
388 or on the top repo config. Abort or return None if no source found.""" |
14963
c035f1c53e39
subrepo: use safehasattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14898
diff
changeset
|
389 if util.safehasattr(repo, '_subparent'): |
14076
924c82157d46
url: move URL parsing functions into util to improve startup time
Brodie Rao <brodie@bitheap.org>
parents:
14052
diff
changeset
|
390 source = util.url(repo._subsource) |
14766
4f56b7530eab
subrepos: be smarter about what's an absolute path (issue2808)
Matt Mackall <mpm@selenic.com>
parents:
14664
diff
changeset
|
391 if source.isabs(): |
4f56b7530eab
subrepos: be smarter about what's an absolute path (issue2808)
Matt Mackall <mpm@selenic.com>
parents:
14664
diff
changeset
|
392 return str(source) |
13771
ce6227306c9a
subrepos: use url.url when normalizing repo paths
Brodie Rao <brodie@bitheap.org>
parents:
13753
diff
changeset
|
393 source.path = posixpath.normpath(source.path) |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
394 parent = _abssource(repo._subparent, push, abort=False) |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
395 if parent: |
15498
ac5a340b26de
subrepo: use correct paths for subrepos with ..-relative paths on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15287
diff
changeset
|
396 parent = util.url(util.pconvert(parent)) |
15055
d629f1e89021
subrepo: fix cloning of repos from urls without slash after host (issue2970)
Mads Kiilerich <mads@kiilerich.com>
parents:
14994
diff
changeset
|
397 parent.path = posixpath.join(parent.path or '', source.path) |
13771
ce6227306c9a
subrepos: use url.url when normalizing repo paths
Brodie Rao <brodie@bitheap.org>
parents:
13753
diff
changeset
|
398 parent.path = posixpath.normpath(parent.path) |
ce6227306c9a
subrepos: use url.url when normalizing repo paths
Brodie Rao <brodie@bitheap.org>
parents:
13753
diff
changeset
|
399 return str(parent) |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
400 else: # recursion reached top repo |
14963
c035f1c53e39
subrepo: use safehasattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
14898
diff
changeset
|
401 if util.safehasattr(repo, '_subtoppath'): |
12852
5dbff89cf107
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
Mads Kiilerich <mads@kiilerich.com>
parents:
12799
diff
changeset
|
402 return repo._subtoppath |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
403 if push and repo.ui.config('paths', 'default-push'): |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
404 return repo.ui.config('paths', 'default-push') |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
405 if repo.ui.config('paths', 'default'): |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
406 return repo.ui.config('paths', 'default') |
23666
965788d9ae09
localrepo: introduce shared method to check if a repository is shared
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23580
diff
changeset
|
407 if repo.shared(): |
18510
f254ab6207ae
subrepo: use sharepath if available when locating the source repo
Matt Harbison <matt_harbison@yahoo.com>
parents:
18364
diff
changeset
|
408 # chop off the .hg component to get the default path form |
f254ab6207ae
subrepo: use sharepath if available when locating the source repo
Matt Harbison <matt_harbison@yahoo.com>
parents:
18364
diff
changeset
|
409 return os.path.dirname(repo.sharedpath) |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
410 if abort: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
411 raise error.Abort(_("default path for subrepository not found")) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
412 |
24724
95eb067b2b5e
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24695
diff
changeset
|
413 def _sanitize(ui, vfs, ignore): |
24726
747748766421
subrepo: use vfs.walk instead of os.walk
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24724
diff
changeset
|
414 for dirname, dirs, names in vfs.walk(): |
21567
5900bc09e684
subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21566
diff
changeset
|
415 for i, d in enumerate(dirs): |
5900bc09e684
subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21566
diff
changeset
|
416 if d.lower() == ignore: |
5900bc09e684
subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21566
diff
changeset
|
417 del dirs[i] |
5900bc09e684
subrepo: avoid sanitizing ".hg/hgrc" in meta data area for non-hg subrepos
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21566
diff
changeset
|
418 break |
25771
a7178d8fe7ee
subrepo: use vfs.basename instead of os.path.basename
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25769
diff
changeset
|
419 if vfs.basename(dirname).lower() != '.hg': |
21564
2e91d4964ecd
subrepo: make "_sanitize()" work
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21041
diff
changeset
|
420 continue |
20104
224e96078708
subrepo: sanitize non-hg subrepos
Matt Mackall <mpm@selenic.com>
parents:
19811
diff
changeset
|
421 for f in names: |
224e96078708
subrepo: sanitize non-hg subrepos
Matt Mackall <mpm@selenic.com>
parents:
19811
diff
changeset
|
422 if f.lower() == 'hgrc': |
21564
2e91d4964ecd
subrepo: make "_sanitize()" work
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21041
diff
changeset
|
423 ui.warn(_("warning: removing potentially hostile 'hgrc' " |
24726
747748766421
subrepo: use vfs.walk instead of os.walk
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24724
diff
changeset
|
424 "in '%s'\n") % vfs.join(dirname)) |
747748766421
subrepo: use vfs.walk instead of os.walk
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24724
diff
changeset
|
425 vfs.unlink(vfs.reljoin(dirname, f)) |
20104
224e96078708
subrepo: sanitize non-hg subrepos
Matt Mackall <mpm@selenic.com>
parents:
19811
diff
changeset
|
426 |
34984
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
427 def _auditsubrepopath(repo, path): |
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
428 # auditor doesn't check if the path itself is a symlink |
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
429 pathutil.pathauditor(repo.root)(path) |
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
430 if repo.wvfs.islink(path): |
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
431 raise error.Abort(_("subrepo '%s' traverses symbolic link") % path) |
071cbeba4212
subrepo: disallow symlink traversal across subrepo mount point (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34879
diff
changeset
|
432 |
34989
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
433 SUBREPO_ALLOWED_DEFAULTS = { |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
434 'hg': True, |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
435 'git': False, |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
436 'svn': False, |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
437 } |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
438 |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
439 def _checktype(ui, kind): |
34989
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
440 # subrepos.allowed is a master kill switch. If disabled, subrepos are |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
441 # disabled period. |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
442 if not ui.configbool('subrepos', 'allowed', True): |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
443 raise error.Abort(_('subrepos not enabled'), |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
444 hint=_("see 'hg help config.subrepos' for details")) |
34989
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
445 |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
446 default = SUBREPO_ALLOWED_DEFAULTS.get(kind, False) |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
447 if not ui.configbool('subrepos', '%s:allowed' % kind, default): |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
448 raise error.Abort(_('%s subrepos not allowed') % kind, |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
449 hint=_("see 'hg help config.subrepos' for details")) |
1a314176da9c
subrepo: use per-type config options to enable subrepos
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34987
diff
changeset
|
450 |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
451 if kind not in types: |
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
452 raise error.Abort(_('unknown subrepo type %s') % kind) |
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
453 |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
454 def subrepo(ctx, path, allowwdir=False, allowcreate=True): |
11571 | 455 """return instance of the right subrepo class for subrepo in path""" |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
456 # subrepo inherently violates our import layering rules |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
457 # because it wants to make repo objects from deep inside the stack |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
458 # so we manually delay the circular imports to not break |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
459 # scripts that don't use our demand-loading |
9092
9aebeea7ac00
subrepo: use hg.repository instead of creating localrepo directly
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
9049
diff
changeset
|
460 global hg |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
461 from . import hg as h |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
462 hg = h |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
463 |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
464 repo = ctx.repo() |
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
465 _auditsubrepopath(repo, path) |
16756
2e3513e7348a
subrepo: make subrepo.subrepo(<not a subrepo path>) fail
Dov Feldstern <dfeldstern@gmail.com>
parents:
16683
diff
changeset
|
466 state = ctx.substate[path] |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
467 _checktype(repo.ui, state[2]) |
25600
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25591
diff
changeset
|
468 if allowwdir: |
70ac1868b707
subrepo: allow a representation of the working directory subrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
25591
diff
changeset
|
469 state = (state[0], ctx.subrev(path), state[2]) |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
470 return types[state[2]](ctx, path, state[:2], allowcreate) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
471 |
25416
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
472 def nullsubrepo(ctx, path, pctx): |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
473 """return an empty subrepo in pctx for the extant subrepo in ctx""" |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
474 # subrepo inherently violates our import layering rules |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
475 # because it wants to make repo objects from deep inside the stack |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
476 # so we manually delay the circular imports to not break |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
477 # scripts that don't use our demand-loading |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
478 global hg |
25980
38c585c2f8cc
subrepo: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25848
diff
changeset
|
479 from . import hg as h |
25416
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
480 hg = h |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
481 |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
482 repo = ctx.repo() |
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
483 _auditsubrepopath(repo, path) |
25416
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
484 state = ctx.substate[path] |
34985
5e27afeddaee
subrepo: add config option to reject any subrepo operations (SEC)
Yuya Nishihara <yuya@tcha.org>
parents:
34984
diff
changeset
|
485 _checktype(repo.ui, state[2]) |
25416
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
486 subrev = '' |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
487 if state[2] == 'hg': |
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
488 subrev = "0" * 40 |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
489 return types[state[2]](pctx, path, (state[0], subrev), True) |
25416
c4a92867c048
subrepo: introduce the nullsubrepo() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
25228
diff
changeset
|
490 |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
491 def newcommitphase(ui, ctx): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
492 commitphase = phases.newcommitphase(ui) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
493 substate = getattr(ctx, "substate", None) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
494 if not substate: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
495 return commitphase |
33499
0407a51b9d8c
codemod: register core configitems using a script
Jun Wu <quark@fb.com>
parents:
33365
diff
changeset
|
496 check = ui.config('phases', 'checksubrepos') |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
497 if check not in ('ignore', 'follow', 'abort'): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
498 raise error.Abort(_('invalid phases.checksubrepos configuration: %s') |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
499 % (check)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
500 if check == 'ignore': |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
501 return commitphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
502 maxphase = phases.public |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
503 maxsub = None |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
504 for s in sorted(substate): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
505 sub = ctx.sub(s) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
506 subphase = sub.phase(substate[s][1]) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
507 if maxphase < subphase: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
508 maxphase = subphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
509 maxsub = s |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
510 if commitphase < maxphase: |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
511 if check == 'abort': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
512 raise error.Abort(_("can't commit in %s phase" |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
513 " conflicting %s from subrepository %s") % |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
514 (phases.phasenames[commitphase], |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
515 phases.phasenames[maxphase], maxsub)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
516 ui.warn(_("warning: changes are committed in" |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
517 " %s phase from subrepository %s\n") % |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
518 (phases.phasenames[maxphase], maxsub)) |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
519 return maxphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
520 return commitphase |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
521 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
522 # subrepo classes need to implement the following abstract class: |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
523 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
524 class abstractsubrepo(object): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
525 |
24671
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
526 def __init__(self, ctx, path): |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
527 """Initialize abstractsubrepo part |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
528 |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
529 ``ctx`` is the context referring this subrepository in the |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
530 parent repository. |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
531 |
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
532 ``path`` is the path to this subrepository as seen from |
24671
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
533 innermost repository. |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
534 """ |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
535 self.ui = ctx.repo().ui |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
536 self._ctx = ctx |
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
537 self._path = path |
23536
fcbc66b5da6a
subrepo: store the ui object in the base class
Matt Harbison <matt_harbison@yahoo.com>
parents:
23523
diff
changeset
|
538 |
32005
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
539 def addwebdirpath(self, serverpath, webconf): |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
540 """Add the hgwebdir entries for this subrepo, and any of its subrepos. |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
541 |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
542 ``serverpath`` is the path component of the URL for this repo. |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
543 |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
544 ``webconf`` is the dictionary of hgwebdir entries. |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
545 """ |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
546 pass |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
547 |
18937
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
548 def storeclean(self, path): |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
549 """ |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
550 returns true if the repository has not changed since it was last |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
551 cloned from or pushed to a given repository. |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
552 """ |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
553 return False |
9a171baa9202
subrepo: introduce storeclean method
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18936
diff
changeset
|
554 |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
555 def dirty(self, ignoreupdate=False, missing=False): |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13172
diff
changeset
|
556 """returns true if the dirstate of the subrepo is dirty or does not |
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13172
diff
changeset
|
557 match current stored state. If ignoreupdate is true, only check |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
558 whether the subrepo has uncommitted changes in its dirstate. If missing |
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
559 is true, check for deleted files. |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
560 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
561 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
562 |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
563 def dirtyreason(self, ignoreupdate=False, missing=False): |
24470
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
564 """return reason string if it is ``dirty()`` |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
565 |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
566 Returned string should have enough information for the message |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
567 of exception. |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
568 |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
569 This returns None, otherwise. |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
570 """ |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
571 if self.dirty(ignoreupdate=ignoreupdate, missing=missing): |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
572 return _('uncommitted changes in subrepository "%s"' |
24470
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
573 ) % subrelpath(self) |
76b0b0fed2e3
subrepo: add dirtyreason to centralize composing dirty reason message
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24413
diff
changeset
|
574 |
30755
0fbb3a5c188e
rebase: provide detailed hint to abort message if working dir is not clean
Valters Vingolds <valters@vingolds.ch>
parents:
30639
diff
changeset
|
575 def bailifchanged(self, ignoreupdate=False, hint=None): |
24471
1ff35d76421c
subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24470
diff
changeset
|
576 """raise Abort if subrepository is ``dirty()`` |
1ff35d76421c
subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24470
diff
changeset
|
577 """ |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
578 dirtyreason = self.dirtyreason(ignoreupdate=ignoreupdate, |
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
579 missing=True) |
24471
1ff35d76421c
subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24470
diff
changeset
|
580 if dirtyreason: |
30755
0fbb3a5c188e
rebase: provide detailed hint to abort message if working dir is not clean
Valters Vingolds <valters@vingolds.ch>
parents:
30639
diff
changeset
|
581 raise error.Abort(dirtyreason, hint=hint) |
24471
1ff35d76421c
subrepo: add bailifchanged to centralize raising Abort if subrepo is dirty
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24470
diff
changeset
|
582 |
16072
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
583 def basestate(self): |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
584 """current working directory base state, disregarding .hgsubstate |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
585 state and working directory modifications""" |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
586 raise NotImplementedError |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
587 |
12506
e7d45e41338c
subrepos: add missing self argument to abstractsubrepo.checknested
Brodie Rao <brodie@bitheap.org>
parents:
12503
diff
changeset
|
588 def checknested(self, path): |
12162
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
589 """check if path is a subrepository within this repository""" |
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
590 return False |
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
591 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
592 def commit(self, text, user, date): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
593 """commit the current changes to the subrepo with the given |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
594 log message. Use given user and date if possible. Return the |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
595 new state of the subrepo. |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
596 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
597 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
598 |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
599 def phase(self, state): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
600 """returns phase of specified state in the subrepository. |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
601 """ |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
602 return phases.public |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
603 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
604 def remove(self): |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
605 """remove the subrepo |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
606 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
607 (should verify the dirstate is not dirty first) |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
608 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
609 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
610 |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
611 def get(self, state, overwrite=False): |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
612 """run whatever commands are needed to put the subrepo into |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
613 this state |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
614 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
615 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
616 |
13413
fa921dcd9993
subrepo: remove argument introduced by mistake in c19b9282d3a7
Erik Zielke <ez@aragost.com>
parents:
13333
diff
changeset
|
617 def merge(self, state): |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
618 """merge currently-saved state with the new state.""" |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
619 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
620 |
15708
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
621 def push(self, opts): |
11572 | 622 """perform whatever action is analogous to 'hg push' |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
623 |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
624 This may be a no-op on some systems. |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
625 """ |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
626 raise NotImplementedError |
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
627 |
23963
8f02682ff3b0
subrepo: don't abort in add when non-hg subrepos are present (issue4513)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23938
diff
changeset
|
628 def add(self, ui, match, prefix, explicitonly, **opts): |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12210
diff
changeset
|
629 return [] |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
630 |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
631 def addremove(self, matcher, prefix, opts, dry_run, similarity): |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
632 self.ui.warn("%s: %s" % (prefix, _("addremove is not supported"))) |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
633 return 1 |
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
634 |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
635 def cat(self, match, fm, fntemplate, prefix, **opts): |
21041
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
636 return 1 |
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
637 |
12166
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
638 def status(self, rev2, **opts): |
22914
c95db3208a33
status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22695
diff
changeset
|
639 return scmutil.status([], [], [], [], [], [], []) |
12166
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
640 |
18006
0c10cf819146
subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17895
diff
changeset
|
641 def diff(self, ui, diffopts, node2, match, prefix, **opts): |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
642 pass |
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
643 |
12272
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
644 def outgoing(self, ui, dest, opts): |
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
645 return 1 |
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
646 |
12274
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
647 def incoming(self, ui, source, opts): |
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
648 return 1 |
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
649 |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
650 def files(self): |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
651 """return filename iterator""" |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
652 raise NotImplementedError |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
653 |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
654 def filedata(self, name, decode): |
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
655 """return file data, optionally passed through repo decoders""" |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
656 raise NotImplementedError |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
657 |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
658 def fileflags(self, name): |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
659 """return file flags""" |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
660 return '' |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
661 |
25121
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
662 def getfileset(self, expr): |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
663 """Resolve the fileset expression for this repo""" |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
664 return set() |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
665 |
25228
63a57a2727b6
files: recurse into subrepos automatically with an explicit path
Matt Harbison <matt_harbison@yahoo.com>
parents:
25172
diff
changeset
|
666 def printfiles(self, ui, m, fm, fmt, subrepos): |
24413
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
667 """handle the files command for this subrepo""" |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
668 return 1 |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
669 |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
670 def archive(self, archiver, prefix, match=None, decode=True): |
17108
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
671 if match is not None: |
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
672 files = [f for f in self.files() if match(f)] |
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
673 else: |
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
674 files = self.files() |
13144
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
675 total = len(files) |
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
676 relpath = subrelpath(self) |
23575
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
677 self.ui.progress(_('archiving (%s)') % relpath, 0, |
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
678 unit=_('files'), total=total) |
13144
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
679 for i, name in enumerate(files): |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
680 flags = self.fileflags(name) |
25658
e93036747902
global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25601
diff
changeset
|
681 mode = 'x' in flags and 0o755 or 0o644 |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
682 symlink = 'l' in flags |
24924
41cd8171e58f
archive: always use portable path component separators with subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
24877
diff
changeset
|
683 archiver.addfile(prefix + self._path + '/' + name, |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
684 mode, symlink, self.filedata(name, decode)) |
23575
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
685 self.ui.progress(_('archiving (%s)') % relpath, i + 1, |
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
686 unit=_('files'), total=total) |
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
687 self.ui.progress(_('archiving (%s)') % relpath, None) |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
688 return total |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
689 |
15410
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
690 def walk(self, match): |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
691 ''' |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
692 walk recursively through the directory tree, finding all files |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
693 matched by the match function |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
694 ''' |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
695 |
23577
597b071a0e0d
subrepo: drop the 'ui' parameter to forget()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23576
diff
changeset
|
696 def forget(self, match, prefix): |
16527
17a1f7690b49
subrepo: fix default implementation of forget() (issue3404)
Patrick Mezard <patrick@mezard.eu>
parents:
16468
diff
changeset
|
697 return ([], []) |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
698 |
28607
a88959ae5938
remove: queue warnings until after status messages (issue5140) (API)
timeless <timeless@mozdev.org>
parents:
28017
diff
changeset
|
699 def removefiles(self, matcher, prefix, after, force, subrepos, warnings): |
23325
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
700 """remove the matched files from the subrepository and the filesystem, |
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
701 possibly by force and/or after the file has been removed from the |
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
702 filesystem. Return 0 on success, 1 on any warning. |
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
703 """ |
28607
a88959ae5938
remove: queue warnings until after status messages (issue5140) (API)
timeless <timeless@mozdev.org>
parents:
28017
diff
changeset
|
704 warnings.append(_("warning: removefiles not implemented (%s)") |
a88959ae5938
remove: queue warnings until after status messages (issue5140) (API)
timeless <timeless@mozdev.org>
parents:
28017
diff
changeset
|
705 % self._path) |
23325
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
706 return 1 |
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
707 |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
708 def revert(self, substate, *pats, **opts): |
29243
28dc0030228a
subrepo: make a message translatable
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
29021
diff
changeset
|
709 self.ui.warn(_('%s: reverting %s subrepos is unsupported\n') \ |
16468
2fb521d75dc2
revert: show warning when reverting subrepos that do not support revert
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16451
diff
changeset
|
710 % (substate[0], substate[2])) |
16429
71dcce391a44
revert: add support for reverting subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16197
diff
changeset
|
711 return [] |
71dcce391a44
revert: add support for reverting subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16197
diff
changeset
|
712 |
21400
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
713 def shortid(self, revid): |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
714 return revid |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
715 |
34879
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
716 def unshare(self): |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
717 ''' |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
718 convert this repository from shared to normal storage. |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
719 ''' |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
720 |
25591
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
721 def verify(self): |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
722 '''verify the integrity of the repository. Return 0 on success or |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
723 warning, 1 on any error. |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
724 ''' |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
725 return 0 |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
726 |
24672
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
727 @propertycache |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
728 def wvfs(self): |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
729 """return vfs to access the working directory of this subrepository |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
730 """ |
31236
8a0687a2be75
vfs: use 'vfs' module directly in 'mercurial.subrepo'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31102
diff
changeset
|
731 return vfsmod.vfs(self._ctx.repo().wvfs.join(self._path)) |
24672
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
732 |
24673
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
733 @propertycache |
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
734 def _relpath(self): |
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
735 """return path to this subrepository as seen from outermost repository |
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
736 """ |
24785
39f519be5e65
subrepo: backout 93b0e0db7929 to restore reporelpath()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24778
diff
changeset
|
737 return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path) |
24673
105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24672
diff
changeset
|
738 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
739 class hgsubrepo(abstractsubrepo): |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
740 def __init__(self, ctx, path, state, allowcreate): |
24671
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
741 super(hgsubrepo, self).__init__(ctx, path) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
742 self._state = state |
24302
6e092ea2eff1
subrepo: replace 'ctx._repo' with 'ctx.repo()'
Matt Harbison <matt_harbison@yahoo.com>
parents:
24256
diff
changeset
|
743 r = ctx.repo() |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
744 root = r.wjoin(path) |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
745 create = allowcreate and not r.wvfs.exists('%s/.hg' % path) |
17873
573bec4ab7ba
subrepo: isolate configuration between each repositories in subrepo tree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17707
diff
changeset
|
746 self._repo = hg.repository(r.baseui, root, create=create) |
24877
cc497780eaf9
subrepo: propagate the --hidden option to hg subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
24876
diff
changeset
|
747 |
cc497780eaf9
subrepo: propagate the --hidden option to hg subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
24876
diff
changeset
|
748 # Propagate the parent's --hidden option |
cc497780eaf9
subrepo: propagate the --hidden option to hg subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
24876
diff
changeset
|
749 if r is r.unfiltered(): |
cc497780eaf9
subrepo: propagate the --hidden option to hg subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
24876
diff
changeset
|
750 self._repo = self._repo.unfiltered() |
cc497780eaf9
subrepo: propagate the --hidden option to hg subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
24876
diff
changeset
|
751 |
23573
3fec2a3c768b
subrepo: reset 'self.ui' to the subrepo copy of 'ui' in the hgsubrepo class
Matt Harbison <matt_harbison@yahoo.com>
parents:
23572
diff
changeset
|
752 self.ui = self._repo.ui |
17873
573bec4ab7ba
subrepo: isolate configuration between each repositories in subrepo tree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17707
diff
changeset
|
753 for s, k in [('ui', 'commitsubrepos')]: |
573bec4ab7ba
subrepo: isolate configuration between each repositories in subrepo tree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17707
diff
changeset
|
754 v = r.ui.config(s, k) |
573bec4ab7ba
subrepo: isolate configuration between each repositories in subrepo tree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17707
diff
changeset
|
755 if v: |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
756 self.ui.setconfig(s, k, v, 'subrepo') |
25848
0ae07173881d
subrepo: mark internal-only option
Matt Mackall <mpm@selenic.com>
parents:
25773
diff
changeset
|
757 # internal config: ui._usedassubrepo |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
758 self.ui.setconfig('ui', '_usedassubrepo', 'True', 'subrepo') |
14281
ccb7240acf32
subrepo: create subrepos using clone instead of pull
Martin Geisler <mg@aragost.com>
parents:
14221
diff
changeset
|
759 self._initrepo(r, state[0], create) |
ccb7240acf32
subrepo: create subrepos using clone instead of pull
Martin Geisler <mg@aragost.com>
parents:
14221
diff
changeset
|
760 |
32005
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
761 @annotatesubrepoerror |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
762 def addwebdirpath(self, serverpath, webconf): |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
763 cmdutil.addwebdirpath(self._repo, subrelpath(self), webconf) |
2406dbba49bd
serve: add support for Mercurial subrepositories
Matt Harbison <matt_harbison@yahoo.com>
parents:
31551
diff
changeset
|
764 |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
765 def storeclean(self, path): |
27844
469b86c49503
with: use context manager in subrepo storeclean
Bryan O'Sullivan <bryano@fb.com>
parents:
27843
diff
changeset
|
766 with self._repo.lock(): |
21885
fe9db58b0b2d
subrepo: ensure "lock.release()" execution at the end of "storeclean()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21585
diff
changeset
|
767 return self._storeclean(path) |
fe9db58b0b2d
subrepo: ensure "lock.release()" execution at the end of "storeclean()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21585
diff
changeset
|
768 |
fe9db58b0b2d
subrepo: ensure "lock.release()" execution at the end of "storeclean()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21585
diff
changeset
|
769 def _storeclean(self, path): |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
770 clean = True |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
771 itercache = self._calcstorehash(path) |
25172
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
772 for filehash in self._readstorehashcache(path): |
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
773 if filehash != next(itercache, None): |
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
774 clean = False |
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
775 break |
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
776 if clean: |
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
777 # if not empty: |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
778 # the cached and current pull states have a different size |
25172
ca9c02cb81be
subrepo: further replacement of try/except with 'next'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25121
diff
changeset
|
779 clean = next(itercache, None) is None |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
780 return clean |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
781 |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
782 def _calcstorehash(self, remotepath): |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
783 '''calculate a unique "store hash" |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
784 |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
785 This method is used to to detect when there are changes that may |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
786 require a push to a given remote path.''' |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
787 # sort the files that will be hashed in increasing (likely) file size |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
788 filelist = ('bookmarks', 'store/phaseroots', 'store/00changelog.i') |
18940
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
789 yield '# %s\n' % _expandedabspath(remotepath) |
23365
2ff394bbfa74
subrepo: replace "_calcfilehash" invocation by "vfs.tryread"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23364
diff
changeset
|
790 vfs = self._repo.vfs |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
791 for relname in filelist: |
29341
0d83ad967bf8
cleanup: replace uses of util.(md5|sha1|sha256|sha512) with hashlib.\1
Augie Fackler <raf@durin42.com>
parents:
29243
diff
changeset
|
792 filehash = hashlib.sha1(vfs.tryread(relname)).hexdigest() |
23365
2ff394bbfa74
subrepo: replace "_calcfilehash" invocation by "vfs.tryread"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23364
diff
changeset
|
793 yield '%s = %s\n' % (relname, filehash) |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
794 |
23367
115af8de76a4
subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23366
diff
changeset
|
795 @propertycache |
115af8de76a4
subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23366
diff
changeset
|
796 def _cachestorehashvfs(self): |
31325
b589f5b953f4
subrepo: directly use repo.vfs.join
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31236
diff
changeset
|
797 return vfsmod.vfs(self._repo.vfs.join('cache/storehash')) |
23367
115af8de76a4
subrepo: add "_cachestorehashvfs" to handle cache store hash files via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23366
diff
changeset
|
798 |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
799 def _readstorehashcache(self, remotepath): |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
800 '''read the store hash cache for a given remote repository''' |
23369
22e00674d17e
subrepo: replace direct file APIs around "readlines" by "vfs.tryreadlines"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23367
diff
changeset
|
801 cachefile = _getstorehashcachename(remotepath) |
22e00674d17e
subrepo: replace direct file APIs around "readlines" by "vfs.tryreadlines"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23367
diff
changeset
|
802 return self._cachestorehashvfs.tryreadlines(cachefile, 'r') |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
803 |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
804 def _cachestorehash(self, remotepath): |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
805 '''cache the current store hash |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
806 |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
807 Each remote repo requires its own store hash cache, because a subrepo |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
808 store may be "clean" versus a given remote repo, but not versus another |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
809 ''' |
23372
6cfa7a73b6e7
subrepo: replace direct file APIs around "writelines" by "vfs.writelines"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23369
diff
changeset
|
810 cachefile = _getstorehashcachename(remotepath) |
27843
b2efdb66c406
with: use context manager in subrepo _cachestorehash
Bryan O'Sullivan <bryano@fb.com>
parents:
27651
diff
changeset
|
811 with self._repo.lock(): |
21886
b9e8fdc35daf
subrepo: ensure "lock.release()" execution at the end of "_cachestorehash()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21885
diff
changeset
|
812 storehash = list(self._calcstorehash(remotepath)) |
23372
6cfa7a73b6e7
subrepo: replace direct file APIs around "writelines" by "vfs.writelines"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23369
diff
changeset
|
813 vfs = self._cachestorehashvfs |
6cfa7a73b6e7
subrepo: replace direct file APIs around "writelines" by "vfs.writelines"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
23369
diff
changeset
|
814 vfs.writelines(cachefile, storehash, mode='w', notindexed=True) |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
815 |
25572
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
816 def _getctx(self): |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
817 '''fetch the context for this subrepo revision, possibly a workingctx |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
818 ''' |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
819 if self._ctx.rev() is None: |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
820 return self._repo[None] # workingctx if parent is workingctx |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
821 else: |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
822 rev = self._state[1] |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
823 return self._repo[rev] |
3d8c044ed513
subrepo: introduce hgsubrepo._getctx()
Matt Harbison <matt_harbison@yahoo.com>
parents:
25416
diff
changeset
|
824 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
825 @annotatesubrepoerror |
14281
ccb7240acf32
subrepo: create subrepos using clone instead of pull
Martin Geisler <mg@aragost.com>
parents:
14221
diff
changeset
|
826 def _initrepo(self, parentrepo, source, create): |
ccb7240acf32
subrepo: create subrepos using clone instead of pull
Martin Geisler <mg@aragost.com>
parents:
14221
diff
changeset
|
827 self._repo._subparent = parentrepo |
ccb7240acf32
subrepo: create subrepos using clone instead of pull
Martin Geisler <mg@aragost.com>
parents:
14221
diff
changeset
|
828 self._repo._subsource = source |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
829 |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
830 if create: |
21891
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
831 lines = ['[paths]\n'] |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
832 |
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
833 def addpathconfig(key, value): |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
834 if value: |
21891
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
835 lines.append('%s = %s\n' % (key, value)) |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
836 self.ui.setconfig('paths', key, value, 'subrepo') |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
837 |
12753
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
838 defpath = _abssource(self._repo, abort=False) |
ef5eaf53f4f7
subrepo: abort instead of pushing/pulling to the repo itself
Mads Kiilerich <mads@kiilerich.com>
parents:
12752
diff
changeset
|
839 defpushpath = _abssource(self._repo, True, abort=False) |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
840 addpathconfig('default', defpath) |
10697
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
841 if defpath != defpushpath: |
c90d923fff64
subrepo: fix hgrc paths section during subrepo pulling
Edouard Gomez <ed.gomez@free.fr>
parents:
10666
diff
changeset
|
842 addpathconfig('default-push', defpushpath) |
21891
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
843 |
23877
7cc77030c557
localrepo: remove all external users of localrepo.opener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23679
diff
changeset
|
844 fp = self._repo.vfs("hgrc", "w", text=True) |
21891
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
845 try: |
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
846 fp.write(''.join(lines)) |
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
847 finally: |
db8a27d92818
subrepo: ensure "close()" execution at the end of "_initrepo()"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
21889
diff
changeset
|
848 fp.close() |
10666
4c50a90b90fc
subrepo: keep ui and hgrc in sync when creating new repo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10665
diff
changeset
|
849 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
850 @annotatesubrepoerror |
23885
9994f45ba714
add: pass options via keyword args
Matt Harbison <matt_harbison@yahoo.com>
parents:
23877
diff
changeset
|
851 def add(self, ui, match, prefix, explicitonly, **opts): |
9994f45ba714
add: pass options via keyword args
Matt Harbison <matt_harbison@yahoo.com>
parents:
23877
diff
changeset
|
852 return cmdutil.add(ui, self._repo, match, |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
853 self.wvfs.reljoin(prefix, self._path), |
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
854 explicitonly, **opts) |
12270
166b9866580a
add: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12210
diff
changeset
|
855 |
24132
b5898bf7119a
subrepo: annotate addremove with @annotatesubrepoerror
Matt Harbison <matt_harbison@yahoo.com>
parents:
23991
diff
changeset
|
856 @annotatesubrepoerror |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
857 def addremove(self, m, prefix, opts, dry_run, similarity): |
23540
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
858 # In the same way as sub directories are processed, once in a subrepo, |
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
859 # always entry any of its subrepos. Don't corrupt the options that will |
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
860 # be used to process sibling subrepos however. |
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
861 opts = copy.copy(opts) |
f274d27f1994
addremove: automatically process a subrepository's subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
23537
diff
changeset
|
862 opts['subrepos'] = True |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
863 return scmutil.addremove(self._repo, m, |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
864 self.wvfs.reljoin(prefix, self._path), opts, |
23537
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
865 dry_run, similarity) |
f1b06a8aad42
commit: propagate --addremove to subrepos if -S is specified (issue3759)
Matt Harbison <matt_harbison@yahoo.com>
parents:
23536
diff
changeset
|
866 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
867 @annotatesubrepoerror |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
868 def cat(self, match, fm, fntemplate, prefix, **opts): |
21041
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
869 rev = self._state[1] |
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
870 ctx = self._repo[rev] |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
871 return cmdutil.cat(self.ui, self._repo, ctx, match, fm, fntemplate, |
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
872 prefix, **opts) |
21041
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
873 |
a2cc3c08c3ac
cat: support cat with explicit paths in subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
20970
diff
changeset
|
874 @annotatesubrepoerror |
12166
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
875 def status(self, rev2, **opts): |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
876 try: |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
877 rev1 = self._state[1] |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
878 ctx1 = self._repo[rev1] |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
879 ctx2 = self._repo[rev2] |
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
880 return self._repo.status(ctx1, ctx2, **opts) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
881 except error.RepoLookupError as inst: |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
882 self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
883 % (inst, subrelpath(self))) |
22914
c95db3208a33
status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22695
diff
changeset
|
884 return scmutil.status([], [], [], [], [], [], []) |
12166
441a74b8def1
status: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12162
diff
changeset
|
885 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
886 @annotatesubrepoerror |
18006
0c10cf819146
subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17895
diff
changeset
|
887 def diff(self, ui, diffopts, node2, match, prefix, **opts): |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
888 try: |
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
889 node1 = node.bin(self._state[1]) |
12209
affec9fb56ef
subrepos: handle diff nodeids in subrepos, not before
Patrick Mezard <pmezard@gmail.com>
parents:
12176
diff
changeset
|
890 # We currently expect node2 to come from substate and be |
affec9fb56ef
subrepos: handle diff nodeids in subrepos, not before
Patrick Mezard <pmezard@gmail.com>
parents:
12176
diff
changeset
|
891 # in hex format |
12210
21eb85e9ea94
subrepo: handle diff with working copy
Martin Geisler <mg@lazybytes.net>
parents:
12209
diff
changeset
|
892 if node2 is not None: |
21eb85e9ea94
subrepo: handle diff with working copy
Martin Geisler <mg@lazybytes.net>
parents:
12209
diff
changeset
|
893 node2 = node.bin(node2) |
18006
0c10cf819146
subrepo: add argument to "diff()" to pass "ui" of caller side (issue3712) (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17895
diff
changeset
|
894 cmdutil.diffordiffstat(ui, self._repo, diffopts, |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
895 node1, node2, match, |
17968
a9f4a6076740
subrepo: use posixpath when diffing, for consistent paths
Bryan O'Sullivan <bryano@fb.com>
parents:
17895
diff
changeset
|
896 prefix=posixpath.join(prefix, self._path), |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
897 listsubrepos=True, **opts) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
898 except error.RepoLookupError as inst: |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
899 self.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
900 % (inst, subrelpath(self))) |
12167
d2c5b0927c28
diff: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12166
diff
changeset
|
901 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
902 @annotatesubrepoerror |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
903 def archive(self, archiver, prefix, match=None, decode=True): |
15286
4be845e3932c
subrepo: pull revisions on demand when archiving hg subrepos
Martin Geisler <mg@aragost.com>
parents:
15234
diff
changeset
|
904 self._get(self._state + ('hg',)) |
23575
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
905 total = abstractsubrepo.archive(self, archiver, prefix, match) |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
906 rev = self._state[1] |
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
907 ctx = self._repo[rev] |
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
908 for subpath in ctx.substate: |
25601
3ec8351fa6ed
archive: support 'wdir()'
Matt Harbison <matt_harbison@yahoo.com>
parents:
25600
diff
changeset
|
909 s = subrepo(ctx, subpath, True) |
28017
d3f1b7ee5e70
match: rename "narrowmatcher" to "subdirmatcher" (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
27935
diff
changeset
|
910 submatch = matchmod.subdirmatcher(subpath, match) |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
911 total += s.archive(archiver, prefix + self._path + '/', submatch, |
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
912 decode) |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
913 return total |
12323
f00953d9533c
subrepo: add support for 'hg archive'
Martin Geisler <mg@aragost.com>
parents:
12322
diff
changeset
|
914 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
915 @annotatesubrepoerror |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
916 def dirty(self, ignoreupdate=False, missing=False): |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
917 r = self._state[1] |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13172
diff
changeset
|
918 if r == '' and not ignoreupdate: # no state recorded |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
919 return True |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
920 w = self._repo[None] |
14316
d5b525697ddb
extensions: drop maxlength from enabled and disabled
Matt Mackall <mpm@selenic.com>
parents:
14312
diff
changeset
|
921 if r != w.p1().hex() and not ignoreupdate: |
13325
7ebdfa37842e
subrepo: clarify comments in dirty() methods
Kevin Bullock <kbullock@ringworld.org>
parents:
13324
diff
changeset
|
922 # different version checked out |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
923 return True |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
924 return w.dirty(missing=missing) # working directory changed |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
925 |
16072
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
926 def basestate(self): |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
927 return self._repo['.'].hex() |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
928 |
12162
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
929 def checknested(self, path): |
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
930 return self._repo._checknested(self._repo.wjoin(path)) |
af8c4929931c
localrepo: add auditor attribute which knows about subrepos
Martin Geisler <mg@lazybytes.net>
parents:
12060
diff
changeset
|
931 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
932 @annotatesubrepoerror |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
933 def commit(self, text, user, date): |
14898
95ced9f5bf29
subrepo: don't commit in subrepo if it's clean
Kevin Bullock <kbullock@ringworld.org>
parents:
14820
diff
changeset
|
934 # don't bother committing in the subrepo if it's only been |
95ced9f5bf29
subrepo: don't commit in subrepo if it's clean
Kevin Bullock <kbullock@ringworld.org>
parents:
14820
diff
changeset
|
935 # updated |
95ced9f5bf29
subrepo: don't commit in subrepo if it's clean
Kevin Bullock <kbullock@ringworld.org>
parents:
14820
diff
changeset
|
936 if not self.dirty(True): |
95ced9f5bf29
subrepo: don't commit in subrepo if it's clean
Kevin Bullock <kbullock@ringworld.org>
parents:
14820
diff
changeset
|
937 return self._repo['.'].hex() |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
938 self.ui.debug("committing subrepo %s\n" % subrelpath(self)) |
8813
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
939 n = self._repo.commit(text, user, date) |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
940 if not n: |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
941 return self._repo['.'].hex() # different version checked out |
db3c1ab0e632
commit: recurse into subrepositories
Matt Mackall <mpm@selenic.com>
parents:
8812
diff
changeset
|
942 return node.hex(n) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
943 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
944 @annotatesubrepoerror |
20176
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
945 def phase(self, state): |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
946 return self._repo[state].phase() |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
947 |
4c96c50ef937
subrepo: check phase of state in each subrepositories before committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20108
diff
changeset
|
948 @annotatesubrepoerror |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
949 def remove(self): |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
950 # we can't fully delete the repository as it may contain |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
951 # local-only history |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
952 self.ui.note(_('removing subrepo %s\n') % subrelpath(self)) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
953 hg.clean(self._repo, node.nullid, False) |
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
954 |
9507
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
955 def _get(self, state): |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
956 source, revision, kind = state |
34815
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
957 parentrepo = self._repo._subparent |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
958 |
20317
d6939f29b3b3
subrepo: do not try to get hidden revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20176
diff
changeset
|
959 if revision in self._repo.unfiltered(): |
34815
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
960 # Allow shared subrepos tracked at null to setup the sharedpath |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
961 if len(self._repo) != 0 or not parentrepo.shared(): |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
962 return True |
20318
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
963 self._repo._subsource = source |
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
964 srcurl = _abssource(self._repo) |
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
965 other = hg.peer(self._repo, {}, srcurl) |
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
966 if len(self._repo) == 0: |
24690
d1ddf1fe5d33
subrepo: use vfs.rmtree instead of shutil.rmtree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24688
diff
changeset
|
967 # use self._repo.vfs instead of self.wvfs to remove .hg only |
d1ddf1fe5d33
subrepo: use vfs.rmtree instead of shutil.rmtree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24688
diff
changeset
|
968 self._repo.vfs.rmtree() |
34815
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
969 if parentrepo.shared(): |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
970 self.ui.status(_('sharing subrepo %s from %s\n') |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
971 % (subrelpath(self), srcurl)) |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
972 shared = hg.share(self._repo._subparent.baseui, |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
973 other, self._repo.root, |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
974 update=False, bookmarks=False) |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
975 self._repo = shared.local() |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
976 else: |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
977 self.ui.status(_('cloning subrepo %s from %s\n') |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
978 % (subrelpath(self), srcurl)) |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
979 other, cloned = hg.clone(self._repo._subparent.baseui, {}, |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
980 other, self._repo.root, |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
981 update=False) |
68e0bcb90357
subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
Matt Harbison <matt_harbison@yahoo.com>
parents:
34645
diff
changeset
|
982 self._repo = cloned.local() |
20318
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
983 self._initrepo(parentrepo, source, create=True) |
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
984 self._cachestorehash(srcurl) |
20317
d6939f29b3b3
subrepo: do not try to get hidden revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20176
diff
changeset
|
985 else: |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
986 self.ui.status(_('pulling subrepo %s from %s\n') |
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
987 % (subrelpath(self), srcurl)) |
20318
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
988 cleansub = self.storeclean(srcurl) |
22695
15a70ca40b22
subrepo: use exchange.pull
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22657
diff
changeset
|
989 exchange.pull(self._repo, other) |
20318
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
990 if cleansub: |
c5aef7a66607
subrepo: remove unnecessary else clause in hgsubrepo._get
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20317
diff
changeset
|
991 # keep the repo clean after pull |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
992 self._cachestorehash(srcurl) |
20319
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
993 return False |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
994 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
995 @annotatesubrepoerror |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
996 def get(self, state, overwrite=False): |
20319
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
997 inrepo = self._get(state) |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
998 source, revision, kind = state |
20319
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
999 repo = self._repo |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1000 repo.ui.debug("getting subrepo %s\n" % self._path) |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1001 if inrepo: |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1002 urepo = repo.unfiltered() |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1003 ctx = urepo[revision] |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1004 if ctx.hidden(): |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1005 urepo.ui.warn( |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1006 _('revision %s in subrepository "%s" is hidden\n') \ |
20319
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1007 % (revision[0:12], self._path)) |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1008 repo = urepo |
427d672c0e4e
subrepo: make it possible to update to hidden subrepo revisions
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
20318
diff
changeset
|
1009 hg.updaterepo(repo, revision, overwrite) |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
1010 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1011 @annotatesubrepoerror |
8814
ab668c92a036
subrepo: add update/merge logic
Matt Mackall <mpm@selenic.com>
parents:
8813
diff
changeset
|
1012 def merge(self, state): |
9507
5987183d6e59
subrepo: add auto-pull for merge
Matt Mackall <mpm@selenic.com>
parents:
9186
diff
changeset
|
1013 self._get(state) |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
1014 cur = self._repo['.'] |
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
1015 dst = self._repo[state[1]] |
10251
a19d2993385d
subrepo: fix merging of already merged subrepos (issue1986)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
10068
diff
changeset
|
1016 anc = dst.ancestor(cur) |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1017 |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1018 def mergefunc(): |
16196
8ae7626d8bf1
subrepo: fix for merge inconsistencies
Friedrich Kastner-Masilko <kastner_masilko@at.festo.com>
parents:
16022
diff
changeset
|
1019 if anc == cur and dst.branch() == cur.branch(): |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1020 self.ui.debug('updating subrepository "%s"\n' |
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1021 % subrelpath(self)) |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1022 hg.update(self._repo, state[1]) |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1023 elif anc == dst: |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1024 self.ui.debug('skipping subrepository "%s"\n' |
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1025 % subrelpath(self)) |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1026 else: |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1027 self.ui.debug('merging subrepository "%s"\n' % subrelpath(self)) |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1028 hg.merge(self._repo, state[1], remind=False) |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1029 |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1030 wctx = self._repo[None] |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1031 if self.dirty(): |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1032 if anc != dst: |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
1033 if _updateprompt(self.ui, self, wctx.dirty(), cur, dst): |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1034 mergefunc() |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1035 else: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1036 mergefunc() |
9781
eccc8aacd6f9
subrepo: do a linear update when appropriate
Matt Mackall <mpm@selenic.com>
parents:
9780
diff
changeset
|
1037 else: |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1038 mergefunc() |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1039 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1040 @annotatesubrepoerror |
15708
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1041 def push(self, opts): |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1042 force = opts.get('force') |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1043 newbranch = opts.get('new_branch') |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1044 ssh = opts.get('ssh') |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1045 |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1046 # push subrepos depth-first for coherent ordering |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1047 c = self._repo[''] |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1048 subs = c.substate # only repos that are committed |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1049 for s in sorted(subs): |
16022
04604d1a9fc3
push: more precise failure check on subrepo push
Matt Mackall <mpm@selenic.com>
parents:
15912
diff
changeset
|
1050 if c.sub(s).push(opts) == 0: |
11067
49e14ec67144
subrepo: propagate and catch push failures
Matt Mackall <mpm@selenic.com>
parents:
10954
diff
changeset
|
1051 return False |
8815
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1052 |
e87b0fc4750b
subrepo: basic push support
Matt Mackall <mpm@selenic.com>
parents:
8814
diff
changeset
|
1053 dsturl = _abssource(self._repo, True) |
18940
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
1054 if not force: |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
1055 if self.storeclean(dsturl): |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
1056 self.ui.status( |
18940
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
1057 _('no changes made to subrepo %s since last push to %s\n') |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
1058 % (subrelpath(self), dsturl)) |
798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18939
diff
changeset
|
1059 return None |
23574
faa3d6af154e
subrepo: use 'self.ui' instead of 'self._repo.ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23573
diff
changeset
|
1060 self.ui.status(_('pushing subrepo %s to %s\n') % |
12752
18b5b6392fcf
subrepo: rename relpath to subrelpath and introduce reporelpath
Mads Kiilerich <mads@kiilerich.com>
parents:
12506
diff
changeset
|
1061 (subrelpath(self), dsturl)) |
17874
2ba70eec1cf0
peer: subrepo isolation, pass repo instead of repo.ui to hg.peer
Simon Heimberg <simohe@besonet.ch>
parents:
17873
diff
changeset
|
1062 other = hg.peer(self._repo, {'ssh': ssh}, dsturl) |
22619
f6cf96804d27
push: `exchange.push` instead of `localrepo.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22590
diff
changeset
|
1063 res = exchange.push(self._repo, other, force, newbranch=newbranch) |
18939
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
1064 |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
1065 # the repo is now clean |
aab0c14c20d0
subrepo: implement "storeclean" method for mercurial subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18937
diff
changeset
|
1066 self._cachestorehash(dsturl) |
22619
f6cf96804d27
push: `exchange.push` instead of `localrepo.push`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22590
diff
changeset
|
1067 return res.cgresult |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
1068 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1069 @annotatesubrepoerror |
12272
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
1070 def outgoing(self, ui, dest, opts): |
24875
5135c2be6959
subrepo: don't pass the outer repo's --rev or --branch to subrepo outgoing()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24858
diff
changeset
|
1071 if 'rev' in opts or 'branch' in opts: |
5135c2be6959
subrepo: don't pass the outer repo's --rev or --branch to subrepo outgoing()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24858
diff
changeset
|
1072 opts = copy.copy(opts) |
5135c2be6959
subrepo: don't pass the outer repo's --rev or --branch to subrepo outgoing()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24858
diff
changeset
|
1073 opts.pop('rev', None) |
5135c2be6959
subrepo: don't pass the outer repo's --rev or --branch to subrepo outgoing()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24858
diff
changeset
|
1074 opts.pop('branch', None) |
12272
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
1075 return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts) |
42ecd56399d7
outgoing: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12270
diff
changeset
|
1076 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1077 @annotatesubrepoerror |
12274
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
1078 def incoming(self, ui, source, opts): |
24876
b5513ee85dd8
subrepo: don't pass the outer repo's --rev or --branch to subrepo incoming()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24875
diff
changeset
|
1079 if 'rev' in opts or 'branch' in opts: |
b5513ee85dd8
subrepo: don't pass the outer repo's --rev or --branch to subrepo incoming()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24875
diff
changeset
|
1080 opts = copy.copy(opts) |
b5513ee85dd8
subrepo: don't pass the outer repo's --rev or --branch to subrepo incoming()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24875
diff
changeset
|
1081 opts.pop('rev', None) |
b5513ee85dd8
subrepo: don't pass the outer repo's --rev or --branch to subrepo incoming()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24875
diff
changeset
|
1082 opts.pop('branch', None) |
12274
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
1083 return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts) |
c02e1ed3d407
incoming: recurse into subrepositories with --subrepos/-S flag
Martin Geisler <mg@lazybytes.net>
parents:
12272
diff
changeset
|
1084 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1085 @annotatesubrepoerror |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1086 def files(self): |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1087 rev = self._state[1] |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1088 ctx = self._repo[rev] |
24173
2cc8ee4c4e1c
subrepo: return only the manifest keys from hgsubrepo.files()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24148
diff
changeset
|
1089 return ctx.manifest().keys() |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1090 |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1091 def filedata(self, name, decode): |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1092 rev = self._state[1] |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1093 data = self._repo[rev][name].data() |
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1094 if decode: |
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1095 data = self._repo.wwritedata(name, data) |
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1096 return data |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1097 |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1098 def fileflags(self, name): |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1099 rev = self._state[1] |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1100 ctx = self._repo[rev] |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1101 return ctx.flags(name) |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1102 |
24413
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1103 @annotatesubrepoerror |
25228
63a57a2727b6
files: recurse into subrepos automatically with an explicit path
Matt Harbison <matt_harbison@yahoo.com>
parents:
25172
diff
changeset
|
1104 def printfiles(self, ui, m, fm, fmt, subrepos): |
24413
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1105 # If the parent context is a workingctx, use the workingctx here for |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1106 # consistency. |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1107 if self._ctx.rev() is None: |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1108 ctx = self._repo[None] |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1109 else: |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1110 rev = self._state[1] |
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1111 ctx = self._repo[rev] |
25228
63a57a2727b6
files: recurse into subrepos automatically with an explicit path
Matt Harbison <matt_harbison@yahoo.com>
parents:
25172
diff
changeset
|
1112 return cmdutil.files(ui, ctx, m, fm, fmt, subrepos) |
24413
a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Matt Harbison <matt_harbison@yahoo.com>
parents:
24409
diff
changeset
|
1113 |
25121
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1114 @annotatesubrepoerror |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1115 def getfileset(self, expr): |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1116 if self._ctx.rev() is None: |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1117 ctx = self._repo[None] |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1118 else: |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1119 rev = self._state[1] |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1120 ctx = self._repo[rev] |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1121 |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1122 files = ctx.getfileset(expr) |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1123 |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1124 for subpath in ctx.substate: |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1125 sub = ctx.sub(subpath) |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1126 |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1127 try: |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1128 files.extend(subpath + '/' + f for f in sub.getfileset(expr)) |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1129 except error.LookupError: |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1130 self.ui.status(_("skipping missing subrepository: %s\n") |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1131 % self.wvfs.reljoin(reporelpath(self), subpath)) |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1132 return files |
df63d4843581
subrepo: introduce getfileset()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24943
diff
changeset
|
1133 |
15410
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
1134 def walk(self, match): |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
1135 ctx = self._repo[None] |
9e99d2bbb1b1
add: support adding explicit files in subrepos
David M. Carr <david@carrclan.us>
parents:
15287
diff
changeset
|
1136 return ctx.walk(match) |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1137 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1138 @annotatesubrepoerror |
23577
597b071a0e0d
subrepo: drop the 'ui' parameter to forget()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23576
diff
changeset
|
1139 def forget(self, match, prefix): |
597b071a0e0d
subrepo: drop the 'ui' parameter to forget()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23576
diff
changeset
|
1140 return cmdutil.forget(self.ui, self._repo, match, |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1141 self.wvfs.reljoin(prefix, self._path), True) |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1142 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1143 @annotatesubrepoerror |
28607
a88959ae5938
remove: queue warnings until after status messages (issue5140) (API)
timeless <timeless@mozdev.org>
parents:
28017
diff
changeset
|
1144 def removefiles(self, matcher, prefix, after, force, subrepos, warnings): |
23578
d0546e8e1def
subrepo: drop the 'ui' parameter to removefiles()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23577
diff
changeset
|
1145 return cmdutil.remove(self.ui, self._repo, matcher, |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1146 self.wvfs.reljoin(prefix, self._path), |
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1147 after, force, subrepos) |
23325
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
1148 |
4165cfd67519
remove: recurse into subrepositories with --subrepos/-S flag
Matt Harbison <matt_harbison@yahoo.com>
parents:
22927
diff
changeset
|
1149 @annotatesubrepoerror |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
1150 def revert(self, substate, *pats, **opts): |
16430
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1151 # reverting a subrepo is a 2 step process: |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1152 # 1. if the no_backup is not set, revert all modified |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1153 # files inside the subrepo |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1154 # 2. update the subrepo to the revision specified in |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1155 # the corresponding substate dictionary |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
1156 self.ui.status(_('reverting subrepo %s\n') % substate[0]) |
16430
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1157 if not opts.get('no_backup'): |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1158 # Revert all files on the subrepo, creating backups |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1159 # Note that this will not recursively revert subrepos |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1160 # We could do it if there was a set:subrepos() predicate |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1161 opts = opts.copy() |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1162 opts['date'] = None |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1163 opts['rev'] = substate[1] |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1164 |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
1165 self.filerevert(*pats, **opts) |
16429
71dcce391a44
revert: add support for reverting subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16197
diff
changeset
|
1166 |
71dcce391a44
revert: add support for reverting subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16197
diff
changeset
|
1167 # Update the repo to the revision specified in the given substate |
24134
afed5d2e7985
revert: display full subrepo output with --dry-run
Matt Harbison <matt_harbison@yahoo.com>
parents:
24132
diff
changeset
|
1168 if not opts.get('dry_run'): |
afed5d2e7985
revert: display full subrepo output with --dry-run
Matt Harbison <matt_harbison@yahoo.com>
parents:
24132
diff
changeset
|
1169 self.get(substate, overwrite=True) |
16429
71dcce391a44
revert: add support for reverting subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16197
diff
changeset
|
1170 |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
1171 def filerevert(self, *pats, **opts): |
16430
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1172 ctx = self._repo[opts['rev']] |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1173 parents = self._repo.dirstate.parents() |
18943
27e8dfc2c338
subrepo: fix exception on revert when "all" option is omitted
Yuya Nishihara <yuya@tcha.org>
parents:
18940
diff
changeset
|
1174 if opts.get('all'): |
16430
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1175 pats = ['set:modified()'] |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1176 else: |
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1177 pats = [] |
23579
e1c39f207719
subrepo: drop the 'ui' parameter to revert()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23578
diff
changeset
|
1178 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) |
16430
6883c2363f44
revert: add support for reverting subrepos without --no-backup and/or --all
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16429
diff
changeset
|
1179 |
21400
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
1180 def shortid(self, revid): |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
1181 return revid[:12] |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
1182 |
34879
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1183 @annotatesubrepoerror |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1184 def unshare(self): |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1185 # subrepo inherently violates our import layering rules |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1186 # because it wants to make repo objects from deep inside the stack |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1187 # so we manually delay the circular imports to not break |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1188 # scripts that don't use our demand-loading |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1189 global hg |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1190 from . import hg as h |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1191 hg = h |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1192 |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1193 # Nothing prevents a user from sharing in a repo, and then making that a |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1194 # subrepo. Alternately, the previous unshare attempt may have failed |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1195 # part way through. So recurse whether or not this layer is shared. |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1196 if self._repo.shared(): |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1197 self.ui.status(_("unsharing subrepo '%s'\n") % self._relpath) |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1198 |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1199 hg.unshare(self.ui, self._repo) |
7d51a7792f52
subrepo: implement 'unshare' for Mercurial subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
34815
diff
changeset
|
1200 |
25591
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1201 def verify(self): |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1202 try: |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1203 rev = self._state[1] |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1204 ctx = self._repo.unfiltered()[rev] |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1205 if ctx.hidden(): |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1206 # Since hidden revisions aren't pushed/pulled, it seems worth an |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1207 # explicit warning. |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1208 ui = self._repo.ui |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1209 ui.warn(_("subrepo '%s' is hidden in revision %s\n") % |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1210 (self._relpath, node.short(self._ctx.node()))) |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1211 return 0 |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1212 except error.RepoLookupError: |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1213 # A missing subrepo revision may be a case of needing to pull it, so |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1214 # don't treat this as an error. |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1215 self._repo.ui.warn(_("subrepo '%s' not found in revision %s\n") % |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1216 (self._relpath, node.short(self._ctx.node()))) |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1217 return 0 |
f1d46075b13a
verify: check the subrepository references in .hgsubstate
Matt Harbison <matt_harbison@yahoo.com>
parents:
25572
diff
changeset
|
1218 |
24672
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
1219 @propertycache |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
1220 def wvfs(self): |
26781
1aee2ab0f902
spelling: trivial spell checking
Mads Kiilerich <madski@unity3d.com>
parents:
26587
diff
changeset
|
1221 """return own wvfs for efficiency and consistency |
24672
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
1222 """ |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
1223 return self._repo.wvfs |
dd0b86f740ef
subrepo: add wvfs field to access the working directory via vfs
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24671
diff
changeset
|
1224 |
24786
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1225 @propertycache |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1226 def _relpath(self): |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1227 """return path to this subrepository as seen from outermost repository |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1228 """ |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1229 # Keep consistent dir separators by avoiding vfs.join(self._path) |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1230 return reporelpath(self._repo) |
56e15db9109f
subrepo: calculate _relpath for hgsubrepo based on self instead of parent
Matt Harbison <matt_harbison@yahoo.com>
parents:
24785
diff
changeset
|
1231 |
11559
9d88597470af
subrepo: add abstract superclass for subrepo classes
Martin Geisler <mg@lazybytes.net>
parents:
11470
diff
changeset
|
1232 class svnsubrepo(abstractsubrepo): |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
1233 def __init__(self, ctx, path, state, allowcreate): |
24671
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
1234 super(svnsubrepo, self).__init__(ctx, path) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1235 self._state = state |
15190
6dc67dced8c1
subrepo: improve error message when svn isn't found
Matt Mackall <mpm@selenic.com>
parents:
15150
diff
changeset
|
1236 self._exe = util.findexe('svn') |
6dc67dced8c1
subrepo: improve error message when svn isn't found
Matt Mackall <mpm@selenic.com>
parents:
15150
diff
changeset
|
1237 if not self._exe: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1238 raise error.Abort(_("'svn' executable not found for subrepo '%s'") |
15190
6dc67dced8c1
subrepo: improve error message when svn isn't found
Matt Mackall <mpm@selenic.com>
parents:
15150
diff
changeset
|
1239 % self._path) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1240 |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1241 def _svncommand(self, commands, filename='', failok=False): |
15190
6dc67dced8c1
subrepo: improve error message when svn isn't found
Matt Mackall <mpm@selenic.com>
parents:
15150
diff
changeset
|
1242 cmd = [self._exe] |
14506
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1243 extrakw = {} |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1244 if not self.ui.interactive(): |
14506
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1245 # Making stdin be a pipe should prevent svn from behaving |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1246 # interactively even if we can't pass --non-interactive. |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1247 extrakw['stdin'] = subprocess.PIPE |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1248 # Starting in svn 1.5 --non-interactive is a global flag |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1249 # instead of being per-command, but we need to support 1.4 so |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1250 # we have to be intelligent about what commands take |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1251 # --non-interactive. |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1252 if commands[0] in ('update', 'checkout', 'commit'): |
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1253 cmd.append('--non-interactive') |
14025
1052b1421a48
subrepo: tell Subversion when we are non-interactive (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
13912
diff
changeset
|
1254 cmd.extend(commands) |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1255 if filename is not None: |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1256 path = self.wvfs.reljoin(self._ctx.repo().origroot, |
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1257 self._path, filename) |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1258 cmd.append(path) |
30635
a150173da1c1
py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30615
diff
changeset
|
1259 env = dict(encoding.environ) |
10271
9b38bec5dc29
subrepo: make svn use C locale for portability
Patrick Mezard <pmezard@gmail.com>
parents:
10264
diff
changeset
|
1260 # Avoid localized output, preserve current locale for everything else. |
17705
6929b9c70be9
subrepo: setting LC_MESSAGES only works if LC_ALL is empty or unset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17441
diff
changeset
|
1261 lc_all = env.get('LC_ALL') |
6929b9c70be9
subrepo: setting LC_MESSAGES only works if LC_ALL is empty or unset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17441
diff
changeset
|
1262 if lc_all: |
6929b9c70be9
subrepo: setting LC_MESSAGES only works if LC_ALL is empty or unset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17441
diff
changeset
|
1263 env['LANG'] = lc_all |
6929b9c70be9
subrepo: setting LC_MESSAGES only works if LC_ALL is empty or unset
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17441
diff
changeset
|
1264 del env['LC_ALL'] |
10271
9b38bec5dc29
subrepo: make svn use C locale for portability
Patrick Mezard <pmezard@gmail.com>
parents:
10264
diff
changeset
|
1265 env['LC_MESSAGES'] = 'C' |
13108
dcaad69cfd6a
subrepo: use subprocess.Popen without the shell
Eric Eisner <ede@mit.edu>
parents:
13107
diff
changeset
|
1266 p = subprocess.Popen(cmd, bufsize=-1, close_fds=util.closefds, |
13014
d1c52354b0a9
subrepo: use subprocess directly to avoid python 2.6 bug
Patrick Mezard <pmezard@gmail.com>
parents:
13013
diff
changeset
|
1267 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
14506
733af5d9f6b2
subrepo: make stdin for svn a pipe for non-interactive use (issue2759)
Augie Fackler <durin42@gmail.com>
parents:
14505
diff
changeset
|
1268 universal_newlines=True, env=env, **extrakw) |
13014
d1c52354b0a9
subrepo: use subprocess directly to avoid python 2.6 bug
Patrick Mezard <pmezard@gmail.com>
parents:
13013
diff
changeset
|
1269 stdout, stderr = p.communicate() |
d1c52354b0a9
subrepo: use subprocess directly to avoid python 2.6 bug
Patrick Mezard <pmezard@gmail.com>
parents:
13013
diff
changeset
|
1270 stderr = stderr.strip() |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1271 if not failok: |
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1272 if p.returncode: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1273 raise error.Abort(stderr or 'exited with code %d' |
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1274 % p.returncode) |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1275 if stderr: |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1276 self.ui.warn(stderr + '\n') |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1277 return stdout, stderr |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1278 |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1279 @propertycache |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1280 def _svnversion(self): |
17707
35674bd95200
subrepo, hghave: use "svn --version --quiet" to determine version number
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17706
diff
changeset
|
1281 output, err = self._svncommand(['--version', '--quiet'], filename=None) |
34068
6d21737c35bf
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org>
parents:
34022
diff
changeset
|
1282 m = re.search(br'^(\d+)\.(\d+)', output) |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1283 if not m: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1284 raise error.Abort(_('cannot retrieve svn tool version')) |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1285 return (int(m.group(1)), int(m.group(2))) |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1286 |
13287
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1287 def _wcrevs(self): |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1288 # Get the working directory revision as well as the last |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1289 # commit revision so we can compare the subrepo state with |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1290 # both. We used to store the working directory one. |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1291 output, err = self._svncommand(['info', '--xml']) |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
1292 doc = xml.dom.minidom.parseString(output) |
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
1293 entries = doc.getElementsByTagName('entry') |
13287
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1294 lastrev, rev = '0', '0' |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1295 if entries: |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1296 rev = str(entries[0].getAttribute('revision')) or '0' |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1297 commits = entries[0].getElementsByTagName('commit') |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1298 if commits: |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1299 lastrev = str(commits[0].getAttribute('revision')) or '0' |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1300 return (lastrev, rev) |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1301 |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1302 def _wcrev(self): |
d0e0d3d43e14
subrepo: compare svn subrepo state to last committed revision
Patrick Mezard <pmezard@gmail.com>
parents:
13117
diff
changeset
|
1303 return self._wcrevs()[0] |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1304 |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1305 def _wcchanged(self): |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1306 """Return (changes, extchanges, missing) where changes is True |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1307 if the working directory was changed, extchanges is |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1308 True if any of these changes concern an external entry and missing |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1309 is True if any change is a missing entry. |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1310 """ |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1311 output, err = self._svncommand(['status', '--xml']) |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1312 externals, changes, missing = [], [], [] |
10272
886858b834da
subrepo: svn xml output is much easier to parse
Patrick Mezard <pmezard@gmail.com>
parents:
10271
diff
changeset
|
1313 doc = xml.dom.minidom.parseString(output) |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1314 for e in doc.getElementsByTagName('entry'): |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1315 s = e.getElementsByTagName('wc-status') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1316 if not s: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1317 continue |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1318 item = s[0].getAttribute('item') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1319 props = s[0].getAttribute('props') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1320 path = e.getAttribute('path') |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1321 if item == 'external': |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1322 externals.append(path) |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1323 elif item == 'missing': |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1324 missing.append(path) |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1325 if (item not in ('', 'normal', 'unversioned', 'external') |
14994
a115b5ee9c63
subrepo: handle adding svn subrepo with a svn:external file in it (issue2931)
Vasily Titskiy <qehgt0@gmail.com>
parents:
14898
diff
changeset
|
1326 or props not in ('', 'none', 'normal')): |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1327 changes.append(path) |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1328 for path in changes: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1329 for ext in externals: |
30615
bb77654dc7ae
py3: replace os.sep with pycompat.ossep (part 3 of 4)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30060
diff
changeset
|
1330 if path == ext or path.startswith(ext + pycompat.ossep): |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1331 return True, True, bool(missing) |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1332 return bool(changes), False, bool(missing) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1333 |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
1334 def dirty(self, ignoreupdate=False, missing=False): |
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
1335 wcchanged = self._wcchanged() |
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
1336 changed = wcchanged[0] or (missing and wcchanged[2]) |
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
1337 if not changed: |
13288 | 1338 if self._state[1] in self._wcrevs() or ignoreupdate: |
13174
be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
Kevin Bullock <kbullock@ringworld.org>
parents:
13172
diff
changeset
|
1339 return False |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1340 return True |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1341 |
16072
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
1342 def basestate(self): |
16554
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1343 lastrev, rev = self._wcrevs() |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1344 if lastrev != rev: |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1345 # Last committed rev is not the same than rev. We would |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1346 # like to take lastrev but we do not know if the subrepo |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1347 # URL exists at lastrev. Test it and fallback to rev it |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1348 # is not there. |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1349 try: |
17035
ba0286e149aa
subrepo/svn: make rev number retrieval compatible with svn 1.5 (issue2968)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
17025
diff
changeset
|
1350 self._svncommand(['list', '%s@%s' % (self._state[0], lastrev)]) |
16554
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1351 return lastrev |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1352 except error.Abort: |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1353 pass |
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1354 return rev |
16072
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
1355 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1356 @annotatesubrepoerror |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1357 def commit(self, text, user, date): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1358 # user and date are out of our hands since svn is centralized |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1359 changed, extchanged, missing = self._wcchanged() |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1360 if not changed: |
16554
ae2664ee0223
subrepo/svn: fix checked out rev number retrieval (issue2968)
Patrick Mezard <patrick@mezard.eu>
parents:
16530
diff
changeset
|
1361 return self.basestate() |
10273
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1362 if extchanged: |
e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
Patrick Mezard <pmezard@gmail.com>
parents:
10272
diff
changeset
|
1363 # Do not try to commit externals |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1364 raise error.Abort(_('cannot commit svn externals')) |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1365 if missing: |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1366 # svn can commit with missing entries but aborting like hg |
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1367 # seems a better approach. |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1368 raise error.Abort(_('cannot commit missing svn entries')) |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1369 commitinfo, err = self._svncommand(['commit', '-m', text]) |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1370 self.ui.status(commitinfo) |
12060
63eab3b74ba6
subrepo: use [0-9] instead of [\d] in svn subrepo regex
Martin Geisler <mg@lazybytes.net>
parents:
11961
diff
changeset
|
1371 newrev = re.search('Committed revision ([0-9]+).', commitinfo) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1372 if not newrev: |
16529
3d5d204a08c7
subrepo/svn: abort on commit with missing file (issue3029)
Patrick Mezard <patrick@mezard.eu>
parents:
16527
diff
changeset
|
1373 if not commitinfo.strip(): |
3d5d204a08c7
subrepo/svn: abort on commit with missing file (issue3029)
Patrick Mezard <patrick@mezard.eu>
parents:
16527
diff
changeset
|
1374 # Sometimes, our definition of "changed" differs from |
3d5d204a08c7
subrepo/svn: abort on commit with missing file (issue3029)
Patrick Mezard <patrick@mezard.eu>
parents:
16527
diff
changeset
|
1375 # svn one. For instance, svn ignores missing files |
3d5d204a08c7
subrepo/svn: abort on commit with missing file (issue3029)
Patrick Mezard <patrick@mezard.eu>
parents:
16527
diff
changeset
|
1376 # when committing. If there are only missing files, no |
3d5d204a08c7
subrepo/svn: abort on commit with missing file (issue3029)
Patrick Mezard <patrick@mezard.eu>
parents:
16527
diff
changeset
|
1377 # commit is made, no output and no error code. |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1378 raise error.Abort(_('failed to commit svn changes')) |
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1379 raise error.Abort(commitinfo.splitlines()[-1]) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1380 newrev = newrev.groups()[0] |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1381 self.ui.status(self._svncommand(['update', '-r', newrev])[0]) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1382 return newrev |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1383 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1384 @annotatesubrepoerror |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1385 def remove(self): |
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1386 if self.dirty(): |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1387 self.ui.warn(_('not removing repo %s because ' |
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1388 'it has changes.\n') % self._path) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1389 return |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1390 self.ui.note(_('removing subrepo %s\n') % self._path) |
13013
92b0d669637f
subrepo: fix removing read-only svn files on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
12930
diff
changeset
|
1391 |
24690
d1ddf1fe5d33
subrepo: use vfs.rmtree instead of shutil.rmtree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24688
diff
changeset
|
1392 self.wvfs.rmtree(forcibly=True) |
13015
82ca0c43bc44
subrepo: prune empty directories when removing svn subrepo
Patrick Mezard <pmezard@gmail.com>
parents:
13014
diff
changeset
|
1393 try: |
25773
de654a83fe1c
subrepo: use vfs.dirname instead of os.path.dirname
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25771
diff
changeset
|
1394 pwvfs = self._ctx.repo().wvfs |
de654a83fe1c
subrepo: use vfs.dirname instead of os.path.dirname
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
25771
diff
changeset
|
1395 pwvfs.removedirs(pwvfs.dirname(self._path)) |
13015
82ca0c43bc44
subrepo: prune empty directories when removing svn subrepo
Patrick Mezard <pmezard@gmail.com>
parents:
13014
diff
changeset
|
1396 except OSError: |
82ca0c43bc44
subrepo: prune empty directories when removing svn subrepo
Patrick Mezard <pmezard@gmail.com>
parents:
13014
diff
changeset
|
1397 pass |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1398 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1399 @annotatesubrepoerror |
13322
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
1400 def get(self, state, overwrite=False): |
c19b9282d3a7
subrepo: make update -C clean the working directory for svn subrepos
Erik Zielke <ez@aragost.com>
parents:
13287
diff
changeset
|
1401 if overwrite: |
13332
927e3940bfc3
subrepo: fix update -C with svn subrepos when cwd != repo.root
Patrick Mezard <pmezard@gmail.com>
parents:
13322
diff
changeset
|
1402 self._svncommand(['revert', '--recursive']) |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1403 args = ['checkout'] |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1404 if self._svnversion >= (1, 5): |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
14025
diff
changeset
|
1405 args.append('--force') |
14820
7ef125fa9b35
subrepo: correct revision in svn checkout
Eli Carter <eli.carter@tektronix.com>
parents:
14766
diff
changeset
|
1406 # The revision must be specified at the end of the URL to properly |
7ef125fa9b35
subrepo: correct revision in svn checkout
Eli Carter <eli.carter@tektronix.com>
parents:
14766
diff
changeset
|
1407 # update to a directory which has since been deleted and recreated. |
7ef125fa9b35
subrepo: correct revision in svn checkout
Eli Carter <eli.carter@tektronix.com>
parents:
14766
diff
changeset
|
1408 args.append('%s@%s' % (state[0], state[1])) |
33657
60ee7af2a2ba
subrepo: add tests for svn rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33499
diff
changeset
|
1409 |
60ee7af2a2ba
subrepo: add tests for svn rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33499
diff
changeset
|
1410 # SEC: check that the ssh url is safe |
60ee7af2a2ba
subrepo: add tests for svn rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33499
diff
changeset
|
1411 util.checksafessh(state[0]) |
60ee7af2a2ba
subrepo: add tests for svn rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33499
diff
changeset
|
1412 |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1413 status, err = self._svncommand(args, failok=True) |
24724
95eb067b2b5e
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24695
diff
changeset
|
1414 _sanitize(self.ui, self.wvfs, '.svn') |
12060
63eab3b74ba6
subrepo: use [0-9] instead of [\d] in svn subrepo regex
Martin Geisler <mg@lazybytes.net>
parents:
11961
diff
changeset
|
1415 if not re.search('Checked out revision [0-9]+.', status): |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1416 if ('is already a working copy for a different URL' in err |
16530
e37199a1f9d4
subrepo/svn: improve error message on missing files
Patrick Mezard <patrick@mezard.eu>
parents:
16529
diff
changeset
|
1417 and (self._wcchanged()[:2] == (False, False))): |
14664
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1418 # obstructed but clean working copy, so just blow it away. |
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1419 self.remove() |
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1420 self.get(state, overwrite=False) |
0ae98cd2a83f
svn subrepos: work around checkout obstructions (issue2752)
Augie Fackler <durin42@gmail.com>
parents:
14556
diff
changeset
|
1421 return |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1422 raise error.Abort((status or err).splitlines()[-1]) |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1423 self.ui.status(status) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1424 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1425 @annotatesubrepoerror |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1426 def merge(self, state): |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1427 old = self._state[1] |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1428 new = state[1] |
16555
4955e7bf085c
subrepo/svn: cache _wcrev() value in merge()
Patrick Mezard <patrick@mezard.eu>
parents:
16554
diff
changeset
|
1429 wcrev = self._wcrev() |
4955e7bf085c
subrepo/svn: cache _wcrev() value in merge()
Patrick Mezard <patrick@mezard.eu>
parents:
16554
diff
changeset
|
1430 if new != wcrev: |
4955e7bf085c
subrepo/svn: cache _wcrev() value in merge()
Patrick Mezard <patrick@mezard.eu>
parents:
16554
diff
changeset
|
1431 dirty = old == wcrev or self._wcchanged()[0] |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1432 if _updateprompt(self.ui, self, dirty, wcrev, new): |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1433 self.get(state, False) |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1434 |
15708
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1435 def push(self, opts): |
11455
3827728b54e2
subrepo: fix silent push failure for SVN (issue2241)
Matt Mackall <mpm@selenic.com>
parents:
11117
diff
changeset
|
1436 # push is a no-op for SVN |
3827728b54e2
subrepo: fix silent push failure for SVN (issue2241)
Matt Mackall <mpm@selenic.com>
parents:
11117
diff
changeset
|
1437 return True |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
1438 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1439 @annotatesubrepoerror |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1440 def files(self): |
16450
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1441 output = self._svncommand(['list', '--recursive', '--xml'])[0] |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1442 doc = xml.dom.minidom.parseString(output) |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1443 paths = [] |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1444 for e in doc.getElementsByTagName('entry'): |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1445 kind = str(e.getAttribute('kind')) |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1446 if kind != 'file': |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1447 continue |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1448 name = ''.join(c.data for c |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1449 in e.getElementsByTagName('name')[0].childNodes |
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1450 if c.nodeType == c.TEXT_NODE) |
17441
cb12d3ce5607
subrepo: encode unicode path names (issue3610)
Bryan O'Sullivan <bryano@fb.com>
parents:
17191
diff
changeset
|
1451 paths.append(name.encode('utf-8')) |
16450
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1452 return paths |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1453 |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1454 def filedata(self, name, decode): |
16450
c9c8c9053119
archive: make it work with svn subrepos (issue3308)
Patrick Mezard <patrick@mezard.eu>
parents:
16196
diff
changeset
|
1455 return self._svncommand(['cat'], name)[0] |
12322
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1456 |
510afb31cf99
subrepo: introduce files and filedata methods for subrepo classes
Martin Geisler <mg@aragost.com>
parents:
12274
diff
changeset
|
1457 |
13106
c869bd9e1193
subrepo: gitsubrepo should inherit from abstractsubrepo
Eric Eisner <ede@mit.edu>
parents:
13097
diff
changeset
|
1458 class gitsubrepo(abstractsubrepo): |
29021
92d37fb3f1aa
verify: don't init subrepo when missing one is referenced (issue5128) (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
28949
diff
changeset
|
1459 def __init__(self, ctx, path, state, allowcreate): |
24671
98ab035e9332
subrepo: change arguments of abstractsubrepo.__init__ (API)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24645
diff
changeset
|
1460 super(gitsubrepo, self).__init__(ctx, path) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1461 self._state = state |
24302
6e092ea2eff1
subrepo: replace 'ctx._repo' with 'ctx.repo()'
Matt Harbison <matt_harbison@yahoo.com>
parents:
24256
diff
changeset
|
1462 self._abspath = ctx.repo().wjoin(path) |
6e092ea2eff1
subrepo: replace 'ctx._repo' with 'ctx.repo()'
Matt Harbison <matt_harbison@yahoo.com>
parents:
24256
diff
changeset
|
1463 self._subparent = ctx.repo() |
17024
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1464 self._ensuregit() |
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1465 |
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1466 def _ensuregit(self): |
17025
8ad08dcab7d9
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
17024
diff
changeset
|
1467 try: |
8ad08dcab7d9
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
17024
diff
changeset
|
1468 self._gitexecutable = 'git' |
8ad08dcab7d9
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
17024
diff
changeset
|
1469 out, err = self._gitnodir(['--version']) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25658
diff
changeset
|
1470 except OSError as e: |
27935
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1471 genericerror = _("error executing git for subrepo '%s': %s") |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1472 notfoundhint = _("check git is installed and in your PATH") |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1473 if e.errno != errno.ENOENT: |
34022
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33658
diff
changeset
|
1474 raise error.Abort(genericerror % ( |
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33658
diff
changeset
|
1475 self._path, encoding.strtolocal(e.strerror))) |
34645 | 1476 elif pycompat.iswindows: |
27935
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1477 try: |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1478 self._gitexecutable = 'git.cmd' |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1479 out, err = self._gitnodir(['--version']) |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1480 except OSError as e2: |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1481 if e2.errno == errno.ENOENT: |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1482 raise error.Abort(_("couldn't find 'git' or 'git.cmd'" |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1483 " for subrepo '%s'") % self._path, |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1484 hint=notfoundhint) |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1485 else: |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1486 raise error.Abort(genericerror % (self._path, |
34022
d5b2beca16c0
python3: wrap all uses of <exception>.strerror with strtolocal
Augie Fackler <raf@durin42.com>
parents:
33658
diff
changeset
|
1487 encoding.strtolocal(e2.strerror))) |
27935
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1488 else: |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1489 raise error.Abort(_("couldn't find git for subrepo '%s'") |
594bdc380aa2
subrepo: better error messages in _ensuregit
Mason Malone <mason.malone@gmail.com>
parents:
27844
diff
changeset
|
1490 % self._path, hint=notfoundhint) |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1491 versionstatus = self._checkversion(out) |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1492 if versionstatus == 'unknown': |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1493 self.ui.warn(_('cannot retrieve git version\n')) |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1494 elif versionstatus == 'abort': |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1495 raise error.Abort(_('git subrepo requires at least 1.6.0 or later')) |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1496 elif versionstatus == 'warning': |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1497 self.ui.warn(_('git subrepo requires at least 1.6.0 or later\n')) |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1498 |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1499 @staticmethod |
23521
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1500 def _gitversion(out): |
34068
6d21737c35bf
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org>
parents:
34022
diff
changeset
|
1501 m = re.search(br'^git version (\d+)\.(\d+)\.(\d+)', out) |
23522
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1502 if m: |
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1503 return (int(m.group(1)), int(m.group(2)), int(m.group(3))) |
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1504 |
34068
6d21737c35bf
py3: fix type of regex literals in subrepo.py
Yuya Nishihara <yuya@tcha.org>
parents:
34022
diff
changeset
|
1505 m = re.search(br'^git version (\d+)\.(\d+)', out) |
23521
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1506 if m: |
23522
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1507 return (int(m.group(1)), int(m.group(2)), 0) |
23521
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1508 |
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1509 return -1 |
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1510 |
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1511 @staticmethod |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1512 def _checkversion(out): |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1513 '''ensure git version is new enough |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1514 |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1515 >>> _checkversion = gitsubrepo._checkversion |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1516 >>> _checkversion(b'git version 1.6.0') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1517 'ok' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1518 >>> _checkversion(b'git version 1.8.5') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1519 'ok' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1520 >>> _checkversion(b'git version 1.4.0') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1521 'abort' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1522 >>> _checkversion(b'git version 1.5.0') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1523 'warning' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1524 >>> _checkversion(b'git version 1.9-rc0') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1525 'ok' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1526 >>> _checkversion(b'git version 1.9.0.265.g81cdec2') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1527 'ok' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1528 >>> _checkversion(b'git version 1.9.0.GIT') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1529 'ok' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1530 >>> _checkversion(b'git version 12345') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1531 'unknown' |
34131
0fa781320203
doctest: bulk-replace string literals with b'' for Python 3
Yuya Nishihara <yuya@tcha.org>
parents:
34068
diff
changeset
|
1532 >>> _checkversion(b'no') |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1533 'unknown' |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1534 ''' |
23521
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1535 version = gitsubrepo._gitversion(out) |
17024
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1536 # git 1.4.0 can't work at all, but 1.5.X can in at least some cases, |
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1537 # despite the docstring comment. For now, error on 1.4.0, warn on |
33b057778cd2
subrepo: warn user if Git is not version 1.6.0 or higher
Benjamin Pollack <benjamin@bitquabit.com>
parents:
16596
diff
changeset
|
1538 # 1.5.0 but attempt to continue. |
23521
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1539 if version == -1: |
f5de2a82b77e
subrepo: move git version check into a separate method
Mathias De Maré <mathias.demare@gmail.com>
parents:
23411
diff
changeset
|
1540 return 'unknown' |
23522
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1541 if version < (1, 5, 0): |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1542 return 'abort' |
23522
49a58b33d1ce
subrepo: extend git version check to 3 digits
Mathias De Maré <mathias.demare@gmail.com>
parents:
23521
diff
changeset
|
1543 elif version < (1, 6, 0): |
20840
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1544 return 'warning' |
308344d80fe5
subrepo: factor out Git version check to add doctests
Siddharth Agarwal <sid0@fb.com>
parents:
20818
diff
changeset
|
1545 return 'ok' |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1546 |
13095
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1547 def _gitcommand(self, commands, env=None, stream=False): |
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1548 return self._gitdir(commands, env=env, stream=stream)[0] |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1549 |
13095
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1550 def _gitdir(self, commands, env=None, stream=False): |
13181
413bef846806
subrepo: fix subrelpath for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13180
diff
changeset
|
1551 return self._gitnodir(commands, env=env, stream=stream, |
413bef846806
subrepo: fix subrelpath for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13180
diff
changeset
|
1552 cwd=self._abspath) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1553 |
13095
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1554 def _gitnodir(self, commands, env=None, stream=False, cwd=None): |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1555 """Calls the git command |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1556 |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17191
diff
changeset
|
1557 The methods tries to call the git command. versions prior to 1.6.0 |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1558 are not supported and very probably fail. |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1559 """ |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1560 self.ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands))) |
28658
34d43cb85de8
subrepo: set GIT_ALLOW_PROTOCOL to limit git clone protocols (SEC)
Mateusz Kwapich <mitrandir@fb.com>
parents:
28618
diff
changeset
|
1561 if env is None: |
30635
a150173da1c1
py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30615
diff
changeset
|
1562 env = encoding.environ.copy() |
28949
9d3e280864fb
subrepo: disable localizations when calling Git (issue5176)
Matt Mackall <mpm@selenic.com>
parents:
28670
diff
changeset
|
1563 # disable localization for Git output (issue5176) |
9d3e280864fb
subrepo: disable localizations when calling Git (issue5176)
Matt Mackall <mpm@selenic.com>
parents:
28670
diff
changeset
|
1564 env['LC_ALL'] = 'C' |
28658
34d43cb85de8
subrepo: set GIT_ALLOW_PROTOCOL to limit git clone protocols (SEC)
Mateusz Kwapich <mitrandir@fb.com>
parents:
28618
diff
changeset
|
1565 # fix for Git CVE-2015-7545 |
34d43cb85de8
subrepo: set GIT_ALLOW_PROTOCOL to limit git clone protocols (SEC)
Mateusz Kwapich <mitrandir@fb.com>
parents:
28618
diff
changeset
|
1566 if 'GIT_ALLOW_PROTOCOL' not in env: |
34d43cb85de8
subrepo: set GIT_ALLOW_PROTOCOL to limit git clone protocols (SEC)
Mateusz Kwapich <mitrandir@fb.com>
parents:
28618
diff
changeset
|
1567 env['GIT_ALLOW_PROTOCOL'] = 'file:git:http:https:ssh' |
13111
560b8001f765
subrepo: silence git output when ui.quiet is set
Eric Eisner <ede@mit.edu>
parents:
13110
diff
changeset
|
1568 # unless ui.quiet is set, print git's stderr, |
560b8001f765
subrepo: silence git output when ui.quiet is set
Eric Eisner <ede@mit.edu>
parents:
13110
diff
changeset
|
1569 # which is mostly progress and useful info |
560b8001f765
subrepo: silence git output when ui.quiet is set
Eric Eisner <ede@mit.edu>
parents:
13110
diff
changeset
|
1570 errpipe = None |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1571 if self.ui.quiet: |
13111
560b8001f765
subrepo: silence git output when ui.quiet is set
Eric Eisner <ede@mit.edu>
parents:
13110
diff
changeset
|
1572 errpipe = open(os.devnull, 'w') |
31102
96d561c90ad0
color: move git-subrepo support into the subrepo module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31099
diff
changeset
|
1573 if self.ui._colormode and len(commands) and commands[0] == "diff": |
96d561c90ad0
color: move git-subrepo support into the subrepo module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31099
diff
changeset
|
1574 # insert the argument in the front, |
96d561c90ad0
color: move git-subrepo support into the subrepo module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31099
diff
changeset
|
1575 # the end of git diff arguments is used for paths |
96d561c90ad0
color: move git-subrepo support into the subrepo module
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
31099
diff
changeset
|
1576 commands.insert(1, '--color') |
17025
8ad08dcab7d9
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
17024
diff
changeset
|
1577 p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1, |
8ad08dcab7d9
subrepo: support Git being named "git.cmd" on Windows (issue3173)
Benjamin Pollack <benjamin@bitquabit.com>
parents:
17024
diff
changeset
|
1578 cwd=cwd, env=env, close_fds=util.closefds, |
13111
560b8001f765
subrepo: silence git output when ui.quiet is set
Eric Eisner <ede@mit.edu>
parents:
13110
diff
changeset
|
1579 stdout=subprocess.PIPE, stderr=errpipe) |
13027 | 1580 if stream: |
1581 return p.stdout, None | |
1582 | |
13085
b4814f1f415c
subrepo: strip gitcommand output
Eric Eisner <ede@mit.edu>
parents:
13029
diff
changeset
|
1583 retdata = p.stdout.read().strip() |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1584 # wait for the child to exit to avoid race condition. |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1585 p.wait() |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1586 |
13107
3bc237b0eaea
subrepo: treat git error code 1 as success
Eric Eisner <ede@mit.edu>
parents:
13106
diff
changeset
|
1587 if p.returncode != 0 and p.returncode != 1: |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1588 # there are certain error codes that are ok |
13110
cad35f06c031
subrepo: show git command with --debug
Eric Eisner <ede@mit.edu>
parents:
13109
diff
changeset
|
1589 command = commands[0] |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1590 if command in ('cat-file', 'symbolic-ref'): |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1591 return retdata, p.returncode |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1592 # for all others, abort |
29389
98e8313dcd9e
i18n: translate abort messages
liscju <piotr.listkiewicz@gmail.com>
parents:
29341
diff
changeset
|
1593 raise error.Abort(_('git %s error %d in %s') % |
13110
cad35f06c031
subrepo: show git command with --debug
Eric Eisner <ede@mit.edu>
parents:
13109
diff
changeset
|
1594 (command, p.returncode, self._relpath)) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1595 |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1596 return retdata, p.returncode |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1597 |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1598 def _gitmissing(self): |
24695
419528cb05b6
subrepo: convert the os.path references in git to vfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
24694
diff
changeset
|
1599 return not self.wvfs.exists('.git') |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1600 |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1601 def _gitstate(self): |
13085
b4814f1f415c
subrepo: strip gitcommand output
Eric Eisner <ede@mit.edu>
parents:
13029
diff
changeset
|
1602 return self._gitcommand(['rev-parse', 'HEAD']) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1603 |
13152
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1604 def _gitcurrentbranch(self): |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1605 current, err = self._gitdir(['symbolic-ref', 'HEAD', '--quiet']) |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1606 if err: |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1607 current = None |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1608 return current |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1609 |
13569
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1610 def _gitremote(self, remote): |
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1611 out = self._gitcommand(['remote', 'show', '-n', remote]) |
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1612 line = out.split('\n')[1] |
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1613 i = line.index('URL: ') + len('URL: ') |
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1614 return line[i:] |
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1615 |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1616 def _githavelocally(self, revision): |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1617 out, code = self._gitdir(['cat-file', '-e', revision]) |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1618 return code == 0 |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1619 |
13029 | 1620 def _gitisancestor(self, r1, r2): |
13085
b4814f1f415c
subrepo: strip gitcommand output
Eric Eisner <ede@mit.edu>
parents:
13029
diff
changeset
|
1621 base = self._gitcommand(['merge-base', r1, r2]) |
13029 | 1622 return base == r1 |
1623 | |
14440
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1624 def _gitisbare(self): |
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1625 return self._gitcommand(['config', '--bool', 'core.bare']) == 'true' |
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1626 |
15531
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1627 def _gitupdatestat(self): |
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1628 """This must be run before git diff-index. |
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1629 diff-index only looks at changes to file stat; |
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1630 this command looks at file contents and updates the stat.""" |
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1631 self._gitcommand(['update-index', '-q', '--refresh']) |
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1632 |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1633 def _gitbranchmap(self): |
13178 | 1634 '''returns 2 things: |
13086
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1635 a map from git branch to revision |
13178 | 1636 a map from revision to branches''' |
13086
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1637 branch2rev = {} |
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1638 rev2branch = {} |
13178 | 1639 |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1640 out = self._gitcommand(['for-each-ref', '--format', |
13178 | 1641 '%(objectname) %(refname)']) |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1642 for line in out.split('\n'): |
13178 | 1643 revision, ref = line.split(' ') |
13465
fa88fabc1d66
subrepo: disallow all unknown git ref types
Eric Eisner <ede@mit.edu>
parents:
13460
diff
changeset
|
1644 if (not ref.startswith('refs/heads/') and |
fa88fabc1d66
subrepo: disallow all unknown git ref types
Eric Eisner <ede@mit.edu>
parents:
13460
diff
changeset
|
1645 not ref.startswith('refs/remotes/')): |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1646 continue |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1647 if ref.startswith('refs/remotes/') and ref.endswith('/HEAD'): |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1648 continue # ignore remote/HEAD redirects |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1649 branch2rev[ref] = revision |
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1650 rev2branch.setdefault(revision, []).append(ref) |
13178 | 1651 return branch2rev, rev2branch |
1652 | |
1653 def _gittracking(self, branches): | |
1654 'return map of remote branch to local tracking branch' | |
1655 # assumes no more than one local tracking branch for each remote | |
1656 tracking = {} | |
1657 for b in branches: | |
1658 if b.startswith('refs/remotes/'): | |
1659 continue | |
15234
5d700b7edd85
subrepo: fix git branch tracking logic (issue2920)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15208
diff
changeset
|
1660 bname = b.split('/', 2)[2] |
5d700b7edd85
subrepo: fix git branch tracking logic (issue2920)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15208
diff
changeset
|
1661 remote = self._gitcommand(['config', 'branch.%s.remote' % bname]) |
13178 | 1662 if remote: |
15234
5d700b7edd85
subrepo: fix git branch tracking logic (issue2920)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15208
diff
changeset
|
1663 ref = self._gitcommand(['config', 'branch.%s.merge' % bname]) |
13178 | 1664 tracking['refs/remotes/%s/%s' % |
1665 (remote, ref.split('/', 2)[2])] = b | |
1666 return tracking | |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1667 |
13460
64bb8e586a92
subrepo: expand relative sources for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13432
diff
changeset
|
1668 def _abssource(self, source): |
13692
a7c9735307bd
subrepo: recognize scp-style paths as git URLs
Eric Eisner <ede@mit.edu>
parents:
13559
diff
changeset
|
1669 if '://' not in source: |
a7c9735307bd
subrepo: recognize scp-style paths as git URLs
Eric Eisner <ede@mit.edu>
parents:
13559
diff
changeset
|
1670 # recognize the scp syntax as an absolute source |
a7c9735307bd
subrepo: recognize scp-style paths as git URLs
Eric Eisner <ede@mit.edu>
parents:
13559
diff
changeset
|
1671 colon = source.find(':') |
a7c9735307bd
subrepo: recognize scp-style paths as git URLs
Eric Eisner <ede@mit.edu>
parents:
13559
diff
changeset
|
1672 if colon != -1 and '/' not in source[:colon]: |
a7c9735307bd
subrepo: recognize scp-style paths as git URLs
Eric Eisner <ede@mit.edu>
parents:
13559
diff
changeset
|
1673 return source |
13460
64bb8e586a92
subrepo: expand relative sources for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13432
diff
changeset
|
1674 self._subsource = source |
64bb8e586a92
subrepo: expand relative sources for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13432
diff
changeset
|
1675 return _abssource(self) |
64bb8e586a92
subrepo: expand relative sources for git subrepos
Eric Eisner <ede@mit.edu>
parents:
13432
diff
changeset
|
1676 |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1677 def _fetch(self, source, revision): |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1678 if self._gitmissing(): |
33658
db83a1df03fe
subrepo: add tests for git rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33657
diff
changeset
|
1679 # SEC: check for safe ssh url |
db83a1df03fe
subrepo: add tests for git rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33657
diff
changeset
|
1680 util.checksafessh(source) |
db83a1df03fe
subrepo: add tests for git rogue ssh urls (SEC)
Sean Farley <sean@farley.io>
parents:
33657
diff
changeset
|
1681 |
13525
c12088259f64
subrepo: show the source that git clones
Eric Eisner <ede@mit.edu>
parents:
13466
diff
changeset
|
1682 source = self._abssource(source) |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1683 self.ui.status(_('cloning subrepo %s from %s\n') % |
13525
c12088259f64
subrepo: show the source that git clones
Eric Eisner <ede@mit.edu>
parents:
13466
diff
changeset
|
1684 (self._relpath, source)) |
c12088259f64
subrepo: show the source that git clones
Eric Eisner <ede@mit.edu>
parents:
13466
diff
changeset
|
1685 self._gitnodir(['clone', source, self._abspath]) |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1686 if self._githavelocally(revision): |
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1687 return |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1688 self.ui.status(_('pulling subrepo %s from %s\n') % |
13569
3ab3b892d223
subrepo: show the source that git pulls
Eric Eisner <ede@mit.edu>
parents:
13560
diff
changeset
|
1689 (self._relpath, self._gitremote('origin'))) |
13466
f2295f7cd468
subrepo: only attempt pulling from git's origin
Eric Eisner <ede@mit.edu>
parents:
13465
diff
changeset
|
1690 # try only origin: the originally cloned repo |
13097
c922aacf6f1f
subrepo: drop arguments unsupported by old git
Eric Eisner <ede@mit.edu>
parents:
13096
diff
changeset
|
1691 self._gitcommand(['fetch']) |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1692 if not self._githavelocally(revision): |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1693 raise error.Abort(_('revision %s does not exist in subrepository ' |
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1694 '"%s"\n') % (revision, self._relpath)) |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1695 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1696 @annotatesubrepoerror |
33364
bf2daeddd42b
subrepo: consider the parent repo dirty when a file is missing
Matt Harbison <matt_harbison@yahoo.com>
parents:
32584
diff
changeset
|
1697 def dirty(self, ignoreupdate=False, missing=False): |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1698 if self._gitmissing(): |
14469
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1699 return self._state[1] != '' |
14440
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1700 if self._gitisbare(): |
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1701 return True |
13179
b512a7074349
subrepo: support ignoreupdate in gitsubrepo's dirty()
Eric Eisner <ede@mit.edu>
parents:
13178
diff
changeset
|
1702 if not ignoreupdate and self._state[1] != self._gitstate(): |
13325
7ebdfa37842e
subrepo: clarify comments in dirty() methods
Kevin Bullock <kbullock@ringworld.org>
parents:
13324
diff
changeset
|
1703 # different version checked out |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1704 return True |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1705 # check for staged changes or modified files; ignore untracked files |
15531
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1706 self._gitupdatestat() |
13153
dca5488f0e4f
subrepo: use low-level git-diff-index for dirty()
Eric Eisner <ede@mit.edu>
parents:
13152
diff
changeset
|
1707 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) |
dca5488f0e4f
subrepo: use low-level git-diff-index for dirty()
Eric Eisner <ede@mit.edu>
parents:
13152
diff
changeset
|
1708 return code == 1 |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1709 |
16072
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
1710 def basestate(self): |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
1711 return self._gitstate() |
bcb973abcc0b
subrepo: add basestate method
Matt Mackall <mpm@selenic.com>
parents:
16022
diff
changeset
|
1712 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1713 @annotatesubrepoerror |
13323 | 1714 def get(self, state, overwrite=False): |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1715 source, revision, kind = state |
14469
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1716 if not revision: |
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1717 self.remove() |
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1718 return |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1719 self._fetch(source, revision) |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1720 # if the repo was set to be bare, unbare it |
14440
96f1c1b14154
subrepo: bare git repos considered dirty
Paul Molodowitch <pm@stanfordalumni.org>
parents:
14417
diff
changeset
|
1721 if self._gitisbare(): |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1722 self._gitcommand(['config', 'core.bare', 'false']) |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1723 if self._gitstate() == revision: |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1724 self._gitcommand(['reset', '--hard', 'HEAD']) |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1725 return |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1726 elif self._gitstate() == revision: |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1727 if overwrite: |
13927
518344d02761
subrepo: trailing whitespace cleanup
Augie Fackler <durin42@gmail.com>
parents:
13913
diff
changeset
|
1728 # first reset the index to unmark new files for commit, because |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1729 # reset --hard will otherwise throw away files added for commit, |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1730 # not just unmark them. |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1731 self._gitcommand(['reset', 'HEAD']) |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1732 self._gitcommand(['reset', '--hard', 'HEAD']) |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1733 return |
13178 | 1734 branch2rev, rev2branch = self._gitbranchmap() |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1735 |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1736 def checkout(args): |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1737 cmd = ['checkout'] |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1738 if overwrite: |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1739 # first reset the index to unmark new files for commit, because |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1740 # the -f option will otherwise throw away files added for |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1741 # commit, not just unmark them. |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1742 self._gitcommand(['reset', 'HEAD']) |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1743 cmd.append('-f') |
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1744 self._gitcommand(cmd + args) |
24724
95eb067b2b5e
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24695
diff
changeset
|
1745 _sanitize(self.ui, self.wvfs, '.git') |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1746 |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1747 def rawcheckout(): |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1748 # no branch to checkout, check it out with no branch |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1749 self.ui.warn(_('checking out detached HEAD in ' |
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1750 'subrepository "%s"\n') % self._relpath) |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1751 self.ui.warn(_('check out a git branch if you intend ' |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1752 'to make changes\n')) |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1753 checkout(['-q', revision]) |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1754 |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1755 if revision not in rev2branch: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1756 rawcheckout() |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1757 return |
13086
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1758 branches = rev2branch[revision] |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1759 firstlocalbranch = None |
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1760 for b in branches: |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1761 if b == 'refs/heads/master': |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1762 # master trumps all other branches |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1763 checkout(['refs/heads/master']) |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1764 return |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1765 if not firstlocalbranch and not b.startswith('refs/remotes/'): |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1766 firstlocalbranch = b |
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1767 if firstlocalbranch: |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1768 checkout([firstlocalbranch]) |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1769 return |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1770 |
13178 | 1771 tracking = self._gittracking(branch2rev.keys()) |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1772 # choose a remote branch already tracked if possible |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1773 remote = branches[0] |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1774 if remote not in tracking: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1775 for b in branches: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1776 if b in tracking: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1777 remote = b |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1778 break |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1779 |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1780 if remote not in tracking: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1781 # create a new local tracking branch |
19012
811e253226c3
subrepo: clone of git sub-repository creates incorrect git branch (issue3870)
pozheg <pozheg@gmail.com>
parents:
18967
diff
changeset
|
1782 local = remote.split('/', 3)[3] |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1783 checkout(['-b', local, remote]) |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1784 elif self._gitisancestor(branch2rev[tracking[remote]], remote): |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1785 # When updating to a tracked remote branch, |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1786 # if the local tracking branch is downstream of it, |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1787 # a normal `git pull` would have performed a "fast-forward merge" |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1788 # which is equivalent to updating the local branch to the remote. |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1789 # Since we are only looking at branching at update, we need to |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1790 # detect this situation and perform this action lazily. |
13152
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1791 if tracking[remote] != self._gitcurrentbranch(): |
13324
e5617047c926
subrepo: make update -C clean the working directory for git subrepos
Erik Zielke <ez@aragost.com>
parents:
13323
diff
changeset
|
1792 checkout([tracking[remote]]) |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1793 self._gitcommand(['merge', '--ff', remote]) |
24724
95eb067b2b5e
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24695
diff
changeset
|
1794 _sanitize(self.ui, self.wvfs, '.git') |
13087
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1795 else: |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1796 # a real merge would be required, just checkout the revision |
cca0779b4832
subrepo: lazily update git's local tracking branches
Eric Eisner <ede@mit.edu>
parents:
13086
diff
changeset
|
1797 rawcheckout() |
12993
a91334380699
subrepo: cloning and updating of git subrepos
Eric Eisner <ede@mit.edu>
parents:
12992
diff
changeset
|
1798 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1799 @annotatesubrepoerror |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1800 def commit(self, text, user, date): |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1801 if self._gitmissing(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1802 raise error.Abort(_("subrepo %s is missing") % self._relpath) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1803 cmd = ['commit', '-a', '-m', text] |
30635
a150173da1c1
py3: replace os.environ with encoding.environ (part 2 of 5)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30615
diff
changeset
|
1804 env = encoding.environ.copy() |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1805 if user: |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1806 cmd += ['--author', user] |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1807 if date: |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1808 # git's date parser silently ignores when seconds < 1e9 |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1809 # convert to ISO8601 |
13095
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1810 env['GIT_AUTHOR_DATE'] = util.datestr(date, |
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1811 '%Y-%m-%dT%H:%M:%S %1%2') |
49c7e875482d
subrepo: use environment variable instead of git commit's --date
Eric Eisner <ede@mit.edu>
parents:
13094
diff
changeset
|
1812 self._gitcommand(cmd, env=env) |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1813 # make sure commit works otherwise HEAD might not exist under certain |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1814 # circumstances |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1815 return self._gitstate() |
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
1816 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1817 @annotatesubrepoerror |
12994
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1818 def merge(self, state): |
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1819 source, revision, kind = state |
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1820 self._fetch(source, revision) |
13085
b4814f1f415c
subrepo: strip gitcommand output
Eric Eisner <ede@mit.edu>
parents:
13029
diff
changeset
|
1821 base = self._gitcommand(['merge-base', revision, self._state[1]]) |
15531
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
1822 self._gitupdatestat() |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1823 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1824 |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1825 def mergefunc(): |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1826 if base == revision: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1827 self.get(state) # fast forward merge |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1828 elif base != self._state[1]: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1829 self._gitcommand(['merge', '--no-commit', revision]) |
24724
95eb067b2b5e
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24695
diff
changeset
|
1830 _sanitize(self.ui, self.wvfs, '.git') |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1831 |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1832 if self.dirty(): |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1833 if self._gitstate() != revision: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1834 dirty = self._gitstate() == self._state[1] or code != 0 |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1835 if _updateprompt(self.ui, self, dirty, |
13432
5a5bd7614401
subrepo: break long line found by check-code
Martin Geisler <mg@aragost.com>
parents:
13428
diff
changeset
|
1836 self._state[1][:7], revision[:7]): |
13417
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1837 mergefunc() |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1838 else: |
0748e18be470
subrepos: prompt on conflicts on update with dirty subrepos
Erik Zielke <ez@aragost.com>
parents:
13413
diff
changeset
|
1839 mergefunc() |
12994
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1840 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1841 @annotatesubrepoerror |
15708
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1842 def push(self, opts): |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1843 force = opts.get('force') |
309e49491253
push: propagate --new-branch and --ssh options when pushing subrepos
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
15614
diff
changeset
|
1844 |
14469
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1845 if not self._state[1]: |
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1846 return True |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1847 if self._gitmissing(): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25980
diff
changeset
|
1848 raise error.Abort(_("subrepo %s is missing") % self._relpath) |
13029 | 1849 # if a branch in origin contains the revision, nothing to do |
13178 | 1850 branch2rev, rev2branch = self._gitbranchmap() |
13109
53341289eaf8
subrepo: speed up git push logic
Eric Eisner <ede@mit.edu>
parents:
13108
diff
changeset
|
1851 if self._state[1] in rev2branch: |
53341289eaf8
subrepo: speed up git push logic
Eric Eisner <ede@mit.edu>
parents:
13108
diff
changeset
|
1852 for b in rev2branch[self._state[1]]: |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1853 if b.startswith('refs/remotes/origin/'): |
13109
53341289eaf8
subrepo: speed up git push logic
Eric Eisner <ede@mit.edu>
parents:
13108
diff
changeset
|
1854 return True |
13086
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1855 for b, revision in branch2rev.iteritems(): |
13150
8617b8b74fae
subrepo: use low-level git-for-each-ref command in branchmap
Eric Eisner <ede@mit.edu>
parents:
13144
diff
changeset
|
1856 if b.startswith('refs/remotes/origin/'): |
13086
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1857 if self._gitisancestor(self._state[1], revision): |
8db85e39d59c
subrepo: return both mapping directions from gitbranchmap
Eric Eisner <ede@mit.edu>
parents:
13085
diff
changeset
|
1858 return True |
13029 | 1859 # otherwise, try to push the currently checked out branch |
12994
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1860 cmd = ['push'] |
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1861 if force: |
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1862 cmd.append('--force') |
13152
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1863 |
70d80907e4b8
subrepo: defer determination of git's current branch
Eric Eisner <ede@mit.edu>
parents:
13151
diff
changeset
|
1864 current = self._gitcurrentbranch() |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1865 if current: |
13029 | 1866 # determine if the current branch is even useful |
1867 if not self._gitisancestor(self._state[1], current): | |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1868 self.ui.warn(_('unrelated git branch checked out ' |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1869 'in subrepository "%s"\n') % self._relpath) |
13029 | 1870 return False |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1871 self.ui.status(_('pushing branch %s of subrepository "%s"\n') % |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1872 (current.split('/', 2)[2], self._relpath)) |
20970
70312c95f2f7
subrepo: check return code for git push (issue4223)
Matt Mackall <mpm@selenic.com>
parents:
20870
diff
changeset
|
1873 ret = self._gitdir(cmd + ['origin', current]) |
70312c95f2f7
subrepo: check return code for git push (issue4223)
Matt Mackall <mpm@selenic.com>
parents:
20870
diff
changeset
|
1874 return ret[1] == 0 |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1875 else: |
33365
6d88468d435b
subrepo: make the output references to subrepositories consistent
Matt Harbison <matt_harbison@yahoo.com>
parents:
33364
diff
changeset
|
1876 self.ui.warn(_('no branch checked out in subrepository "%s"\n' |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1877 'cannot push revision %s\n') % |
13029 | 1878 (self._relpath, self._state[1])) |
12995
d90fc91c8377
subrepo: update and merge works with any git branch
Eric Eisner <ede@mit.edu>
parents:
12994
diff
changeset
|
1879 return False |
12994
845c602b8635
subrepo: allow git subrepos to push and merge
Eric Eisner <ede@mit.edu>
parents:
12993
diff
changeset
|
1880 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1881 @annotatesubrepoerror |
24174
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1882 def add(self, ui, match, prefix, explicitonly, **opts): |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1883 if self._gitmissing(): |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1884 return [] |
24182
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1885 |
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1886 (modified, added, removed, |
24209
6944b64cc28d
subrepo: explicitly request clean and unknown files in status for git's add
Matt Harbison <matt_harbison@yahoo.com>
parents:
24183
diff
changeset
|
1887 deleted, unknown, ignored, clean) = self.status(None, unknown=True, |
6944b64cc28d
subrepo: explicitly request clean and unknown files in status for git's add
Matt Harbison <matt_harbison@yahoo.com>
parents:
24183
diff
changeset
|
1888 clean=True) |
24174
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1889 |
24183
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1890 tracked = set() |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1891 # dirstates 'amn' warn, 'r' is added again |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1892 for l in (modified, added, deleted, clean): |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1893 tracked.update(l) |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1894 |
24182
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1895 # Unknown files not of interest will be rejected by the matcher |
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1896 files = unknown |
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1897 files.extend(match.files()) |
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1898 |
24183
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1899 rejected = [] |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1900 |
24182
00ef3edcf1d5
subrepo: don't exclude files in .hgignore when adding to git
Matt Harbison <matt_harbison@yahoo.com>
parents:
24174
diff
changeset
|
1901 files = [f for f in sorted(set(files)) if match(f)] |
24174
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1902 for f in files: |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1903 exact = match.exact(f) |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1904 command = ["add"] |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1905 if exact: |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1906 command.append("-f") #should be added, even if ignored |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1907 if ui.verbose or not exact: |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1908 ui.status(_('adding %s\n') % match.rel(f)) |
24183
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1909 |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1910 if f in tracked: # hg prints 'adding' even if already tracked |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1911 if exact: |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1912 rejected.append(f) |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1913 continue |
32147
a77e61b45384
py3: handle opts correctly for `hg add`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32005
diff
changeset
|
1914 if not opts.get(r'dry_run'): |
24174
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1915 self._gitcommand(command + [f]) |
24183
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1916 |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1917 for f in rejected: |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1918 ui.warn(_("%s already tracked!\n") % match.abs(f)) |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1919 |
932de135041f
subrepo: warn when adding already tracked files in gitsubrepo
Matt Harbison <matt_harbison@yahoo.com>
parents:
24182
diff
changeset
|
1920 return rejected |
24174
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1921 |
bd9f64ec891d
subrepos: support adding files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24173
diff
changeset
|
1922 @annotatesubrepoerror |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1923 def remove(self): |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1924 if self._gitmissing(): |
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1925 return |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1926 if self.dirty(): |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1927 self.ui.warn(_('not removing repo %s because ' |
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1928 'it has changes.\n') % self._relpath) |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1929 return |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1930 # we can't fully delete the repository as it may contain |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1931 # local-only history |
23572
40e62fbd7356
subrepo: rename the '_ui' member to 'ui'
Matt Harbison <matt_harbison@yahoo.com>
parents:
23571
diff
changeset
|
1932 self.ui.note(_('removing subrepo %s\n') % self._relpath) |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1933 self._gitcommand(['config', 'core.bare', 'true']) |
24688
897a0715ee71
subrepo: use vfs.readdir instead of os.listdir to avoid expensive stat calls
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24675
diff
changeset
|
1934 for f, kind in self.wvfs.readdir(): |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1935 if f == '.git': |
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1936 continue |
24688
897a0715ee71
subrepo: use vfs.readdir instead of os.listdir to avoid expensive stat calls
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24675
diff
changeset
|
1937 if kind == stat.S_IFDIR: |
24690
d1ddf1fe5d33
subrepo: use vfs.rmtree instead of shutil.rmtree
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24688
diff
changeset
|
1938 self.wvfs.rmtree(f) |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1939 else: |
24691
def1145cec2d
subrepo: use vfs.unlink instead of os.remove
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24690
diff
changeset
|
1940 self.wvfs.unlink(f) |
12996
3a42651b0a62
subrepo: removing (and restoring) git subrepo state
Eric Eisner <ede@mit.edu>
parents:
12995
diff
changeset
|
1941 |
31099
b44ab288358e
subrepo: run the repo decoders when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
30755
diff
changeset
|
1942 def archive(self, archiver, prefix, match=None, decode=True): |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
1943 total = 0 |
13027 | 1944 source, revision = self._state |
14469
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1945 if not revision: |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
1946 return total |
13027 | 1947 self._fetch(source, revision) |
1948 | |
1949 # Parse git's native archive command. | |
1950 # This should be much faster than manually traversing the trees | |
1951 # and objects with many subprocess calls. | |
1952 tarstream = self._gitcommand(['archive', revision], stream=True) | |
1953 tar = tarfile.open(fileobj=tarstream, mode='r|') | |
13144
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
1954 relpath = subrelpath(self) |
23575
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
1955 self.ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files')) |
13144
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
1956 for i, info in enumerate(tar): |
13180
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1957 if info.isdir(): |
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1958 continue |
17108
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
1959 if match and not match(info.name): |
1894dac619de
subrepo: propagate matcher to subrepos when archiving
Matt Harbison <matt_harbison@yahoo.com>
parents:
17036
diff
changeset
|
1960 continue |
13180
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1961 if info.issym(): |
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1962 data = info.linkname |
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1963 else: |
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1964 data = tar.extractfile(info).read() |
24924
41cd8171e58f
archive: always use portable path component separators with subrepos
Matt Harbison <matt_harbison@yahoo.com>
parents:
24877
diff
changeset
|
1965 archiver.addfile(prefix + self._path + '/' + info.name, |
13180
a79e0688a5ee
subrepo: fix git archive parsing of directories and symfiles
Eric Eisner <ede@mit.edu>
parents:
13179
diff
changeset
|
1966 info.mode, info.issym(), data) |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
1967 total += 1 |
23575
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
1968 self.ui.progress(_('archiving (%s)') % relpath, i + 1, |
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
1969 unit=_('files')) |
a2f139d25845
subrepo: drop the 'ui' parameter to archive()
Matt Harbison <matt_harbison@yahoo.com>
parents:
23574
diff
changeset
|
1970 self.ui.progress(_('archiving (%s)') % relpath, None) |
18967
88d1b59f6906
archive: raise error.Abort if the file pattern matches no files
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18964
diff
changeset
|
1971 return total |
13144
aae2d5cbde64
subrepo: add progress bar support to archive
Martin Geisler <mg@aragost.com>
parents:
13137
diff
changeset
|
1972 |
13027 | 1973 |
18109
9e3910db4e78
subrepo: append subrepo path to subrepo error messages
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
18031
diff
changeset
|
1974 @annotatesubrepoerror |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
1975 def cat(self, match, fm, fntemplate, prefix, **opts): |
23991
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1976 rev = self._state[1] |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1977 if match.anypats(): |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1978 return 1 #No support for include/exclude yet |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1979 |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1980 if not match.files(): |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1981 return 1 |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1982 |
32584
746e12a767b3
cat: add formatter support
Yuya Nishihara <yuya@tcha.org>
parents:
32540
diff
changeset
|
1983 # TODO: add support for non-plain formatter (see cmdutil.cat()) |
23991
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1984 for f in match.files(): |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1985 output = self._gitcommand(["show", "%s:%s" % (rev, f)]) |
32540
f4cd4c49e302
cat: pass filename template as explicit argument
Yuya Nishihara <yuya@tcha.org>
parents:
32157
diff
changeset
|
1986 fp = cmdutil.makefileobj(self._subparent, fntemplate, |
23991
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1987 self._ctx.node(), |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
1988 pathname=self.wvfs.reljoin(prefix, f)) |
23991
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1989 fp.write(output) |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1990 fp.close() |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1991 return 0 |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1992 |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1993 |
07c1a7d1ef69
subrepo: add 'cat' support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23963
diff
changeset
|
1994 @annotatesubrepoerror |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
1995 def status(self, rev2, **opts): |
14469
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1996 rev1 = self._state[1] |
2fdea636f254
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner <ede@alum.mit.edu>
parents:
14205
diff
changeset
|
1997 if self._gitmissing() or not rev1: |
13553
dea6efdd7ec4
subrepo: don't crash when git repo is missing
Eric Eisner <ede@mit.edu>
parents:
13531
diff
changeset
|
1998 # if the repo is missing, return no results |
24210
99362821b25b
subrepo: always return scmutil.status() from gitsubrepo.status()
Matt Harbison <matt_harbison@yahoo.com>
parents:
24209
diff
changeset
|
1999 return scmutil.status([], [], [], [], [], [], []) |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2000 modified, added, removed = [], [], [] |
15531
0810ccc51f0a
subrepo: fix git status false positive (issue3109)
Eric Roshan Eisner <ede@alum.mit.edu>
parents:
15498
diff
changeset
|
2001 self._gitupdatestat() |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2002 if rev2: |
28618
7dab4caf11bc
subrepo: adapt to git's recent renames-by-default
Martin von Zweigbergk <martinvonz@google.com>
parents:
27935
diff
changeset
|
2003 command = ['diff-tree', '--no-renames', '-r', rev1, rev2] |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2004 else: |
28618
7dab4caf11bc
subrepo: adapt to git's recent renames-by-default
Martin von Zweigbergk <martinvonz@google.com>
parents:
27935
diff
changeset
|
2005 command = ['diff-index', '--no-renames', rev1] |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2006 out = self._gitcommand(command) |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2007 for line in out.split('\n'): |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2008 tab = line.find('\t') |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2009 if tab == -1: |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2010 continue |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2011 status, f = line[tab - 1], line[tab + 1:] |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2012 if status == 'M': |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2013 modified.append(f) |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2014 elif status == 'A': |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2015 added.append(f) |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2016 elif status == 'D': |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2017 removed.append(f) |
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2018 |
22927
7d754b7acd55
subrepo: use separate instances of empty lists in status
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22914
diff
changeset
|
2019 deleted, unknown, ignored, clean = [], [], [], [] |
23411
2d86f4e38c08
subrepo: add status support for ignored files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23373
diff
changeset
|
2020 |
24256
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2021 command = ['status', '--porcelain', '-z'] |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2022 if opts.get(r'unknown'): |
24256
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2023 command += ['--untracked-files=all'] |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2024 if opts.get(r'ignored'): |
24256
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2025 command += ['--ignored'] |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2026 out = self._gitcommand(command) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2027 |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2028 changedfiles = set() |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2029 changedfiles.update(modified) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2030 changedfiles.update(added) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2031 changedfiles.update(removed) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2032 for line in out.split('\0'): |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2033 if not line: |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2034 continue |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2035 st = line[0:2] |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2036 #moves and copies show 2 files on one line |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2037 if line.find('\0') >= 0: |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2038 filename1, filename2 = line[3:].split('\0') |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2039 else: |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2040 filename1 = line[3:] |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2041 filename2 = None |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2042 |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2043 changedfiles.add(filename1) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2044 if filename2: |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2045 changedfiles.add(filename2) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2046 |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2047 if st == '??': |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2048 unknown.append(filename1) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2049 elif st == '!!': |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2050 ignored.append(filename1) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2051 |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2052 if opts.get(r'clean'): |
24256
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2053 out = self._gitcommand(['ls-files']) |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2054 for f in out.split('\n'): |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2055 if not f in changedfiles: |
e964edc3274e
subrepo: add status support for ignored and clean files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24211
diff
changeset
|
2056 clean.append(f) |
23411
2d86f4e38c08
subrepo: add status support for ignored files in git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23373
diff
changeset
|
2057 |
22914
c95db3208a33
status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22695
diff
changeset
|
2058 return scmutil.status(modified, added, removed, deleted, |
c95db3208a33
status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents:
22695
diff
changeset
|
2059 unknown, ignored, clean) |
13182
2537bd17421d
subrepo: basic support for status of git subrepos
Eric Eisner <ede@mit.edu>
parents:
13181
diff
changeset
|
2060 |
23523
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2061 @annotatesubrepoerror |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2062 def diff(self, ui, diffopts, node2, match, prefix, **opts): |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2063 node1 = self._state[1] |
28618
7dab4caf11bc
subrepo: adapt to git's recent renames-by-default
Martin von Zweigbergk <martinvonz@google.com>
parents:
27935
diff
changeset
|
2064 cmd = ['diff', '--no-renames'] |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2065 if opts[r'stat']: |
23523
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2066 cmd.append('--stat') |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2067 else: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2068 # for Git, this also implies '-p' |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2069 cmd.append('-U%d' % diffopts.context) |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2070 |
24675
47e7d5fbbf04
subrepo: use vfs.reljoin instead of os.path.join
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24674
diff
changeset
|
2071 gitprefix = self.wvfs.reljoin(prefix, self._path) |
23523
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2072 |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2073 if diffopts.noprefix: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2074 cmd.extend(['--src-prefix=%s/' % gitprefix, |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2075 '--dst-prefix=%s/' % gitprefix]) |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2076 else: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2077 cmd.extend(['--src-prefix=a/%s/' % gitprefix, |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2078 '--dst-prefix=b/%s/' % gitprefix]) |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2079 |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2080 if diffopts.ignorews: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2081 cmd.append('--ignore-all-space') |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2082 if diffopts.ignorewsamount: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2083 cmd.append('--ignore-space-change') |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2084 if self._gitversion(self._gitcommand(['--version'])) >= (1, 8, 4) \ |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2085 and diffopts.ignoreblanklines: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2086 cmd.append('--ignore-blank-lines') |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2087 |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2088 cmd.append(node1) |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2089 if node2: |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2090 cmd.append(node2) |
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2091 |
23938
de519517f597
subrepo: correctly add newline for git subrepo diffs
Mathias De Maré <mathias.demare@gmail.com>
parents:
23885
diff
changeset
|
2092 output = "" |
23523
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2093 if match.always(): |
23938
de519517f597
subrepo: correctly add newline for git subrepo diffs
Mathias De Maré <mathias.demare@gmail.com>
parents:
23885
diff
changeset
|
2094 output += self._gitcommand(cmd) + '\n' |
24778
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2095 else: |
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2096 st = self.status(node2)[:3] |
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2097 files = [f for sublist in st for f in sublist] |
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2098 for f in files: |
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2099 if match(f): |
a48b65ab428d
subrepo: add include/exclude support for diffing git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
24726
diff
changeset
|
2100 output += self._gitcommand(cmd + ['--', f]) + '\n' |
23938
de519517f597
subrepo: correctly add newline for git subrepo diffs
Mathias De Maré <mathias.demare@gmail.com>
parents:
23885
diff
changeset
|
2101 |
de519517f597
subrepo: correctly add newline for git subrepo diffs
Mathias De Maré <mathias.demare@gmail.com>
parents:
23885
diff
changeset
|
2102 if output.strip(): |
de519517f597
subrepo: correctly add newline for git subrepo diffs
Mathias De Maré <mathias.demare@gmail.com>
parents:
23885
diff
changeset
|
2103 ui.write(output) |
23523
01a8dfc79cdc
subrepo: add partial diff support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23522
diff
changeset
|
2104 |
23679
dd1e73c4be13
subrepo: add forgotten annotation for reverting git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23678
diff
changeset
|
2105 @annotatesubrepoerror |
23580
e20f36ad092e
subrepo: fix git subrepo ui argument
Matt Mackall <mpm@selenic.com>
parents:
23579
diff
changeset
|
2106 def revert(self, substate, *pats, **opts): |
e20f36ad092e
subrepo: fix git subrepo ui argument
Matt Mackall <mpm@selenic.com>
parents:
23579
diff
changeset
|
2107 self.ui.status(_('reverting subrepo %s\n') % substate[0]) |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2108 if not opts.get(r'no_backup'): |
23678
194d2f185008
subrepo: add full revert support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23666
diff
changeset
|
2109 status = self.status(None) |
194d2f185008
subrepo: add full revert support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23666
diff
changeset
|
2110 names = status.modified |
194d2f185008
subrepo: add full revert support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23666
diff
changeset
|
2111 for name in names: |
27651
07fc2f2134ba
origpath: move from cmdutil to scmutil
Siddharth Agarwal <sid0@fb.com>
parents:
26940
diff
changeset
|
2112 bakname = scmutil.origpath(self.ui, self._subparent, name) |
23678
194d2f185008
subrepo: add full revert support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23666
diff
changeset
|
2113 self.ui.note(_('saving current version of %s as %s\n') % |
194d2f185008
subrepo: add full revert support for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23666
diff
changeset
|
2114 (name, bakname)) |
24695
419528cb05b6
subrepo: convert the os.path references in git to vfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
24694
diff
changeset
|
2115 self.wvfs.rename(name, bakname) |
23550
7fa2189c1e87
subrepo: add revert support without backup for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23540
diff
changeset
|
2116 |
32157
09fb3d3b1b3a
py3: abuse r'' to access keys in keyword arguments
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32147
diff
changeset
|
2117 if not opts.get(r'dry_run'): |
24134
afed5d2e7985
revert: display full subrepo output with --dry-run
Matt Harbison <matt_harbison@yahoo.com>
parents:
24132
diff
changeset
|
2118 self.get(substate, overwrite=True) |
23550
7fa2189c1e87
subrepo: add revert support without backup for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23540
diff
changeset
|
2119 return [] |
7fa2189c1e87
subrepo: add revert support without backup for git subrepos
Mathias De Maré <mathias.demare@gmail.com>
parents:
23540
diff
changeset
|
2120 |
21400
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
2121 def shortid(self, revid): |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
2122 return revid[:7] |
78a60daacea8
subrepo: add shortid() method to subrepo classes
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
21041
diff
changeset
|
2123 |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
2124 types = { |
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
2125 'hg': hgsubrepo, |
10178
cd477be6f2fc
subrepo: Subversion support
Augie Fackler <durin42@gmail.com>
parents:
10177
diff
changeset
|
2126 'svn': svnsubrepo, |
12992
2b73a3279a9f
subrepo: support for adding a git subrepo
Eric Eisner <ede@mit.edu>
parents:
12930
diff
changeset
|
2127 'git': gitsubrepo, |
10177
5ca0d220ae21
subrepo: add table-based dispatch for subrepo types
Augie Fackler <durin42@gmail.com>
parents:
10175
diff
changeset
|
2128 } |