"bzr touch" in nested directories
Parth Malwankar
parth.malwankar at gmail.com
Sun Feb 15 16:18:42 GMT 2009
On Sun, Feb 15, 2009 at 8:56 PM, Barry Warsaw <barry at canonical.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Feb 15, 2009, at 12:48 AM, Parth Malwankar wrote:
>
>> bzr-touch doesn't seem to work in nested directories. I am
>> not sure if I am doing something wrong here or if this is
>> an enhancement request/bug.
>
> As the guy who "wrote" bzr-touch (if a quick hack could be called
> "writing"), my primary use case was adding empty __init__.py files to python
> packages. I welcome any contributions to the plugin, but as it pretty much
> works for what I wanted it for I don't plan on doing much with it myself
> except keep it running in future bzrs. I'd be happy to review any patches
> or branches though.
>
> Barry
Sounds like a good way to learn bzr API. I had a quick look at this
and this is what I came up with. Would very much appreciate
any inputs / pointers as this is the first time I have used the API
so there may be things I don't fully understand.
I am not sure whats the preferred way of submitting a patch
so I am just posting it here.
[parth:touch]% bzr diff
=== modified file '__init__.py'
--- __init__.py 2008-11-10 00:48:43 +0000
+++ __init__.py 2009-02-15 16:09:26 +0000
@@ -17,12 +17,13 @@
takes_args = ['file*']
def run(self, file_list):
- wt = WorkingTree.open('.')
+ wt = WorkingTree.open_containing('.')
# Create the files if they don't exist.
for filename in file_list:
- fd = os.open(filename, FLAGS, 0666)
+ filepath = os.path.join(os.getcwd(), filename)
+ fd = os.open(filepath, FLAGS, 0666)
os.close(fd)
- wt.smart_add(file_list, recurse=False)
+ wt[0].smart_add(file_list, recurse=False)
register_command(cmd_touch)
[parth:touch]%
Below is the interaction from a test run.
[parth:bzr-test]% mkdir -p a/b/c
[parth:bzr-test]% bzr add -q a
[parth:bzr-test]% bzr ci -q -m "initial"
[parth:bzr-test]% cd a/b/c
[parth:c]% bzr st
[parth:c]% bzr touch x
[parth:c]% bzr st
added:
a/b/c/x
[parth:c]% bzr ci
Committing to: /home/parth/tmp/bzr-test/
added a/b/c/x
Committed revision 2.
[parth:c]% cd -
~/tmp/bzr-test
[parth:bzr-test]% bzr touch y
[parth:bzr-test]% bzr st
added:
y
[parth:bzr-test]% bzr ci -q -m "initial y"
[parth:bzr-test]% bzr ls
a/
a/b/
a/b/c/
a/b/c/x
y
[parth:bzr-test]%
~Parth
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Darwin)
>
> iEYEARECAAYFAkmYNBYACgkQ2YZpQepbvXE9UQCfdLgNO23hduWZ57Ciqxe/ZGQz
> kBQAoKyumxJXqXOMvBfmS0xPJ8RMh+LG
> =ffnD
> -----END PGP SIGNATURE-----
>
More information about the bazaar
mailing list