Mercurial > hgsubversion
annotate utility_commands.py @ 204:496ff87e2532
test_rebuildmeta: Remove the "expected missing" hack now that the branch refactor fixed that problem.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 03 Mar 2009 00:02:09 -0600 |
parents | 91db8fc049b0 |
children | a421aca2b0f5 |
rev | line source |
---|---|
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
1 import os |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
2 |
196
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
3 import mercurial |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 from mercurial import cmdutil |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
5 from mercurial import node |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
6 from mercurial import util as mutil |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
7 from hgext import rebase |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
8 |
196
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
9 import svnwrap |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
10 import util |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
11 import hg_delta_editor |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
12 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
13 def print_wc_url(ui, repo, hg_repo_path, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
14 """show the location (URL) of the Subversion repository |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
101
diff
changeset
|
15 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
16 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
17 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 ui.status(hge.url, '\n') |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
165
diff
changeset
|
19 print_wc_url = util.register_subcommand('url')(print_wc_url) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
22 def find_wc_parent_rev(ui, repo, hge, svn_commit_hashes): |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
23 """Find the svn parent revision of the repo's dirstate. |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
24 """ |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
25 workingctx = repo.parents()[0] |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
26 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, workingctx.node()) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
27 if o_r: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
28 workingctx = repo[o_r[-1]].parents()[0] |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
29 return workingctx |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
30 |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
31 |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
32 def generate_ignore(ui, repo, hg_repo_path, force=False, **opts): |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
33 """generate .hgignore from svn:ignore properties. |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
34 """ |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
35 ignpath = os.path.join(hg_repo_path, '.hgignore') |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
36 if not force and os.path.exists(ignpath): |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
37 raise mutil.Abort('not overwriting existing .hgignore, try --force?') |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
38 ignorefile = open(ignpath, 'w') |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
39 ignorefile.write('.hgignore\nsyntax:glob\n') |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
40 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
41 ui_=ui) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
42 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
43 hge.revmap.iterkeys())) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
44 parent = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
45 r, br = svn_commit_hashes[parent.node()] |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
46 if br == None: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
47 branchpath = 'trunk' |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
48 else: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
49 branchpath = 'branches/%s' % br |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
50 url = hge.url |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
51 if url[-1] == '/': |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
52 url = url[:-1] |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
53 svn = svnwrap.SubversionRepo(url) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
54 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r) if d[1] == 'd'] |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
55 for dir in dirs: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
56 props = svn.list_props('%s/%s/' % (branchpath,dir), r) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
57 if 'svn:ignore' in props: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
58 lines = props['svn:ignore'].strip().split('\n') |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
59 for prop in lines: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
60 if dir: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
61 ignorefile.write('%s/%s\n' % (dir, prop)) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
62 else: |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
63 ignorefile.write('%s\n' % prop) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
64 generate_ignore = util.register_subcommand('genignore')(generate_ignore) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
65 |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
66 |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
67 def run_svn_info(ui, repo, hg_repo_path, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
68 """show Subversion details similar to `svn info' |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
101
diff
changeset
|
69 """ |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
70 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
71 ui_=ui) |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
72 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
73 hge.revmap.iterkeys())) |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
74 parent = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes) |
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
75 r, br = svn_commit_hashes[parent.node()] |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
76 if br == None: |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
77 branchpath = '/trunk' |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
78 else: |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
79 branchpath = '/branches/%s' % br |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
80 url = hge.url |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
81 if url[-1] == '/': |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
82 url = url[:-1] |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
83 url = '%s%s' % (url, branchpath) |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
84 author = '@'.join(parent.user().split('@')[:-1]) |
160
7a5a0b5c8e34
info: Actually determine and show the repo root.
Augie Fackler <durin42@gmail.com>
parents:
157
diff
changeset
|
85 # cleverly figure out repo root w/o actually contacting the server |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
86 subdir = parent.extra()['convert_revision'][40:].split('@')[0] |
160
7a5a0b5c8e34
info: Actually determine and show the repo root.
Augie Fackler <durin42@gmail.com>
parents:
157
diff
changeset
|
87 reporoot = url[:len(url)-len(subdir)] |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
88 ui.status('''URL: %(url)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
89 Repository Root: %(reporoot)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
90 Repository UUID: %(uuid)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
91 Revision: %(revision)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
92 Node Kind: directory |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
93 Last Changed Author: %(author)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
94 Last Changed Rev: %(revision)s |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
95 Last Changed Date: %(date)s\n''' % |
160
7a5a0b5c8e34
info: Actually determine and show the repo root.
Augie Fackler <durin42@gmail.com>
parents:
157
diff
changeset
|
96 {'reporoot': reporoot, |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
97 'uuid': open(hge.uuid_file).read(), |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
98 'url': url, |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
99 'author': author, |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
100 'revision': r, |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
101 # TODO I'd like to format this to the user's local TZ if possible |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
102 'date': mutil.datestr(parent.date(), |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
103 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)') |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
104 }) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
165
diff
changeset
|
105 run_svn_info = util.register_subcommand('info')(run_svn_info) |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
106 |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
107 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
108 def print_parent_revision(ui, repo, hg_repo_path, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
109 """show Mercurial & Subversion parents of the working dir or revision |
115
ed42f6e5705a
Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents:
101
diff
changeset
|
110 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
111 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
112 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
113 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
114 hge.revmap.iterkeys())) |
199
91db8fc049b0
Add a genignore utility command that generates an hgignore file by scraping svn:ignore properties.
Augie Fackler <durin42@gmail.com>
parents:
196
diff
changeset
|
115 ha = find_wc_parent_rev(ui, repo, hge, svn_commit_hashes) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
116 if ha.node() != node.nullid: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
117 r, br = svn_commit_hashes[ha.node()] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
118 ui.status('Working copy parent revision is %s: r%s on %s\n' % |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
119 (ha, r, br or 'trunk')) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
120 else: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
121 ui.status('Working copy seems to have no parent svn revision.\n') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
122 return 0 |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
165
diff
changeset
|
123 print_parent_revision = util.register_subcommand('parent')(print_parent_revision) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
124 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
125 |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
126 def rebase_commits(ui, repo, hg_repo_path, extrafn=None, sourcerev=None, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
127 """rebase current unpushed revisions onto the Subversion head |
64
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
128 |
08be8ee73551
Add an hg svn info subsubcommand that prints out what you would expect from svn info.
Augie Fackler <durin42@gmail.com>
parents:
31
diff
changeset
|
129 This moves a line of development from making its own head to the top of |
31
05800c403321
Fix up the rebase docstring to be less vague.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
130 Subversion development, linearizing the changes. In order to make sure you |
05800c403321
Fix up the rebase docstring to be less vague.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
131 rebase on top of the current top of Subversion work, you should probably run |
05800c403321
Fix up the rebase docstring to be less vague.
Augie Fackler <durin42@gmail.com>
parents:
0
diff
changeset
|
132 'hg svn pull' before running this. |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
133 """ |
150
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
134 if extrafn is None: |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
135 def extrafn2(ctx, extra): |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
136 """defined here so we can add things easily. |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
137 """ |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
138 extra['branch'] = ctx.branch() |
58ae90a65f41
push: Improved the rebasing logic for push so that it doesn't break with
Augie Fackler <durin42@gmail.com>
parents:
149
diff
changeset
|
139 extrafn = extrafn2 |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
140 if sourcerev is None: |
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
141 sourcerev = repo.parents()[0].node() |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
142 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
143 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
144 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
145 hge.revmap.iterkeys())) |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
146 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, sourcerev=sourcerev) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
147 if not o_r: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
148 ui.status('Nothing to rebase!\n') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
149 return 0 |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
150 if len(repo[sourcerev].children()): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
151 ui.status('Refusing to rebase non-head commit like a coward\n') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
152 return 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
153 parent_rev = repo[o_r[-1]].parents()[0] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
154 target_rev = parent_rev |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
155 p_n = parent_rev.node() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
156 exhausted_choices = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
157 while target_rev.children() and not exhausted_choices: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
158 for c in target_rev.children(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
159 exhausted_choices = True |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
160 n = c.node() |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
161 if (n in svn_commit_hashes and |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
162 svn_commit_hashes[n][1] == svn_commit_hashes[p_n][1]): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
163 target_rev = c |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
164 exhausted_choices = False |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
165 break |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
166 if parent_rev == target_rev: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
167 ui.status('Already up to date!\n') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
168 return 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
169 # TODO this is really hacky, there must be a more direct way |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
170 return rebase.rebase(ui, repo, dest=node.hex(target_rev.node()), |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
150
diff
changeset
|
171 base=node.hex(sourcerev), |
149
04800fda7af5
rebase: preserve local branch names.
Augie Fackler <durin42@gmail.com>
parents:
115
diff
changeset
|
172 extrafn=extrafn) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
165
diff
changeset
|
173 rebase_commits = util.register_subcommand('rebase')(rebase_commits) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
174 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
175 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
176 def show_outgoing_to_svn(ui, repo, hg_repo_path, **opts): |
185
57355b0e7bd1
Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
181
diff
changeset
|
177 """show changesets not found in the Subversion repository |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
178 """ |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 hge = hg_delta_editor.HgChangeReceiver(hg_repo_path, |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
180 ui_=ui) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
181 svn_commit_hashes = dict(zip(hge.revmap.itervalues(), |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
182 hge.revmap.iterkeys())) |
157
91541523ea5c
utility_commands: Test outgoing and fix it to work again.
Augie Fackler <durin42@gmail.com>
parents:
152
diff
changeset
|
183 o_r = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes, repo.parents()[0].node()) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
184 if not (o_r and len(o_r)): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
185 ui.status('No outgoing changes found.\n') |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
186 return 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
187 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=False) |
95
10dd34deac3b
utility_commands: fix outgoing against crew (required because of crew cset 87158be081b8)
Augie Fackler <durin42@gmail.com>
parents:
64
diff
changeset
|
188 for node in reversed(o_r): |
10dd34deac3b
utility_commands: fix outgoing against crew (required because of crew cset 87158be081b8)
Augie Fackler <durin42@gmail.com>
parents:
64
diff
changeset
|
189 displayer.show(repo[node]) |
181
e37f9d3fd5e7
remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
165
diff
changeset
|
190 show_outgoing_to_svn = util.register_subcommand('outgoing')(show_outgoing_to_svn) |
196
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
191 |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
192 |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
193 def version(ui, **opts): |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
194 """Show current version of hg and hgsubversion. |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
195 """ |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
196 ui.status('hg: %s\n' % mutil.version()) |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
197 ui.status('svn bindings: %s\n' % svnwrap.version()) |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
198 ui.status('hgsubversion: %s\n' % util.version(ui)) |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
199 version = util.register_subcommand('version')(version) |
77812f98e250
Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents:
185
diff
changeset
|
200 version = util.command_needs_no_url(version) |