##// END OF EJS Templates
make all commands be repo-wide by default...
Benoit Boissinot -
r1568:1d7d0c07 default
parent child Browse files
Show More
@@ -33,13 +33,17 b' def relpath(repo, args):'
33 return [util.normpath(os.path.join(cwd, x)) for x in args]
33 return [util.normpath(os.path.join(cwd, x)) for x in args]
34 return args
34 return args
35
35
36 def matchpats(repo, cwd, pats=[], opts={}, head=''):
36 def matchpats(repo, pats=[], opts={}, head=''):
37 cwd = repo.getcwd()
38 if not pats and cwd:
39 opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
40 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
41 cwd = ''
37 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
42 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
38 opts.get('exclude'), head)
43 opts.get('exclude'), head) + (cwd,)
39
44
40 def makewalk(repo, pats, opts, head=''):
45 def makewalk(repo, pats, opts, head=''):
41 cwd = repo.getcwd()
46 files, matchfn, anypats, cwd = matchpats(repo, pats, opts, head)
42 files, matchfn, anypats = matchpats(repo, cwd, pats, opts, head)
43 exact = dict(zip(files, files))
47 exact = dict(zip(files, files))
44 def walk():
48 def walk():
45 for src, fn in repo.walk(files=files, match=matchfn):
49 for src, fn in repo.walk(files=files, match=matchfn):
@@ -51,7 +55,7 b" def walk(repo, pats, opts, head=''):"
51 for r in results:
55 for r in results:
52 yield r
56 yield r
53
57
54 def walkchangerevs(ui, repo, cwd, pats, opts):
58 def walkchangerevs(ui, repo, pats, opts):
55 '''Iterate over files and the revs they changed in.
59 '''Iterate over files and the revs they changed in.
56
60
57 Callers most commonly need to iterate backwards over the history
61 Callers most commonly need to iterate backwards over the history
@@ -81,12 +85,7 b' def walkchangerevs(ui, repo, cwd, pats, '
81 if repo.changelog.count() == 0:
85 if repo.changelog.count() == 0:
82 return [], False
86 return [], False
83
87
84 cwd = repo.getcwd()
88 files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
85 if not pats and cwd:
86 opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
87 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
88 files, matchfn, anypats = matchpats(repo, (pats and cwd) or '',
89 pats, opts)
90 revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0']))
89 revs = map(int, revrange(ui, repo, opts['rev'] or ['tip:0']))
91 wanted = {}
90 wanted = {}
92 slowpath = anypats
91 slowpath = anypats
@@ -483,8 +482,7 b' def add(ui, repo, *pats, **opts):'
483
482
484 The files will be added to the repository at the next commit.
483 The files will be added to the repository at the next commit.
485
484
486 If no names are given, add all files in the current directory and
485 If no names are given, add all files in the repository.
487 its subdirectories.
488 """
486 """
489
487
490 names = []
488 names = []
@@ -759,7 +757,7 b' def commit(ui, repo, *pats, **opts):'
759 Commit changes to the given files into the repository.
757 Commit changes to the given files into the repository.
760
758
761 If a list of files is omitted, all changes reported by "hg status"
759 If a list of files is omitted, all changes reported by "hg status"
762 from the root of the repository will be commited.
760 will be commited.
763
761
764 The HGEDITOR or EDITOR environment variables are used to start an
762 The HGEDITOR or EDITOR environment variables are used to start an
765 editor to add a commit comment.
763 editor to add a commit comment.
@@ -782,12 +780,7 b' def commit(ui, repo, *pats, **opts):'
782
780
783 if opts['addremove']:
781 if opts['addremove']:
784 addremove(ui, repo, *pats, **opts)
782 addremove(ui, repo, *pats, **opts)
785 cwd = repo.getcwd()
783 fns, match, anypats, cwd = matchpats(repo, pats, opts)
786 if not pats and cwd:
787 opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
788 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
789 fns, match, anypats = matchpats(repo, (pats and repo.getcwd()) or '',
790 pats, opts)
791 if pats:
784 if pats:
792 c, a, d, u = repo.changes(files=fns, match=match)
785 c, a, d, u = repo.changes(files=fns, match=match)
793 files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r']
786 files = c + a + [fn for fn in d if repo.dirstate.state(fn) == 'r']
@@ -1097,7 +1090,7 b' def debugwalk(ui, repo, *pats, **opts):'
1097 ui.write("%s\n" % line.rstrip())
1090 ui.write("%s\n" % line.rstrip())
1098
1091
1099 def diff(ui, repo, *pats, **opts):
1092 def diff(ui, repo, *pats, **opts):
1100 """diff working directory (or selected files)
1093 """diff repository (or selected files)
1101
1094
1102 Show differences between revisions for the specified files.
1095 Show differences between revisions for the specified files.
1103
1096
@@ -1123,7 +1116,7 b' def diff(ui, repo, *pats, **opts):'
1123 if len(revs) > 2:
1116 if len(revs) > 2:
1124 raise util.Abort(_("too many revisions to diff"))
1117 raise util.Abort(_("too many revisions to diff"))
1125
1118
1126 fns, matchfn, anypats = matchpats(repo, repo.getcwd(), pats, opts)
1119 fns, matchfn, anypats, cwd = matchpats(repo, pats, opts)
1127
1120
1128 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn,
1121 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn,
1129 text=opts['text'])
1122 text=opts['text'])
@@ -1294,7 +1287,7 b' def grep(ui, repo, pattern, *pats, **opt'
1294
1287
1295 fstate = {}
1288 fstate = {}
1296 skip = {}
1289 skip = {}
1297 changeiter, getchange = walkchangerevs(ui, repo, repo.getcwd(), pats, opts)
1290 changeiter, getchange = walkchangerevs(ui, repo, pats, opts)
1298 count = 0
1291 count = 0
1299 incrementing = False
1292 incrementing = False
1300 for st, rev, fns in changeiter:
1293 for st, rev, fns in changeiter:
@@ -1557,12 +1550,7 b' def log(ui, repo, *pats, **opts):'
1557 self.write(*args)
1550 self.write(*args)
1558 def __getattr__(self, key):
1551 def __getattr__(self, key):
1559 return getattr(self.ui, key)
1552 return getattr(self.ui, key)
1560 cwd = repo.getcwd()
1553 changeiter, getchange = walkchangerevs(ui, repo, pats, opts)
1561 if not pats and cwd:
1562 opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
1563 opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
1564 changeiter, getchange = walkchangerevs(ui, repo, (pats and cwd) or '',
1565 pats, opts)
1566 for st, rev, fns in changeiter:
1554 for st, rev, fns in changeiter:
1567 if st == 'window':
1555 if st == 'window':
1568 du = dui(ui)
1556 du = dui(ui)
@@ -1871,13 +1859,12 b' def revert(ui, repo, *pats, **opts):'
1871
1859
1872 If names are given, all files matching the names are reverted.
1860 If names are given, all files matching the names are reverted.
1873
1861
1874 If no names are given, all files in the current directory and
1862 If no arguments are given, all files in the repository are reverted.
1875 its subdirectories are reverted.
1876 """
1863 """
1877 node = opts['rev'] and repo.lookup(opts['rev']) or \
1864 node = opts['rev'] and repo.lookup(opts['rev']) or \
1878 repo.dirstate.parents()[0]
1865 repo.dirstate.parents()[0]
1879
1866
1880 files, choose, anypats = matchpats(repo, repo.getcwd(), pats, opts)
1867 files, choose, anypats, cwd = matchpats(repo, pats, opts)
1881 (c, a, d, u) = repo.changes(match=choose)
1868 (c, a, d, u) = repo.changes(match=choose)
1882 repo.forget(a)
1869 repo.forget(a)
1883 repo.undelete(d)
1870 repo.undelete(d)
@@ -2000,9 +1987,8 b' def serve(ui, repo, **opts):'
2000 def status(ui, repo, *pats, **opts):
1987 def status(ui, repo, *pats, **opts):
2001 """show changed files in the working directory
1988 """show changed files in the working directory
2002
1989
2003 Show changed files in the working directory. If no names are
1990 Show changed files in the repository. If names are
2004 given, all files are shown. Otherwise, only files matching the
1991 given, only files that match are shown.
2005 given names are shown.
2006
1992
2007 The codes used to show the status of files are:
1993 The codes used to show the status of files are:
2008 M = modified
1994 M = modified
@@ -2011,8 +1997,7 b' def status(ui, repo, *pats, **opts):'
2011 ? = not tracked
1997 ? = not tracked
2012 """
1998 """
2013
1999
2014 cwd = repo.getcwd()
2000 files, matchfn, anypats, cwd = matchpats(repo, pats, opts)
2015 files, matchfn, anypats = matchpats(repo, cwd, pats, opts)
2016 (c, a, d, u) = [[util.pathto(cwd, x) for x in n]
2001 (c, a, d, u) = [[util.pathto(cwd, x) for x in n]
2017 for n in repo.changes(files=files, match=matchfn)]
2002 for n in repo.changes(files=files, match=matchfn)]
2018
2003
@@ -6,7 +6,7 b' basic commands (use "hg help" for the fu'
6 annotate show changeset information per file line
6 annotate show changeset information per file line
7 clone make a copy of an existing repository
7 clone make a copy of an existing repository
8 commit commit the specified files or all outstanding changes
8 commit commit the specified files or all outstanding changes
9 diff diff working directory (or selected files)
9 diff diff repository (or selected files)
10 export dump the header and diffs for one or more changesets
10 export dump the header and diffs for one or more changesets
11 init create a new repository in the given directory
11 init create a new repository in the given directory
12 log show revision history of entire repository or files
12 log show revision history of entire repository or files
@@ -22,7 +22,7 b' basic commands (use "hg help" for the fu'
22 annotate show changeset information per file line
22 annotate show changeset information per file line
23 clone make a copy of an existing repository
23 clone make a copy of an existing repository
24 commit commit the specified files or all outstanding changes
24 commit commit the specified files or all outstanding changes
25 diff diff working directory (or selected files)
25 diff diff repository (or selected files)
26 export dump the header and diffs for one or more changesets
26 export dump the header and diffs for one or more changesets
27 init create a new repository in the given directory
27 init create a new repository in the given directory
28 log show revision history of entire repository or files
28 log show revision history of entire repository or files
@@ -46,7 +46,7 b' list of commands (use "hg help -v" to sh'
46 clone make a copy of an existing repository
46 clone make a copy of an existing repository
47 commit commit the specified files or all outstanding changes
47 commit commit the specified files or all outstanding changes
48 copy mark files as copied for the next commit
48 copy mark files as copied for the next commit
49 diff diff working directory (or selected files)
49 diff diff repository (or selected files)
50 export dump the header and diffs for one or more changesets
50 export dump the header and diffs for one or more changesets
51 forget don't add the specified files on the next commit
51 forget don't add the specified files on the next commit
52 grep search for a pattern in specified files and revisions
52 grep search for a pattern in specified files and revisions
@@ -88,7 +88,7 b' list of commands (use "hg help -v" to sh'
88 clone make a copy of an existing repository
88 clone make a copy of an existing repository
89 commit commit the specified files or all outstanding changes
89 commit commit the specified files or all outstanding changes
90 copy mark files as copied for the next commit
90 copy mark files as copied for the next commit
91 diff diff working directory (or selected files)
91 diff diff repository (or selected files)
92 export dump the header and diffs for one or more changesets
92 export dump the header and diffs for one or more changesets
93 forget don't add the specified files on the next commit
93 forget don't add the specified files on the next commit
94 grep search for a pattern in specified files and revisions
94 grep search for a pattern in specified files and revisions
@@ -130,8 +130,7 b' add the specified files on the next comm'
130
130
131 The files will be added to the repository at the next commit.
131 The files will be added to the repository at the next commit.
132
132
133 If no names are given, add all files in the current directory and
133 If no names are given, add all files in the repository.
134 its subdirectories.
135
134
136 options:
135 options:
137
136
@@ -146,8 +145,7 b' add the specified files on the next comm'
146
145
147 The files will be added to the repository at the next commit.
146 The files will be added to the repository at the next commit.
148
147
149 If no names are given, add all files in the current directory and
148 If no names are given, add all files in the repository.
150 its subdirectories.
151
149
152 options:
150 options:
153
151
@@ -155,7 +153,7 b' options:'
155 -X --exclude exclude names matching the given patterns
153 -X --exclude exclude names matching the given patterns
156 hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...
154 hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...
157
155
158 diff working directory (or selected files)
156 diff repository (or selected files)
159
157
160 Show differences between revisions for the specified files.
158 Show differences between revisions for the specified files.
161
159
@@ -181,9 +179,8 b' hg status [OPTION]... [FILE]...'
181
179
182 show changed files in the working directory
180 show changed files in the working directory
183
181
184 Show changed files in the working directory. If no names are
182 Show changed files in the repository. If names are
185 given, all files are shown. Otherwise, only files matching the
183 given, only files that match are shown.
186 given names are shown.
187
184
188 The codes used to show the status of files are:
185 The codes used to show the status of files are:
189 M = modified
186 M = modified
@@ -215,7 +212,7 b' basic commands (use "hg help" for the fu'
215 annotate show changeset information per file line
212 annotate show changeset information per file line
216 clone make a copy of an existing repository
213 clone make a copy of an existing repository
217 commit commit the specified files or all outstanding changes
214 commit commit the specified files or all outstanding changes
218 diff diff working directory (or selected files)
215 diff diff repository (or selected files)
219 export dump the header and diffs for one or more changesets
216 export dump the header and diffs for one or more changesets
220 init create a new repository in the given directory
217 init create a new repository in the given directory
221 log show revision history of entire repository or files
218 log show revision history of entire repository or files
@@ -236,7 +233,7 b' basic commands (use "hg help" for the fu'
236 annotate show changeset information per file line
233 annotate show changeset information per file line
237 clone make a copy of an existing repository
234 clone make a copy of an existing repository
238 commit commit the specified files or all outstanding changes
235 commit commit the specified files or all outstanding changes
239 diff diff working directory (or selected files)
236 diff diff repository (or selected files)
240 export dump the header and diffs for one or more changesets
237 export dump the header and diffs for one or more changesets
241 init create a new repository in the given directory
238 init create a new repository in the given directory
242 log show revision history of entire repository or files
239 log show revision history of entire repository or files
@@ -42,4 +42,4 b' echo "relglob:*" > .hgignore'
42 echo "--" ; hg status
42 echo "--" ; hg status
43
43
44 cd dir
44 cd dir
45 echo "--" ; hg status
45 echo "--" ; hg status .
@@ -20,14 +20,14 b' hg addremove'
20 hg commit -m "commit #0" -d "0 0"
20 hg commit -m "commit #0" -d "0 0"
21 hg debugwalk
21 hg debugwalk
22 cd mammals
22 cd mammals
23 hg debugwalk
23 hg debugwalk .
24 hg debugwalk Procyonidae
24 hg debugwalk Procyonidae
25 cd Procyonidae
25 cd Procyonidae
26 hg debugwalk
26 hg debugwalk .
27 hg debugwalk ..
27 hg debugwalk ..
28 cd ..
28 cd ..
29 hg debugwalk ../beans
29 hg debugwalk ../beans
30 hg debugwalk
30 hg debugwalk .
31 cd ..
31 cd ..
32 hg debugwalk -Ibeans
32 hg debugwalk -Ibeans
33 hg debugwalk 'glob:mammals/../beans/b*'
33 hg debugwalk 'glob:mammals/../beans/b*'
General Comments 0
You need to be logged in to leave comments. Login now